idlize
140 строк · 4.4 Кб
1diff --git a/compiler/test/utForPartialUpdate/render_decorator/@extend/@extend.ts b/compiler/test/utForPartialUpdate/render_decorator/@extend/@extend.ts
2deleted file mode 100644
3index 6df7674..0000000
4--- a/compiler/test/utForPartialUpdate/render_decorator/@extend/@extend.ts
5+++ /dev/null
6@@ -1,134 +0,0 @@
7-/*
8- * Copyright (c) 2022 Huawei Device Co., Ltd.
9- * Licensed under the Apache License, Version 2.0 (the "License");
10- * you may not use this file except in compliance with the License.
11- * You may obtain a copy of the License at
12- *
13- * http://www.apache.org/licenses/LICENSE-2.0
14- *
15- * Unless required by applicable law or agreed to in writing, software
16- * distributed under the License is distributed on an "AS IS" BASIS,
17- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18- * See the License for the specific language governing permissions and
19- * limitations under the License.
20- */
21-
22-exports.source = `
23-@Extend Text.fancy(color:string){
24- .backgroundColor(color)
25-}
26-
27-@Extend Text.superFancy(size:number){
28- .fontSize(size)
29- .fancy(Color.Red)
30-}
31-
32-@Extend(Button) function fancybut(color:string|Color){
33- .backgroundColor(color)
34- .width(200)
35- .height(100)
36-}
37-
38-@Entry
39-@Component
40-struct FancyUse {
41- build() {
42- Column(){
43- Row() {
44- Text("Just Fancy").fancy(Color.Yellow)
45- Text("Super Fancy Text").superFancy(24)
46- Button("Fancy Button").fancybut(Color.Green)
47- }
48- Row({ space: 10 }) {
49- Text("Fancy")
50- .fancytext(24)
51- }
52- }
53- }
54-}
55-
56-@Extend(Text) function fancytext(fontSize: number) {
57- .fontColor(Color.Red)
58- .fontSize(fontSize)
59- .fontStyle(FontStyle.Italic)
60-}
61-`
62-exports.expectResult =
63-`"use strict";
64-function __Text__fancy(color) {
65- Text.backgroundColor(color);
66-}
67-function __Text__superFancy(size) {
68- Text.fontSize(size);
69- __Text__fancy(Color.Red);
70-}
71-function __Button__fancybut(color) {
72- Button.backgroundColor(color);
73- Button.width(200);
74- Button.height(100);
75-}
76-class FancyUse extends ViewPU {
77- constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
78- super(parent, __localStorage, elmtId, extraInfo);
79- if (typeof paramsLambda === "function") {
80- this.paramsGenerator_ = paramsLambda;
81- }
82- this.setInitiallyProvidedValue(params);
83- }
84- setInitiallyProvidedValue(params) {
85- }
86- updateStateVars(params) {
87- }
88- purgeVariableDependenciesOnElmtId(rmElmtId) {
89- }
90- aboutToBeDeleted() {
91- SubscriberManager.Get().delete(this.id__());
92- this.aboutToBeDeletedInternal();
93- }
94- initialRender() {
95- this.observeComponentCreation2((elmtId, isInitialRender) => {
96- Column.create();
97- }, Column);
98- this.observeComponentCreation2((elmtId, isInitialRender) => {
99- Row.create();
100- }, Row);
101- this.observeComponentCreation2((elmtId, isInitialRender) => {
102- Text.create("Just Fancy");
103- __Text__fancy(Color.Yellow);
104- }, Text);
105- Text.pop();
106- this.observeComponentCreation2((elmtId, isInitialRender) => {
107- Text.create("Super Fancy Text");
108- __Text__superFancy(24);
109- }, Text);
110- Text.pop();
111- this.observeComponentCreation2((elmtId, isInitialRender) => {
112- Button.createWithLabel("Fancy Button");
113- __Button__fancybut(Color.Green);
114- }, Button);
115- Button.pop();
116- Row.pop();
117- this.observeComponentCreation2((elmtId, isInitialRender) => {
118- Row.create({ space: 10 });
119- }, Row);
120- this.observeComponentCreation2((elmtId, isInitialRender) => {
121- Text.create("Fancy");
122- __Text__fancytext(24);
123- }, Text);
124- Text.pop();
125- Row.pop();
126- Column.pop();
127- }
128- rerender() {
129- this.updateDirtyElements();
130- }
131-}
132-function __Text__fancytext(fontSize) {
133- Text.fontColor(Color.Red);
134- Text.fontSize(fontSize);
135- Text.fontStyle(FontStyle.Italic);
136-}
137-ViewStackProcessor.StartGetAccessRecordingFor(ViewStackProcessor.AllocateNewElmetIdForNextComponent());
138-loadDocument(new FancyUse(undefined, {}));
139-ViewStackProcessor.StopGetAccessRecording();
140-`
141