diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_class_getter.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_class_getter.js index 8cb94531f2b5e688530aa2fdb97477d0610cba51..6cf1a884e1329af79ace604620230e8287e4d473 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_class_getter.js +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_class_getter.js @@ -15,7 +15,6 @@ const { etsVm, getTestModule } = require('scenarios.test.js'); const etsMod = getTestModule('scenarios_test'); -const GCJSRuntimeCleanup = etsMod.getFunction('GCJSRuntimeCleanup'); const ClassWithGetterSetterEts = etsMod.getClass('ClassWithGetterSetterEts'); { diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_class_method_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_class_method_call.js index 871ff2bd71360b84d356b3bd41ba6b103c754d71..5c056ce7aaf11faf2e62229fa2b72c536a23932e 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_class_method_call.js +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_class_method_call.js @@ -15,7 +15,6 @@ const { etsVm, getTestModule } = require('scenarios.test.js'); const etsMod = getTestModule('scenarios_test'); -const GCJSRuntimeCleanup = etsMod.getFunction('GCJSRuntimeCleanup'); const ClassWithMethodEts = etsMod.getClass('ClassWithMethodEts'); { diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_class_setter.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_class_setter.js index b43a24216c0d1540ed056356da596baf622c26ed..bf7c6b690b53189944a0a87efbc81edd4002574b 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_class_setter.js +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_class_setter.js @@ -15,7 +15,6 @@ const { etsVm, getTestModule } = require('scenarios.test.js'); const etsMod = getTestModule('scenarios_test'); -const GCJSRuntimeCleanup = etsMod.getFunction('GCJSRuntimeCleanup'); const ClassWithGetterSetterEts = etsMod.getClass('ClassWithGetterSetterEts'); { diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_extend_class.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_extend_class.js index fff3243086661b37ef59b6a129aded7147ea89bd..52eb6edc43fbfed2b73d532cf6aa58aefcb162b8 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_extend_class.js +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_extend_class.js @@ -15,7 +15,6 @@ const { etsVm, getTestModule } = require('scenarios.test.js'); const etsMod = getTestModule('scenarios_test'); -const GCJSRuntimeCleanup = etsMod.getFunction('GCJSRuntimeCleanup'); const ClassToExtendEts = etsMod.getClass('ClassToExtendEts'); class ChildClass extends ClassToExtendEts { } diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_any_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_any_call.js index bcf3a74df063a952e15b092ce86f2b48d762af88..6d5882469b6b346ac69c7017ae83bd1fec013b0d 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_any_call.js +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_any_call.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -15,10 +15,9 @@ const { etsVm, getTestModule } = require('scenarios.test.js'); const etsMod = getTestModule('scenarios_test'); -const GCJSRuntimeCleanup = etsMod.getFunction('GCJSRuntimeCleanup'); -const functionArgTypeAnyEts = etsMod.getFunction('function_arg_type_any_ets'); +const function_arg_type_any_ets = etsMod.getFunction('function_arg_type_any_ets'); { - let ret = functionArgTypeAnyEts(1); + let ret = function_arg_type_any_ets(1); ASSERT_EQ(ret, 1); } diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_array_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_array_call.js new file mode 100644 index 0000000000000000000000000000000000000000..72aff0c97bfa3690514d56592ebdece1cd0f822e --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_array_call.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_array_ets = etsMod.getFunction('function_arg_type_array_ets'); + +{ + let ret = function_arg_type_array_ets(['one', 'two']); + ASSERT_EQ(ret[0], 'one'); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_array_call_neg.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_array_call_neg.js new file mode 100644 index 0000000000000000000000000000000000000000..ccf9ea66d8ef7fb9a1fb08dfe97f41ba316ec549 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_array_call_neg.js @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_array_ets = etsMod.getFunction('function_arg_type_array_ets'); + +{ + ASSERT_THROWS(TypeError, () => function_arg_type_array_ets([1, 'two'])) +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_boolean_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_boolean_call.js new file mode 100644 index 0000000000000000000000000000000000000000..0b35eebb44e325c06f7b5039d0fa913d33155fa3 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_boolean_call.js @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_boolean_ets = etsMod.getFunction('function_arg_type_boolean_ets'); + +{ + let test = Boolean(true); + let res = function_arg_type_boolean_ets(test); + // calling similar JS method also gets type boolean not Boolean + ASSERT_TRUE(typeof res === 'boolean', 'type \'boolean\' expected'); + ASSERT_TRUE(res); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_boolean_call_neg.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_boolean_call_neg.js new file mode 100644 index 0000000000000000000000000000000000000000..2043cd759b664b5abbd5d2b3b0afc5830e992941 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_boolean_call_neg.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_boolean_ets = etsMod.getFunction('function_arg_type_boolean_ets'); + +{ + let test = 1; + ASSERT_THROWS(TypeError, () => function_arg_type_boolean_ets(test)) +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_byte_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_byte_call.js new file mode 100644 index 0000000000000000000000000000000000000000..5eb819f85da877ddab4ad10ee7df4667fbe36904 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_byte_call.js @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_byte_ets = etsMod.getFunction('function_arg_type_byte_ets'); + +{ + const EXPECTED_POSITIVE_MAX = 127; + const EXPECTED_NEGATIVE_MAX = -128; + const EXCEEDED_VALUE = 128; + ASSERT_EQ(function_arg_type_byte_ets(EXPECTED_POSITIVE_MAX), EXPECTED_POSITIVE_MAX); + ASSERT_EQ(function_arg_type_byte_ets(EXPECTED_NEGATIVE_MAX), EXPECTED_NEGATIVE_MAX); + ASSERT_THROWS(TypeError, () => function_arg_type_byte_ets(EXCEEDED_VALUE)); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_byte_call_neg.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_byte_call_neg.js new file mode 100644 index 0000000000000000000000000000000000000000..0b5e4c14872392a886621267df204f8c41ec7946 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_byte_call_neg.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_byte_ets = etsMod.getFunction('function_arg_type_byte_ets'); + +{ + let WRONG_TYPE_VALUE = '1'; + ASSERT_THROWS(TypeError, () => function_arg_type_byte_ets(WRONG_TYPE_VALUE)); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_callable_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_callable_call.js index 007bc7626de2e88be990e4c26bbe08f9c9aaeba7..97cf047fc272b67a59089c64c100f96c9347d8fa 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_callable_call.js +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_callable_call.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -15,11 +15,10 @@ const { etsVm, getTestModule } = require('scenarios.test.js'); const etsMod = getTestModule('scenarios_test'); -const GCJSRuntimeCleanup = etsMod.getFunction('GCJSRuntimeCleanup'); -const functionArgTypeCallableEts = etsMod.getFunction('function_arg_type_callable_ets'); +const function_arg_type_callable_ets = etsMod.getFunction('function_arg_type_callable_ets'); { - let functionToCall = () => 1; - let ret = functionArgTypeCallableEts(functionToCall); + let function_to_call = () => 1; + let ret = function_arg_type_callable_ets(function_to_call); ASSERT_EQ(ret, 1); } diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_callable_call_neg.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_callable_call_neg.js new file mode 100644 index 0000000000000000000000000000000000000000..330f31c2df7fffe294cef7de17d43a250db243d1 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_callable_call_neg.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_callable_ets = etsMod.getFunction('function_arg_type_callable_ets'); + +{ + let not_function_to_call = 1; + ASSERT_THROWS(TypeError, () => function_arg_type_callable_ets(not_function_to_call)); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_char_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_char_call.js new file mode 100644 index 0000000000000000000000000000000000000000..f16168b70c0b1976cd31a66c06d45fffe020cdf8 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_char_call.js @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_char_ets = etsMod.getFunction('function_arg_type_char_ets'); + +{ + // We use charCodeAt() because JS doesn't have char type but string only + // let EXPECTED_CHAR = 'c'.charCodeAt(0); it works, but returns string 'c' (not char code) + let EXPECTED_CHAR = 'c'; // it works either + ASSERT_EQ(function_arg_type_char_ets(EXPECTED_CHAR), EXPECTED_CHAR); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_char_call_neg.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_char_call_neg.js new file mode 100644 index 0000000000000000000000000000000000000000..d92bbf597174cac9318924352f09f0492685480b --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_char_call_neg.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_char_ets = etsMod.getFunction('function_arg_type_char_ets'); + +{ + const WRONG_CHAR = -1000; + ASSERT_THROWS(TypeError, () => function_arg_type_char_ets(WRONG_CHAR)); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_class_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_class_call.js new file mode 100644 index 0000000000000000000000000000000000000000..be1c6a5fca2284a74165162828419471f8f3c680 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_class_call.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const ClassWithMethodEts = etsMod.getClass('ClassWithMethodEts'); +const function_arg_type_class_ets = etsMod.getFunction('function_arg_type_class_ets'); + +{ + let test = new ClassWithMethodEts(); + ASSERT_EQ(function_arg_type_class_ets(test), 1); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_class_call_neg.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_class_call_neg.js new file mode 100644 index 0000000000000000000000000000000000000000..c9820fc8aeb6896d09b7bc950e670c48efd930ed --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_class_call_neg.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_class_ets = etsMod.getFunction('function_arg_type_class_ets'); + +{ + let not_class = 1; + ASSERT_THROWS(TypeError, () => function_arg_type_class_ets(not_class)); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_float_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_float_call.js new file mode 100644 index 0000000000000000000000000000000000000000..005a8e9bd2da51e8ae9b3e08be23e6763eb262a6 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_float_call.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_float_ets = etsMod.getFunction('function_arg_type_float_ets'); + +{ + const EXPECTED_VALUE = 3.14; + ASSERT_EQ(function_arg_type_float_ets(EXPECTED_VALUE), EXPECTED_VALUE); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_float_call_neg.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_float_call_neg.js new file mode 100644 index 0000000000000000000000000000000000000000..b6e05f57a5eafebc17136f9d228185c8aad458c0 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_float_call_neg.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_float_ets = etsMod.getFunction('function_arg_type_float_ets'); + +{ + let not_float = '1'; + ASSERT_THROWS(TypeError, () => function_arg_type_float_ets(not_float)); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_int_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_int_call.js new file mode 100644 index 0000000000000000000000000000000000000000..1e10302a40c79217aee5d5e177e6706615221ddd --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_int_call.js @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_int_ets = etsMod.getFunction('function_arg_type_int_ets'); + +{ + const EXPECTED_POSITIVE_INT = 2147483647; + const EXPECTED_NEGATIVE_INT = -2147483648; + const EXCEEDED_VALUE = 2147483648; + ASSERT_EQ(function_arg_type_int_ets(EXPECTED_POSITIVE_INT), EXPECTED_POSITIVE_INT); + ASSERT_EQ(function_arg_type_int_ets(EXPECTED_NEGATIVE_INT), EXPECTED_NEGATIVE_INT); + ASSERT_THROWS(Error, () => function_arg_type_int_ets(EXCEEDED_VALUE)); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_int_call_neg.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_int_call_neg.js new file mode 100644 index 0000000000000000000000000000000000000000..57cb43a5c5d92758f340ee5d7ea6a9e719fecb81 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_int_call_neg.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_int_ets = etsMod.getFunction('function_arg_type_int_ets'); + +{ + let not_int = '1'; + ASSERT_THROWS(TypeError, () => function_arg_type_int_ets(not_int)); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_long_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_long_call.js new file mode 100644 index 0000000000000000000000000000000000000000..96b0b24d4ecf88dd75e4b2e24355746c2918f4ec --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_long_call.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_long_ets = etsMod.getFunction('function_arg_type_long_ets'); + +{ + const EXPECTED_LONG = 9007199254740991; + ASSERT_EQ(function_arg_type_long_ets(EXPECTED_LONG), EXPECTED_LONG); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_long_call_neg.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_long_call_neg.js new file mode 100644 index 0000000000000000000000000000000000000000..53b170f14fd0c84cda141ec448e931703cb31ca3 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_long_call_neg.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_long_ets = etsMod.getFunction('function_arg_type_long_ets'); + +{ + let not_long = '1'; + ASSERT_THROWS(TypeError, () => function_arg_type_long_ets(not_long)); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_number_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_number_call.js new file mode 100644 index 0000000000000000000000000000000000000000..5fe52729821b742bb59c6529c2dec64815c30d10 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_number_call.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_number_ets = etsMod.getFunction('function_arg_type_number_ets'); + +{ + const EXPECTED_VALUE = 1; + ASSERT_EQ(function_arg_type_number_ets(EXPECTED_VALUE), EXPECTED_VALUE); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_number_call_neg.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_number_call_neg.js new file mode 100644 index 0000000000000000000000000000000000000000..cd0eaf1c6b18cf1b6dd1776bfb8a5256ce7cedaa --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_number_call_neg.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_number_ets = etsMod.getFunction('function_arg_type_number_ets'); + +{ + let not_number = '1'; + ASSERT_THROWS(TypeError, () => function_arg_type_number_ets(not_number)); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_object_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_object_call.js new file mode 100644 index 0000000000000000000000000000000000000000..d4b68a30217d31f26d9f57d3d952fb8169731889 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_object_call.js @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_object_ets = etsMod.getFunction('function_arg_type_object_ets'); + +{ + let test = new Object({id: 1}); + let res = function_arg_type_object_ets(test); + ASSERT_TRUE(typeof res === 'object'); + ASSERT_EQ(res.id, 1); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_object_call_neg.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_object_call_neg.js new file mode 100644 index 0000000000000000000000000000000000000000..34ac5867788648b49626ee0175d3b62f16b03b44 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_object_call_neg.js @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_object_ets = etsMod.getFunction('function_arg_type_object_ets'); + +{ + ASSERT_THROWS(TypeError, () => function_arg_type_object_ets(1)); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_short_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_short_call.js new file mode 100644 index 0000000000000000000000000000000000000000..53649f434fa7b24ec4447c8722920cdc66be7dd8 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_short_call.js @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_short_ets = etsMod.getFunction('function_arg_type_short_ets'); + +{ + const EXPECTED_POSITIVE_SHORT = 32767; + const EXPECTED_NEGATIVE_SHORT = -32768; + const EXCEEDED_VALUE = 32768; + ASSERT_EQ(function_arg_type_short_ets(EXPECTED_POSITIVE_SHORT), EXPECTED_POSITIVE_SHORT); + ASSERT_EQ(function_arg_type_short_ets(EXPECTED_NEGATIVE_SHORT), EXPECTED_NEGATIVE_SHORT); + ASSERT_THROWS(TypeError, () => function_arg_type_short_ets(EXCEEDED_VALUE)); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_short_call_neg.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_short_call_neg.js new file mode 100644 index 0000000000000000000000000000000000000000..eceb43527fa831c0d9ff7637162d8b2e42923abc --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_short_call_neg.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_short_ets = etsMod.getFunction('function_arg_type_short_ets'); + +{ + let not_short = '1'; + ASSERT_THROWS(TypeError, () => function_arg_type_short_ets(not_short)); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_string_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_string_call.js new file mode 100644 index 0000000000000000000000000000000000000000..b97c3883350a2da58c14495426afcdbef13eae5c --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_string_call.js @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_string_ets = etsMod.getFunction('function_arg_type_string_ets'); + +{ + let test = 'test'; + let res = function_arg_type_string_ets(test); + // calling similar JS method also gets type string not String + ASSERT_TRUE(typeof res === 'string', 'type \'string\' expected'); + ASSERT_EQ(res, 'test'); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_string_call_neg.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_string_call_neg.js new file mode 100644 index 0000000000000000000000000000000000000000..6fc05181a26f17afca8453d90cffc39b5c3f7dd5 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_string_call_neg.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_string_ets = etsMod.getFunction('function_arg_type_string_ets'); + +{ + let not_string = 1; + ASSERT_THROWS(TypeError, () => function_arg_type_string_ets(not_string)); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_tuple_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_tuple_call.js index 5a4f5c92a37d7e9df0c6bce4036417fed5abc9a5..dcb2d75a649da6bd745633487eccf64ab68a0541 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_tuple_call.js +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_tuple_call.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -16,9 +16,8 @@ const { etsVm, getTestModule } = require('scenarios.test.js'); const etsMod = getTestModule('scenarios_test'); const GCJSRuntimeCleanup = etsMod.getFunction('GCJSRuntimeCleanup'); -const functionArgTypeTupleEts = etsMod.getFunction('function_arg_type_tuple_ets'); +const function_arg_type_tuple_ets = etsMod.getFunction('function_arg_type_tuple_ets'); { - let ret = functionArgTypeTupleEts([1, 'one']); - ASSERT_EQ(ret, 1); + ASSERT_EQ(function_arg_type_tuple_ets([1, 'one']), 1); } diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_tuple_call_neg.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_tuple_call_neg.js new file mode 100644 index 0000000000000000000000000000000000000000..9294a2d6489e4dcf90443e374114df941a14a965 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_tuple_call_neg.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_tuple_ets = etsMod.getFunction('function_arg_type_tuple_ets'); + +{ + let not_tuple = 1; + ASSERT_THROWS(TypeError, () => function_arg_type_tuple_ets(not_tuple)); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_undefined_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_undefined_call.js index fc57f32a14c7cf29002a4029c48c0ae798874b86..4b3c46a5a495d381df9b301e290da5ba7fac3c34 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_undefined_call.js +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_undefined_call.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -15,10 +15,8 @@ const { etsVm, getTestModule } = require('scenarios.test.js'); const etsMod = getTestModule('scenarios_test'); -const GCJSRuntimeCleanup = etsMod.getFunction('GCJSRuntimeCleanup'); -const functionArgTypeUndefinedEts = etsMod.getFunction('function_arg_type_undefined_ets'); +const function_arg_type_undefined_ets = etsMod.getFunction('function_arg_type_undefined_ets'); { - let ret = functionArgTypeUndefinedEts(1); - ASSERT_EQ(ret, 1); + ASSERT_EQ(function_arg_type_undefined_ets(1), 1); } diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_union_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_union_call.js new file mode 100644 index 0000000000000000000000000000000000000000..92cace3feff7720b76fac1953f6bb8f526b1552d --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_union_call.js @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_union_ets = etsMod.getFunction('function_arg_type_union_ets'); + +{ + let test_string = 'test'; + let test_number = 1; + let res_string = function_arg_type_union_ets(test_string); + // calling similar JS method also gets type string not String + ASSERT_TRUE(typeof res_string === 'string', 'type \'string\' expected'); + ASSERT_EQ(res_string, 'test'); + let res_number = function_arg_type_union_ets(test_number); + ASSERT_TRUE(typeof res_number === 'number', 'type \'number\' expected'); + ASSERT_EQ(res_number, 1); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_union_call_neg.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_union_call_neg.js new file mode 100644 index 0000000000000000000000000000000000000000..8dfa4002fa3fa1eecfb765f6462dd93975f2f8f7 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_union_call_neg.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_arg_type_union_ets = etsMod.getFunction('function_arg_type_union_ets'); + +{ + let not_union = ['one', 'two']; + ASSERT_THROWS(TypeError, () => function_arg_type_union_ets(not_union)); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_unknown_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_unknown_call.js index 69f6799df983f75940c47b4769b9c3ee22e767ca..b072c0e336ca54f00b3fbc291ee007e3e257e0df 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_unknown_call.js +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_unknown_call.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -15,10 +15,8 @@ const { etsVm, getTestModule } = require('scenarios.test.js'); const etsMod = getTestModule('scenarios_test'); -const GCJSRuntimeCleanup = etsMod.getFunction('GCJSRuntimeCleanup'); -const functionArgTypeUnknownEts = etsMod.getFunction('function_arg_type_unknown_ets'); +const function_arg_type_unknown_ets = etsMod.getFunction('function_arg_type_unknown_ets'); { - let ret = functionArgTypeUnknownEts(1); - ASSERT_EQ(ret, 1); + ASSERT_EQ(function_arg_type_unknown_ets(1), 1); } diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_array_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_array_call.js new file mode 100644 index 0000000000000000000000000000000000000000..7e03cb97275bbfdf47dadaeab168e062318a57eb --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_array_call.js @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_arg_type_array_ets = etsMod.getFunction('function_opt_arg_type_array_ets'); + +{ + let ret = function_opt_arg_type_array_ets(['one', 'two']); + ASSERT_EQ(ret[0], 'one'); + ret = function_opt_arg_type_array_ets(); + ASSERT_EQ(ret[0], 'one'); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_boolean_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_boolean_call.js new file mode 100644 index 0000000000000000000000000000000000000000..f56913aa13f34dd9ef2edf3289cf4c191bda5ecc --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_boolean_call.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_arg_type_boolean_ets = etsMod.getFunction('function_opt_arg_type_boolean_ets'); + +{ + ASSERT_TRUE(function_opt_arg_type_boolean_ets(true)); + ASSERT_TRUE(function_opt_arg_type_boolean_ets()); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_byte_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_byte_call.js new file mode 100644 index 0000000000000000000000000000000000000000..253aadcf16a4212083c9b2f79e2ea88eb24f74f8 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_byte_call.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_arg_type_byte_ets = etsMod.getFunction('function_opt_arg_type_byte_ets'); + +{ + const EXPECTED_VALUE = 1; + ASSERT_EQ(function_opt_arg_type_byte_ets(EXPECTED_VALUE), EXPECTED_VALUE); + ASSERT_EQ(function_opt_arg_type_byte_ets(), EXPECTED_VALUE); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_callable_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_callable_call.js new file mode 100644 index 0000000000000000000000000000000000000000..77f02153651ae95e1cdf45514b4cac71b622c5e7 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_callable_call.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_arg_type_callable_ets = etsMod.getFunction('function_opt_arg_type_callable_ets'); + +{ + let functionToCall = () => 1; + ASSERT_EQ(function_opt_arg_type_callable_ets(functionToCall), 1); + ASSERT_EQ(function_opt_arg_type_callable_ets(), 1); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_char_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_char_call.js new file mode 100644 index 0000000000000000000000000000000000000000..e04e2e3d16b780b9f1a4c5ecb1ff3853bca5de1a --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_char_call.js @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_arg_type_char_ets = etsMod.getFunction('function_opt_arg_type_char_ets'); + +{ + // We use charCodeAt() because JS doesn't have char type but string only + // let EXPECTED_CHAR = 'c'.charCodeAt(0); + let EXPECTED_CHAR = 'c'; + ASSERT_EQ(function_opt_arg_type_char_ets(EXPECTED_CHAR), EXPECTED_CHAR); + ASSERT_EQ(function_opt_arg_type_char_ets(), EXPECTED_CHAR); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_class_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_class_call.js new file mode 100644 index 0000000000000000000000000000000000000000..29adb5b97e5b68a7a7b30b5746ed9d3c3289b110 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_class_call.js @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const ClassWithMethodEts = etsMod.getClass('ClassWithMethodEts'); +const function_opt_arg_type_class_ets = etsMod.getFunction('function_opt_arg_type_class_ets'); + +{ + let test = new ClassWithMethodEts(); + ASSERT_EQ(function_opt_arg_type_class_ets(test), 1); + ASSERT_EQ(function_opt_arg_type_class_ets(), 1); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_float_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_float_call.js new file mode 100644 index 0000000000000000000000000000000000000000..f566b5b53b4c795424b93b8af62081729cbd88cd --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_float_call.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_arg_type_float_ets = etsMod.getFunction('function_opt_arg_type_float_ets'); + +{ + const EXPECTED_VALUE = 1; + ASSERT_EQ(function_opt_arg_type_float_ets(EXPECTED_VALUE), EXPECTED_VALUE); + ASSERT_EQ(function_opt_arg_type_float_ets(), EXPECTED_VALUE); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_int_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_int_call.js new file mode 100644 index 0000000000000000000000000000000000000000..bc99efeee7dd6ee9b62064c9bfa5068d4960aeb5 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_int_call.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_arg_type_int_ets = etsMod.getFunction('function_opt_arg_type_int_ets'); + +{ + const EXPECTED_VALUE = 1; + ASSERT_EQ(function_opt_arg_type_int_ets(EXPECTED_VALUE), EXPECTED_VALUE); + ASSERT_EQ(function_opt_arg_type_int_ets(), EXPECTED_VALUE); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_long_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_long_call.js new file mode 100644 index 0000000000000000000000000000000000000000..4830e3f13361795e2c2ca6d573d63e4fdd157b78 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_long_call.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_arg_type_long_ets = etsMod.getFunction('function_opt_arg_type_long_ets'); + +{ + const EXPECTED_VALUE = 1; + ASSERT_EQ(function_opt_arg_type_long_ets(EXPECTED_VALUE), EXPECTED_VALUE); + ASSERT_EQ(function_opt_arg_type_long_ets(), EXPECTED_VALUE); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_number_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_number_call.js new file mode 100644 index 0000000000000000000000000000000000000000..82ea960152bf70489e8691dacbbba68847c86a6b --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_number_call.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_arg_type_number_ets = etsMod.getFunction('function_opt_arg_type_number_ets'); + +{ + const EXPECTED_VALUE = 1; + ASSERT_EQ(function_opt_arg_type_number_ets(EXPECTED_VALUE), EXPECTED_VALUE); + ASSERT_EQ(function_opt_arg_type_number_ets(), EXPECTED_VALUE); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_object_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_object_call.js new file mode 100644 index 0000000000000000000000000000000000000000..e4aaebfa8b3dc07ee2a7f4debcf9671f8cab2f8d --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_object_call.js @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_arg_type_object_ets = etsMod.getFunction('function_opt_arg_type_object_ets'); + +{ + let test = new Object({id: 1}); + let res = function_opt_arg_type_object_ets(test); + ASSERT_EQ(res.id, 1); + res = function_opt_arg_type_object_ets(); + ASSERT_EQ(res.id, 1); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_short_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_short_call.js new file mode 100644 index 0000000000000000000000000000000000000000..d19ca777ff3046fad8ea4be162866d1541af0f09 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_short_call.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_arg_type_short_ets = etsMod.getFunction('function_opt_arg_type_short_ets'); + +{ + const EXPECTED_VALUE = 1; + ASSERT_EQ(function_opt_arg_type_short_ets(EXPECTED_VALUE), EXPECTED_VALUE); + ASSERT_EQ(function_opt_arg_type_short_ets(), EXPECTED_VALUE); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_string_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_string_call.js new file mode 100644 index 0000000000000000000000000000000000000000..5990a1882f1f3547573cb21434710e885a8e0acd --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_string_call.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_arg_type_string_ets = etsMod.getFunction('function_opt_arg_type_string_ets'); + +{ + const EXPECTED_VALUE = 'test'; + ASSERT_EQ(function_opt_arg_type_string_ets(EXPECTED_VALUE), EXPECTED_VALUE); + ASSERT_EQ(function_opt_arg_type_string_ets(), EXPECTED_VALUE); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_tuple_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_tuple_call.js new file mode 100644 index 0000000000000000000000000000000000000000..03d642f3f054b76ce47173694c6f30b2d77c4c80 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_tuple_call.js @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_arg_type_tuple_ets = etsMod.getFunction('function_opt_arg_type_tuple_ets'); + +{ + let res = function_opt_arg_type_tuple_ets([1, 'one']; + ASSERT_EQ(res[0]), 1); + res = function_opt_arg_type_tuple_ets(); + ASSERT_EQ(res[0]), 1); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_union_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_union_call.js new file mode 100644 index 0000000000000000000000000000000000000000..78fe8271536b61c05ae784aa440d747063173cad --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_union_call.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_arg_type_union_ets = etsMod.getFunction('function_opt_arg_type_union_ets'); + +{ + ASSERT_EQ(function_opt_arg_type_union_ets(1), 1); + ASSERT_EQ(function_opt_arg_type_union_ets(), 'test'); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_array_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_array_call.js new file mode 100644 index 0000000000000000000000000000000000000000..23c3e5316e0cd5b00bb995d150a9c08871907ed4 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_array_call.js @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_default_arg_type_array_ets = etsMod.getFunction('function_opt_default_arg_type_array_ets'); + +{ + let ret = function_opt_default_arg_type_array_ets(['one', 'two']); + ASSERT_EQ(ret[0], 'one'); + ret = function_opt_default_arg_type_array_ets(); + ASSERT_EQ(ret[0], 'one'); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_boolean_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_boolean_call.js new file mode 100644 index 0000000000000000000000000000000000000000..e7a8fdda27adc67b6bc517fa37f439f97117300b --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_boolean_call.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_default_arg_type_boolean_ets = etsMod.getFunction('function_opt_default_arg_type_boolean_ets'); + +{ + ASSERT_TRUE(function_opt_default_arg_type_boolean_ets(true)); + ASSERT_TRUE(function_opt_default_arg_type_boolean_ets()); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_byte_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_byte_call.js new file mode 100644 index 0000000000000000000000000000000000000000..affd8dece486ea090d524826d3a3ed7f38c6bf3d --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_byte_call.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_default_arg_type_byte_ets = etsMod.getFunction('function_opt_default_arg_type_byte_ets'); + +{ + const EXPECTED_VALUE = 1; + ASSERT_EQ(function_opt_default_arg_type_byte_ets(EXPECTED_VALUE), EXPECTED_VALUE); + ASSERT_EQ(function_opt_default_arg_type_byte_ets(), EXPECTED_VALUE); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_callable_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_callable_call.js new file mode 100644 index 0000000000000000000000000000000000000000..818479b55ca96543022af40ebef71bea931901b7 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_callable_call.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_default_arg_type_callable_ets = etsMod.getFunction('function_opt_default_arg_type_callable_ets'); + +{ + let functionToCall = () => 1; + ASSERT_EQ(function_opt_default_arg_type_callable_ets(functionToCall), 1); + ASSERT_EQ(function_opt_default_arg_type_callable_ets(), 1); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_char_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_char_call.js new file mode 100644 index 0000000000000000000000000000000000000000..aa35eb5096064927b8aecfc7b389b61e5d636d8f --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_char_call.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_default_arg_type_char_ets = etsMod.getFunction('function_opt_default_arg_type_char_ets'); + +{ + let EXPECTED_CHAR = 'c'; + ASSERT_EQ(function_opt_default_arg_type_char_ets(EXPECTED_CHAR), EXPECTED_CHAR); + ASSERT_EQ(function_opt_default_arg_type_char_ets(), EXPECTED_CHAR); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_class_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_class_call.js new file mode 100644 index 0000000000000000000000000000000000000000..63660034aad54696ea0fc30c4d4f2ee4460a3293 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_class_call.js @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const ClassWithMethodEts = etsMod.getClass('ClassWithMethodEts'); +const function_opt_default_arg_type_class_ets = etsMod.getFunction('function_opt_default_arg_type_class_ets'); + +{ + let test = new ClassWithMethodEts(); + ASSERT_EQ(function_opt_default_arg_type_class_ets(test), 1); + ASSERT_EQ(function_opt_default_arg_type_class_ets(), 1); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_float_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_float_call.js new file mode 100644 index 0000000000000000000000000000000000000000..92bc09844b8508ceb5fcc6b94647424e08903c61 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_float_call.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_default_arg_type_float_ets = etsMod.getFunction('function_opt_default_arg_type_float_ets'); + +{ + const EXPECTED_VALUE = 1; + ASSERT_EQ(function_opt_default_arg_type_float_ets(EXPECTED_VALUE), EXPECTED_VALUE); + ASSERT_EQ(function_opt_default_arg_type_float_ets(), EXPECTED_VALUE); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_int_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_int_call.js new file mode 100644 index 0000000000000000000000000000000000000000..032e690843ca27a965e9c5985d0d55622436bb6a --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_int_call.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_default_arg_type_int_ets = etsMod.getFunction('function_opt_default_arg_type_int_ets'); + +{ + const EXPECTED_VALUE = 1; + ASSERT_EQ(function_opt_default_arg_type_int_ets(EXPECTED_VALUE), EXPECTED_VALUE); + ASSERT_EQ(function_opt_default_arg_type_int_ets(), EXPECTED_VALUE); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_long_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_long_call.js new file mode 100644 index 0000000000000000000000000000000000000000..484e02bb6111ff539125a9acbac7d971252583b2 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_long_call.js @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const GCJSRuntimeCleanup = etsMod.getFunction('GCJSRuntimeCleanup'); +const function_opt_default_arg_type_long_ets = etsMod.getFunction('function_opt_default_arg_type_long_ets'); + +{ + const EXPECTED_VALUE = 1; + ASSERT_EQ(function_opt_default_arg_type_long_ets(EXPECTED_VALUE), EXPECTED_VALUE); + ASSERT_EQ(function_opt_default_arg_type_long_ets(), EXPECTED_VALUE); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_number_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_number_call.js new file mode 100644 index 0000000000000000000000000000000000000000..818f5395207065e1cf9121fd7e16a4076cb35d62 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_number_call.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_default_arg_type_number_ets = etsMod.getFunction('function_opt_default_arg_type_number_ets'); + +{ + const EXPECTED_VALUE = 1; + ASSERT_EQ(function_opt_default_arg_type_number_ets(EXPECTED_VALUE), EXPECTED_VALUE); + ASSERT_EQ(function_opt_default_arg_type_number_ets(), EXPECTED_VALUE); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_object_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_object_call.js new file mode 100644 index 0000000000000000000000000000000000000000..a9fb9a217c42eb776bee26d6b9f574fc70742269 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_object_call.js @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_default_arg_type_object_ets = etsMod.getFunction('function_opt_default_arg_type_object_ets'); + +{ + let test = new Object({id: 1}); + let res = function_opt_default_arg_type_object_ets(test); + ASSERT_EQ(res.id, 1); + res = function_opt_default_arg_type_object_ets(); + ASSERT_EQ(res.id, 1); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_short_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_short_call.js new file mode 100644 index 0000000000000000000000000000000000000000..90a231c764b3e9f7e6e06fa01ade62385ef5c6fe --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_short_call.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_default_arg_type_short_ets = etsMod.getFunction('function_opt_default_arg_type_short_ets'); + +{ + const EXPECTED_VALUE = 1; + ASSERT_EQ(function_opt_default_arg_type_short_ets(EXPECTED_VALUE), EXPECTED_VALUE); + ASSERT_EQ(function_opt_default_arg_type_short_ets(), EXPECTED_VALUE); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_string_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_string_call.js new file mode 100644 index 0000000000000000000000000000000000000000..141795beceb35fa1f93daa8ef9bb992a2ce4c729 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_string_call.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_default_arg_type_string_ets = etsMod.getFunction('function_opt_default_arg_type_string_ets'); + +{ + const EXPECTED_VALUE = 'test'; + ASSERT_EQ(function_opt_default_arg_type_string_ets(EXPECTED_VALUE), EXPECTED_VALUE); + ASSERT_EQ(function_opt_default_arg_type_string_ets(), EXPECTED_VALUE); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_tuple_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_tuple_call.js new file mode 100644 index 0000000000000000000000000000000000000000..fb2b33efc50959a5a1f4421ddd2c8eb62841c0c2 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_tuple_call.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_opt_default_arg_type_tuple_ets = etsMod.getFunction('function_opt_default_arg_type_tuple_ets'); + +{ + ASSERT_EQ(function_opt_default_arg_type_tuple_ets([1, 'one']), 1); + ASSERT_EQ(function_opt_default_arg_type_tuple_ets(), 1); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_union_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_union_call.js new file mode 100644 index 0000000000000000000000000000000000000000..cf18f978517a26f5b2d90b30336147cbbe3bd55f --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_union_call.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const functionOptDefaultArgTypeUnionEts = etsMod.getFunction('function_opt_default_arg_type_union_ets'); + +{ + ASSERT_EQ(function_opt_default_arg_type_union_ets(1), 1); + ASSERT_EQ(function_opt_default_arg_type_union_ets(), 'test'); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_array_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_array_call.js new file mode 100644 index 0000000000000000000000000000000000000000..4e025118cca4283ea0e8b5bee55fba6b14612129 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_array_call.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_ret_type_array_ets = etsMod.getFunction('function_ret_type_array_ets'); + +{ + let res = function_ret_type_array_ets() + ASSERT_EQ(res[0], 'one'); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_boolean_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_boolean_call.js new file mode 100644 index 0000000000000000000000000000000000000000..1ef415c9f5d91eeb76bebf53e5d656d85744021f --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_boolean_call.js @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_ret_type_boolean_ets = etsMod.getFunction('function_ret_type_boolean_ets'); + +{ + ASSERT_TRUE(function_ret_type_boolean_ets()); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_byte_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_byte_call.js new file mode 100644 index 0000000000000000000000000000000000000000..c50e2190f531a5a7de696ca329ab6647a432e91f --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_byte_call.js @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_ret_type_byte_ets = etsMod.getFunction('function_ret_type_byte_ets'); + +{ + ASSERT_EQ(function_ret_type_byte_ets(), 1); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_callable_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_callable_call.js new file mode 100644 index 0000000000000000000000000000000000000000..4125bf0c117f96ca9c8b4eca2d608ae6d2cebb74 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_callable_call.js @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_ret_type_callable_ets = etsMod.getFunction('function_ret_type_callable_ets'); + +{ + ASSERT_EQ(function_ret_type_callable_ets()(), 1); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_char_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_char_call.js new file mode 100644 index 0000000000000000000000000000000000000000..eb62079fd9071590451b828ff720290b12b27024 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_char_call.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_ret_type_char_ets = etsMod.getFunction('function_ret_type_char_ets'); + +{ + let EXPECTED_CHAR = 'c'; + ASSERT_EQ(function_ret_type_char_ets(), EXPECTED_CHAR); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_class_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_class_call.js new file mode 100644 index 0000000000000000000000000000000000000000..f9e0640323b4769ab64837a3ecddb2a9a9c8c432 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_class_call.js @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const ClassWithMethodEts = etsMod.getClass('ClassWithMethodEts'); +const function_ret_type_class_ets = etsMod.getFunction('function_ret_type_class_ets'); + +{ + let res = function_ret_type_class_ets(); + ASSERT_TRUE(res instanceof ClassWithMethodEts); + ASSERT_EQ(res.methodInClass(), 1); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_float_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_float_call.js new file mode 100644 index 0000000000000000000000000000000000000000..3f69651f5a0d6e263ebeba8767cdea214049a126 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_float_call.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_ret_type_float_ets = etsMod.getFunction('function_ret_type_float_ets'); + +{ + const EXPECTED_FLOAT = 3.140000104904175; + ASSERT_EQ(function_ret_type_float_ets(), EXPECTED_FLOAT); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_int_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_int_call.js new file mode 100644 index 0000000000000000000000000000000000000000..dc2cb7059b7015e07127fac6093f1bf254bb2af3 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_int_call.js @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_ret_type_int_ets = etsMod.getFunction('function_ret_type_int_ets'); + +{ + ASSERT_EQ(function_ret_type_int_ets(), 1); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_long_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_long_call.js new file mode 100644 index 0000000000000000000000000000000000000000..e226a08339caec6a7a0e8e80262e5cc2ef6fc676 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_long_call.js @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_ret_type_long_ets = etsMod.getFunction('function_ret_type_long_ets'); + +{ + ASSERT_EQ(function_ret_type_long_ets(), 1); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_number_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_number_call.js new file mode 100644 index 0000000000000000000000000000000000000000..91f2b88b47b764afc64dc911ac7163ad55b83b1e --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_number_call.js @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_ret_type_number_ets = etsMod.getFunction('function_ret_type_number_ets'); + +{ + ASSERT_EQ(function_ret_type_number_ets(), 1); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_object_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_object_call.js new file mode 100644 index 0000000000000000000000000000000000000000..ccc6cd5ff4c64b5e733bbe0de0444235c9214ce6 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_object_call.js @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_ret_type_object_ets = etsMod.getFunction('function_ret_type_object_ets'); + +{ + let res = function_ret_type_object_ets(); + ASSERT_TRUE(typeof res === 'object'); + ASSERT_EQ(res.id, 1); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_short_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_short_call.js new file mode 100644 index 0000000000000000000000000000000000000000..99542537cdcc6fef1fdee56b2b0f7c5b0754c0a1 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_short_call.js @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_ret_type_short_ets = etsMod.getFunction('function_ret_type_short_ets'); + +{ + ASSERT_EQ(function_ret_type_short_ets(), 1); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_string_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_string_call.js new file mode 100644 index 0000000000000000000000000000000000000000..373060ec1dc391dc114cca4eb5c722ff6b9772f9 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_string_call.js @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_ret_type_string_ets = etsMod.getFunction('function_ret_type_string_ets'); + +{ + ASSERT_EQ(function_ret_type_string_ets(), 'test'); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_tuple_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_tuple_call.js new file mode 100644 index 0000000000000000000000000000000000000000..614f418142f483bf5f3dfeb3ecb36da5a914cd44 --- /dev/null +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_tuple_call.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2023-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. + */ +const { etsVm, getTestModule } = require('scenarios.test.js'); + +const etsMod = getTestModule('scenarios_test'); +const function_ret_type_tuple_ets = etsMod.getFunction('function_ret_type_tuple_ets'); + +{ + let res = function_ret_type_tuple_ets() + ASSERT_EQ(res[0], 1); +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_generic_function_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_generic_function_call.js index 77a8a65db50f504ade77b47cefca04c7f33aefc5..ddaba60c6834d55173e4332bd0e7d954d275fb4b 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_generic_function_call.js +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_generic_function_call.js @@ -15,11 +15,10 @@ const { etsVm, getTestModule } = require('scenarios.test.js'); const etsMod = getTestModule('scenarios_test'); -const GCJSRuntimeCleanup = etsMod.getFunction('GCJSRuntimeCleanup'); -const genericFunctionEts = etsMod.getFunction('generic_function_ets'); +const generic_function_ets = etsMod.getFunction('generic_function_ets'); { - let ret = genericFunctionEts(1); + let ret = generic_function_ets(1); ASSERT_EQ(typeof ret, 'number'); ASSERT_EQ(ret, 1); } diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_interface_method_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_interface_method_call.js index 815accc2127291820a90d18bbe90db2a14270b69..56af4efc0312085b8e796dd73e2dd4924dee23d5 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_interface_method_call.js +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_interface_method_call.js @@ -15,7 +15,6 @@ const { etsVm, getTestModule } = require('scenarios.test.js'); const etsMod = getTestModule('scenarios_test'); -const GCJSRuntimeCleanup = etsMod.getFunction('GCJSRuntimeCleanup'); const newInterfaceWithMethodEts = etsMod.getFunction('newInterfaceWithMethodEts'); { diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_lambda_function_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_lambda_function_call.js index 8a24c8fbbedd03fe0e82486adef56b21179dc496..484186000d190f177b4e681140d524f4ce2dee5b 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_lambda_function_call.js +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_lambda_function_call.js @@ -15,11 +15,10 @@ const { etsVm, getTestModule } = require('scenarios.test.js'); const etsMod = getTestModule('scenarios_test'); -const GCJSRuntimeCleanup = etsMod.getFunction('GCJSRuntimeCleanup'); -const getLambdaFunctionEts = etsMod.getFunction('get_lambda_function_ets'); +const get_lambda_function_ets = etsMod.getFunction('get_lambda_function_ets'); { - let lambdaFunctionEts = getLambdaFunctionEts(); + let lambdaFunctionEts = get_lambda_function_ets(); let ret = lambdaFunctionEts(); ASSERT_EQ(ret, 1); } diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_standalone_function_call.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_standalone_function_call.js index 290f067c7892c5c1fcf202aafb14fe6f244ee6d9..c5a8a91c78927cef05030fdb768f3b39d11766da 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_standalone_function_call.js +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_standalone_function_call.js @@ -15,10 +15,9 @@ const { etsVm, getTestModule } = require('scenarios.test.js'); const etsMod = getTestModule('scenarios_test'); -const GCJSRuntimeCleanup = etsMod.getFunction('GCJSRuntimeCleanup'); -const standaloneFunctionEts = etsMod.getFunction('standalone_function_ets'); +const standalone_function_ets = etsMod.getFunction('standalone_function_ets'); { - let ret = standaloneFunctionEts(); + let ret = standalone_function_ets(); ASSERT_EQ(ret, 1); } diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/scenarios.cpp b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/scenarios.cpp index 86965b46ef037f02938b7c1446a11fb475412509..5ba5b6f6414c90abdbf8290f9a784c35ec671979 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/scenarios.cpp +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/scenarios.cpp @@ -84,16 +84,429 @@ TEST_F(EtsInteropScenariosEtsToJs, test_function_arg_type_undefined_call) ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_undefined_call.js")); } +// Reference type as a parameter + +TEST_F(EtsInteropScenariosEtsToJs, test_function_arg_type_number_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_number_call.js")); +} + +// NOTE (vladimiralpavlov) Causes system crash +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_arg_type_number_call_neg) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_number_call_neg.js")); +} + +TEST_F(EtsInteropScenariosEtsToJs, test_function_arg_type_byte_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_byte_call.js")); +} + +// NOTE (vladimiralpavlov) Causes system crash +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_arg_type_byte_call_neg) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_byte_call_neg.js")); +} + +TEST_F(EtsInteropScenariosEtsToJs, test_function_arg_type_short_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_short_call.js")); +} + +// NOTE (vladimiralpavlov) Causes system crash +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_arg_type_short_call_neg) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_short_call_neg.js")); +} + +// NOTE (vladimiralpavlov) enable this after interop is implemented in this direction +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_arg_type_int_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_int_call.js")); +} + +// NOTE (vladimiralpavlov) Causes system crash +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_arg_type_int_call_neg) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_int_call_neg.js")); +} + +TEST_F(EtsInteropScenariosEtsToJs, test_function_arg_type_long_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_long_call.js")); +} + +// NOTE (vladimiralpavlov) Causes system crash +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_arg_type_long_call_neg) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_long_call_neg.js")); +} + +// NOTE (vladimiralpavlov) Causes type error exception +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_arg_type_float_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_float_call.js")); +} + +// NOTE (vladimiralpavlov) Causes type error exception +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_arg_type_float_call_neg) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_float_call_neg.js")); +} + +// NOTE (vladimiralpavlov) enable this after interop is implemented in this direction +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_arg_type_char_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_char_call.js")); +} + +TEST_F(EtsInteropScenariosEtsToJs, test_function_arg_type_char_call_neg) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_char_call_neg.js")); +} + +TEST_F(EtsInteropScenariosEtsToJs, test_function_arg_type_boolean_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_boolean_call.js")); +} + +// NOTE (vladimiralpavlov) Causes system crash +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_arg_type_boolean_call_neg) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_boolean_call_neg.js")); +} + +TEST_F(EtsInteropScenariosEtsToJs, test_function_arg_type_string_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_string_call.js")); +} + +TEST_F(EtsInteropScenariosEtsToJs, test_function_arg_type_string_call_neg) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_string_call_neg.js")); +} + +TEST_F(EtsInteropScenariosEtsToJs, test_function_arg_type_object_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_object_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (check argument type) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_arg_type_object_call_neg) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_object_call_neg.js")); +} + +TEST_F(EtsInteropScenariosEtsToJs, test_function_arg_type_class_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_class_call.js")); +} + +TEST_F(EtsInteropScenariosEtsToJs, test_function_arg_type_class_call_neg) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_class_call_neg.js")); +} + +TEST_F(EtsInteropScenariosEtsToJs, test_function_arg_type_array_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_array_call.js")); +} + +TEST_F(EtsInteropScenariosEtsToJs, test_function_arg_type_array_call_neg) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_array_call_neg.js")); +} + +TEST_F(EtsInteropScenariosEtsToJs, test_function_arg_type_union_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_union_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (check argument type) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_arg_type_union_call_neg) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_union_call_neg.js")); +} + // NOTE(oignatenko) enable this after interop is implemented in this direction TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_arg_type_tuple_call) { ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_tuple_call.js")); } +TEST_F(EtsInteropScenariosEtsToJs, test_function_arg_type_tuple_call_neg) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_tuple_call_neg.js")); +} + // NOTE(oignatenko) enable this after interop is implemented in this direction TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_arg_type_callable_call) { ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_callable_call.js")); } +// NOTE (vladimiralpavlov) enable this after interop is implemented in this direction +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_arg_type_callable_call_neg) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_arg_type_callable_call_neg.js")); +} + +// Reference type as a return value + +TEST_F(EtsInteropScenariosEtsToJs, test_function_ret_type_number_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_ret_type_number_call.js")); +} + +TEST_F(EtsInteropScenariosEtsToJs, test_function_ret_type_byte_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_ret_type_byte_call.js")); +} + +TEST_F(EtsInteropScenariosEtsToJs, test_function_ret_type_short_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_ret_type_short_call.js")); +} + +TEST_F(EtsInteropScenariosEtsToJs, test_function_ret_type_int_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_ret_type_int_call.js")); +} + +TEST_F(EtsInteropScenariosEtsToJs, test_function_ret_type_long_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_ret_type_long_call.js")); +} + +TEST_F(EtsInteropScenariosEtsToJs, test_function_ret_type_float_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_ret_type_float_call.js")); +} + +// NOTE (vladimiralpavlov) enable this after interop is implemented in this direction +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_ret_type_char_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_ret_type_char_call.js")); +} + +TEST_F(EtsInteropScenariosEtsToJs, test_function_ret_type_boolean_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_ret_type_boolean_call.js")); +} + +TEST_F(EtsInteropScenariosEtsToJs, test_function_ret_type_string_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_ret_type_string_call.js")); +} + +TEST_F(EtsInteropScenariosEtsToJs, test_function_ret_type_object_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_ret_type_object_call.js")); +} + +TEST_F(EtsInteropScenariosEtsToJs, test_function_ret_type_class_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_ret_type_class_call.js")); +} + +TEST_F(EtsInteropScenariosEtsToJs, test_function_ret_type_array_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_ret_type_array_call.js")); +} + +TEST_F(EtsInteropScenariosEtsToJs, test_function_ret_type_tuple_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_ret_type_tuple_call.js")); +} + +// NOTE (vladimiralpavlov) enable this after interop is implemented in this direction +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_ret_type_callable_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_ret_type_callable_call.js")); +} + +// Optional reference type as a parameter + +// NOTE (vladimiralpavlov) Doesn't pass the test (CallEtsFunction: wrong argc) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_arg_type_number_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_arg_type_number_call.js")); +} + +// Note (vladimiralpavlov) Doesn't pass the test (std.core.Double cannot be cast to std.core.Byte) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_arg_type_byte_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_arg_type_byte_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (std.core.Double cannot be cast to std.core.Short) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_arg_type_short_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_arg_type_short_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (std.core.Double cannot be cast to std.core.Int) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_arg_type_int_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_arg_type_int_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (std.core.Double cannot be cast to std.core.Long) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_arg_type_long_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_arg_type_long_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (std.core.Double cannot be cast to std.core.Float) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_arg_type_float_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_arg_type_float_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (std.core.Double cannot be cast to std.core.Char) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_arg_type_char_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_arg_type_char_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (CallEtsFunction: wrong argc) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_arg_type_boolean_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_arg_type_boolean_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (CallEtsFunction: wrong argc) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_arg_type_string_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_arg_type_string_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (CallEtsFunction: wrong argc) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_arg_type_object_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_arg_type_object_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (CallEtsFunction: wrong argc) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_arg_type_class_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_arg_type_class_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (CallEtsFunction: wrong argc) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_arg_type_array_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_arg_type_array_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (CallEtsFunction: wrong argc) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_arg_type_union_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_arg_type_union_call.js")); +} + +// NOTE (vladimiralpavlov) The test function cannot be compiled (see scenarios.ets) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_arg_type_tuple_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_arg_type_tuple_call.js")); +} + +// NOTE (vladimiralpavlov) The test dumped core +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_arg_type_callable_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_arg_type_callable_call.js")); +} + +// Optional reference type as a default parameter + +// NOTE (vladimiralpavlov) Doesn't pass the test (CallEtsFunction: wrong argc) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_default_arg_type_number_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_default_arg_type_number_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (CallEtsFunction: wrong argc) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_default_arg_type_byte_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_default_arg_type_byte_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (CallEtsFunction: wrong argc) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_default_arg_type_short_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_default_arg_type_short_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (CallEtsFunction: wrong argc) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_default_arg_type_int_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_default_arg_type_int_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (CallEtsFunction: wrong argc) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_default_arg_type_long_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_default_arg_type_long_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (CallEtsFunction: wrong argc) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_default_arg_type_float_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_default_arg_type_float_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (CallEtsFunction: wrong argc) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_default_arg_type_char_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_default_arg_type_char_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (CallEtsFunction: wrong argc) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_default_arg_type_boolean_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_default_arg_type_boolean_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (CallEtsFunction: wrong argc) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_default_arg_type_string_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_default_arg_type_string_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (CallEtsFunction: wrong argc) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_default_arg_type_object_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_default_arg_type_object_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (CallEtsFunction: wrong argc) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_default_arg_type_class_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_default_arg_type_class_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (CallEtsFunction: wrong argc) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_default_arg_type_array_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_default_arg_type_array_call.js")); +} + +// NOTE (vladimiralpavlov) Doesn't pass the test (CallEtsFunction: wrong argc) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_default_arg_type_union_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_default_arg_type_union_call.js")); +} + +// NOTE (vladimiralpavlov) The test function cannot be compiled (see scenarios.ets) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_default_arg_type_tuple_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_default_arg_type_tuple_call.js")); +} + +// NOTE (vladimiralpavlov) The test function cannot be compiled (see scenarios.ets) +TEST_F(EtsInteropScenariosEtsToJs, DISABLED_test_function_opt_default_arg_type_callable_call) +{ + ASSERT_EQ(true, RunJsTestSuite("js_suites/test_function_opt_default_arg_type_callable_call.js")); +} + } // namespace ark::ets::interop::js::testing diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/scenarios.ets b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/scenarios.ets index e6b61e1000e48c60bf1a25717c5d41a308aae12b..12fa3d900dc61fbf985aa938f7ab16b4d0cac4db 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/scenarios.ets +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/scenarios.ets @@ -83,14 +83,277 @@ function function_arg_type_undefined_ets(arg: JSValue): JSValue { return arg; } -function function_arg_type_tuple(arg: [number, string]): number { +type U = Number | String; + +// Reference type as a parameter + +function function_arg_type_number_ets(arg: Number): Number { + return arg; +} + +function function_arg_type_byte_ets(arg: Byte): Byte { + return arg; +} + +function function_arg_type_short_ets(arg: Short): Short { + return arg; +} + +function function_arg_type_int_ets(arg: Int): Int { + return arg; +} + +function function_arg_type_long_ets(arg: Long): Long { + return arg; +} + +function function_arg_type_float_ets(arg: Float): Float { + return arg; +} + +function function_arg_type_char_ets(arg: Char): Char { + return arg; +} + +function function_arg_type_boolean_ets(arg: Boolean): Boolean { + return arg; +} + +function function_arg_type_string_ets(arg: String): String { + return arg; +} + +function function_arg_type_object_ets(arg: Object): Object { + return arg; +} + +function function_arg_type_class_ets(arg: ClassWithMethodEts): number { + return arg.methodInClass(); +} + +function function_arg_type_array_ets(arg: string[]): string[] { + return arg; +} + +function function_arg_type_tuple_ets(arg: [number, string]): number { return arg[0]; } -function function_arg_type_callable_ets(function_to_call: () => JSValue): JSValue { - return function_to_call(); +function function_arg_type_union_ets(arg: U): U { + return arg; +} + +function function_arg_type_callable_ets(arg: () => JSValue): JSValue { + return arg(); +} + +// Reference type as a return value + +function function_ret_type_number_ets(): number { + let x: number = 1; + return x; +} + +function function_ret_type_byte_ets(): Byte { + let x: Byte = 1; + return x; +} + +function function_ret_type_short_ets(): Short { + let x: Short = 1; + return x; +} + +function function_ret_type_int_ets(): Int { + let x: Int = 1; + return x; +} + +function function_ret_type_long_ets(): Long { + let x: Long = 1; + return x; +} + +function function_ret_type_float_ets(): Float { + const x: Float = 3.140000104904175; + return x; +} + +function function_ret_type_char_ets(): Char { + let x: Char = c'c'; + return x; +} + +function function_ret_type_boolean_ets(): Boolean { + let x: Boolean = true; + return x; +} + +function function_ret_type_string_ets(): String { + let x: String = 'test'; + return x; +} + +class X { + public id: number = 0; +} + +function function_ret_type_object_ets(): X { + let x: X = {id: 1}; + return x; +} + +function function_ret_type_class_ets(): ClassWithMethodEts { + let x: ClassWithMethodEts = new ClassWithMethodEts(); + return x; +} + +function function_ret_type_array_ets(): string[] { + let x: string[] = ['one', 'two']; + return x; +} + +function function_ret_type_tuple_ets(): [number, string] { + let x: [number, string] = [1, 'one']; + return x; +} + +function function_ret_type_callable_ets(): () => int { + return standalone_function_ets; +} + +// Optional reference type as a parameter + +function function_opt_arg_type_number_ets(arg?: Number): Number { + return arg != undefined ? arg : 1; +} + +function function_opt_arg_type_byte_ets(arg?: Byte): Byte { + return arg != undefined ? arg : 1; +} + +function function_opt_arg_type_short_ets(arg?: Short): Short { + return arg != undefined ? arg : 1; +} + +function function_opt_arg_type_int_ets(arg?: Int): Int { + return arg ?? 1; // for other number types this syntax generates type error +} + +function function_opt_arg_type_long_ets(arg?: Long): Long { + return arg != undefined ? arg : 1; +} + +function function_opt_arg_type_float_ets(arg?: Float): Float { + return arg != undefined ? arg : 1; +} + +function function_opt_arg_type_char_ets(arg?: Char): Char { + return arg != undefined ? arg : c'c'; +// return arg ?? c'c'; causes core to dump +} + +function function_opt_arg_type_boolean_ets(arg?: Boolean): Boolean { + return arg != undefined ? arg : true; +// return arg ?? true; causes core to dump +} + +function function_opt_arg_type_string_ets(arg?: String): String { + return arg ?? 'test'; +} + +function function_opt_arg_type_object_ets(arg?: JSValue): JSValue { + let x: JSValue = {id: 1}; + return arg ?? x; +} + +function function_opt_arg_type_class_ets(arg?: JSValue): number { + if (arg == undefined) arg = new ClassWithMethodEts(); + return arg.methodInClass(); +} + +function function_opt_arg_type_array_ets(arg?: JSValue): JSValue { + return arg ?? ['one', 'two']; +} + +// NOTE (vladimiralpavlov) the following code can't be compiled +// function function_opt_arg_type_tuple_ets(arg?: [number, string]): number { +// return arg != undefined ? arg: [1, 'test']; +// } + +// function function_opt_arg_type_union_ets(arg?: U): U { +// return arg != undefined ? arg: 'test'; +// } + +//function function_opt_arg_type_callable_ets(function_to_call?: () => Int): Int { +// return function_to_call != undefined ? function_to_call(): standalone_function_ets(); +//} + +// Optional reference type as a default parameter + +function function_opt_default_arg_type_number_ets(arg: Number = 1): Number { + return arg; +} + +function function_opt_default_arg_type_byte_ets(arg: Byte = 1): Byte { + return arg; +} + +function function_opt_default_arg_type_short_ets(arg: Short = 1): Short { + return arg; +} + +function function_opt_default_arg_type_int_ets(arg: Int = 1): Int { + return arg; +} + +function function_opt_default_arg_type_long_ets(arg: Long = 1): Long { + return arg; } +function function_opt_default_arg_type_float_ets(arg: Float = 1): Float { + return arg; +} + +function function_opt_default_arg_type_char_ets(arg: Char = c'c'): Char { + return arg; +} + +function function_opt_default_arg_type_boolean_ets(arg: Boolean = true): Boolean { + return arg; +} + +function function_opt_default_arg_type_string_ets(arg: String = 'test'): String { + return arg; +} + +function function_opt_default_arg_type_object_ets(arg: JSValue = {id: 1}): JSValue { + return arg; +} + +let defaultClass: ClassWithMethodEts = new ClassWithMethodEts() +function function_opt_default_arg_type_class_ets(arg: ClassWithMethodEts = defaultClass): number { + return arg.methodInClass(); +} + +function function_opt_default_arg_type_array_ets(arg: string[] = ['one', 'two']): string[] { + return arg; +} + +// NOTE (vladimiralpavlov) the following code can't be compiled +//function function_opt_default_arg_type_tuple_ets(arg: [number, string] = [1, 'test']): number { +// return arg[0]; +//} + +function function_opt_default_arg_type_union_ets(arg: U = 'test'): U { + return arg; +} + +// NOTE (vladimiralpavlov) the following code can't be compiled +//function function_opt_default_arg_type_callable_ets(function_to_call: () => Int = standalone_function_ets): Int { + //return function_to_call(); +//} + function GCJSRuntimeCleanup(): void { try { // trigger FinalizationRegistry cleanup diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/js_to_ets/scenarios.cpp b/static_core/plugins/ets/tests/interop_js/tests/scenarios/js_to_ets/scenarios.cpp index 05ce9f64af2dbe8b7553c84ee72a4683a324d1dd..eda01dc187f119497d5b3606b941ef7d5ddf364f 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/scenarios/js_to_ets/scenarios.cpp +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/js_to_ets/scenarios.cpp @@ -80,13 +80,6 @@ TEST_F(EtsInteropScenariosJsToEts, Test_function_arg_type_undefined) ASSERT_EQ(ret, true); } -// NOTE(oignatenko) enable this after interop is implemented in this direction -TEST_F(EtsInteropScenariosJsToEts, DISABLED_Test_function_arg_type_tuple) -{ - auto ret = CallEtsMethod("Test_function_arg_type_tuple"); - ASSERT_EQ(ret, true); -} - TEST_F(EtsInteropScenariosJsToEts, Test_function_return_type_any) { auto ret = CallEtsMethod("Test_function_return_type_any"); @@ -105,11 +98,266 @@ TEST_F(EtsInteropScenariosJsToEts, Test_function_return_type_undefined) ASSERT_EQ(ret, true); } +// Reference type as a parameter + +TEST_F(EtsInteropScenariosJsToEts, Test_function_arg_type_double) +{ + auto ret = CallEtsMethod("Test_function_arg_type_double"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_arg_type_byte) +{ + auto ret = CallEtsMethod("Test_function_arg_type_byte"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_arg_type_short) +{ + auto ret = CallEtsMethod("Test_function_arg_type_short"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_arg_type_int) +{ + auto ret = CallEtsMethod("Test_function_arg_type_int"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_arg_type_long) +{ + auto ret = CallEtsMethod("Test_function_arg_type_long"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_arg_type_float) +{ + auto ret = CallEtsMethod("Test_function_arg_type_float"); + ASSERT_EQ(ret, true); +} + +// Note (vladimiralpavlov) enable this after interop is implemented in this direction +TEST_F(EtsInteropScenariosJsToEts, DISABLED_Test_function_arg_type_char) +{ + auto ret = CallEtsMethod("Test_function_arg_type_char"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_arg_type_boolean) +{ + auto ret = CallEtsMethod("Test_function_arg_type_boolean"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_arg_type_string) +{ + auto ret = CallEtsMethod("Test_function_arg_type_string"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_arg_type_object) +{ + auto ret = CallEtsMethod("Test_function_arg_type_object"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_arg_type_class) +{ + auto ret = CallEtsMethod("Test_function_arg_type_class"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_arg_type_array) +{ + auto ret = CallEtsMethod("Test_function_arg_type_array"); + ASSERT_EQ(ret, true); +} + // NOTE(oignatenko) enable this after interop is implemented in this direction +TEST_F(EtsInteropScenariosJsToEts, DISABLED_Test_function_arg_type_tuple) +{ + auto ret = CallEtsMethod("Test_function_arg_type_tuple"); + ASSERT_EQ(ret, true); +} + +// NOTE(oignatenko) enable this after interop is implemented in this direction +TEST_F(EtsInteropScenariosJsToEts, DISABLED_Test_function_arg_type_callable) +{ + auto ret = CallEtsMethod("Test_function_arg_type_callable"); + ASSERT_EQ(ret, true); +} + +// Reference type as a return value + +TEST_F(EtsInteropScenariosJsToEts, Test_function_return_type_double) +{ + auto ret = CallEtsMethod("Test_function_return_type_double"); + ASSERT_EQ(ret, true); +} + +// Note (vladimiralpavlov) this test dumped core +TEST_F(EtsInteropScenariosJsToEts, DISABLED_Test_function_return_type_byte) +{ + auto ret = CallEtsMethod("Test_function_return_type_byte"); + ASSERT_EQ(ret, true); +} + +// Note (vladimiralpavlov) this test dumped core +TEST_F(EtsInteropScenariosJsToEts, DISABLED_Test_function_return_type_short) +{ + auto ret = CallEtsMethod("Test_function_return_type_short"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_return_type_int) +{ + auto ret = CallEtsMethod("Test_function_return_type_int"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_return_type_long) +{ + auto ret = CallEtsMethod("Test_function_return_type_long"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_return_type_float) +{ + auto ret = CallEtsMethod("Test_function_return_type_float"); + ASSERT_EQ(ret, true); +} + +// Note (vladimiralpavlov) enable this after interop is implemented in this direction +TEST_F(EtsInteropScenariosJsToEts, DISABLED_Test_function_return_type_char) +{ + auto ret = CallEtsMethod("Test_function_return_type_char"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_return_type_boolean) +{ + auto ret = CallEtsMethod("Test_function_return_type_boolean"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_return_type_string) +{ + auto ret = CallEtsMethod("Test_function_return_type_string"); + ASSERT_EQ(ret, true); +} + +// Note (vladimiralpavlov) this test dumped core +TEST_F(EtsInteropScenariosJsToEts, DISABLED_Test_function_return_type_object) +{ + auto ret = CallEtsMethod("Test_function_return_type_object"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_return_type_class) +{ + auto ret = CallEtsMethod("Test_function_return_type_class"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_return_type_array) +{ + auto ret = CallEtsMethod("Test_function_return_type_array"); + ASSERT_EQ(ret, true); +} + +// NOTE (vladimiralpavlov) enable this after interop is implemented in this direction TEST_F(EtsInteropScenariosJsToEts, DISABLED_Test_function_return_type_callable) { auto ret = CallEtsMethod("Test_function_return_type_callable"); ASSERT_EQ(ret, true); } +// Optional reference type as a parameter + +TEST_F(EtsInteropScenariosJsToEts, Test_function_arg_type_double_opt) +{ + auto ret = CallEtsMethod("Test_function_arg_type_double_opt"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_arg_type_byte_opt) +{ + auto ret = CallEtsMethod("Test_function_arg_type_byte_opt"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_arg_type_short_opt) +{ + auto ret = CallEtsMethod("Test_function_arg_type_short_opt"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_arg_type_int_opt) +{ + auto ret = CallEtsMethod("Test_function_arg_type_int_opt"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_arg_type_long_opt) +{ + auto ret = CallEtsMethod("Test_function_arg_type_long_opt"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_arg_type_float_opt) +{ + auto ret = CallEtsMethod("Test_function_arg_type_float_opt"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_arg_type_char_opt) +{ + auto ret = CallEtsMethod("Test_function_arg_type_char_opt"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, DISABLED_Test_function_arg_type_boolean_opt) +{ + auto ret = CallEtsMethod("Test_function_arg_type_boolean_opt"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_arg_type_string_opt) +{ + auto ret = CallEtsMethod("Test_function_arg_type_string_opt"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_arg_type_object_opt) +{ + auto ret = CallEtsMethod("Test_function_arg_type_object_opt"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_arg_type_class_opt) +{ + auto ret = CallEtsMethod("Test_function_arg_type_class_opt"); + ASSERT_EQ(ret, true); +} + +TEST_F(EtsInteropScenariosJsToEts, Test_function_arg_type_array_opt) +{ + auto ret = CallEtsMethod("Test_function_arg_type_array_opt"); + ASSERT_EQ(ret, true); +} + +// NOTE (vladimiralpavlov) enable this after interop is implemented in this direction +TEST_F(EtsInteropScenariosJsToEts, DISABLED_Test_function_arg_type_tuple_opt) +{ + auto ret = CallEtsMethod("Test_function_arg_type_tuple_opt"); + ASSERT_EQ(ret, true); +} + +// NOTE (vladimiralpavlov) enable this after interop is implemented in this direction +TEST_F(EtsInteropScenariosJsToEts, DISABLED_Test_function_arg_type_callable_opt) +{ + auto ret = CallEtsMethod("Test_function_arg_type_callable_opt"); + ASSERT_EQ(ret, true); +} + } // namespace ark::ets::interop::js::testing diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/js_to_ets/scenarios.ets b/static_core/plugins/ets/tests/interop_js/tests/scenarios/js_to_ets/scenarios.ets index 63f05cc44357e08b35de743fd283f6fa61f8a557..a6e7f821f9f2599b38683dabd052891f0576ea6c 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/scenarios/js_to_ets/scenarios.ets +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/js_to_ets/scenarios.ets @@ -13,10 +13,22 @@ * limitations under the License. */ -import { standaloneFunctionJs, ClassWithMethodJs, newInterfaceWithMethod, ClassWithGetterSetter, lambdaFunction, - genericFunction, ClassToExtend, functionArgTypeAny, functionArgTypeUnknown, functionArgTypeUndefined, - functionArgTypeTuple, functionReturnTypeAny, functionReturnTypeUnknown, functionReturnTypeUndefined, - functionArgTypeCallable } from "/plugins/ets/tests/interop_js/tests/scenarios/js_to_ets/scenarios.js" +import { standaloneFunctionJs, ClassWithMethodJs, newInterfaceWithMethod, ClassWithGetterSetter, + lambdaFunction, genericFunction, ClassToExtend, functionArgTypeAny, functionArgTypeUnknown, + functionArgTypeUndefined, functionReturnTypeAny, functionReturnTypeUnknown, + functionReturnTypeUndefined, functionArgTypeIdentical, functionArgTypeObject, + functionArgTypeClass, functionArgTypeArray, functionArgTypeTuple, functionArgTypeCallable, + JsClassAsReturnValue, functionReturnTypeDouble, functionReturnTypeByte, + functionReturnTypeShort, functionReturnTypeInt, functionReturnTypeLong, + functionReturnTypeFloat, functionReturnTypeChar, functionReturnTypeBoolean, + functionReturnTypeString, functionReturnTypeObject, functionReturnTypeClass, + functionReturnTypeArray, functionReturnTypeCallable, functionArgTypeDoubleOpt, + functionArgTypeByteOpt, functionArgTypeShortOpt, functionArgTypeIntOpt, + functionArgTypeLongOpt, functionArgTypeFloatOpt, functionArgTypeCharOpt, + functionArgTypeBooleanOpt, functionArgTypeStringOpt, functionArgTypeObjectOpt, + functionArgTypeClassOpt, functionArgTypeArrayOpt, functionArgTypeTupleOpt, + functionArgTypeCallableOpt } + from "/plugins/ets/tests/interop_js/tests/scenarios/js_to_ets/scenarios.js" function Test_standalone_function_call(): boolean { return standaloneFunctionJs() as int == 1; @@ -78,13 +90,6 @@ function Test_function_arg_type_undefined(): boolean { return functionArgTypeUndefined(arg) as int == 1; } -function Test_function_arg_type_tuple(): boolean { - // NOTE(oignatenko) uncomment below after interop is implemented in this direction - // let arg: [int, String] = [1, "one"]; - // return functionArgTypeTuple(arg) as int == 1; - return false; -} - function Test_function_return_type_any(): boolean { return functionReturnTypeAny() as int == 1; } @@ -99,10 +104,235 @@ function Test_function_return_type_undefined(): boolean { // NOTE(oignatenko) uncomment below after interop is implemented in this direction // class Child extends ClassToExtend {} -// function function_to_call(): int { -// return 1; -// } +function function_to_call(): int { + return 1; +} + +// Reference type as a parameter + +function Test_function_arg_type_double(): boolean { + let arg: Double = 1.7976931348623157e+308; + return functionArgTypeIdentical(arg) as Double == 1.7976931348623157e+308; +} + +function Test_function_arg_type_byte(): boolean { + let arg: Byte = -128; + return functionArgTypeIdentical(arg) as Byte == -128; +} + +function Test_function_arg_type_short(): boolean { + let arg: Short = -32768; + return functionArgTypeIdentical(arg) as Short == -32768; +} + +function Test_function_arg_type_int(): boolean { + let arg: Int = -2147483648; + return functionArgTypeIdentical(arg) as int == -2147483648; +} + +function Test_function_arg_type_long(): boolean { + let arg: Long = 9007199254740991; // Max safe integer value in JS (IEEE 754 64-bit) + return functionArgTypeIdentical(arg) as Long == 9007199254740991; +} + +function Test_function_arg_type_float(): boolean { + let arg: Float = 3.14f; + return functionArgTypeIdentical(arg) as Float == 3.14f; +} + +function Test_function_arg_type_char(): boolean { + let arg: Char = c'c'; + return functionArgTypeIdentical(arg) as Char == c'c'; +} + +function Test_function_arg_type_boolean(): boolean { + let arg: Boolean = true; + return functionArgTypeIdentical(arg) as Boolean; +} + +function Test_function_arg_type_string(): boolean { + let arg: String = 'string'; + return functionArgTypeIdentical(arg) as String == 'string'; +} + +class ArkTSObjectAsParameter { + public id: number = 1 +} + +function Test_function_arg_type_object(): boolean { + let arg: ArkTSObjectAsParameter = new ArkTSObjectAsParameter(); + return functionArgTypeObject(arg) as int == 1; +} + +class ArkTSClassAsParameter { + method(): int { + return 1; + } +} + +function Test_function_arg_type_class(): boolean { + let arg: ArkTSClassAsParameter = new ArkTSClassAsParameter(); + return functionArgTypeClass(arg) as int == 1; +} + +function Test_function_arg_type_array(): boolean { + let arg: int[] = [1, 2, 3]; + return functionArgTypeArray(arg) as int == 1; +} + +function Test_function_arg_type_tuple(): boolean { + // NOTE(oignatenko) uncomment below after interop is implemented in this direction + // let arg: [int, String] = [1, "one"]; + // return functionArgTypeTuple(arg) as int == 1; + return false; +} + function Test_function_arg_type_callable(): boolean { + // NOTE(oignatenko) uncomment below after interop is implemented in this direction // return functionArgTypeCallable(function_to_call) as int == 1; return false; } + +// Reference type as a return value + +function Test_function_return_type_double(): boolean { + return functionReturnTypeDouble() as Double == 1.7976931348623157e+308; +} + +// NOTE: (vladimiralpavlov) This test causes a termination with a core dump +// because the JS can return only number (int) value which cannot be casted +// to byte type +function Test_function_return_type_byte(): boolean { + let res: Byte = functionReturnTypeByte() as Byte; + return res == -1; +} + +// NOTE: (vladimiralpavlov) This test causes a termination with a core dump +// because the JS can return only number (int) value which cannot be casted +// to short type +function Test_function_return_type_short(): boolean { + let res: Short = functionReturnTypeShort() as Short; + return res == -1; +} + +function Test_function_return_type_int(): boolean { + let res: Int = functionReturnTypeInt() as int; + return res == -1; +} + +function Test_function_return_type_long(): boolean { + let res: Long = functionReturnTypeLong() as Long; + return res == 9007199254740991; +} + +function Test_function_return_type_float(): boolean { + return functionReturnTypeFloat() as number == 3.140000104904175; +} + +function Test_function_return_type_char(): boolean { + return functionReturnTypeChar() as Char == c'c'; +} + +function Test_function_return_type_boolean(): boolean { + let res: Boolean = functionReturnTypeBoolean() as Boolean; + return res; +} + +function Test_function_return_type_string(): boolean { + return functionReturnTypeString() as String == 'string'; +} + +function Test_function_return_type_object(): boolean { + let c: ArkTSObjectAsParameter = functionReturnTypeObject() as ArkTSObjectAsParameter; + return c.id as int == 1; +} + +function Test_function_return_type_class(): boolean { + let c: JsClassAsReturnValue = functionReturnTypeClass() as JsClassAsReturnValue; + return c.method() as int == 1; +} + +function Test_function_return_type_array(): boolean { + let arr: int[] = functionReturnTypeArray() as int[]; + return arr[0] == 1; +} + +// NOTE (vladimiralpavlov) uncomment below after interop is implemented in this direction +function Test_function_return_type_callable(): boolean { + //return functionReturnTypeCallable()() as int == 1; + return false; +} + +// Reference type as an optional parameter + +function Test_function_arg_type_double_opt(): boolean { + let arg: Double = 1.7976931348623157e+308; + return functionArgTypeDoubleOpt(arg) as Double == functionArgTypeDoubleOpt() as Double; +} + +function Test_function_arg_type_byte_opt(): boolean { + let arg: Byte = -128; + return functionArgTypeByteOpt(arg) as Byte == functionArgTypeByteOpt() as Byte; +} + +function Test_function_arg_type_short_opt(): boolean { + let arg: Short = -32768; + return functionArgTypeShortOpt(arg) as Short == functionArgTypeShortOpt(arg) as Short; +} + +function Test_function_arg_type_int_opt(): boolean { + let arg: Int = -2147483648; + return functionArgTypeIntOpt(arg) as int == functionArgTypeIntOpt() as int; +} + +function Test_function_arg_type_long_opt(): boolean { + let arg: Long = 9007199254740991; // Max safe integer value in JS (IEEE 754 64-bit) + return functionArgTypeLongOpt(arg) as Long == functionArgTypeLongOpt() as Long; +} + +function Test_function_arg_type_float_opt(): boolean { + let arg: Float = 3.14; + return functionArgTypeFloatOpt(arg) as Float == functionArgTypeFloatOpt(arg) as Float; +} + +function Test_function_arg_type_char_opt(): boolean { + let arg: Char = c'c'; + return functionArgTypeCharOpt(arg) as Char == functionArgTypeCharOpt() as Char; +} + +function Test_function_arg_type_boolean_opt(): boolean { + return functionArgTypeBooleanOpt(true) as Boolean == functionArgTypeBooleanOpt() as Boolean; +} + +function Test_function_arg_type_string_opt(): boolean { + let arg: String = 'test'; + return functionArgTypeStringOpt(arg) as String == functionArgTypeStringOpt() as String; +} + +function Test_function_arg_type_object_opt(): boolean { + let arg: ArkTSObjectAsParameter = new ArkTSObjectAsParameter(); + return functionArgTypeObjectOpt(arg) as int == functionArgTypeObjectOpt() as int; +} + +function Test_function_arg_type_class_opt(): boolean { + let arg: ArkTSClassAsParameter = new ArkTSClassAsParameter(); + return functionArgTypeClassOpt(arg) as int == functionArgTypeClassOpt() as int; +} + +function Test_function_arg_type_array_opt(): boolean { + let arg: int[] = [1, 2, 3]; + return functionArgTypeArrayOpt(arg) as int == functionArgTypeArrayOpt() as int; +} + +function Test_function_arg_type_tuple_opt(): boolean { + // NOTE (vladimiralpavlov) uncomment below after interop is implemented in this direction + // let arg: [int, String] = [1, 'test']; + // return functionArgTypeTupleOpt(arg) as int == functionArgTypeTupleOpt() as int; + return false; +} + +function Test_function_arg_type_callable_opt(): boolean { + // NOTE (vladimiralpavlov) uncomment below after interop is implemented in this direction + // return functionArgTypeCallableOpt(function_to_call) as int == functionArgTypeCallableOpt(function_to_call) as int; + return false; +} diff --git a/static_core/plugins/ets/tests/interop_js/tests/scenarios/js_to_ets/scenarios.js b/static_core/plugins/ets/tests/interop_js/tests/scenarios/js_to_ets/scenarios.js index 0bfd86c81855c19d65ac7862ec5c5eaf008509d5..cbfb31961650e2e54c9efd89cd14ea6b714d3346 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/scenarios/js_to_ets/scenarios.js +++ b/static_core/plugins/ets/tests/interop_js/tests/scenarios/js_to_ets/scenarios.js @@ -91,10 +91,6 @@ function functionArgTypeUndefined(arg) { return arg; // transpiled from Typescript code: functionArgTypeUndefined(arg: undefined) } -function functionArgTypeTuple(arg) { - return arg[0]; // transpiled from Typescript code: functionArgTypeTuple(arg: [number, string]): number -} - function functionReturnTypeAny() { let value = 1; return value; // transpiled from Typescript code:functionReturnTypeAny(): any @@ -110,11 +106,169 @@ function functionReturnTypeUndefined() { return value; // transpiled from Typescript code: functionReturnTypeUndefined(): undefined } +// Reference type as a parameter + +const FIRST_ELEMENT = 1; +const SECOND_ELEMENT = 2; +const THIRD_ELEMENT = 3; + +function functionArgTypeIdentical(arg) { + return arg; +} + +function functionArgTypeObject(arg) { + return arg.id; +} + +function functionArgTypeClass(arg) { + return arg.method(); +} + +function functionArgTypeArray(arg) { + return arg[0]; +} + +function functionArgTypeTuple(arg) { + return arg[0]; // transpiled from Typescript code: functionArgTypeTuple(arg: [number, string]): number +} + function functionArgTypeCallable(functionToCall) { return functionToCall(); // transpiled from Typescript code: unctionArgTypeCallable(functionToCall: () => number): number } +// Reference type as a return value + +function functionReturnTypeDouble() { + const DOUBLE_VALUE = 1.7976931348623157e+308; + return DOUBLE_VALUE; +} + +function functionReturnTypeByte() { + const MAX_BYTE_VALUE = 0xFF; + return MAX_BYTE_VALUE; +} + +function functionReturnTypeShort() { + const MAX_SHORT_VALUE = 0xFF; + return v; +} + +function functionReturnTypeInt() { + const NEGATIVE_INT_VALUE = -1; + return NEGATIVE_INT_VALUE; +} + +function functionReturnTypeLong() { + // Test of value more than 9007199254740991 doesn't make sense + // because JS uses IEEE 754 64-bit format for numbers + const MAX_SAFE_LONG_VALUE = 9007199254740991; + return MAX_SAFE_LONG_VALUE; +} + +function functionReturnTypeFloat() { + const FLOAT_VALUE = 3.14; + return FLOAT_VALUE; +} + +function functionReturnTypeChar() { + return 'c'; +} + +function functionReturnTypeBoolean() { + let v = true; + return v; +} + +function functionReturnTypeString() { + let v = 'string'; + return v; +} + +function functionReturnTypeObject() { + return {id: 1}; +} + +class JsClassAsReturnValue { + method() { + return 1; + } +} + +function functionReturnTypeClass() { + return new JsClassAsReturnValue(); +} + +function functionReturnTypeArray() { + return [FIRST_ELEMENT, SECOND_ELEMENT, THIRD_ELEMENT]; +} + +function returnedFunction() { + return 1; +} + +function functionReturnTypeCallable() { + return returnedFunction; +} + +// Reference type as an optional parameter + +function functionArgTypeDoubleOpt(arg = 1.7976931348623157e+308) { + return arg; +} + +function functionArgTypeByteOpt(arg = -128) { + return arg; +} + +function functionArgTypeShortOpt(arg = -32768) { + return arg; +} + +function functionArgTypeIntOpt(arg = -2147483648) { + return arg; +} + +function functionArgTypeLongOpt(arg = 9007199254740991) { + return arg; +} + +function functionArgTypeFloatOpt(arg = 3.14) { + return arg; +} + +function functionArgTypeCharOpt(arg = 'c') { + return arg; +} + +function functionArgTypeBooleanOpt(arg = true) { + return arg; +} + +function functionArgTypeStringOpt(arg = 'test') { + return arg; +} + +function functionArgTypeObjectOpt(arg = {id: 1}) { + return arg.id; +} + +function functionArgTypeClassOpt(arg = {method: () => 1}) { + return arg.method(); +} + +function functionArgTypeArrayOpt(arg = [FIRST_ELEMENT, SECOND_ELEMENT, THIRD_ELEMENT]) { + return arg[0]; +} + +function functionArgTypeTupleOpt(arg = [1, 'test']) { + return arg[0]; +} + +function functionArgTypeCallableOpt(arg = returnedFunction) { + return arg(); +} + exports.standaloneFunctionJs = standaloneFunctionJs; exports.ClassWithMethodJs = ClassWithMethodJs; exports.newInterfaceWithMethod = newInterfaceWithMethod; @@ -125,8 +279,43 @@ exports.ClassToExtend = ClassToExtend; exports.functionArgTypeAny = functionArgTypeAny; exports.functionArgTypeUnknown = functionArgTypeUnknown; exports.functionArgTypeUndefined = functionArgTypeUndefined; -exports.functionArgTypeTuple = functionArgTypeTuple; exports.functionReturnTypeAny = functionReturnTypeAny; exports.functionReturnTypeUnknown = functionReturnTypeUnknown; exports.functionReturnTypeUndefined = functionReturnTypeUndefined; + +exports.functionArgTypeIdentical = functionArgTypeIdentical; +exports.functionArgTypeObject = functionArgTypeObject; +exports.functionArgTypeClass = functionArgTypeClass; +exports.functionArgTypeArray = functionArgTypeArray; +exports.functionArgTypeTuple = functionArgTypeTuple; exports.functionArgTypeCallable = functionArgTypeCallable; + +exports.JsClassAsReturnValue = JsClassAsReturnValue; +exports.functionReturnTypeDouble = functionReturnTypeDouble; +exports.functionReturnTypeByte = functionReturnTypeByte; +exports.functionReturnTypeShort = functionReturnTypeShort; +exports.functionReturnTypeInt = functionReturnTypeInt; +exports.functionReturnTypeLong = functionReturnTypeLong; +exports.functionReturnTypeFloat = functionReturnTypeFloat; +exports.functionReturnTypeChar = functionReturnTypeChar; +exports.functionReturnTypeBoolean = functionReturnTypeBoolean; +exports.functionReturnTypeString = functionReturnTypeString; +exports.functionReturnTypeObject = functionReturnTypeObject; +exports.functionReturnTypeClass = functionReturnTypeClass; +exports.functionReturnTypeArray = functionReturnTypeArray; +exports.functionReturnTypeCallable = functionReturnTypeCallable; + +exports.functionArgTypeDoubleOpt = functionArgTypeDoubleOpt; +exports.functionArgTypeByteOpt = functionArgTypeByteOpt; +exports.functionArgTypeShortOpt = functionArgTypeShortOpt; +exports.functionArgTypeIntOpt = functionArgTypeIntOpt; +exports.functionArgTypeLongOpt = functionArgTypeLongOpt; +exports.functionArgTypeFloatOpt = functionArgTypeFloatOpt; +exports.functionArgTypeCharOpt = functionArgTypeCharOpt; +exports.functionArgTypeBooleanOpt = functionArgTypeBooleanOpt; +exports.functionArgTypeStringOpt = functionArgTypeStringOpt; +exports.functionArgTypeObjectOpt = functionArgTypeObjectOpt; +exports.functionArgTypeClassOpt = functionArgTypeClassOpt; +exports.functionArgTypeArrayOpt = functionArgTypeArrayOpt; +exports.functionArgTypeTupleOpt = functionArgTypeTupleOpt; +exports.functionArgTypeCallableOpt = functionArgTypeCallableOpt;