diff --git a/test/aottest/BUILD.gn b/test/aottest/BUILD.gn index 5d12e644..10f1f22c 100644 --- a/test/aottest/BUILD.gn +++ b/test/aottest/BUILD.gn @@ -17,8 +17,11 @@ group("ark_aot_test") { "add:addAotAction", "and:andAotAction", "ashr:ashrAotAction", + "createarraywithbuffer:createarraywithbufferAotAction", "createemptyarray:createemptyarrayAotAction", "createemptyobject:createemptyobjectAotAction", + "createobjectwithbuffer:createobjectwithbufferAotAction", + "createregexpwithliteral:createregexpwithliteralAotAction", "dec:decAotAction", # "definefunc:definefuncAotAction", @@ -36,6 +39,7 @@ group("ark_aot_test") { "neg:negAotAction", "not:notAotAction", "or:orAotAction", + "setobjectwithproto:setobjectwithprotoAotAction", "shl:shlAotAction", "shr:shrAotAction", "starrayspread:starrayspreadAotAction", @@ -43,6 +47,9 @@ group("ark_aot_test") { "stglobalvar:stglobalvarAotAction", "stlettoglobalrecord:stlettoglobalrecordAotAction", "stobjbyname:stobjbynameAotAction", + "stownbyindex:stownbyindexAotAction", + "stownbyname:stownbynameAotAction", + "stownbyvalue:stownbyvalueAotAction", "strictequal:strictequalAotAction", "strictnotequal:strictnotequalAotAction", "sub:subAotAction", diff --git a/test/aottest/createarraywithbuffer/BUILD.gn b/test/aottest/createarraywithbuffer/BUILD.gn new file mode 100644 index 00000000..1c01acb9 --- /dev/null +++ b/test/aottest/createarraywithbuffer/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright (c) 2022 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("//ark/js_runtime/test/test_helper.gni") + +host_aot_test_action("createarraywithbuffer") { + deps = [] +} diff --git a/test/aottest/createarraywithbuffer/createarraywithbuffer.ts b/test/aottest/createarraywithbuffer/createarraywithbuffer.ts new file mode 100644 index 00000000..2fd57035 --- /dev/null +++ b/test/aottest/createarraywithbuffer/createarraywithbuffer.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022 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. + */ + +declare function print(str:any):string; +var arrayIterator = ['fifth', 'sixth', 666]; +print(arrayIterator[0]); +print(arrayIterator[1]); +print(arrayIterator[2]); \ No newline at end of file diff --git a/test/aottest/createarraywithbuffer/expect_output.txt b/test/aottest/createarraywithbuffer/expect_output.txt new file mode 100644 index 00000000..425363ed --- /dev/null +++ b/test/aottest/createarraywithbuffer/expect_output.txt @@ -0,0 +1,16 @@ +# Copyright (c) 2022 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. + +fifth +sixth +666 diff --git a/test/aottest/createobjectwithbuffer/BUILD.gn b/test/aottest/createobjectwithbuffer/BUILD.gn new file mode 100644 index 00000000..434ce2a8 --- /dev/null +++ b/test/aottest/createobjectwithbuffer/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright (c) 2022 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("//ark/js_runtime/test/test_helper.gni") + +host_aot_test_action("createobjectwithbuffer") { + deps = [] +} diff --git a/test/aottest/createobjectwithbuffer/createobjectwithbuffer.ts b/test/aottest/createobjectwithbuffer/createobjectwithbuffer.ts new file mode 100644 index 00000000..b46ba14f --- /dev/null +++ b/test/aottest/createobjectwithbuffer/createobjectwithbuffer.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2022 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. + */ + +declare function print(str:any):string; +let obj:{a:number, b:string}={ + a:1, + b:"str", +} +print(obj.a); +print(obj.b); \ No newline at end of file diff --git a/test/aottest/createobjectwithbuffer/expect_output.txt b/test/aottest/createobjectwithbuffer/expect_output.txt new file mode 100644 index 00000000..05452cb8 --- /dev/null +++ b/test/aottest/createobjectwithbuffer/expect_output.txt @@ -0,0 +1,15 @@ +# Copyright (c) 2022 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. + +1 +str diff --git a/test/aottest/createregexpwithliteral/BUILD.gn b/test/aottest/createregexpwithliteral/BUILD.gn new file mode 100644 index 00000000..fc5f5c6f --- /dev/null +++ b/test/aottest/createregexpwithliteral/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright (c) 2022 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("//ark/js_runtime/test/test_helper.gni") + +host_aot_test_action("createregexpwithliteral") { + deps = [] +} diff --git a/test/aottest/createregexpwithliteral/createregexpwithliteral.ts b/test/aottest/createregexpwithliteral/createregexpwithliteral.ts new file mode 100644 index 00000000..5417ea54 --- /dev/null +++ b/test/aottest/createregexpwithliteral/createregexpwithliteral.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 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. + */ + +declare function print(str:boolean):boolean; +var re = /abc+/; +var str1 = "abcc"; +var str2 = "ac"; +var res1 = re.test(str1); +var res2 = re.test(str2); +print(res1); +print(res2); \ No newline at end of file diff --git a/test/aottest/createregexpwithliteral/expect_output.txt b/test/aottest/createregexpwithliteral/expect_output.txt new file mode 100644 index 00000000..1455f704 --- /dev/null +++ b/test/aottest/createregexpwithliteral/expect_output.txt @@ -0,0 +1,15 @@ +# Copyright (c) 2022 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. + +true +false diff --git a/test/aottest/defineasyncfunc/BUILD.gn b/test/aottest/defineasyncfunc/BUILD.gn new file mode 100644 index 00000000..2094b58b --- /dev/null +++ b/test/aottest/defineasyncfunc/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright (c) 2022 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("//ark/js_runtime/test/test_helper.gni") + +host_aot_test_action("defineasyncfunc") { + deps = [] +} diff --git a/test/aottest/defineasyncfunc/defineasyncfunc.ts b/test/aottest/defineasyncfunc/defineasyncfunc.ts new file mode 100644 index 00000000..75e9ab14 --- /dev/null +++ b/test/aottest/defineasyncfunc/defineasyncfunc.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 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. + */ + +declare function print(str:any):string; +async function hello(): Promise { + return "hello1"; +} + +hello().then(print); + +print('hello2'); \ No newline at end of file diff --git a/test/aottest/defineasyncfunc/expect_output.txt b/test/aottest/defineasyncfunc/expect_output.txt new file mode 100644 index 00000000..c9cf96b9 --- /dev/null +++ b/test/aottest/defineasyncfunc/expect_output.txt @@ -0,0 +1,15 @@ +# Copyright (c) 2022 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. + +hello2 +hello1 diff --git a/test/aottest/definegeneratorfunc/BUILD.gn b/test/aottest/definegeneratorfunc/BUILD.gn new file mode 100644 index 00000000..cffdb4e3 --- /dev/null +++ b/test/aottest/definegeneratorfunc/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright (c) 2022 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("//ark/js_runtime/test/test_helper.gni") + +host_aot_test_action("definegeneratorfunc") { + deps = [] +} diff --git a/test/aottest/definegeneratorfunc/definegeneratorfunc.ts b/test/aottest/definegeneratorfunc/definegeneratorfunc.ts new file mode 100644 index 00000000..803ce575 --- /dev/null +++ b/test/aottest/definegeneratorfunc/definegeneratorfunc.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2022 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. + */ + +declare function print(str:any):string; +function* genfunc() { + yield 1; + yield 2; + yield 3; +} + +let gen = genfunc(); + +print(gen.next().value); +print(gen.next().value); +print(gen.next().value); +print(gen.next().done); \ No newline at end of file diff --git a/test/aottest/definegeneratorfunc/expect_output.txt b/test/aottest/definegeneratorfunc/expect_output.txt new file mode 100644 index 00000000..f5f89290 --- /dev/null +++ b/test/aottest/definegeneratorfunc/expect_output.txt @@ -0,0 +1,17 @@ +# Copyright (c) 2022 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. + +1 +2 +3 +true diff --git a/test/aottest/getnextpropname/BUILD.gn b/test/aottest/getnextpropname/BUILD.gn new file mode 100644 index 00000000..2f758307 --- /dev/null +++ b/test/aottest/getnextpropname/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright (c) 2022 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("//ark/js_runtime/test/test_helper.gni") + +host_aot_test_action("getnextpropname") { + deps = [] +} diff --git a/test/aottest/getnextpropname/expect_output.txt b/test/aottest/getnextpropname/expect_output.txt new file mode 100644 index 00000000..da3b5d54 --- /dev/null +++ b/test/aottest/getnextpropname/expect_output.txt @@ -0,0 +1,16 @@ +# Copyright (c) 2022 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. + +1 +2 +success diff --git a/test/aottest/getnextpropname/getnextpropname.ts b/test/aottest/getnextpropname/getnextpropname.ts new file mode 100644 index 00000000..5917a96b --- /dev/null +++ b/test/aottest/getnextpropname/getnextpropname.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022 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. + */ + +declare function print(s:any):string; +var test = [1, 2, "success"]; +for(let i in test) { + print(test[i]); +} \ No newline at end of file diff --git a/test/aottest/gettemplateobject/BUILD.gn b/test/aottest/gettemplateobject/BUILD.gn new file mode 100644 index 00000000..f304770a --- /dev/null +++ b/test/aottest/gettemplateobject/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright (c) 2022 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("//ark/js_runtime/test/test_helper.gni") + +host_aot_test_action("gettemplateobject") { + deps = [] +} diff --git a/test/aottest/gettemplateobject/expect_output.txt b/test/aottest/gettemplateobject/expect_output.txt new file mode 100644 index 00000000..5c3a403f --- /dev/null +++ b/test/aottest/gettemplateobject/expect_output.txt @@ -0,0 +1,14 @@ +# Copyright (c) 2022 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. + +hello world! diff --git a/test/aottest/gettemplateobject/gettemplateobject.ts b/test/aottest/gettemplateobject/gettemplateobject.ts new file mode 100644 index 00000000..c7dfd67e --- /dev/null +++ b/test/aottest/gettemplateobject/gettemplateobject.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022 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. + */ + +declare function print(str:any):string; +function f(strarray:any, ...str:any){ +let result = ""; +for(let i = 0; i < strarray.length; i++) { + result += strarray[i]; + if(str[i]) + result += str[i]; +} + return result; +} +let str = "world"; +print(f`hello ${str}!`); \ No newline at end of file diff --git a/test/aottest/ldstlexvar/BUILD.gn b/test/aottest/ldstlexvar/BUILD.gn new file mode 100644 index 00000000..1e416834 --- /dev/null +++ b/test/aottest/ldstlexvar/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright (c) 2022 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("//ark/js_runtime/test/test_helper.gni") + +host_aot_test_action("ldstlexvar") { + deps = [] +} diff --git a/test/aottest/ldstlexvar/expect_output.txt b/test/aottest/ldstlexvar/expect_output.txt new file mode 100644 index 00000000..fbdf0fc9 --- /dev/null +++ b/test/aottest/ldstlexvar/expect_output.txt @@ -0,0 +1,14 @@ +# Copyright (c) 2022 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. + +2 diff --git a/test/aottest/ldstlexvar/ldstlexvar.ts b/test/aottest/ldstlexvar/ldstlexvar.ts new file mode 100644 index 00000000..323b6609 --- /dev/null +++ b/test/aottest/ldstlexvar/ldstlexvar.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 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. + */ + +declare function print(str:any):string; +{ +function f() { return x + 1; } + +const x = 1; + +print(f()); +} \ No newline at end of file diff --git a/test/aottest/setobjectwithproto/BUILD.gn b/test/aottest/setobjectwithproto/BUILD.gn new file mode 100644 index 00000000..02d1a148 --- /dev/null +++ b/test/aottest/setobjectwithproto/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright (c) 2022 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("//ark/js_runtime/test/test_helper.gni") + +host_aot_test_action("setobjectwithproto") { + deps = [] +} diff --git a/test/aottest/setobjectwithproto/expect_output.txt b/test/aottest/setobjectwithproto/expect_output.txt new file mode 100644 index 00000000..1455f704 --- /dev/null +++ b/test/aottest/setobjectwithproto/expect_output.txt @@ -0,0 +1,15 @@ +# Copyright (c) 2022 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. + +true +false diff --git a/test/aottest/setobjectwithproto/setobjectwithproto.ts b/test/aottest/setobjectwithproto/setobjectwithproto.ts new file mode 100644 index 00000000..69ece1ab --- /dev/null +++ b/test/aottest/setobjectwithproto/setobjectwithproto.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 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. + */ + +declare function print(str:any):string; +var proto = {}; +var proto2 = {}; +var obj ={ + __proto__: proto +} +print(obj.__proto__ == proto) +print(obj.__proto__ == proto2); \ No newline at end of file diff --git a/test/aottest/stownbyindex/BUILD.gn b/test/aottest/stownbyindex/BUILD.gn new file mode 100644 index 00000000..feb4a5ac --- /dev/null +++ b/test/aottest/stownbyindex/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright (c) 2022 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("//ark/js_runtime/test/test_helper.gni") + +host_aot_test_action("stownbyindex") { + deps = [] +} diff --git a/test/aottest/stownbyindex/expect_output.txt b/test/aottest/stownbyindex/expect_output.txt new file mode 100644 index 00000000..e111f15c --- /dev/null +++ b/test/aottest/stownbyindex/expect_output.txt @@ -0,0 +1,21 @@ +# Copyright (c) 2022 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. + +ok +1 +2 +3 +yes +no +4 +5 diff --git a/test/aottest/stownbyindex/stownbyindex.ts b/test/aottest/stownbyindex/stownbyindex.ts new file mode 100644 index 00000000..31a33a11 --- /dev/null +++ b/test/aottest/stownbyindex/stownbyindex.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022 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. + */ + +declare function print(str:any):string; +var a : any[] = [ ["ok"], [1, 2, 3] ]; +print(a[0][0]); +print(a[1][0]); +print(a[1][1]); +print(a[1][2]); + +var b = { + 1 : ["yes", "no"], + "100" : [4, 5], +} +print(b[1][0]); +print(b[1][1]); +print(b["100"][0]); +print(b["100"][1]); \ No newline at end of file diff --git a/test/aottest/stownbyname/BUILD.gn b/test/aottest/stownbyname/BUILD.gn new file mode 100644 index 00000000..3d10add7 --- /dev/null +++ b/test/aottest/stownbyname/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright (c) 2022 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("//ark/js_runtime/test/test_helper.gni") + +host_aot_test_action("stownbyname") { + deps = [] +} diff --git a/test/aottest/stownbyname/expect_output.txt b/test/aottest/stownbyname/expect_output.txt new file mode 100644 index 00000000..b30e0ffb --- /dev/null +++ b/test/aottest/stownbyname/expect_output.txt @@ -0,0 +1,15 @@ +# Copyright (c) 2022 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. + +a +b diff --git a/test/aottest/stownbyname/stownbyname.ts b/test/aottest/stownbyname/stownbyname.ts new file mode 100644 index 00000000..56e64c25 --- /dev/null +++ b/test/aottest/stownbyname/stownbyname.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 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. + */ + +declare function print(str:any):string; +var foo = { + bar: [ "a", "b" ] + }; +print(foo.bar[0]); +print(foo.bar[1]); \ No newline at end of file diff --git a/test/aottest/stownbyvalue/BUILD.gn b/test/aottest/stownbyvalue/BUILD.gn new file mode 100644 index 00000000..a95ef194 --- /dev/null +++ b/test/aottest/stownbyvalue/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright (c) 2022 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("//ark/js_runtime/test/test_helper.gni") + +host_aot_test_action("stownbyvalue") { + deps = [] +} diff --git a/test/aottest/stownbyvalue/expect_output.txt b/test/aottest/stownbyvalue/expect_output.txt new file mode 100644 index 00000000..6c73b538 --- /dev/null +++ b/test/aottest/stownbyvalue/expect_output.txt @@ -0,0 +1,15 @@ +# Copyright (c) 2022 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. + +Male +10 diff --git a/test/aottest/stownbyvalue/stownbyvalue.ts b/test/aottest/stownbyvalue/stownbyvalue.ts new file mode 100644 index 00000000..a9534b0d --- /dev/null +++ b/test/aottest/stownbyvalue/stownbyvalue.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022 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. + */ + +declare function print(str:any):string; +var prop:string="gender"; +var prop2:string="age"; +var person:{[key:string]:any} = { + [prop]: "Male", + [prop2]: 10, +} +print(person.gender) +print(person.age) \ No newline at end of file