From 625fcbf0490fd294b97243688bccf866f80c426f Mon Sep 17 00:00:00 2001 From: vladimiralpavlov Date: Tue, 20 Feb 2024 10:24:35 +0300 Subject: [PATCH] Add interoperability test cases for reference types as parameters and return values Issue: https://gitee.com/openharmony/arkcompiler_runtime_core/issues/I8S6HV Test: build Signed-off-by: Vladimir --- .../ets_to_js/js_suites/test_class_getter.js | 1 - .../js_suites/test_class_method_call.js | 1 - .../ets_to_js/js_suites/test_class_setter.js | 1 - .../ets_to_js/js_suites/test_extend_class.js | 1 - .../test_function_arg_type_any_call.js | 7 +- .../test_function_arg_type_array_call.js | 23 + .../test_function_arg_type_array_call_neg.js | 22 + .../test_function_arg_type_boolean_call.js | 26 ++ ...test_function_arg_type_boolean_call_neg.js | 23 + .../test_function_arg_type_byte_call.js | 27 ++ .../test_function_arg_type_byte_call_neg.js | 23 + .../test_function_arg_type_callable_call.js | 9 +- ...est_function_arg_type_callable_call_neg.js | 23 + .../test_function_arg_type_char_call.js | 25 ++ .../test_function_arg_type_char_call_neg.js | 23 + .../test_function_arg_type_class_call.js | 24 + .../test_function_arg_type_class_call_neg.js | 23 + .../test_function_arg_type_float_call.js | 23 + .../test_function_arg_type_float_call_neg.js | 23 + .../test_function_arg_type_int_call.js | 27 ++ .../test_function_arg_type_int_call_neg.js | 23 + .../test_function_arg_type_long_call.js | 23 + .../test_function_arg_type_long_call_neg.js | 23 + .../test_function_arg_type_number_call.js | 23 + .../test_function_arg_type_number_call_neg.js | 23 + .../test_function_arg_type_object_call.js | 25 ++ .../test_function_arg_type_object_call_neg.js | 22 + .../test_function_arg_type_short_call.js | 27 ++ .../test_function_arg_type_short_call_neg.js | 23 + .../test_function_arg_type_string_call.js | 26 ++ .../test_function_arg_type_string_call_neg.js | 23 + .../test_function_arg_type_tuple_call.js | 7 +- .../test_function_arg_type_tuple_call_neg.js | 23 + .../test_function_arg_type_undefined_call.js | 8 +- .../test_function_arg_type_union_call.js | 30 ++ .../test_function_arg_type_union_call_neg.js | 23 + .../test_function_arg_type_unknown_call.js | 8 +- .../test_function_opt_arg_type_array_call.js | 25 ++ ...test_function_opt_arg_type_boolean_call.js | 23 + .../test_function_opt_arg_type_byte_call.js | 24 + ...est_function_opt_arg_type_callable_call.js | 24 + .../test_function_opt_arg_type_char_call.js | 26 ++ .../test_function_opt_arg_type_class_call.js | 25 ++ .../test_function_opt_arg_type_float_call.js | 24 + .../test_function_opt_arg_type_int_call.js | 24 + .../test_function_opt_arg_type_long_call.js | 24 + .../test_function_opt_arg_type_number_call.js | 24 + .../test_function_opt_arg_type_object_call.js | 26 ++ .../test_function_opt_arg_type_short_call.js | 24 + .../test_function_opt_arg_type_string_call.js | 24 + .../test_function_opt_arg_type_tuple_call.js | 25 ++ .../test_function_opt_arg_type_union_call.js | 23 + ...unction_opt_default_arg_type_array_call.js | 25 ++ ...ction_opt_default_arg_type_boolean_call.js | 23 + ...function_opt_default_arg_type_byte_call.js | 24 + ...tion_opt_default_arg_type_callable_call.js | 24 + ...function_opt_default_arg_type_char_call.js | 24 + ...unction_opt_default_arg_type_class_call.js | 25 ++ ...unction_opt_default_arg_type_float_call.js | 24 + ..._function_opt_default_arg_type_int_call.js | 24 + ...function_opt_default_arg_type_long_call.js | 25 ++ ...nction_opt_default_arg_type_number_call.js | 24 + ...nction_opt_default_arg_type_object_call.js | 26 ++ ...unction_opt_default_arg_type_short_call.js | 24 + ...nction_opt_default_arg_type_string_call.js | 24 + ...unction_opt_default_arg_type_tuple_call.js | 23 + ...unction_opt_default_arg_type_union_call.js | 23 + .../test_function_ret_type_array_call.js | 23 + .../test_function_ret_type_boolean_call.js | 22 + .../test_function_ret_type_byte_call.js | 22 + .../test_function_ret_type_callable_call.js | 22 + .../test_function_ret_type_char_call.js | 23 + .../test_function_ret_type_class_call.js | 25 ++ .../test_function_ret_type_float_call.js | 23 + .../test_function_ret_type_int_call.js | 22 + .../test_function_ret_type_long_call.js | 22 + .../test_function_ret_type_number_call.js | 22 + .../test_function_ret_type_object_call.js | 24 + .../test_function_ret_type_short_call.js | 22 + .../test_function_ret_type_string_call.js | 22 + .../test_function_ret_type_tuple_call.js | 23 + .../js_suites/test_generic_function_call.js | 5 +- .../js_suites/test_interface_method_call.js | 1 - .../js_suites/test_lambda_function_call.js | 5 +- .../test_standalone_function_call.js | 5 +- .../tests/scenarios/ets_to_js/scenarios.cpp | 413 ++++++++++++++++++ .../tests/scenarios/ets_to_js/scenarios.ets | 269 +++++++++++- .../tests/scenarios/js_to_ets/scenarios.cpp | 262 ++++++++++- .../tests/scenarios/js_to_ets/scenarios.ets | 258 ++++++++++- .../tests/scenarios/js_to_ets/scenarios.js | 199 ++++++++- 90 files changed, 3110 insertions(+), 66 deletions(-) create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_array_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_array_call_neg.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_boolean_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_boolean_call_neg.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_byte_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_byte_call_neg.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_callable_call_neg.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_char_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_char_call_neg.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_class_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_class_call_neg.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_float_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_float_call_neg.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_int_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_int_call_neg.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_long_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_long_call_neg.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_number_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_number_call_neg.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_object_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_object_call_neg.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_short_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_short_call_neg.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_string_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_string_call_neg.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_tuple_call_neg.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_union_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_arg_type_union_call_neg.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_array_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_boolean_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_byte_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_callable_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_char_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_class_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_float_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_int_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_long_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_number_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_object_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_short_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_string_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_tuple_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_arg_type_union_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_array_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_boolean_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_byte_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_callable_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_char_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_class_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_float_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_int_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_long_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_number_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_object_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_short_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_string_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_tuple_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_opt_default_arg_type_union_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_array_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_boolean_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_byte_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_callable_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_char_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_class_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_float_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_int_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_long_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_number_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_object_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_short_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_string_call.js create mode 100644 static_core/plugins/ets/tests/interop_js/tests/scenarios/ets_to_js/js_suites/test_function_ret_type_tuple_call.js 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 8cb94531f2..6cf1a884e1 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 871ff2bd71..5c056ce7aa 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 b43a24216c..bf7c6b690b 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 fff3243086..52eb6edc43 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 bcf3a74df0..6d5882469b 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 0000000000..72aff0c97b --- /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 0000000000..ccf9ea66d8 --- /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 0000000000..0b35eebb44 --- /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 0000000000..2043cd759b --- /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 0000000000..5eb819f85d --- /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 0000000000..0b5e4c1487 --- /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 007bc7626d..97cf047fc2 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 0000000000..330f31c2df --- /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 0000000000..f16168b70c --- /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 0000000000..d92bbf5971 --- /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 0000000000..be1c6a5fca --- /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 0000000000..c9820fc8ae --- /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 0000000000..005a8e9bd2 --- /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 0000000000..b6e05f57a5 --- /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 0000000000..1e10302a40 --- /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 0000000000..57cb43a5c5 --- /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 0000000000..96b0b24d4e --- /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 0000000000..53b170f14f --- /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 0000000000..5fe5272982 --- /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 0000000000..cd0eaf1c6b --- /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 0000000000..d4b68a3021 --- /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 0000000000..34ac586778 --- /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 0000000000..53649f434f --- /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 0000000000..eceb43527f --- /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 0000000000..b97c388335 --- /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 0000000000..6fc05181a2 --- /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 5a4f5c92a3..dcb2d75a64 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 0000000000..9294a2d648 --- /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 fc57f32a14..4b3c46a5a4 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 0000000000..92cace3fef --- /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 0000000000..8dfa4002fa --- /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 69f6799df9..b072c0e336 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 0000000000..7e03cb9727 --- /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 0000000000..f56913aa13 --- /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 0000000000..253aadcf16 --- /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 0000000000..77f0215365 --- /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 0000000000..e04e2e3d16 --- /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 0000000000..29adb5b97e --- /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 0000000000..f566b5b53b --- /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 0000000000..bc99efeee7 --- /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 0000000000..4830e3f133 --- /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 0000000000..82ea960152 --- /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 0000000000..e4aaebfa8b --- /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 0000000000..d19ca777ff --- /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 0000000000..5990a1882f --- /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 0000000000..03d642f3f0 --- /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 0000000000..78fe827153 --- /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 0000000000..23c3e5316e --- /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 0000000000..e7a8fdda27 --- /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 0000000000..affd8dece4 --- /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 0000000000..818479b55c --- /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 0000000000..aa35eb5096 --- /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 0000000000..63660034aa --- /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 0000000000..92bc09844b --- /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 0000000000..032e690843 --- /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 0000000000..484e02bb61 --- /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 0000000000..818f539520 --- /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 0000000000..a9fb9a217c --- /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 0000000000..90a231c764 --- /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 0000000000..141795bece --- /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 0000000000..fb2b33efc5 --- /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 0000000000..cf18f97851 --- /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 0000000000..4e025118cc --- /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 0000000000..1ef415c9f5 --- /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 0000000000..c50e2190f5 --- /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 0000000000..4125bf0c11 --- /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 0000000000..eb62079fd9 --- /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 0000000000..f9e0640323 --- /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 0000000000..3f69651f5a --- /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 0000000000..dc2cb7059b --- /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 0000000000..e226a08339 --- /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 0000000000..91f2b88b47 --- /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 0000000000..ccc6cd5ff4 --- /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 0000000000..99542537cd --- /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 0000000000..373060ec1d --- /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 0000000000..614f418142 --- /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 77a8a65db5..ddaba60c68 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 815accc212..56af4efc03 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 8a24c8fbbe..484186000d 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 290f067c78..c5a8a91c78 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 86965b46ef..5ba5b6f641 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 e6b61e1000..12fa3d900d 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 05ce9f64af..eda01dc187 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 63f05cc443..a6e7f821f9 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 0bfd86c818..cbfb319616 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; -- Gitee