idlize
99 строк · 2.3 Кб
1/*
2* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
3* Licensed under the Apache License, Version 2.0 (the "License");
4* you may not use this file except in compliance with the License.
5* You may obtain a copy of the License at
6*
7* http://www.apache.org/licenses/LICENSE-2.0
8*
9* Unless required by applicable law or agreed to in writing, software
10* distributed under the License is distributed on an "AS IS" BASIS,
11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12* See the License for the specific language governing permissions and
13* limitations under the License.
14*/
15
16import { Context } from "./context.test"17import { resetLog } from "./util.test"18
19const someId = "xxx"20
21/** @memo */
22function foo() {}23
24interface Y {25/** @memo */26prop: () => void27}
28
29class X {30/** @memo */31prop: () => void = foo32}
33
34class Z implements Y {35/** @memo */36prop: () => void = foo37}
38
39class W extends X {40}
41
42/** @memo */
43function entry1() {44const x = new X()45x.prop()46}
47
48/** @memo */
49function entry2() {50const z = new Z()51z.prop()52}
53
54/** @memo */
55function entry3() {56const w = new W()57w.prop()58}
59
60/** @memo */
61function entry4() {62const y: Y = { prop: foo }63y.prop()64}
65
66suite("Memo functional type property", () => {67test("Memo functional type property is expanded", () => {68resetLog()69/** @memo:entry */70function start(__memo_context: Context, __memo_id: any) {71entry1()72}73start(new Context(), someId)74})75test("Memo override functional type property is expanded", () => {76resetLog()77/** @memo:entry */78function start(__memo_context: Context, __memo_id: any) {79entry2()80}81start(new Context(), someId)82})83test("Memo inherit functional type property is expanded", () => {84resetLog()85/** @memo:entry */86function start(__memo_context: Context, __memo_id: any) {87entry3()88}89start(new Context(), someId)90})91test("Memo functional type property in interface is expanded", () => {92resetLog()93/** @memo:entry */94function start(__memo_context: Context, __memo_id: any) {95entry4()96}97start(new Context(), someId)98})99})100
101