diff --git a/arkoala-arkts/shopping/arktsconfig-run-unmemoized.json b/arkoala-arkts/shopping/arktsconfig-run-unmemoized.json index 0ff90ba8a6573ec0e0b96dcefe1f02db0105c7e1..97c161de553d027acd8ffe471bcff2b6cc034cc8 100644 --- a/arkoala-arkts/shopping/arktsconfig-run-unmemoized.json +++ b/arkoala-arkts/shopping/arktsconfig-run-unmemoized.json @@ -36,6 +36,10 @@ "#arkcompat": [ "../../arkoala/arkui-common/build/unmemoized/src/arkts" ] + }, + "dynamicPaths":{ + "@ohos.hilog":{"language" : "js", "hasDecl" : false}, + "pure" : {"language" : "js", "hasDecl" : false} } } } diff --git a/arkoala-arkts/shopping/package.json b/arkoala-arkts/shopping/package.json index ae78c82328010bd6180c9e72c6dcacc5b7ec82ab..25613b5398c55af424ce33a7c06280e043526cb6 100644 --- a/arkoala-arkts/shopping/package.json +++ b/arkoala-arkts/shopping/package.json @@ -11,14 +11,16 @@ "unmemoize:arkui-no-common": "npm run unmemoize --prefix ../arkui", "unmemoize:arkui-common": "npm run unmemoize --prefix ../../arkoala/arkui-common", "unmemoize:all": "npm run unmemoize:runtime && npm run unmemoize:arkui-no-common && npm run unmemoize:arkui-common && npm run unmemoize", - "build:shopping": "npm run interface-sdk:download --prefix ../../arkoala/arkui-common && npm run unmemoize:all && npm run build:shopping:prepare-non-subset && npm run build:shopping:inc", - "build:shopping:prepare-non-subset": "rm ./build/unmemoized/build/generated/arkcompilerPOC/concurrency.ts && cp ./src/ets/arkcompilerPOC/concurrency.sts ./build/unmemoized/build/generated/arkcompilerPOC/concurrency.ts", + "build:shopping": "npm run interface-sdk:download --prefix ../../arkoala/arkui-common && npm run unmemoize:all && npm run build:shopping:inc", "build:shopping:inc": "fast-arktsc --input-files ./arktsconfig-run-unmemoized.json --output-dir ./build --compiler ../../incremental/tools/panda/arkts/arktsc --link-name shopping && ninja -f build/build.ninja", + + "build:shopping:prepare-non-subset": "rm -r ./build/unmemoized/build/generated/arkcompilerPOC/ && cp -r ./src/ets/arkcompilerPOCFiles/ ./build/unmemoized/build/generated/ && mv ./build/unmemoized/build/generated/arkcompilerPOCFiles ./build/unmemoized/build/generated/arkcompilerPOC", + "build:shopping:interop": "npm run interface-sdk:download --prefix ../../arkoala/arkui-common && npm run unmemoize:all && npm run build:shopping:prepare-non-subset && npm run build:shopping:inc", "pack": "npm run cli-tools:check && cd app && DEVECO_SDK_HOME=../../../arkoala/ohos-sdk/ohos-sdk ../command-line-tools/hvigor/bin/hvigorw --no-daemon --mode module -p product=default -p module=shopping@default assembleHar", "har-arm32": "npm run build:shopping && npm run --prefix ../../arkoala/ohos-sdk download && node scripts/build-har.mjs --name shopping --arch arm32 && npm run pack", "har-arm64": "npm run build:shopping && npm run --prefix ../../arkoala/ohos-sdk download && node scripts/build-har.mjs --name shopping --arch arm64 && npm run pack", - + "har-arm64-interop": "npm run build:shopping:interop && npm run --prefix ../../arkoala/ohos-sdk download && node scripts/build-har.mjs --name shopping --arch arm64 && npm run pack", "cli-tools:chmod:bz": "node ../../arkoala/ohos-sdk/scripts/openlab-cli.mjs chmod -p ./command-line-tools/ohpm/bin -b 755 && node ../../arkoala/ohos-sdk/scripts/openlab-cli.mjs chmod -p ./command-line-tools/hvigor/bin -b 755", "cli-tools:chmod:yz": "node ../../../sdk/scripts/gitlab/gitlab-cli.mjs chmod -p ./command-line-tools/ohpm/bin -b 755 && node ../../../sdk/scripts/gitlab/gitlab-cli.mjs chmod -p ./command-line-tools/hvigor/bin -b 755", "cli-tools:download:bz": "node ../../arkoala/ohos-sdk/scripts/openlab-cli.mjs download -p command-line-tools -v 5.0.3502 -f command-line-tools.5.0.3502.zip -d command-line-tools && npm run cli-tools:chmod:bz", diff --git a/arkoala-arkts/shopping/src/ets/arkcompilerPOC/test_s2d_operators.ets b/arkoala-arkts/shopping/src/ets/arkcompilerPOC/test_s2d_operators.ets new file mode 100644 index 0000000000000000000000000000000000000000..4deecfba080e71dade3f36aacdb26b6fd581ac46 --- /dev/null +++ b/arkoala-arkts/shopping/src/ets/arkcompilerPOC/test_s2d_operators.ets @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function TestOperators(): void { +} \ No newline at end of file diff --git a/arkoala-arkts/shopping/src/ets/arkcompilerPOC/concurrency.sts b/arkoala-arkts/shopping/src/ets/arkcompilerPOCFiles/concurrency.ts similarity index 100% rename from arkoala-arkts/shopping/src/ets/arkcompilerPOC/concurrency.sts rename to arkoala-arkts/shopping/src/ets/arkcompilerPOCFiles/concurrency.ts diff --git a/arkoala-arkts/shopping/src/ets/arkcompilerPOCFiles/test_s2d_operators.ts b/arkoala-arkts/shopping/src/ets/arkcompilerPOCFiles/test_s2d_operators.ts new file mode 100644 index 0000000000000000000000000000000000000000..cc0afb4d078b414d0d8268249071a134e5859558 --- /dev/null +++ b/arkoala-arkts/shopping/src/ets/arkcompilerPOCFiles/test_s2d_operators.ts @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { info } from "@ohos.hilog"; + +import { + Fruits, + Person, + arr, + numbers, + man, + myMap, + jsonVal, + calculator, + globalVar, + err, + call, + anonymousFunction, + arrowFunction, + Order +} from "pure"; + +function Log(msg: String) { + info(0, "[LOG]", msg); +} + +export function TestOperators(): void { + Log('Panda Test[S2D]: ============ test operators return type begin ============'); + + const newConstructor = new Fruits('apple', 10); + if (newConstructor.kinds as string == "apple" && newConstructor.weight as number == 10) { + Log('Panda Test[S2D]: Passed the test for funcNewConstructor!'); + } else { + Log('Panda Test[S2D]: Failed the test for funcNewConstructor!'); + } + + const newClassInstance = new Person('Alice', 30); + if (newClassInstance.name as string == "Alice" && newClassInstance.age as number == 30) { + Log('Panda Test[S2D]: Passed the test for funcNewClassInstance!'); + } else { + Log('Panda Test[S2D]: Failed the test for funcNewClassInstance!'); + } + + if (arr.length as number == 3) { + Log('Panda Test[S2D]: Passed the test for funcNewBuiltIn!'); + } else { + Log('Panda Test[S2D]: Failed the test for funcNewBuiltIn!'); + } + + if (numbers[0] as number == 10) { + Log('Panda Test[S2D]: Passed the test for funcAccessArrElement!'); + } else { + Log('Panda Test[S2D]: Failed the test for funcAccessArrElement!'); + } + +// if (man["name"] as string == "John") { compile error +// Log('Panda Test[S2D]: Passed the test for funcAccessObjValByKey!'); +// } else { +// Log('Panda Test[S2D]: Failed the test for funcAccessObjValByKey!'); +// } + +// if (myMap[name] as string == "Alice") { compile error +// Log('Panda Test[S2D]: Passed the test for funcAccessMapValByKey!'); +// } else { +// Log('Panda Test[S2D]: Failed the test for funcAccessMapValByKey!'); +// } + + let p = new Person('Doe', 30); + if (p.name as string == "Doe") { + Log('Panda Test[S2D]: Passed the test for funcAccessClassInstanceAttr!'); + } else { + Log('Panda Test[S2D]: Failed the test for funcAccessClassInstanceAttr!'); + } + + if (jsonVal as number == 30) { + Log('Panda Test[S2D]: Passed the test for funcAccessJsonValByKey!'); + } else { + Log('Panda Test[S2D]: Failed the test for funcAccessJsonValByKey!'); + } + + if (calculator.add(1, 2) as number == 3) { + Log('Panda Test[S2D]: Passed the test for funcObjMethod!'); + } else { + Log('Panda Test[S2D]: Failed the test for funcObjMethod!'); + } + + let p1 = new Person('Doe', 30); + if (p1.add(1, 2) as number == 3) { + Log('Panda Test[S2D]: Passed the test for funcClassInstanceMethod!'); + } else { + Log('Panda Test[S2D]: Failed the test for funcClassInstanceMethod!'); + } + + if (Person.staticProp as string == "static prop") { + Log('Panda Test[S2D]: Passed the test for funcClassInstanceStaticProp!'); + } else { + Log('Panda Test[S2D]: Failed the test for funcClassInstanceStaticProp!'); + } + + if (Person.staticMethod() as string == "static method") { + Log('Panda Test[S2D]: Passed the test for funcClassInstanceStaticMethod!'); + } else { + Log('Panda Test[S2D]: Failed the test for funcClassInstanceStaticMethod!'); + } + + if (globalVar as string == "global variable") { + Log('Panda Test[S2D]: Passed the test for funcGlobalObjProp!'); + } else { + Log('Panda Test[S2D]: Failed the test for funcGlobalObjProp!'); + } + + if (err.message as string == "Something went wrong!") { + Log('Panda Test[S2D]: Passed the test for funcErrorProp!'); + } else { + Log('Panda Test[S2D]: Failed the test for funcErrorProp!'); + } + + if (call() as string == "call") { + Log('Panda Test[S2D]: Passed the test for funcCall!'); + } else { + Log('Panda Test[S2D]: Failed the test for funcCall!'); + } + + if (p1.add(3, 3) as number == 6) { + Log('Panda Test[S2D]: Passed the test for funcClassCall!'); + } else { + Log('Panda Test[S2D]: Failed the test for funcClassCall!'); + } + + if (anonymousFunction() as string == "anonymous") { + Log('Panda Test[S2D]: Passed the test for funcAnonymousCall!'); + } else { + Log('Panda Test[S2D]: Failed the test for funcAnonymousCall!'); + } + + if (arrowFunction() as string == "arrow") { + Log('Panda Test[S2D]: Passed the test for funcArrowCall!'); + } else { + Log('Panda Test[S2D]: Failed the test for funcArrowCall!'); + } + + let order = new Order(101,10); + if (order.id as number == 101) { + Log('Panda Test[S2D]: Passed the test for funcConstructorCall!'); + } else { + Log('Panda Test[S2D]: Failed the test for funcConstructorCall!'); + } +} \ No newline at end of file diff --git a/arkoala-arkts/shopping/src/ets/pages/homePage/informance.ets b/arkoala-arkts/shopping/src/ets/pages/homePage/informance.ets index d564f974ea19fb1e4c45ec9e8c916ec296e13c51..a7f583217c288ef811fe25076fbaa5c1992ddd15 100644 --- a/arkoala-arkts/shopping/src/ets/pages/homePage/informance.ets +++ b/arkoala-arkts/shopping/src/ets/pages/homePage/informance.ets @@ -16,7 +16,7 @@ import { InformationModel } from '../../model/homeModel' import { informationData } from '../../data/homeData' import { callFetchWithEACoroutine, callFetchWithCoroutine, callFetchWithTaskPool} from '../../arkcompilerPOC/concurrency' - +import { TestOperators } from '../../arkcompilerPOC/test_s2d_operators' @Component export struct Information { @State color1: string = '#ff0000' @@ -45,6 +45,11 @@ export struct Information { .onClick((e?: ClickEvent) => { callFetchWithEACoroutine(); }) + Button("RunInteropTest") + .width(200).height(100) + .onClick((e?: ClickEvent) => { + TestOperators(); + }) } .width('100%').height('100%') .backgroundColor(Color.Gray)