diff --git a/libabckit/tests/ut/ir_core/basic_blocks/basic_blocks_static.cpp b/libabckit/tests/ut/ir_core/basic_blocks/basic_blocks_static.cpp index b31bce2b39ed6532d85d525f30c669b77d703e63..7b77a9d7dad89998e9953ec385a0b5e64dbe4a76 100644 --- a/libabckit/tests/ut/ir_core/basic_blocks/basic_blocks_static.cpp +++ b/libabckit/tests/ut/ir_core/basic_blocks/basic_blocks_static.cpp @@ -1,5 +1,5 @@ /** - * Copyright (c) 2024-2025 Huawei Device Co., Ltd. + * Copyright (c) 2025 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 diff --git a/libabckit/tests/ut/isa/isa_static/cast/target_type_static.ets b/libabckit/tests/ut/isa/isa_static/cast/target_type_static.ets index 71ccc9222d129a5429f8de3f072d2b7e20984886..a68d85d2c0d75c7d55a09029289852f40d1aac09 100644 --- a/libabckit/tests/ut/isa/isa_static/cast/target_type_static.ets +++ b/libabckit/tests/ut/isa/isa_static/cast/target_type_static.ets @@ -21,7 +21,7 @@ function ConsoleLog(a: double) { class MyClass { handle() { let a: double = 3.14 - let b: double = a as int + let b: double = Double.toInt(a) ConsoleLog(b) } } @@ -40,7 +40,7 @@ function main() { // class MyClass { // handle() { // let a: double = 3.14 -// let b: int = a as double +// let b: int = Double.toInt(a) // ConsoleLog(b) // } // } diff --git a/static_core/codecheck_ignore.json b/static_core/codecheck_ignore.json index 1ea2fc9fc44b501418dddffaaf2dd68bca8d3392..e3cae40dd5e0b87ff2ddbf9d11162231dcda056f 100644 --- a/static_core/codecheck_ignore.json +++ b/static_core/codecheck_ignore.json @@ -73,6 +73,8 @@ "plugins/ets/tests/ets_test_suite/coroutines/CMakeLists.txt": {"bc-40001": "*"}, "plugins/ets/tests/ets_test_suite/linker": "*", "plugins/ets/tests/ets_test_suite/strings": "*", + "plugins/ets/tests/ets_test_suite/generics/CMakeLists.txt": {"bc-40001": "*"}, + "plugins/ets/tests/ets_test_suite/intrinsics/CMakeLists.txt": {"bc-40001": "*"}, "plugins/ets/tests/ets_test_suite/functions/CMakeLists.txt": {"bc-40001": "*"}, "plugins/ets/tests/ets_test_suite/object_literal/CMakeLists.txt": {"bc-40001": "*"}, "plugins/ets/tests/ets_warnings_tests": "*", diff --git a/static_core/compiler/optimizer/optimizations/balance_expressions.cpp b/static_core/compiler/optimizer/optimizations/balance_expressions.cpp index f375ce99cc6950dec026fae646b47371c6a6a2c9..2ffd77e6d9ec518fe0c278e9dd090561fd5c5abe 100644 --- a/static_core/compiler/optimizer/optimizations/balance_expressions.cpp +++ b/static_core/compiler/optimizer/optimizations/balance_expressions.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021 - 2025 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 @@ -221,7 +221,7 @@ void BalanceExpressions::TryExtendChainRec(Inst *inst) { ASSERT(inst); if (inst->GetOpcode() == GetOpcode()) { - if (inst->HasSingleUser()) { + if (inst->HasSingleUser() && !inst->IsIntrinsic()) { inst->SetMarker(processedInstMrk_); AnalyzeInputsRec(inst); diff --git a/static_core/helper.txt b/static_core/helper.txt new file mode 100644 index 0000000000000000000000000000000000000000..4cb1484318982f5b591b0e80498249bdb6d7fabc --- /dev/null +++ b/static_core/helper.txt @@ -0,0 +1 @@ +0001-test-fixing-ref-equality.patch diff --git a/static_core/isa/gen.rb b/static_core/isa/gen.rb index 66827e00a4f746d570fdf3888eb15cb07584202a..fb5f81fb90e118ca5c7b052f41f3e0704e220ec8 100755 --- a/static_core/isa/gen.rb +++ b/static_core/isa/gen.rb @@ -18,6 +18,7 @@ require 'optparse' require 'yaml' require 'json' require 'erb' +require 'ostruct' # Extend Module to implement a decorator for ISAPI methods class Module diff --git a/static_core/plugins/ets/GenerateStdLib.cmake b/static_core/plugins/ets/GenerateStdLib.cmake index 10cfc9e82e34d9ed02bc3705032309e5fcf0a475..7019c61958d65a91c6d5fcc94f3b9f9ec2ddebda 100644 --- a/static_core/plugins/ets/GenerateStdLib.cmake +++ b/static_core/plugins/ets/GenerateStdLib.cmake @@ -51,7 +51,7 @@ function(regenerate_and_check_stdlib) RESULT_VARIABLE compare_result ) if( NOT compare_result EQUAL 0) - message(FATAL_ERROR "Generated ${file} is not equal to currently used ${file}, fix and rerun generating script. " + message(FATAL_ERROR " ${file} is not equal to currently used ${file}, fix and rerun generating script. " "Checkout the guide: " "https://gitee.com/OpenHarmony/arkcompiler_runtime_core/blob/master/static_core/plugins/ets/stdlib/README.md") endif() diff --git a/static_core/plugins/ets/doc/stdlib/packages/escompat.rst b/static_core/plugins/ets/doc/stdlib/packages/escompat.rst index 8c3e8ef9d501d92801d25bb3a57f41522822b814..6bf3e732b5da05422fe7c6467c31ce9818622975 100644 --- a/static_core/plugins/ets/doc/stdlib/packages/escompat.rst +++ b/static_core/plugins/ets/doc/stdlib/packages/escompat.rst @@ -4592,7 +4592,7 @@ Properties .. rst-class:: doc-code-block - - static BYTES_PER_ELEMENT\: :kw:`number` + - static BYTES_PER_ELEMENT\: :kw:`int` - buffer\: :ref:`ArrayBuffer` - byteLength\: :kw:`number` - byteOffset\: :kw:`number` @@ -6244,7 +6244,7 @@ Properties .. rst-class:: doc-code-block - - static BYTES_PER_ELEMENT\: :kw:`number` + - static BYTES_PER_ELEMENT\: :kw:`int` - buffer\: :ref:`ArrayBuffer` - byteLength\: :kw:`number` - byteOffset\: :kw:`number` @@ -9899,7 +9899,7 @@ Properties .. rst-class:: doc-code-block - - static BYTES_PER_ELEMENT\: :kw:`number` + - static BYTES_PER_ELEMENT\: :kw:`int` - buffer\: :ref:`ArrayBuffer` - byteLength\: :kw:`number` - byteOffset\: :kw:`number` @@ -11147,7 +11147,7 @@ Properties .. rst-class:: doc-code-block - - static BYTES_PER_ELEMENT\: :kw:`number` + - static BYTES_PER_ELEMENT\: :kw:`int` - buffer\: :ref:`ArrayBuffer` - byteLength\: :kw:`number` - byteOffset\: :kw:`number` @@ -12423,7 +12423,7 @@ Properties .. rst-class:: doc-code-block - - static BYTES_PER_ELEMENT\: :kw:`number` + - static BYTES_PER_ELEMENT\: :kw:`int` - buffer\: :ref:`ArrayBuffer` - byteLength\: :kw:`number` - byteOffset\: :kw:`number` @@ -13699,7 +13699,7 @@ Properties .. rst-class:: doc-code-block - - static BYTES_PER_ELEMENT\: :kw:`number` + - static BYTES_PER_ELEMENT\: :kw:`int` - buffer\: :ref:`ArrayBuffer` - byteLength\: :kw:`number` - byteOffset\: :kw:`number` @@ -14975,7 +14975,7 @@ Properties .. rst-class:: doc-code-block - - static BYTES_PER_ELEMENT\: :kw:`number` + - static BYTES_PER_ELEMENT\: :kw:`int` - buffer\: :ref:`ArrayBuffer` - byteLength\: :kw:`number` - byteOffset\: :kw:`number` @@ -19132,7 +19132,7 @@ Properties .. rst-class:: doc-code-block - - static BYTES_PER_ELEMENT\: :kw:`number` + - static BYTES_PER_ELEMENT\: :kw:`int` - buffer\: :ref:`ArrayBuffer` - byteLength\: :kw:`number` - byteOffset\: :kw:`number` @@ -20784,7 +20784,7 @@ Properties .. rst-class:: doc-code-block - - static BYTES_PER_ELEMENT\: :kw:`number` + - static BYTES_PER_ELEMENT\: :kw:`int` - buffer\: :ref:`ArrayBuffer` - byteLength\: :kw:`number` - byteOffset\: :kw:`number` @@ -22436,7 +22436,7 @@ Properties .. rst-class:: doc-code-block - - static BYTES_PER_ELEMENT\: :kw:`number` + - static BYTES_PER_ELEMENT\: :kw:`int` - buffer\: :ref:`ArrayBuffer` - byteLength\: :kw:`number` - byteOffset\: :kw:`number` @@ -24088,7 +24088,7 @@ Properties .. rst-class:: doc-code-block - - static BYTES_PER_ELEMENT\: :kw:`number` + - static BYTES_PER_ELEMENT\: :kw:`int` - buffer\: :ref:`ArrayBuffer` - byteLength\: :kw:`number` - byteOffset\: :kw:`number` diff --git a/static_core/plugins/ets/runtime/ets_libbase_runtime.yaml b/static_core/plugins/ets/runtime/ets_libbase_runtime.yaml index f0599f2874e6fe70f7fbfd2134722d36a7746d66..a3963238291c0dbd6bbf6567ce7a53b9af449ae3 100644 --- a/static_core/plugins/ets/runtime/ets_libbase_runtime.yaml +++ b/static_core/plugins/ets/runtime/ets_libbase_runtime.yaml @@ -3230,26 +3230,26 @@ intrinsics: llvm_codegen_func: EmitIsSafeInteger safe_intrinsic: true - - name: StdCoreFloatToByte + - name: StdCoreFloatToShort space: ets class_name: std.core.Float - method_name: toByte + method_name: toShort static: true signature: - ret: i8 + ret: i16 args: [ f32 ] - impl: ark::ets::intrinsics::StdCoreFloatToByte + impl: ark::ets::intrinsics::StdCoreFloatToShort safe_intrinsic: true - - name: StdCoreFloatToShort + - name: StdCoreFloatToByte space: ets class_name: std.core.Float - method_name: toShort + method_name: toByte static: true signature: - ret: i16 + ret: i8 args: [ f32 ] - impl: ark::ets::intrinsics::StdCoreFloatToShort + impl: ark::ets::intrinsics::StdCoreFloatToByte safe_intrinsic: true - name: StdCoreFloatToInt @@ -3285,6 +3285,17 @@ intrinsics: impl: ark::ets::intrinsics::StdCoreFloatToDouble safe_intrinsic: true + - name: StdCoreFloatToChar + space: ets + class_name: std.core.Float + method_name: toChar + static: true + signature: + ret: u16 + args: [ f32 ] + impl: ark::ets::intrinsics::StdCoreFloatToChar + safe_intrinsic: true + ################### # std.core.Double # ################### @@ -3441,26 +3452,26 @@ intrinsics: llvm_codegen_func: EmitIsSafeInteger safe_intrinsic: true - - name: StdCoreDoubleToByte + - name: StdCoreDoubleToShort space: ets class_name: std.core.Double - method_name: toByte + method_name: toShort static: true signature: - ret: i8 + ret: i16 args: [ f64 ] - impl: ark::ets::intrinsics::StdCoreDoubleToByte + impl: ark::ets::intrinsics::StdCoreDoubleToShort safe_intrinsic: true - - name: StdCoreDoubleToShort + - name: StdCoreDoubleToByte space: ets class_name: std.core.Double - method_name: toShort + method_name: toByte static: true signature: - ret: i16 + ret: i8 args: [ f64 ] - impl: ark::ets::intrinsics::StdCoreDoubleToShort + impl: ark::ets::intrinsics::StdCoreDoubleToByte safe_intrinsic: true - name: StdCoreDoubleToInt @@ -3496,6 +3507,17 @@ intrinsics: impl: ark::ets::intrinsics::StdCoreDoubleToFloat safe_intrinsic: true + - name: StdCoreDoubleToChar + space: ets + class_name: std.core.Double + method_name: toChar + static: true + signature: + ret: u16 + args: [ f64 ] + impl: ark::ets::intrinsics::StdCoreDoubleToChar + safe_intrinsic: true + ############## # std.core.unsafeMemory # ############## @@ -5929,6 +5951,66 @@ intrinsics: ################# # std.core.Char # ################# + - name: StdCoreCharToByte + space: ets + class_name: std.core.Char + method_name: toByte + static: true + signature: + ret: i8 + args: [ u16 ] + impl: ark::ets::intrinsics::StdCoreCharToByte + + - name: StdCoreCharToShort + space: ets + class_name: std.core.Char + method_name: toShort + static: true + signature: + ret: i16 + args: [ u16 ] + impl: ark::ets::intrinsics::StdCoreCharToByte + + - name: StdCoreCharToInt + space: ets + class_name: std.core.Char + method_name: toInt + static: true + signature: + ret: i32 + args: [ u16 ] + impl: ark::ets::intrinsics::StdCoreCharToInt + + - name: StdCoreCharToLong + space: ets + class_name: std.core.Char + method_name: toLong + static: true + signature: + ret: i64 + args: [ u16 ] + impl: ark::ets::intrinsics::StdCoreCharToLong + + - name: StdCoreCharToFloat + space: ets + class_name: std.core.Char + method_name: toFloat + static: true + signature: + ret: f32 + args: [ u16 ] + impl: ark::ets::intrinsics::StdCoreCharToFloat + + - name: StdCoreCharToDouble + space: ets + class_name: std.core.Char + method_name: toDouble + static: true + signature: + ret: f64 + args: [ u16 ] + impl: ark::ets::intrinsics::StdCoreCharToDouble + - name: StdCoreCharIsUpperCase space: ets class_name: std.core.Char @@ -7591,26 +7673,26 @@ intrinsics: # std.core.Int # ################ - - name: StdCoreIntToByte + - name: StdCoreIntToShort space: ets class_name: std.core.Int - method_name: toByte + method_name: toShort static: true signature: - ret: i8 + ret: i16 args: [ i32 ] - impl: ark::ets::intrinsics::StdCoreIntToByte + impl: ark::ets::intrinsics::StdCoreIntToShort safe_intrinsic: true - - name: StdCoreIntToShort + - name: StdCoreIntToByte space: ets class_name: std.core.Int - method_name: toShort + method_name: toByte static: true signature: - ret: i16 + ret: i8 args: [ i32 ] - impl: ark::ets::intrinsics::StdCoreIntToShort + impl: ark::ets::intrinsics::StdCoreIntToByte safe_intrinsic: true - name: StdCoreIntToLong @@ -7661,26 +7743,26 @@ intrinsics: # std.core.Long # ################ - - name: StdCoreLongToByte + - name: StdCoreLongToShort space: ets class_name: std.core.Long - method_name: toByte + method_name: toShort static: true signature: - ret: i8 + ret: i16 args: [ i64 ] - impl: ark::ets::intrinsics::StdCoreLongToByte + impl: ark::ets::intrinsics::StdCoreLongToShort safe_intrinsic: true - - name: StdCoreLongToShort + - name: StdCoreLongToByte space: ets class_name: std.core.Long - method_name: toShort + method_name: toByte static: true signature: - ret: i16 + ret: i8 args: [ i64 ] - impl: ark::ets::intrinsics::StdCoreLongToShort + impl: ark::ets::intrinsics::StdCoreLongToByte safe_intrinsic: true - name: StdCoreLongToInt diff --git a/static_core/plugins/ets/runtime/ets_stubs.cpp b/static_core/plugins/ets/runtime/ets_stubs.cpp index e96656005c35f7bf45144dcd901b2e3bea2c7436..be1a97b8243dda2dfc7e62a39d3fa0c2f7b9e68a 100644 --- a/static_core/plugins/ets/runtime/ets_stubs.cpp +++ b/static_core/plugins/ets/runtime/ets_stubs.cpp @@ -88,7 +88,7 @@ bool EtsValueTypedEquals(EtsCoroutine *coro, EtsObject *obj1, EtsObject *obj2) { auto cls1 = obj1->GetClass(); auto cls2 = obj2->GetClass(); - ASSERT(cls1->IsValueTyped() && cls1->IsValueTyped()); + ASSERT(cls1->IsValueTyped() && cls2->IsValueTyped()); auto ptypes = PlatformTypes(coro); ASSERT(ptypes != nullptr); diff --git a/static_core/plugins/ets/runtime/intrinsics/helpers/ets_intrinsics_helpers.cpp b/static_core/plugins/ets/runtime/intrinsics/helpers/ets_intrinsics_helpers.cpp index 1a390fdb1ac33a71c96d727ae03f46c6c925a907..8648a62ade6bb515146ce34fab228f0ac745909d 100644 --- a/static_core/plugins/ets/runtime/intrinsics/helpers/ets_intrinsics_helpers.cpp +++ b/static_core/plugins/ets/runtime/intrinsics/helpers/ets_intrinsics_helpers.cpp @@ -423,6 +423,36 @@ EtsString *DoubleToPrecision(double number, int digit) return DoubleToExponential(number, digit - 1); } +EtsFloat GetStdFloatArgument(ObjectHeader *obj) +{ + auto *cls = obj->ClassAddr(); + + // Assume std.core.Float has only one `float` field + ASSERT(cls->GetInstanceFields().size() == 1); + + Field &fieldVal = cls->GetInstanceFields()[0]; + + ASSERT(fieldVal.GetTypeId() == panda_file::Type::TypeId::F32); + + size_t offset = fieldVal.GetOffset(); + return obj->GetFieldPrimitive(offset); +} + +double GetStdDoubleArgument(ObjectHeader *obj) +{ + auto *cls = obj->ClassAddr(); + + // Assume std.core.Double has only one `double` field + ASSERT(cls->GetInstanceFields().size() == 1); + + Field &fieldVal = cls->GetInstanceFields()[0]; + + ASSERT(fieldVal.GetTypeId() == panda_file::Type::TypeId::F64); + + size_t offset = fieldVal.GetOffset(); + return obj->GetFieldPrimitive(offset); +} + // NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic) template , bool> = true> void GetBase(FpType d, int digits, int *decpt, Span buf) diff --git a/static_core/plugins/ets/runtime/intrinsics/helpers/ets_intrinsics_helpers.h b/static_core/plugins/ets/runtime/intrinsics/helpers/ets_intrinsics_helpers.h index b3a7dad7f1d72f5932f5bc2bfe8158d509d3e210..9b88a664412f37e4fa8b3c1252e696f698b25a39 100644 --- a/static_core/plugins/ets/runtime/intrinsics/helpers/ets_intrinsics_helpers.h +++ b/static_core/plugins/ets/runtime/intrinsics/helpers/ets_intrinsics_helpers.h @@ -1,4 +1,5 @@ /** + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Copyright (c) 2021-2025 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. @@ -306,6 +307,37 @@ double StringToDoubleWithRadix(const uint8_t *start, const uint8_t *end, int rad EtsString *DoubleToExponential(double number, int digit); EtsString *DoubleToFixed(double number, int digit); EtsString *DoubleToPrecision(double number, int digit); +EtsFloat GetStdFloatArgument(ObjectHeader *obj); +double GetStdDoubleArgument(ObjectHeader *obj); + +template +// CC-OFFNXT(G.FUD.06) perf critical +inline IntType CastFPToInt(FpType val) +{ + if (std::isnan(val)) { + return 0; + } + + IntType minInt = std::numeric_limits::min(); + IntType maxInt = std::numeric_limits::max(); + + if (std::isinf(val)) { + return std::signbit(val) ? minInt : maxInt; + } + + ASSERT(std::is_floating_point_v); + auto floatMinInt = static_cast(minInt); + auto floatMaxInt = static_cast(maxInt); + + if (val > floatMinInt) { + if (val < floatMaxInt) { + return static_cast(TruncateFp(val)); + } + return maxInt; + } + + return minInt; +} template , bool> = true> inline const char *FpNonFiniteToString(FpType number) diff --git a/static_core/plugins/ets/runtime/intrinsics/std_core_Arrays.cpp b/static_core/plugins/ets/runtime/intrinsics/std_core_Arrays.cpp index 8112d288b6a5b8a0c047e528c598299139772b11..7ef4b59bc612bc4eb35b7e0005a26cad5a8d98dc 100644 --- a/static_core/plugins/ets/runtime/intrinsics/std_core_Arrays.cpp +++ b/static_core/plugins/ets/runtime/intrinsics/std_core_Arrays.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 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 diff --git a/static_core/plugins/ets/runtime/intrinsics/std_core_Char.cpp b/static_core/plugins/ets/runtime/intrinsics/std_core_Char.cpp index f1aa80c15fa2282b3133f0900957dd88ae485dda..9f69585ec65f3a6de1b9da7f8b7cd700a4931dfa 100644 --- a/static_core/plugins/ets/runtime/intrinsics/std_core_Char.cpp +++ b/static_core/plugins/ets/runtime/intrinsics/std_core_Char.cpp @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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,6 +15,7 @@ #include "intrinsics.h" #include "helpers/ets_intrinsics_helpers.h" +#include "types/ets_primitives.h" namespace ark::ets::intrinsics { @@ -41,4 +42,34 @@ extern "C" EtsBoolean StdCoreCharIsWhiteSpace(EtsChar value) return ToEtsBoolean(utf::IsWhiteSpaceChar(value)); } +EtsByte StdCoreCharToByte(EtsChar val) +{ + return static_cast(val); +} + +EtsShort StdCoreCharToShort(EtsChar val) +{ + return static_cast(val); +} + +EtsInt StdCoreCharToInt(EtsChar val) +{ + return static_cast(val); +} + +EtsLong StdCoreCharToLong(EtsChar val) +{ + return static_cast(val); +} + +EtsFloat StdCoreCharToFloat(EtsChar val) +{ + return static_cast(val); +} + +EtsDouble StdCoreCharToDouble(EtsChar val) +{ + return static_cast(val); +} + } // namespace ark::ets::intrinsics diff --git a/static_core/plugins/ets/runtime/intrinsics/std_core_Double.cpp b/static_core/plugins/ets/runtime/intrinsics/std_core_Double.cpp index bd35f41525bca359041428cf7385d004d86f866b..e34e2a0419e5b9ca2248e88853358a1b2e93a716 100644 --- a/static_core/plugins/ets/runtime/intrinsics/std_core_Double.cpp +++ b/static_core/plugins/ets/runtime/intrinsics/std_core_Double.cpp @@ -309,24 +309,28 @@ double StdCoreDoubleNumberFromString(EtsString *s) return ParseFloat(s, flags); } -EtsInt StdCoreDoubleToInt(EtsDouble val) +EtsShort StdCoreDoubleToShort(EtsDouble val) { - return CastFloatToInt(val); + // CC-OFFNXT(G.NAM.03) false positive + int intVal = helpers::CastFPToInt(val); + return static_cast(intVal); } EtsByte StdCoreDoubleToByte(EtsDouble val) { - return static_cast(StdCoreDoubleToInt(val)); + // CC-OFFNXT(G.NAM.03) false positive + int intVal = helpers::CastFPToInt(val); + return static_cast(intVal); } -EtsShort StdCoreDoubleToShort(EtsDouble val) +EtsInt StdCoreDoubleToInt(EtsDouble val) { - return static_cast(StdCoreDoubleToInt(val)); + return helpers::CastFPToInt(val); } EtsLong StdCoreDoubleToLong(EtsDouble val) { - return CastFloatToInt(val); + return helpers::CastFPToInt(val); } EtsFloat StdCoreDoubleToFloat(EtsDouble val) @@ -334,4 +338,9 @@ EtsFloat StdCoreDoubleToFloat(EtsDouble val) return static_cast(val); } +EtsChar StdCoreDoubleToChar(EtsDouble val) +{ + return helpers::CastFPToInt(val); +} + } // namespace ark::ets::intrinsics diff --git a/static_core/plugins/ets/runtime/intrinsics/std_core_Float.cpp b/static_core/plugins/ets/runtime/intrinsics/std_core_Float.cpp index e5b8d7b1acfddadf8931430928eb4c44a38bddf8..1043f1e4fb5ef362d9bd29ddaedac4e6a968fd19 100644 --- a/static_core/plugins/ets/runtime/intrinsics/std_core_Float.cpp +++ b/static_core/plugins/ets/runtime/intrinsics/std_core_Float.cpp @@ -71,24 +71,28 @@ extern "C" EtsBoolean StdCoreFloatIsSafeInteger(float v) return ToEtsBoolean(IsInteger(v) && (std::fabs(v) <= helpers::MaxSafeInteger())); } -EtsInt StdCoreFloatToInt(EtsFloat val) +EtsShort StdCoreFloatToShort(EtsFloat val) { - return CastFloatToInt(val); + // CC-OFFNXT(G.NAM.03) false positive + int intVal = helpers::CastFPToInt(val); + return static_cast(intVal); } -EtsShort StdCoreFloatToShort(EtsFloat val) +EtsByte StdCoreFloatToByte(EtsFloat val) { - return static_cast(StdCoreFloatToInt(val)); + // CC-OFFNXT(G.NAM.03) false positive + int intVal = helpers::CastFPToInt(val); + return static_cast(intVal); } -EtsByte StdCoreFloatToByte(EtsFloat val) +EtsInt StdCoreFloatToInt(EtsFloat val) { - return static_cast(StdCoreFloatToInt(val)); + return helpers::CastFPToInt(val); } EtsLong StdCoreFloatToLong(EtsFloat val) { - return CastFloatToInt(val); + return helpers::CastFPToInt(val); } EtsDouble StdCoreFloatToDouble(EtsFloat val) @@ -96,4 +100,9 @@ EtsDouble StdCoreFloatToDouble(EtsFloat val) return static_cast(val); } +EtsChar StdCoreFloatToChar(EtsFloat val) +{ + return helpers::CastFPToInt(val); +} + } // namespace ark::ets::intrinsics diff --git a/static_core/plugins/ets/runtime/types/ets_typed_arrays.h b/static_core/plugins/ets/runtime/types/ets_typed_arrays.h index 05ea4dc75013cbd6426ac70fe127c879683f9fda..ec3760b032d81fc9820ccd1d1b52b43ae872364e 100644 --- a/static_core/plugins/ets/runtime/types/ets_typed_arrays.h +++ b/static_core/plugins/ets/runtime/types/ets_typed_arrays.h @@ -68,7 +68,7 @@ public: return byteLength_; } - EtsDouble GetBytesPerElement() const + EtsInt GetBytesPerElement() { return bytesPerElement_; } @@ -86,9 +86,9 @@ public: private: ObjectPointer buffer_; ObjectPointer name_; - EtsDouble bytesPerElement_; EtsDouble byteOffset_; EtsDouble byteLength_; + EtsInt bytesPerElement_; EtsInt lengthInt_; }; diff --git a/static_core/plugins/ets/runtime/types/ets_typed_unsigned_arrays.h b/static_core/plugins/ets/runtime/types/ets_typed_unsigned_arrays.h index afb2984de9529dc1ca25f03ca08587857cef745d..620b0bb0a5e2c08d7377695d1abcd55263b16207 100644 --- a/static_core/plugins/ets/runtime/types/ets_typed_unsigned_arrays.h +++ b/static_core/plugins/ets/runtime/types/ets_typed_unsigned_arrays.h @@ -82,7 +82,7 @@ public: private: ObjectPointer buffer_; ObjectPointer name_; - EtsDouble bytesPerElement_; + EtsInt bytesPerElement_; EtsInt byteOffset_; EtsInt byteLength_; EtsInt lengthInt_; diff --git a/static_core/plugins/ets/sdk/api/@ohos.buffer.ets b/static_core/plugins/ets/sdk/api/@ohos.buffer.ets index 0b964bd0fa3a2261dc8f6296d49c836341da29c2..4c1c7dca488f6a035034f31612c496c843f04369 100644 --- a/static_core/plugins/ets/sdk/api/@ohos.buffer.ets +++ b/static_core/plugins/ets/sdk/api/@ohos.buffer.ets @@ -36,9 +36,9 @@ function getArrayBufferFrom(value: buffer.Buffer | Uint8Array): ArrayBuffer { function fillInPaddingBase64(str: string): string { let base64Divisible: int = 4; - let remainder: int = str.length % base64Divisible as int; + let remainder: int = Double.toInt(str.length % base64Divisible); const paddingCount: int = remainder != 0 ? base64Divisible - remainder : 0; - return str.padRight(c'=', str.length as int + paddingCount); + return str.padRight(c'=', Double.toInt(str.length) + paddingCount); } /** @@ -376,7 +376,7 @@ It must be >= 0 and <= uint32 max. Received value is: ${length}`) */ export function transcode(source: Buffer | Uint8Array, fromEnc: string, toEnc: string): Buffer { const resolvedSource = getArrayBufferFrom(source); - const sourceBytesLength = resolvedSource.byteLength as int; + const sourceBytesLength = resolvedSource.byteLength.toInt(); const str = ArrayBuffer.stringify(resolvedSource, toEnc, 0, sourceBytesLength); const newBytes = ArrayBuffer.from(str, toEnc); return new Buffer(newBytes); @@ -386,7 +386,7 @@ It must be >= 0 and <= uint32 max. Received value is: ${length}`) private length: int private idx: int = 0 constructor(parent: Buffer) { - this.length = parent.length as int + this.length = parent.length.toInt() } public override $_iterator(): IterableIterator { return this @@ -395,7 +395,7 @@ It must be >= 0 and <= uint32 max. Received value is: ${length}`) if (this.idx < 0 || this.idx >= this.length) { return new IteratorResult() } - return new IteratorResult(false, this.idx++ as number) + return new IteratorResult(false, (this.idx++).toDouble()) } } @@ -404,7 +404,7 @@ It must be >= 0 and <= uint32 max. Received value is: ${length}`) private parent: Buffer private idx: int = 0 constructor(parent: Buffer) { - this.length = parent.length as int + this.length = parent.length.toInt() this.parent = parent } public override $_iterator(): IterableIterator { @@ -423,7 +423,7 @@ It must be >= 0 and <= uint32 max. Received value is: ${length}`) private parent: Buffer private idx: int = 0 constructor(parent: Buffer) { - this.length = parent.length as int + this.length = parent.length.toInt() this.parent = parent } public override $_iterator(): IterableIterator<[number, number]> { @@ -472,7 +472,7 @@ It must be >= 0 and <= uint32 max. Received value is: ${length}`) public toString(): string { let resolvedEncoding: string = "utf8"; let resolvedStart: int = 0; - let resolvedEnd: int = buffer.byteLength(this.buffer) as int; + let resolvedEnd: int = buffer.byteLength(this.buffer).toInt(); return ArrayBuffer.stringify(this.buffer, resolvedEncoding, resolvedStart, resolvedEnd); } @@ -487,18 +487,18 @@ It must be >= 0 and <= uint32 max. Received value is: ${length}`) public toString(encoding?: BufferEncoding, start?: number, end?: number): string { let resolvedEncoding: string = encoding ?? "utf8"; let resolvedStart: int = 0; - let resolvedEnd: int = this.length as int; + let resolvedEnd: int = (this.length).toInt(); if (start && !isNaN(start!) && start! > 0) { - resolvedStart = start as int; + resolvedStart = start.toInt(); } if (end && !isNaN(end!)) { - resolvedEnd = end as int; + resolvedEnd = end.toInt(); } let bufLength = this.length; if (resolvedStart >= bufLength || resolvedStart > resolvedEnd) { return ''; } - resolvedEnd = resolvedEnd > bufLength ? bufLength as int : resolvedEnd + resolvedEnd = resolvedEnd > bufLength ? bufLength.toInt() : resolvedEnd return ArrayBuffer.stringify(this.buffer, resolvedEncoding, resolvedStart, resolvedEnd); } @@ -601,7 +601,7 @@ It must be >= 0 and <= uint32 max. Received value is: ${length}`) return false; } for (let j: int = 0; j < searchBuffer.length; j++) { - if (this.at(startIndex as int + j) != searchBuffer.at(j)) { + if (this.at(startIndex.toInt() + j) != searchBuffer.at(j)) { return false; } } @@ -663,9 +663,9 @@ It must be >= 0 and <= uint32 max. Received value is: ${length}`) { const resolvedTarget = getArrayBufferFrom(target); const resolvedSource = this.buffer; - const resolvedTargetStart = (targetStart ?? 0) as int; - const resolvedSourceStart = (sourceStart ?? 0) as int; - const resolvedSourceEnd = (sourceEnd ?? this.length) as int; + const resolvedTargetStart = (targetStart ?? 0).toInt(); + const resolvedSourceStart = (sourceStart ?? 0).toInt(); + const resolvedSourceEnd = (sourceEnd ?? this.length).toInt(); if (resolvedTargetStart < 0) { throw createBusinessError(OutOfBoundsErrorCodeId, `The value of "targetStart" is out of range. It must be >= 0. @@ -753,8 +753,8 @@ Received value is: ${resolvedEnd}`) klass = parts[parts.length - 1]; } - const offsetInt = offset as int; - const resolvedEndInt = resolvedEnd as int; + const offsetInt = offset.toInt(); + const resolvedEndInt = resolvedEnd.toInt(); const resolvedEncoding: BufferEncoding = encoding ?? "utf-8"; switch (klass) { @@ -762,25 +762,25 @@ Received value is: ${resolvedEnd}`) let buff = ArrayBuffer.from(value as string, resolvedEncoding as string); for (let i: int = offsetInt; i < resolvedEndInt; i++) { - this.buffer.set(i, buff.at((i % buff.byteLength) as int) as byte); + this.buffer.set(i, buff.at((i % buff.byteLength).toInt()).toByte()); } return this; case "number": let asNum = value as number; for (let i: int = offsetInt; i < resolvedEndInt; i++) { - this.buffer.set(i, asNum as byte); + this.buffer.set(i, asNum.toByte()); } return this; case "Buffer": let asBuf = value as Buffer; for (let i: int = offsetInt; i < resolvedEndInt; i++) { - this.buffer.set(i, asBuf.at((i % asBuf.length) as int)); + this.buffer.set(i, asBuf.at((i % asBuf.length).toInt())); } return this; case "Uint8Array": let asU8a = value as Uint8Array; for (let i: int = offsetInt; i < resolvedEndInt; i++) { - this.buffer.set(i, asU8a.at(i % asU8a.length)! as byte); + this.buffer.set(i, asU8a.at(i % asU8a.length)!.toByte()); } return this; default: @@ -1138,7 +1138,7 @@ It must be >= 0 and <= ${this.length}. Received value is: ${tmpLength}`) const byteLen = buffer.byteLength(resolvedString, resolvedEncoding); const strBuffer = buffer.from(resolvedString, resolvedEncoding); for (let i = 0; i < resolvedLength && i < byteLen; i++) { - this.buffer.set((offset + i) as int, strBuffer.at(i)); + this.buffer.set((offset + i).toInt(), strBuffer.at(i)); } return Math.min(resolvedLength, byteLen); } diff --git a/static_core/plugins/ets/sdk/api/@ohos.url.ets b/static_core/plugins/ets/sdk/api/@ohos.url.ets index 97c83c6fded403eba3040e3430f32ca358fc1dcd..9ff4b2a638ec3412be0a626cb93a9f01a0e92b36 100644 --- a/static_core/plugins/ets/sdk/api/@ohos.url.ets +++ b/static_core/plugins/ets/sdk/api/@ohos.url.ets @@ -226,7 +226,7 @@ export namespace url { } function isFileNotHost(input: string) { - if (isAlpha(input.charAt(0)) && (input[1] == c':' || input[1] == c'|')) { + if (isAlpha(input.charAt(0).toString()) && (input[1] == c':' || input[1] == c'|')) { return true; } return false; @@ -531,13 +531,13 @@ export namespace url { private ipv4Array: Array = new Array(); analysizeScheme(input: string): boolean { - if (!isAlpha(input.charAt(0))) { + if (!isAlpha(input.charAt(0).toString())) { this.flags[0] = true; return false; } let sizeLen: number = input.length; for (let i = 1; i < sizeLen - 1; i++) { - if (!isAlphaNum(input.charAt(i)) && input[i] != c'+' && input[i] != c'-' && input[i] != c'.') { + if (!isAlphaNum(input.charAt(i).toString()) && input[i] != c'+' && input[i] != c'-' && input[i] != c'.') { this.flags[0] = true; return false; } @@ -592,7 +592,7 @@ export namespace url { } let it = this.cPath[0]; - if (isAlpha(it.charAt(0)) && (it[1] == c':' || it[1] == c'|')) { + if (isAlpha(it.charAt(0).toString()) && (it[1] == c':' || it[1] == c'|')) { if (it.length == 2) { this.cPath[0] = it[0] + ':'; this.flags[4] = false; @@ -753,7 +753,7 @@ export namespace url { let inputSize: number = input.length; for (let i = 0; i < inputSize; i++) { let ch = input[i]; - let result = Helper.specialcharacter.indexOf(ch); + let result = Helper.specialcharacter.indexOf(ch.toString()); if ((ch != c'%') && (result != -1)) { this.flags[0] = true; return; @@ -862,7 +862,7 @@ export namespace url { return; } for (let i = 0; i < port.length; i++) { - if (!isNum(port.charAt(i))) { + if (!isNum(port.charAt(i).toString())) { this.flags[0] = true; return; } @@ -1561,7 +1561,7 @@ export namespace url { resUrl.cPath.pop(); return; } - if ((baseUrl.cPath.length == 1) && isFile && isAlpha(baseUrl.cPath[0].charAt(0)) && (baseUrl.cPath[0].charAt(1) == c':')) { + if ((baseUrl.cPath.length == 1) && isFile && isAlpha(baseUrl.cPath[0].charAt(0).toString()) && (baseUrl.cPath[0].charAt(1) == c':')) { return; } baseUrl.cPath.pop(); @@ -2500,7 +2500,7 @@ export namespace url { const UNICODE_0x10000 = 0x10000; outer: for (; i < len; i++) { - let c = str.charCodeAt(i as number); + let c = str.charCodeAt(i.toDouble()); // ASCII while (c < UNICODE_0x80) { diff --git a/static_core/plugins/ets/sdk/api/@ohos.util.ArrayList.ets b/static_core/plugins/ets/sdk/api/@ohos.util.ArrayList.ets index 2fca17aeee2b69fa69e44f287cd72cf3f18a5a27..7908fd25b2694364ccb2dabd56eefecb30918d29 100644 --- a/static_core/plugins/ets/sdk/api/@ohos.util.ArrayList.ets +++ b/static_core/plugins/ets/sdk/api/@ohos.util.ArrayList.ets @@ -60,7 +60,7 @@ export class ArrayList implements Iterable { } if (this.length == this.capacity) { - this.increaseCap((this.capacity * 1.5) as int); + this.increaseCap((this.capacity * 1.5).toInt()); } this.buffer.push(element); return true; @@ -79,12 +79,12 @@ export class ArrayList implements Iterable { if (this.length + 1 <= this.capacity) { this.buffer.push(element); // length++ - for (let i: int = this.length - 1 as int; i > index; i--) { + for (let i: int = (this.length - 1).toInt(); i > index; i--) { this.buffer[i] = this.buffer[i - 1]; } - this.buffer[index as int] = element; + this.buffer[index.toInt()] = element; } else { - this.increaseCap((this.capacity * 1.5) as int); + this.increaseCap((this.capacity * 1.5).toInt()); let newBuffer: Array = new Array(this.capacity); newBuffer.length = 0; @@ -92,7 +92,7 @@ export class ArrayList implements Iterable { newBuffer.push(this.buffer[i]); } newBuffer.push(element); - for (let i: int = index as int; i < this.length; i++) { + for (let i: int = index.toInt(); i < this.length; i++) { newBuffer.push(this.buffer[i]); } @@ -151,7 +151,7 @@ export class ArrayList implements Iterable { let delItem: T = this.buffer[index]; - for (let i: int = index as int + 1; i < this.length; i++) { + for (let i: int = index.toInt() + 1; i < this.length; i++) { this.buffer[i - 1] = this.buffer[i]; } this.buffer.length-- @@ -186,7 +186,7 @@ export class ArrayList implements Iterable { this.checkEmptyContainer(); this.checkRange(fromIndex, toIndex); - for (let i: int = fromIndex as int, j: int = toIndex as int; j < this.length; i++, j++) { + for (let i: int = fromIndex.toInt(), j: int = toIndex.toInt(); j < this.length; i++, j++) { this.buffer[i] = this.buffer[j]; } @@ -201,7 +201,7 @@ export class ArrayList implements Iterable { */ public replaceAllElements(callbackfn: (value: T, index: number, arrList: ArrayList) => T): void { for (let i: int = 0; i < this.length; i++) { - this.buffer[i] = callbackfn(this.buffer[i], i as number, this); + this.buffer[i] = callbackfn(this.buffer[i], i.toDouble(), this); } } @@ -213,7 +213,7 @@ export class ArrayList implements Iterable { */ public forEach(callbackfn: (value: T, index: number, arrList: ArrayList) => void): void { for (let i: int = 0; i < this.length; i++) { - callbackfn(this.buffer[i], i as number, this); + callbackfn(this.buffer[i], i.toDouble(), this); } } @@ -241,8 +241,8 @@ export class ArrayList implements Iterable { this.checkRange(fromIndex, toIndex); let subArrLength = toIndex - fromIndex; - let newBuffer: ArrayList = new ArrayList(subArrLength as int); - for (let i: int = fromIndex as int; i < toIndex; i++) { + let newBuffer: ArrayList = new ArrayList(subArrLength.toInt()); + for (let i: int = fromIndex.toInt(); i < toIndex; i++) { newBuffer.add(this.buffer[i]); } @@ -344,7 +344,7 @@ export class ArrayList implements Iterable { } if (newCapacity > this.capacity) { - this.increaseCap(newCapacity as int); + this.increaseCap(newCapacity.toInt()); } } @@ -356,7 +356,7 @@ export class ArrayList implements Iterable { for (let i: int = 0; i < this.length; i++) { newBuffer[i] = this.buffer[i]; } - this.capacity = this.length as int; + this.capacity = this.length.toInt(); this.buffer = newBuffer; } diff --git a/static_core/plugins/ets/sdk/api/@ohos.util.Deque.ets b/static_core/plugins/ets/sdk/api/@ohos.util.Deque.ets index e1b4b73b6a3d3f254ab9b8d8370acdf83db015c3..5d1870aae82299fdc8afda799885c10990e259ae 100644 --- a/static_core/plugins/ets/sdk/api/@ohos.util.Deque.ets +++ b/static_core/plugins/ets/sdk/api/@ohos.util.Deque.ets @@ -211,7 +211,7 @@ export default class Deque implements Iterable { i = (i + 1) % this.capacity; } - this.rear = this.length as int; + this.rear = this.length.toInt(); this.front = 0; this.capacity = newCap; this.buffer = newBuffer; diff --git a/static_core/plugins/ets/sdk/api/@ohos.util.LightWeightMap.ets b/static_core/plugins/ets/sdk/api/@ohos.util.LightWeightMap.ets index 1e51115c15b3d39d6ca5219e253f14839c4112b2..ab2d4317919c4913eb6e334a97daa0ea348ea320 100644 --- a/static_core/plugins/ets/sdk/api/@ohos.util.LightWeightMap.ets +++ b/static_core/plugins/ets/sdk/api/@ohos.util.LightWeightMap.ets @@ -178,7 +178,7 @@ export default class LightWeightMap implements ReadonlyLightWeightMap implements ReadonlyLightWeightMap Int.MAX_VALUE) { return; } - this.buckets.increaseCapacityTo(minimumCapacity as int); + this.buckets.increaseCapacityTo(minimumCapacity.toInt()); } /** @@ -392,7 +392,7 @@ export default class LightWeightMap implements ReadonlyLightWeightMap implements ReadonlyLightWeightMap 0) && (this.buckets.entryHashs[right] === hashCode)) { if (this.buckets.entryKeys[left] === key) { - return left as number; + return left.toDouble(); } left--; } diff --git a/static_core/plugins/ets/sdk/api/@ohos.util.TreeMap.ets b/static_core/plugins/ets/sdk/api/@ohos.util.TreeMap.ets index af60cf1471786c6394d404674f94c899965016aa..fc0c743ae8603cb8d30feb0aef12a54ba4fac50c 100644 --- a/static_core/plugins/ets/sdk/api/@ohos.util.TreeMap.ets +++ b/static_core/plugins/ets/sdk/api/@ohos.util.TreeMap.ets @@ -267,8 +267,8 @@ export default class TreeMap implements ReadonlyTreeMap { if (Number.isInteger(firstValueN) && Number.isInteger(secondValueN) && firstValueN <= Int.MAX_VALUE / 128 && firstValueN >= Int.MIN_VALUE / 128 && secondValueN <= Int.MAX_VALUE / 128 && secondValueN >= Int.MIN_VALUE / 128) { - const firstValueI = firstValueN as int; - const secondValueI = secondValueN as int; + const firstValueI = firstValueN.toInt(); + const secondValueI = secondValueN.toInt(); return secondValueI - firstValueI; } } else if (firstValue instanceof String && secondValue instanceof String) { diff --git a/static_core/plugins/ets/sdk/api/@ohos.util.ets b/static_core/plugins/ets/sdk/api/@ohos.util.ets index 4859954245be9e951309cefb326966656909d8dc..ad774ba5e37cdbfae21ac7ea79ddce797211ac7a 100644 --- a/static_core/plugins/ets/sdk/api/@ohos.util.ets +++ b/static_core/plugins/ets/sdk/api/@ohos.util.ets @@ -132,23 +132,23 @@ export namespace util { } public getCreateCount(): number { - return this.createCount as number; + return this.createCount.toDouble(); } public getMissCount(): number { - return this.missCount as number; + return this.missCount.toDouble(); } public getRemovalCount(): number { - return this.evictionCount as number; + return this.evictionCount.toDouble(); } public getMatchCount(): number { - return this.hitCount as number; + return this.hitCount.toDouble(); } public getPutCount(): number { - return this.putCount as number; + return this.putCount.toDouble(); } public $_iterator(): IterableIterator<[K, V]> { @@ -295,11 +295,11 @@ export namespace util { let bytes: Array = new Array(); for (let i = 0; i < cleaned.length; i++) { - let ch: string = cleaned[i]; + let ch: string = cleaned[i].toString(); if (ch == "=") { break; } - let index: int = table.indexOf(ch) as int; + let index: int = table.indexOf(ch).toInt(); if (index == -1) { continue; } @@ -1620,4 +1620,3 @@ export namespace util { return result; } } - diff --git a/static_core/plugins/ets/sdk/api/@ohos.util.stream.ets b/static_core/plugins/ets/sdk/api/@ohos.util.stream.ets index 84d7341d2d861ea377887fec995af57a165d9b56..075fa65a6aabf59e4de3b275a9ed690c18d97e51 100644 --- a/static_core/plugins/ets/sdk/api/@ohos.util.stream.ets +++ b/static_core/plugins/ets/sdk/api/@ohos.util.stream.ets @@ -631,7 +631,7 @@ export namespace stream { let buffer: string | null = null; if (size > 0 && size <= this.readableLengthInner) { this.readableLengthInner -= size; - buffer = this.stringDecoder.write(this.buf.slice(0, size)); + buffer = this.stringDecoder.write(this.buf.slice(0 as int, size)); this.buf = this.buf.slice(size); if (this.doReadFunc !== null && this.listener !== undefined) { this.listener!.emit(ReadableEvent.DATA, buffer); diff --git a/static_core/plugins/ets/sdk/arkts/@arkts.collections.ets b/static_core/plugins/ets/sdk/arkts/@arkts.collections.ets index b877f608a44bd42403792e0600d4ab4d769654f7..6d0ee8010fd2cf21e90d8885d5980fb31e740a5e 100644 --- a/static_core/plugins/ets/sdk/arkts/@arkts.collections.ets +++ b/static_core/plugins/ets/sdk/arkts/@arkts.collections.ets @@ -173,8 +173,8 @@ export namespace collections { throw new BusinessError(OutOfBoundsErrorCodeId, new Error(`The value of \"fromIndex\" is out of range. It must be >= 0 && <= ${toIndex - 1}. Received value is: ${fromIndex}`)); } - let from = new BitIndex(this.computeElementIdAndBitId(fromIndex as int)); - let to = new BitIndex(this.computeElementIdAndBitId(toIndex as int)); + let from = new BitIndex(this.computeElementIdAndBitId(fromIndex.toInt())); + let to = new BitIndex(this.computeElementIdAndBitId(toIndex.toInt())); if (from.elementId === to.elementId) { return this.checkBit(this.buffer[from.elementId], from.index, to.index - 1, element); @@ -265,8 +265,8 @@ export namespace collections { throw new BusinessError(OutOfBoundsErrorCodeId, new Error(`The value of \"fromIndex\" is out of range. It must be >= 0 && <= ${toIndex - 1}. Received value is: ${fromIndex}`)); } - let from = new BitIndex(this.computeElementIdAndBitId(fromIndex as int)); - let to = new BitIndex(this.computeElementIdAndBitId(toIndex as int)); + let from = new BitIndex(this.computeElementIdAndBitId(fromIndex.toInt())); + let to = new BitIndex(this.computeElementIdAndBitId(toIndex.toInt())); if (from.elementId === to.elementId) { this.buffer[from.elementId] = this.flipBits(this.buffer[from.elementId], from.index, to.index - 1); @@ -308,8 +308,8 @@ export namespace collections { throw new BusinessError(OutOfBoundsErrorCodeId, new Error(`The value of \"fromIndex\" is out of range. It must be >= 0 && <= ${toIndex - 1}. Received value is: ${fromIndex}`)); } - let from = new BitIndex(this.computeElementIdAndBitId(fromIndex as int)); - let to = new BitIndex(this.computeElementIdAndBitId(toIndex as int)); + let from = new BitIndex(this.computeElementIdAndBitId(fromIndex.toInt())); + let to = new BitIndex(this.computeElementIdAndBitId(toIndex.toInt())); let newBitVector = new BitVector(toIndex - fromIndex); @@ -347,8 +347,8 @@ export namespace collections { throw new BusinessError(OutOfBoundsErrorCodeId, new Error(`The value of \"fromIndex\" is out of range. It must be >= 0 && <= ${toIndex - 1}. Received value is: ${fromIndex}`)); } - let from = new BitIndex(this.computeElementIdAndBitId(fromIndex as int)); - let to = new BitIndex(this.computeElementIdAndBitId(toIndex as int)); + let from = new BitIndex(this.computeElementIdAndBitId(fromIndex.toInt())); + let to = new BitIndex(this.computeElementIdAndBitId(toIndex.toInt())); if (from.elementId === to.elementId) { this.buffer[from.elementId] = this.setBits(this.buffer[from.elementId], from.index, to.index - 1, element); @@ -446,8 +446,8 @@ export namespace collections { throw new BusinessError(OutOfBoundsErrorCodeId, new Error(`The value of \"fromIndex\" is out of range. It must be >= 0 && <= ${toIndex - 1}. Received value is: ${fromIndex}`)); } - let from = new BitIndex(this.computeElementIdAndBitId(fromIndex as int)); - let to = new BitIndex(this.computeElementIdAndBitId(toIndex as int)); + let from = new BitIndex(this.computeElementIdAndBitId(fromIndex.toInt())); + let to = new BitIndex(this.computeElementIdAndBitId(toIndex.toInt())); if (from.elementId === to.elementId) { let count = this.countBit1InRange(this.buffer[from.elementId], from.index, to.index - 1); diff --git a/static_core/plugins/ets/sdk/arkts/@arkts.math.Decimal.ets b/static_core/plugins/ets/sdk/arkts/@arkts.math.Decimal.ets index 27724fecfc74e5613d3521c77bb02450a3bb7a57..aa2aa9d055cf0b81e0570b7dc6821d71b3dec207 100644 --- a/static_core/plugins/ets/sdk/arkts/@arkts.math.Decimal.ets +++ b/static_core/plugins/ets/sdk/arkts/@arkts.math.Decimal.ets @@ -281,7 +281,7 @@ export class Decimal { rep = 1; } else { if (Utils.toNumber(n) > 0 || Utils.toNumber(n.slice(1)) > 0 - && (n.charAt(0) as String).equals('5')) { + && (n.charAt(0).toString()).equals('5')) { Utils.finalise(r, e + 1, 1); m = !r.mul(r).equals(x); } @@ -405,7 +405,7 @@ export class Decimal { k = Math.pow(+x.toNumber(), yn); e = k == 0 || !isFinite(k) - ? Math.floor(yn * (Math.log(Utils.toNumber('0.' + Utils.digitsToString(x.d!))) / Math.LN10 + x.e + 1)) + ? Math.floor(yn * (Math.log(Utils.toNumber('0.' + Utils.digitsToString(x.d!))) / Utils.toNumber(Math.LN10) + x.e + 1)) : new Decimal(k + '').e; if (e > Decimal.maxE + 1 || e < Decimal.minE - 1) { @@ -1073,7 +1073,7 @@ export class Decimal { // Use 2 * log10(2^k) + 5 (empirically derived) to estimate the increase in precision // necessary to ensure the first 4 rounding digits are correct. - let guard = Math.log(Math.pow(2, k)) / Math.LN10 * 2 + 5 | 0; + let guard = Math.log(Math.pow(2, k)) / Utils.toNumber(Math.LN10) * 2 + 5 | 0; wpr += guard; let denominator = new Decimal(1); let pow = new Decimal(1); @@ -1128,14 +1128,14 @@ export class Decimal { let guard: number = 10; Decimal.precision = wpr += guard; let c = Utils.digitsToString(xd!); - let c0 = Utils.toNumber(c.charAt(0)); + let c0 = Utils.toNumber(c.charAt(0).toString()); let e: number; if (Math.abs(e = x.e) < 1.5e15) { let n: number = 1; - while (c0 < 7 && c0 != 1 || c0 == 1 && (Utils.toNumber(c.charAt(1))) > 3) { + while (c0 < 7 && c0 != 1 || c0 == 1 && (Utils.toNumber(c.charAt(1).toString())) > 3) { x = x.mul(y); c = Utils.digitsToString(x.d!); - c0 = Utils.toNumber(c.charAt(0)); + c0 = Utils.toNumber(c.charAt(0).toString()); n++; } e = x.e; diff --git a/static_core/plugins/ets/stdlib/escompat/Array.ets b/static_core/plugins/ets/stdlib/escompat/Array.ets index 2d0353b4fd75042d592774bfad81786bd1c114cf..830de4c62c6bed7160519f0b466a56c5a119eef2 100644 --- a/static_core/plugins/ets/stdlib/escompat/Array.ets +++ b/static_core/plugins/ets/stdlib/escompat/Array.ets @@ -21,7 +21,7 @@ function asIntOrDefault(n: Number | undefined, def: int): int { if (n === undefined) { return def } - return (n! as Object as Number) as number as int; + return Double.toInt(n!); } function normalizeIndex(idx: int, len: int): int { @@ -51,7 +51,7 @@ class ArrayKeysIterator implements IterableIterator { this.isDone = true return new IteratorResult() } - return new IteratorResult(this.idx++ as number) + return new IteratorResult(Int.toDouble(this.idx++)) } override $_iterator(): IterableIterator { @@ -71,11 +71,11 @@ export class Array implements ReadonlyArray, Iterable { internal actualLength: int override get length(): number { - return this.actualLength as number + return Int.toDouble(this.actualLength) } set length(newLen: number) { - const len = newLen as int + const len = Double.toInt(newLen) if (len < 0 || len > this.actualLength) { throw new RangeError("can't change length to bigger or negative") } @@ -83,11 +83,11 @@ export class Array implements ReadonlyArray, Iterable { } public override $_get(index: number): T { - return this.$_get(index as int) + return this.$_get(Double.toInt(index)) } public $_set(i: number, val: T): void { - this.$_set(i as int, val) + this.$_set(Double.toInt(i), val) } public native $_get(idx: int): T; @@ -111,7 +111,7 @@ export class Array implements ReadonlyArray, Iterable { } public constructor(arrayLen: number) { - this(arrayLen as int) + this(Double.toInt(arrayLen)) } internal constructor(_tag: FromBuffer, buf: FixedArray) { @@ -131,7 +131,7 @@ export class Array implements ReadonlyArray, Iterable { */ public constructor(first: T, ...d: T[]) { this.buffer = new NullishType[d.length + 1] - this.actualLength = d.length as int + 1 + this.actualLength = Double.toInt(d.length) + 1 this.buffer[0] = first @@ -149,7 +149,7 @@ export class Array implements ReadonlyArray, Iterable { * */ public static create(arrayLength: number, initialValue: T): Array { - let other = new Array(arrayLength as int) + let other = new Array(Double.toInt(arrayLength)) other.fill(initialValue) return other } @@ -166,7 +166,7 @@ export class Array implements ReadonlyArray, Iterable { if (arrayLength > Int.MAX_VALUE) { throw new RangeError("arrayLength must be <= int32 max") } - const len = arrayLength as int + const len = Double.toInt(arrayLength) const delta: int = len - this.actualLength if (delta <= 0) { return @@ -188,7 +188,7 @@ export class Array implements ReadonlyArray, Iterable { if (arrayLength >= this.actualLength) { return } - let newLen: int = arrayLength as int + let newLen: int = Double.toInt(arrayLength) if (newLen < 0) { // Convert from signed to unsigned newLen = newLen & Int.MAX_VALUE @@ -261,7 +261,7 @@ export class Array implements ReadonlyArray, Iterable { * @returns `Array` intance constructed from `Object[]` ArrayLike. */ public static from(arr: ArrayLike): Array { - const ret = new Array(arr.length as int) + const ret = new Array(arr.length.toInt()) let i = 0 iteratorForEach(arr.$_iterator(), (x: T): void => { ret[i] = x @@ -287,7 +287,7 @@ export class Array implements ReadonlyArray, Iterable { const idx : FixedArray = new int[1] idx[0] = 0 iteratorForEach(iterable.$_iterator(), (x: T): void => { - ret.push(mapfn(x, idx[0] as number)) + ret.push(mapfn(x, Int.toDouble(idx[0]))) idx[0] += 1 }) return ret @@ -310,7 +310,7 @@ export class Array implements ReadonlyArray, Iterable { */ public static from(arr: FixedArray): Array { const len = arr.length - const ret : FixedArray = new NullishType[len as int] + const ret : FixedArray = new NullishType[Double.toInt(len)] for (let i: int = 0; i < len; i++) { ret[i] = arr[i] as NullishType } @@ -348,7 +348,7 @@ export class Array implements ReadonlyArray, Iterable { } private lastIndexOfNumber(val: Number, fi: int): int { - const unboxedVal: number = val.valueOf() + const unboxedVal: number = val if (isNaN(val)) { return -1 } @@ -364,7 +364,7 @@ export class Array implements ReadonlyArray, Iterable { } private lastIndexOfFloat(val: Float, fi: int): int { - const unboxedVal: float = val.unboxed() + const unboxedVal: float = val if (isNaN(val)) { return -1 } @@ -636,13 +636,13 @@ export class Array implements ReadonlyArray, Iterable { */ private static defaultComparator(a: NullishType, b: NullishType): number { if (a instanceof Number && b instanceof Number) { - const x = (a as Number).valueOf() - const y = (b as Number).valueOf() + const x = a + const y = b if (Number.isInteger(x) && Number.isInteger(y) && x <= Int.MAX_VALUE / 128 && x >= Int.MIN_VALUE / 128 && y <= Int.MAX_VALUE / 128 && y >= Int.MIN_VALUE / 128) { - let z = x as int - let w = y as int + let z = Double.toInt(x) + let w = Double.toInt(y) return Array.defaultComparatorInts(z, w) } } else if (a instanceof String && b instanceof String) { @@ -840,11 +840,11 @@ export class Array implements ReadonlyArray, Iterable { * @returns new length */ public push(...val: T[]): number { - this.ensureUnusedCapacity(val.length as int) + this.ensureUnusedCapacity(Double.toInt(val.length)) for (let i = 0; i < val.length; i++) { this.buffer[this.actualLength + i] = val[i] } - this.actualLength += val.length + this.actualLength += Double.toInt(val.length) return this.actualLength } @@ -854,11 +854,11 @@ export class Array implements ReadonlyArray, Iterable { * @returns new length */ public pushECMA(...val: T[]): number { - this.ensureUnusedCapacity(val.length as int) + this.ensureUnusedCapacity(Double.toInt(val.length)) for (let i = 0; i < val.length; i++) { this.buffer[this.actualLength + i] = val[i] } - this.actualLength += val.length + this.actualLength += Double.toInt(val.length) return this.actualLength } @@ -883,7 +883,7 @@ export class Array implements ReadonlyArray, Iterable { * @returns an Array with deleted elements */ public splice(start: number, delete: Number | undefined, ...items: T[]): Array { - return this.splice(start as int, asIntOrDefault(delete, 0), ...items) + return this.splice(Double.toInt(start), asIntOrDefault(delete, 0), ...items) } /** @@ -906,9 +906,9 @@ export class Array implements ReadonlyArray, Iterable { } // this: [left middle right], we must replace middle with `items` - this.ensureUnusedCapacity(items.length as int - delete) + this.ensureUnusedCapacity(Double.toInt(items.length) - delete) const oldLen = this.actualLength - this.actualLength = this.actualLength - delete + items.length as int + this.actualLength = this.actualLength - delete + Double.toInt(items.length) let ret = new Array(delete) let lastSet = start @@ -925,7 +925,7 @@ export class Array implements ReadonlyArray, Iterable { } } else { for (let i = 0; i < rightLen; i++) { - this.buffer[start + items.length as int + i] = this.buffer[start + delete + i] + this.buffer[start + Double.toInt(items.length) + i] = this.buffer[start + delete + i] } } // insert middle part @@ -944,7 +944,7 @@ export class Array implements ReadonlyArray, Iterable { * @returns an Array with deleted elements from start to the last element of the current instance */ public splice(start: number): Array { - return this.splice(start as int) + return this.splice(Double.toInt(start)) } /** @@ -983,7 +983,7 @@ export class Array implements ReadonlyArray, Iterable { */ public static of(...values: T[]): Array { const ret = new Array() - ret.ensureUnusedCapacity(values.length as int) + ret.ensureUnusedCapacity(Double.toInt(values.length)) for (let i = 0; i < values.length; i++) { ret.push(values[i]) } @@ -1004,13 +1004,13 @@ export class Array implements ReadonlyArray, Iterable { buffer = new NullishType[this.buffer.length * 2 + values.length] } for (let i = 0; i < this.actualLength; i++) { - buffer[this.actualLength + values.length as int - i - 1] = this.buffer[this.actualLength - 1 - i] + buffer[this.actualLength + Double.toInt(values.length) - i - 1] = this.buffer[this.actualLength - 1 - i] } for (let i = 0; i < values.length; i++) { buffer[i] = values[i] } this.buffer = buffer - this.actualLength += values.length + this.actualLength += Double.toInt(values.length) return this.actualLength } @@ -1040,7 +1040,7 @@ export class Array implements ReadonlyArray, Iterable { const res = new Array() for (let i: int = 0; i < this.actualLength; i++) { const val = this.$_get_unsafe(i) - if (predicate(val, i as number, this)) { + if (predicate(val, Int.toDouble(i), this)) { res.push(val) } } @@ -1056,7 +1056,7 @@ export class Array implements ReadonlyArray, Iterable { * @returns a flattened Array with respect to depth */ public flat(depth: number): Array { - return this.flat(depth as int) + return this.flat(Double.toInt(depth)) } /** @@ -1113,7 +1113,7 @@ export class Array implements ReadonlyArray, Iterable { * Returns undefined if `index` < `-length()` or `index` >= `length()`. */ public override at(index: number): T | undefined { - return this.at(index as int) + return this.at(Double.toInt(index)) } /** @@ -1130,7 +1130,7 @@ export class Array implements ReadonlyArray, Iterable { public concat(...items: FixedArray>): Array { let totalAdd = this.actualLength; for (let i = 0; i < items.length; i++) { - totalAdd += items[i].length as int + totalAdd += Double.toInt(items[i].length) } const buf : FixedArray = new NullishType[totalAdd]; @@ -1142,7 +1142,7 @@ export class Array implements ReadonlyArray, Iterable { let insertTo = this.actualLength; for (let i = 0; i < items.length; i++) { const arr = items[i] - const len = arr.length as int + const len = Double.toInt(arr.length) for (let j = 0; j < len; j++) { buf[insertTo++] = arr.$_get(j) } @@ -1190,7 +1190,7 @@ export class Array implements ReadonlyArray, Iterable { * @returns this array after transformation */ public copyWithin(target: number, start: number, end?: Number): this { - this.copyWithin(target as int, start as int, asIntOrDefault(end, this.actualLength)); + this.copyWithin(Double.toInt(target), Double.toInt(start), asIntOrDefault(end, this.actualLength)); return this; } @@ -1312,7 +1312,7 @@ export class Array implements ReadonlyArray, Iterable { if (res == -1) { return undefined } - return this.$_get_unsafe(res as int); + return this.$_get_unsafe(Double.toInt(res)); } /** @@ -1327,7 +1327,7 @@ export class Array implements ReadonlyArray, Iterable { */ public override findIndex(predicate: (value: T, index: number, array: Array) => boolean): number { for (let i = 0; i < this.actualLength; i++) { - if (predicate(this.$_get_unsafe(i), i as number, this)) { + if (predicate(this.$_get_unsafe(i), Int.toDouble(i), this)) { return i; } } @@ -1345,7 +1345,7 @@ export class Array implements ReadonlyArray, Iterable { public override findLast(predicate: (elem: T, index: number, array: Array) => boolean): T | undefined { for (let i = this.actualLength - 1; i >= 0; i--) { const val = this.$_get_unsafe(i); - if (predicate(val, i as number, this)) { + if (predicate(val, Int.toDouble(i), this)) { return val; } } @@ -1364,7 +1364,7 @@ export class Array implements ReadonlyArray, Iterable { public override every(predicate: (value: T, index: number, array: Array) => boolean): boolean { let curArrLength = this.actualLength for (let i = 0; i < curArrLength && i < this.actualLength; i++) { - if (!predicate(this.$_get_unsafe(i), i as number, this)) { + if (!predicate(this.$_get_unsafe(i), Int.toDouble(i), this)) { return false } } @@ -1382,7 +1382,7 @@ export class Array implements ReadonlyArray, Iterable { */ public override some(predicate: (value: T, index: number, array: Array) => boolean): boolean { for (let i = 0; i < this.actualLength; i++) { - if (predicate(this.$_get_unsafe(i), i as number, this)) { + if (predicate(this.$_get_unsafe(i), Int.toDouble(i), this)) { return true } } @@ -1400,7 +1400,7 @@ export class Array implements ReadonlyArray, Iterable { */ public override findLastIndex(predicate: (element: T, index: number, array: Array) => boolean): number { for (let i = this.actualLength - 1; i >= 0; i--) { - if (predicate(this.$_get_unsafe(i), i as number, this)) { + if (predicate(this.$_get_unsafe(i), Int.toDouble(i), this)) { return i } } @@ -1420,7 +1420,7 @@ export class Array implements ReadonlyArray, Iterable { } let acc: T = this.$_get_unsafe(0); for (let i = 1; i < this.actualLength; i++) { - acc = callbackfn(acc, this.$_get_unsafe(i), i as number, this) + acc = callbackfn(acc, this.$_get_unsafe(i), Int.toDouble(i), this) } return acc } @@ -1437,7 +1437,7 @@ export class Array implements ReadonlyArray, Iterable { public override reduce(callbackfn: (previousValue: U, currentValue: T, index: number, array: Array) => U, initialValue: U): U { let acc = initialValue for (let i = 0; i < this.actualLength; i++) { - acc = callbackfn(acc, this.$_get_unsafe(i), i as number, this) + acc = callbackfn(acc, this.$_get_unsafe(i), Int.toDouble(i), this) } return acc } @@ -1454,7 +1454,7 @@ export class Array implements ReadonlyArray, Iterable { public override reduceRight(callbackfn: (previousValue: U, currentValue: T, index: number, array: Array) => U, initialValue: U): U { let acc = initialValue for (let i = this.actualLength - 1; i >= 0; i--) { - acc = callbackfn(acc, this.$_get_unsafe(i), i as number, this) + acc = callbackfn(acc, this.$_get_unsafe(i), Int.toDouble(i), this) } return acc } @@ -1467,7 +1467,7 @@ export class Array implements ReadonlyArray, Iterable { public override forEach(callbackfn: (value: T, index: number, array: Array) => void): void { const len0 = this.actualLength; for (let i = 0; i < len0; i++) { - callbackfn(this.$_get_unsafe(i), i as number, this) + callbackfn(this.$_get_unsafe(i), Int.toDouble(i), this) } } @@ -1522,7 +1522,7 @@ export class Array implements ReadonlyArray, Iterable { * @returns `Array` instance, constructed from extracted elements of `this` instance. */ public slice(start: int): Array { - return this.slice(start, Int.MAX_VALUE as int); + return this.slice(start, Int.MAX_VALUE); } /** @@ -1691,7 +1691,7 @@ export class Array implements ReadonlyArray, Iterable { */ public toSpliced(start: number, delete: number, ...items: FixedArray): Array { const len = this.actualLength; - return this.toSpliced(start as int, delete as int, ...items) + return this.toSpliced(Double.toInt(start), Double.toInt(delete), ...items) } /** @@ -1866,7 +1866,7 @@ export class Array implements ReadonlyArray, Iterable { * @returns a new Array with the element at the given index replaced with the given value */ public with(index: number, value: T): Array { - return this.with(index as int, value) + return this.with(Double.toInt(index), value) } /** @@ -1916,7 +1916,7 @@ export class Array implements ReadonlyArray, Iterable { const len = this.actualLength; let res : FixedArray = new NullishType[len]; for (let i = 0; i < this.actualLength; i++) { - res[i] = callbackfn(this.$_get_unsafe(i), i as number, this); + res[i] = callbackfn(this.$_get_unsafe(i), Int.toDouble(i), this); } return new Array(FROM_BUFFER, res); } @@ -1935,7 +1935,7 @@ export class Array implements ReadonlyArray, Iterable { let acc: T = this.$_get_unsafe(this.actualLength - 1); for (let i = this.actualLength - 2; i >= 0; i--) { if (this.actualLength > i) { - acc = callbackfn(acc, this.$_get_unsafe(i), i as number, this) + acc = callbackfn(acc, this.$_get_unsafe(i), Int.toDouble(i), this) } } return acc @@ -1965,7 +1965,7 @@ class ArrayValuesIterator_T implements IterableIterator { } public __Iterator_getLength(): int { - return this.parent.length as int + return Double.toInt(this.parent.length) } } @@ -1984,7 +1984,7 @@ class ArrayEntriesIterator_T implements IterableIterator<[number, T]> { return new IteratorResult<[number, T]>() } const i = this.idx++; - const vl: [number, T] = [i as number, this.parent.$_get_unsafe(i)] + const vl: [number, T] = [Int.toDouble(i), this.parent.$_get_unsafe(i)] return new IteratorResult<[number, T]>(vl); } @@ -1993,6 +1993,6 @@ class ArrayEntriesIterator_T implements IterableIterator<[number, T]> { } public __Iterator_getLength(): int { - return this.parent.length as int + return Double.toInt(this.parent.length) } } diff --git a/static_core/plugins/ets/stdlib/escompat/ArrayBuffer.ets b/static_core/plugins/ets/stdlib/escompat/ArrayBuffer.ets index bd4d54c55e36b7dee74bc9a2e5f07588d6bf794c..4c494928f49306d18fbf40d002ab6eafafdcb610 100644 --- a/static_core/plugins/ets/stdlib/escompat/ArrayBuffer.ets +++ b/static_core/plugins/ets/stdlib/escompat/ArrayBuffer.ets @@ -81,7 +81,7 @@ export class ArrayBuffer extends Buffer */ public constructor(length: number, maxByteLength?: number) { - this(length as int, (maxByteLength !== undefined) ? maxByteLength as int : undefined) + this(Double.toInt(length), (maxByteLength !== undefined) ? Double.toInt(maxByteLength) : undefined) } /** @@ -136,8 +136,8 @@ export class ArrayBuffer extends Buffer * @returns data taken from current ArrayBuffer with respect to begin and end parameters */ public slice(begin: number, end?: number): ArrayBuffer { - if (end == undefined) return this.slice(begin as int) - else return this.slice(begin as int, end as int) + if (end == undefined) return this.slice(Double.toInt(begin)) + else return this.slice(Double.toInt(begin), Double.toInt(end)) } /** @@ -282,7 +282,7 @@ export class ArrayBuffer extends Buffer public static from(array: number[]): ArrayBuffer { const buf = new ArrayBuffer(array.length) for (let i = 0; i < array.length; ++i) { - buf.set(i, array[i] as byte) + buf.set(i, Double.toByte(array[i])) } return buf } @@ -333,21 +333,6 @@ export class ArrayBuffer extends Buffer */ public static native from(buff: ArrayBuffer, byteOffset: int, length: int): ArrayBuffer; - /** - * Creates a new ArrayBuffer from a segment of an existing ArrayBuffer. - * - * This overload accepts numeric values for the byte offset and length parameters, - * converts them to the native integer type, and then copies the specified range from the source ArrayBuffer. - * - * @param {ArrayBuffer} buff - The source ArrayBuffer. - * @param {number} byteOffset - The starting byte index to copy from. - * @param {number} length - The number of bytes to copy. - * @returns {ArrayBuffer} A new ArrayBuffer containing the specified segment. - */ - public static from(buff: ArrayBuffer, byteOffset: number, length: number): ArrayBuffer { - return ArrayBuffer.from(buff, byteOffset as int, length as int); - } - /** * Creates a new ArrayBuffer by slicing a segment from an existing ArrayBuffer. * @@ -362,7 +347,7 @@ export class ArrayBuffer extends Buffer public static from(buffer: ArrayBuffer, byteOffset?: number, length?: number): ArrayBuffer { const resolvedByteOffset = byteOffset ?? 0; const resolvedLength = length ?? buffer.byteLength; - return ArrayBuffer.from(buffer, resolvedByteOffset as int, resolvedLength as int); + return ArrayBuffer.from(buffer, Double.toInt(resolvedByteOffset), Double.toInt(resolvedLength)); } /** @@ -386,7 +371,7 @@ export class ArrayBuffer extends Buffer if (!(obj instanceof ArrayBuffer)) { throw Error("Incorrect args"); } - return ArrayBuffer.from(obj as ArrayBuffer, byteOffsetOrEncoding as int, length as int); + return ArrayBuffer.from(obj, Double.toInt(byteOffsetOrEncoding as number), Double.toInt(length)); } diff --git a/static_core/plugins/ets/stdlib/escompat/Atomics.ets b/static_core/plugins/ets/stdlib/escompat/Atomics.ets index c9a64778f140cc6c66ed54ec9c60f443eca1b617..d981a205b4916c4bb1df5743d91f7b61080e55c0 100644 --- a/static_core/plugins/ets/stdlib/escompat/Atomics.ets +++ b/static_core/plugins/ets/stdlib/escompat/Atomics.ets @@ -54,7 +54,7 @@ class Waiter { ConcurrencyHelpers.mutexUnlock(this.mutex); return true; } - + private mutex: Object = ConcurrencyHelpers.mutexCreate(); private promiseQueue: BlockingQueue = new LinkedBlockingQueue(); } @@ -71,21 +71,21 @@ export class Atomics { public static isLockFree(byteSize: int): boolean { return byteSize == 1 || byteSize == 2 || byteSize == 4 || byteSize == 8 } - + public static add(typedArray: Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array, index: int, value: number): number { let buffer = typedArray.buffer if (typedArray instanceof Int8Array) { - return buffer.atomicAddI8(index, value as byte) + return buffer.atomicAddI8(index, value.toByte()) } else if (typedArray instanceof Int16Array) { - return buffer.atomicAddI16(index, value as short) + return buffer.atomicAddI16(index, value.toShort()) } else if (typedArray instanceof Int32Array) { - return buffer.atomicAddI32(index, value as int) + return buffer.atomicAddI32(index, value.toInt()) } else if (typedArray instanceof Uint8Array) { - return buffer.atomicAddU8(index, value as byte) + return buffer.atomicAddU8(index, value.toByte()) } else if (typedArray instanceof Uint16Array) { - return buffer.atomicAddU16(index, value as short) + return buffer.atomicAddU16(index, value.toShort()) } else if (typedArray instanceof Uint32Array) { - return buffer.atomicAddU32(index, value as int) + return buffer.atomicAddU32(index, value.toInt()) } else { throw new Error("Unhandled array type!") } @@ -105,17 +105,17 @@ export class Atomics { public static and(typedArray: Int8Array | Int16Array | Int32Array| Uint8Array | Uint16Array | Uint32Array, index: int, value: number): number { let buffer = typedArray.buffer if (typedArray instanceof Int8Array) { - return buffer.atomicAndI8(index, value as byte) + return buffer.atomicAndI8(index, value.toByte()) } else if (typedArray instanceof Int16Array) { - return buffer.atomicAndI16(index, value as short) + return buffer.atomicAndI16(index, value.toShort()) } else if (typedArray instanceof Int32Array) { - return buffer.atomicAndI32(index, value as int) + return buffer.atomicAndI32(index, value.toInt()) } else if (typedArray instanceof Uint8Array) { - return buffer.atomicAndU8(index, value as byte) + return buffer.atomicAndU8(index, value.toByte()) } else if (typedArray instanceof Uint16Array) { - return buffer.atomicAndU16(index, value as short) + return buffer.atomicAndU16(index, value.toShort()) } else if (typedArray instanceof Uint32Array) { - return buffer.atomicAndU32(index, value as int) + return buffer.atomicAndU32(index, value.toInt()) } else { throw new Error("Unhandled array type!") } @@ -135,22 +135,22 @@ export class Atomics { public static compareExchange(typedArray: Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array, index: int, expectedValue: number, replacementValue: number): number { let buffer = typedArray.buffer if (typedArray instanceof Int8Array) { - return buffer.atomicCompareExchangeI8(index, expectedValue as byte, replacementValue as byte) + return buffer.atomicCompareExchangeI8(index, expectedValue.toByte(), replacementValue.toByte()) } else if (typedArray instanceof Int16Array) { - return buffer.atomicCompareExchangeI16(index, expectedValue as short, replacementValue as short) + return buffer.atomicCompareExchangeI16(index, expectedValue.toShort(), replacementValue.toShort()) } else if (typedArray instanceof Int32Array) { - return buffer.atomicCompareExchangeI32(index, expectedValue as int, replacementValue as int) + return buffer.atomicCompareExchangeI32(index, expectedValue.toInt(), replacementValue.toInt()) } else if (typedArray instanceof Uint8Array) { - return buffer.atomicCompareExchangeU8(index, expectedValue as byte, replacementValue as byte) + return buffer.atomicCompareExchangeU8(index, expectedValue.toByte(), replacementValue.toByte()) } else if (typedArray instanceof Uint16Array) { - return buffer.atomicCompareExchangeU16(index, expectedValue as short, replacementValue as short) + return buffer.atomicCompareExchangeU16(index, expectedValue.toShort(), replacementValue.toShort()) } else if (typedArray instanceof Uint32Array) { - return buffer.atomicCompareExchangeU32(index, expectedValue as int, replacementValue as int) + return buffer.atomicCompareExchangeU32(index, expectedValue.toInt(), replacementValue.toInt()) } else { throw new Error("Unhandled array type!") } } - + public static compareExchange(typedArray: BigInt64Array | BigUint64Array, index: int, expectedValue: bigint, replacementValue: bigint): bigint { let buffer = typedArray.buffer if (typedArray instanceof BigUint64Array) { @@ -165,22 +165,22 @@ export class Atomics { public static exchange(typedArray: Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array, index: int, value: number): number { let buffer = typedArray.buffer if (typedArray instanceof Int8Array) { - return buffer.atomicExchangeI8(index, value as byte) + return buffer.atomicExchangeI8(index, value.toByte()) } else if (typedArray instanceof Int16Array) { - return buffer.atomicExchangeI16(index, value as short) + return buffer.atomicExchangeI16(index, value.toShort()) } else if (typedArray instanceof Int32Array) { - return buffer.atomicExchangeI32(index, value as int) + return buffer.atomicExchangeI32(index, value.toInt()) } else if (typedArray instanceof Uint8Array) { - return buffer.atomicExchangeU8(index, value as byte) + return buffer.atomicExchangeU8(index, value.toByte()) } else if (typedArray instanceof Uint16Array) { - return buffer.atomicExchangeU16(index, value as short) + return buffer.atomicExchangeU16(index, value.toShort()) } else if (typedArray instanceof Uint32Array) { - return buffer.atomicExchangeU32(index, value as int) + return buffer.atomicExchangeU32(index, value.toInt()) } else { throw new Error("Unhandled array type!") } } - + public static exchange(typedArray: BigInt64Array | BigUint64Array, index: int, value: bigint): bigint { let buffer = typedArray.buffer if (typedArray instanceof BigInt64Array) { @@ -191,7 +191,7 @@ export class Atomics { throw new Error("Unhandled array type!") } } - + public static load(typedArray: Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array, index: int): number { let buffer = typedArray.buffer if (typedArray instanceof Int8Array) { @@ -216,7 +216,7 @@ export class Atomics { let buffer = typedArray.buffer return new BigInt(buffer.atomicLoadI64(index)) } - + public static load(typedArray: BigUint64Array, index: int): bigint { let buffer = typedArray.buffer return new BigInt(buffer.atomicLoadU64(index)) @@ -225,22 +225,22 @@ export class Atomics { public static or(typedArray: Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array, index: int, value: number): number { let buffer = typedArray.buffer if (typedArray instanceof Int8Array) { - return buffer.atomicOrI8(index, value as byte) + return buffer.atomicOrI8(index, value.toByte()) } else if (typedArray instanceof Int16Array) { - return buffer.atomicOrI16(index, value as short) + return buffer.atomicOrI16(index, value.toShort()) } else if (typedArray instanceof Int32Array) { - return buffer.atomicOrI32(index, value as int) + return buffer.atomicOrI32(index, value.toInt()) } else if (typedArray instanceof Uint8Array) { - return buffer.atomicOrU8(index, value as byte) + return buffer.atomicOrU8(index, value.toByte()) } else if (typedArray instanceof Uint16Array) { - return buffer.atomicOrU16(index, value as short) + return buffer.atomicOrU16(index, value.toShort()) } else if (typedArray instanceof Uint32Array) { - return buffer.atomicOrU32(index, value as int) + return buffer.atomicOrU32(index, value.toInt()) } else { throw new Error("Unhandled array type!") } } - + public static or(typedArray: BigInt64Array | BigUint64Array, index: int, value: bigint): bigint { let buffer = typedArray.buffer if (typedArray instanceof BigInt64Array) { @@ -255,22 +255,22 @@ export class Atomics { public static store(typedArray: Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array, index: int, value: number): number { let buffer = typedArray.buffer if (typedArray instanceof Int8Array) { - return buffer.atomicStoreI8(index, value as byte) + return buffer.atomicStoreI8(index, value.toByte()) } else if (typedArray instanceof Int16Array) { - return buffer.atomicStoreI16(index, value as short) + return buffer.atomicStoreI16(index, value.toShort()) } else if (typedArray instanceof Int32Array) { - return buffer.atomicStoreI32(index, value as int) + return buffer.atomicStoreI32(index, value.toInt()) } else if (typedArray instanceof Uint8Array) { - return buffer.atomicStoreU8(index, value as byte) + return buffer.atomicStoreU8(index, value.toByte()) } else if (typedArray instanceof Uint16Array) { - return buffer.atomicStoreU16(index, value as short) + return buffer.atomicStoreU16(index, value.toShort()) } else if (typedArray instanceof Uint32Array) { - return buffer.atomicStoreU32(index, value as int) + return buffer.atomicStoreU32(index, value.toInt()) } else { throw new Error("Unhandled array type!") } } - + public static store(typedArray: BigInt64Array | BigUint64Array, index: int, value: bigint): bigint { let buffer = typedArray.buffer if (typedArray instanceof BigInt64Array) { @@ -285,22 +285,22 @@ export class Atomics { public static sub(typedArray: Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array, index: int, value: number): number { let buffer = typedArray.buffer if (typedArray instanceof Int8Array) { - return buffer.atomicSubI8(index, value as byte) + return buffer.atomicSubI8(index, value.toByte()) } else if (typedArray instanceof Int16Array) { - return buffer.atomicSubI16(index, value as short) + return buffer.atomicSubI16(index, value.toShort()) } else if (typedArray instanceof Int32Array) { - return buffer.atomicSubI32(index, value as int) + return buffer.atomicSubI32(index, value.toInt()) } else if (typedArray instanceof Uint8Array) { - return buffer.atomicSubU8(index, value as byte) + return buffer.atomicSubU8(index, value.toByte()) } else if (typedArray instanceof Uint16Array) { - return buffer.atomicSubU16(index, value as short) + return buffer.atomicSubU16(index, value.toShort()) } else if (typedArray instanceof Uint32Array) { - return buffer.atomicSubU32(index, value as int) + return buffer.atomicSubU32(index, value.toInt()) } else { throw new Error("Unhandled array type!") } } - + public static sub(typedArray: BigInt64Array | BigUint64Array, index: int, value: bigint): bigint { let buffer = typedArray.buffer if (typedArray instanceof BigInt64Array) { @@ -315,22 +315,22 @@ export class Atomics { public static xor(typedArray: Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array, index: int, value: number): number { let buffer = typedArray.buffer if (typedArray instanceof Int8Array) { - return buffer.atomicXorI8(index, value as byte) + return buffer.atomicXorI8(index, value.toByte()) } else if (typedArray instanceof Int16Array) { - return buffer.atomicXorI16(index, value as short) + return buffer.atomicXorI16(index, value.toShort()) } else if (typedArray instanceof Int32Array) { - return buffer.atomicXorI32(index, value as int) + return buffer.atomicXorI32(index, value.toInt()) } else if (typedArray instanceof Uint8Array) { - return buffer.atomicXorU8(index, value as byte) + return buffer.atomicXorU8(index, value.toByte()) } else if (typedArray instanceof Uint16Array) { - return buffer.atomicXorU16(index, value as short) + return buffer.atomicXorU16(index, value.toShort()) } else if (typedArray instanceof Uint32Array) { - return buffer.atomicXorU32(index, value as int) + return buffer.atomicXorU32(index, value.toInt()) } else { throw new Error("Unhandled array type!") } } - + public static xor(typedArray: BigInt64Array | BigUint64Array, index: int, value: bigint): bigint { let buffer = typedArray.buffer if (typedArray instanceof BigInt64Array) { @@ -350,17 +350,16 @@ export class Atomics { public static wait(typedArray: Int32Array | BigInt64Array, offset: int, value: bigint): string { return await Atomics.waitAsync(typedArray, offset, value) } - + public async static waitAsync(typedArray: Int32Array | BigInt64Array, offset: int, value: bigint): Promise { let buffer = typedArray.buffer if (typedArray instanceof Int32Array) { - return Atomics.wait(buffer, offset, value.getLong(), (b: ArrayBuffer, offset: int) => { return b.atomicLoadI32(offset) as long; }) + return Atomics.wait(buffer, offset, value.getLong(), (b: ArrayBuffer, offset: int) => { return Int.toLong(b.atomicLoadI32(offset)); }) } else { return Atomics.wait(buffer, offset, value.getLong(), (b: ArrayBuffer, offset: int) => { return buffer.atomicLoadI64(offset); }) - } + } } - /** * If "typedArray[offset] != value" suspends the current thread until it is notified by Atomics.notify * or until the given timeout passes. @@ -370,14 +369,14 @@ export class Atomics { public static wait(typedArray: Int32Array | BigInt64Array, offset: int, value: bigint, timeout: long): string { return await Atomics.waitAsync(typedArray, offset, value, timeout); } - + public async static waitAsync(typedArray: Int32Array | BigInt64Array, offset: int, value: bigint, timeout: long): Promise { let buffer = typedArray.buffer if (typedArray instanceof Int32Array) { - return Atomics.wait(buffer, offset, value.getLong(), (b: ArrayBuffer, offset: int) => { return b.atomicLoadI32(offset) as long; }, timeout) + return Atomics.wait(buffer, offset, value.getLong(), (b: ArrayBuffer, offset: int) => { return Int.toLong(b.atomicLoadI32(offset)); }, timeout) } else { return Atomics.wait(buffer, offset, value.getLong(), (b: ArrayBuffer, offset: int) => { return buffer.atomicLoadI64(offset); }, timeout) - } + } } /** @@ -404,7 +403,7 @@ export class Atomics { return Atomics.notify(buffer, offset, count) } } - + private static globalWaitingTable: ConcurrentHashMap> = new ConcurrentHashMap>(); private static globalWaitingTableMutex = ConcurrencyHelpers.mutexCreate(); diff --git a/static_core/plugins/ets/stdlib/escompat/BigInt.ets b/static_core/plugins/ets/stdlib/escompat/BigInt.ets index 0e3705ef181e2bb4dc6cdb82699e39a52d6b9542..f43ea745364be8cf55ab10dd4a5b50cabc25f0e9 100644 --- a/static_core/plugins/ets/stdlib/escompat/BigInt.ets +++ b/static_core/plugins/ets/stdlib/escompat/BigInt.ets @@ -70,13 +70,13 @@ export final class BigInt { internal static fromLongHelper(val: long, bitLen: int, sign: int): FixedArray { // get required array of Ints' size to store whole value // split by suported mode (baseSys) - let size: int = ((bitLen + BigInt.shiftSys - 1) / BigInt.shiftSys) as int + let size: int = Long.toInt((bitLen + BigInt.shiftSys - 1) / BigInt.shiftSys) let digits: FixedArray = new int[size] for (let i = 0; i < size; i++) { let d: long = val & BigInt.maskSys val = val >> BigInt.shiftSys - digits[i] = d as int + digits[i] = Long.toInt(d) } if (sign < 0) { @@ -93,22 +93,22 @@ export final class BigInt { constructor(d: byte) { this.sign = d < 0 ? -1 : (d == 0 ? 0 : 1) - this.bytes = this.sign == 0 ? [] as FixedArray : BigInt.fromLongHelper(d as long, 8, this.sign) + this.bytes = this.sign == 0 ? [] as FixedArray : BigInt.fromLongHelper(Byte.toLong(d), 8, this.sign) } constructor(d: short) { this.sign = d < 0 ? -1 : (d == 0 ? 0 : 1) - this.bytes = this.sign == 0 ? [] as FixedArray : BigInt.fromLongHelper(d as long, 16, this.sign) + this.bytes = this.sign == 0 ? [] as FixedArray : BigInt.fromLongHelper(Short.toLong(d), 16, this.sign) } constructor(d: int) { this.sign = d < 0 ? -1 : (d == 0 ? 0 : 1) - this.bytes = this.sign == 0 ? [] as FixedArray : BigInt.fromLongHelper(d as long, 32, this.sign) + this.bytes = this.sign == 0 ? [] as FixedArray : BigInt.fromLongHelper(Int.toLong(d), 32, this.sign) } constructor(d: long) { this.sign = d < 0 ? -1 : (d == 0 ? 0 : 1) - this.bytes = this.sign == 0 ? [] as FixedArray : BigInt.fromLongHelper(d as long, 64, this.sign) + this.bytes = this.sign == 0 ? [] as FixedArray : BigInt.fromLongHelper(d, 64, this.sign) } constructor(d: double) { @@ -120,8 +120,8 @@ export final class BigInt { constructor(d: string) { let trimmed = d.trim() let a = BigInt.parseFromString(trimmed) - this.bytes = a[0] - this.sign = a[1] + this.bytes = a[0] as FixedArray + this.sign = a[1] as int } constructor(d: boolean) { @@ -129,7 +129,7 @@ export final class BigInt { this.sign = oz this.bytes = this.sign == 0 ? [] as FixedArray - : BigInt.fromLongHelper(oz as long, 1, this.sign) + : BigInt.fromLongHelper(Int.toLong(oz), 1, this.sign) } constructor(d: BigInt) { @@ -182,7 +182,7 @@ export final class BigInt { * * @returns string representation */ - public toLocaleString(locales?: Intl.LocalesArgument, options?: BigIntToLocaleStringOptions): string { + public toLocaleString(locales?: string | Intl.Locale | (string | Intl.Locale)[], options?: BigIntToLocaleStringOptions): string { const numFmtOptions = BigInt.toNumberFormatOptions(options) const formatter = new Intl.NumberFormat(intlLocalesToLanguageTags(locales), numFmtOptions) return formatter.format(this) @@ -276,7 +276,7 @@ export final class BigInt { if (radix == -Infinity || radix == +Infinity || radix == NaN) { throw new RangeError(BigInt.INVALID_RADIX_MESSAGE) } - return this.toString(radix as int) + return this.toString(Double.toInt(radix)) } public toString(radix: int): string { @@ -294,9 +294,9 @@ export final class BigInt { internal toStringAsBinary(): string { let reversedInts = BigInt.reverse(this.bytes) let intToBinaryString = (value: Long) => { return value.toString(2) } - let result = new StringBuilder(intToBinaryString((reversedInts[0]!) as long)) + let result = new StringBuilder(intToBinaryString(Int.toLong(reversedInts[0]!))) for (let i = 1; i < reversedInts.length; ++i) { - result = result.append(intToBinaryString((reversedInts[i] as long) & BigInt.maskSys).padStart(BigInt.shiftSys, '0')) + result = result.append(intToBinaryString(Int.toLong(reversedInts[i]) & BigInt.maskSys).padStart(BigInt.shiftSys, '0')) } return result.toString() } @@ -316,13 +316,13 @@ export final class BigInt { let dividend = this.abs() while (dividend > 0n) { if (dividend < MAX_REGULAR_INTEGER) { - result = StringBuilder.concatStrings((dividend.getLong() as Number).toString(radix), result) + result = StringBuilder.concatStrings(Long.toDouble(dividend.getLong()).toString(radix), result) break } // NOTE(@aendrewpolyakov, #18313): Rewrite once destructuring assignment got support let divisionResult = dividend.operatorDivideInternal(radixBigInt) let quotent = divisionResult[0], remainder = divisionResult[1] - result = StringBuilder.concatStrings((remainder.getLong() as Number).toString(radix), result) + result = StringBuilder.concatStrings(Long.toDouble(remainder.getLong()).toString(radix), result) dividend = quotent } return result.toString() @@ -336,7 +336,7 @@ export final class BigInt { let result = new StringBuilder let bitChunks = this.sliceToBinaryChunks(chunkSize) for (let bitChunk of bitChunks) { - result = result.append((parseInt(bitChunk!, 2) as Number).toString(radix)) + result = result.append(parseInt(bitChunk!, 2).toString(radix)) } return result.toString() } @@ -347,7 +347,7 @@ export final class BigInt { let requiredLength: Number = binaryRepresentation.length + (chunkSize - binaryRepresentation.length % chunkSize) binaryRepresentation = binaryRepresentation.padStart(requiredLength, '0') } - let chunksCount: int = (binaryRepresentation.length / chunkSize) as int + let chunksCount: int = Double.toInt(binaryRepresentation.length / chunkSize) let result: FixedArray = new string[chunksCount] for (let index: int = 0, offset: int = 0; index < chunksCount; ++index, offset += chunkSize) { result[index] = binaryRepresentation.substring(offset, offset + chunkSize) @@ -360,7 +360,7 @@ export final class BigInt { } public static asIntN(bits: Number, num: BigInt): BigInt { - return BigInt.asIntN(bits as long, num) + return BigInt.asIntN(Double.toLong(bits), num) } public static asIntN(bits: long, num: BigInt): BigInt { @@ -388,7 +388,7 @@ export final class BigInt { } public static asUintN(bits: Number, num: BigInt): BigInt { - return BigInt.asUintN(bits as long, num) + return BigInt.asUintN(Number.toLong(bits), num) } public static asUintN(bits: long, num: BigInt): BigInt { @@ -471,13 +471,13 @@ export final class BigInt { sum = carry carry = 0 if (i < lhs.length) { - sum += (lhs[i] as long) & BigInt.maskSys + sum += Int.toLong(lhs[i]) & BigInt.maskSys } if (i < rhs.length) { - sum += (rhs[i] as long) & BigInt.maskSys + sum += Int.toLong(rhs[i]) & BigInt.maskSys } carry = sum >> BigInt.shiftSys - res[i] = (sum & BigInt.maskSys) as int + res[i] = Long.toInt(sum & BigInt.maskSys) } let sign: int = 1 @@ -516,18 +516,18 @@ export final class BigInt { for (let i = 0; i < lhs.bytes.length; i++) { BigInt.resetBytes(product) let div: long = 0 - let l: long = (lhs.bytes[i] as long) & BigInt.maskSys + let l: long = Int.toLong(lhs.bytes[i]) & BigInt.maskSys for (let j = 0; j < rhs.bytes.length; j++) { - let r: long = (rhs.bytes[j] as long) & BigInt.maskSys + let r: long = Int.toLong(rhs.bytes[j]) & BigInt.maskSys let mul: long = l * r + div - product[i + j] = (mul & BigInt.maskSys) as int + product[i + j] = Long.toInt(mul & BigInt.maskSys) div = mul >>> BigInt.shiftSys } if (div > 0) { - product[i + rhs.bytes.length] = div as int + product[i + rhs.bytes.length] = Long.toInt(div) } result = result + new BigInt(product, 1) @@ -615,17 +615,17 @@ export final class BigInt { do { let ret: [Long, BigInt] ret = this.getNearestDivider(div, divisor) - res[position++] = ret[0] as int + res[position++] = Long.toInt(ret[0]) if (idx >= 0) { - let size = ret[1].bytes.length + 1 + let size = (ret[1] as BigInt).bytes.length + 1 bytes = new int[size] bytes[0] = this.bytes[idx] - for (let i=0; i < ret[1].bytes.length; i++) { - bytes[i + 1] = ret[1].bytes[i] + for (let i=0; i < (ret[1] as BigInt).bytes.length; i++) { + bytes[i + 1] = (ret[1] as BigInt).bytes[i] } div = new BigInt(bytes, 1) } else { - div = ret[1] + div = ret[1] as BigInt } } while(idx-- >= 0) @@ -775,14 +775,14 @@ export final class BigInt { let first: long = this.negative() ? 1 : 0 for (let j: int = (lhs.length as int) - 1; j>=0; j--) { - let a: long = (lhs[j] as long) & BigInt.maskSys + let a: long = Int.toLong(lhs[j]) & BigInt.maskSys last = a & 0x1 a = (a >> 1) & BigInt.maskSys if (first) { a = a | bit } - lhs[j] = (a & BigInt.maskSys) as Int + lhs[j] = Long.toInt(a & BigInt.maskSys) first = last } } @@ -807,7 +807,7 @@ export final class BigInt { private static invertBytes(bytes: FixedArray): void{ for (let i = 0; i < bytes.length; i++) { - bytes[i] = (~bytes[i]) & BigInt.maskSys as int + bytes[i] = (~bytes[i]) & BigInt.maskSys.toInt() } } @@ -885,8 +885,8 @@ export final class BigInt { } for (let i = 0; i < rbytes.length; i++) { digits = BigInt.multiplyDigits(digits, mask) - let b = (((rbytes[i] as long) & BigInt.maskSys) as Long).toString() - let temp: FixedArray = new int[b.length as int] + let b = ((Int.toLong(rbytes[i]) & BigInt.maskSys) as Long).toString() + let temp: FixedArray = new int[Double.toInt(b.length)] for (let j = 0; j < b.length; j++) { temp[j] = b.charAt(j) - c'0' } @@ -914,7 +914,7 @@ export final class BigInt { start = 1 } - let len: int = s.length as int + let len: int = Double.toInt(s.length) let shift: int = 0 let expPosition: int = s.indexOf(c'e') if (expPosition > 0) { @@ -974,23 +974,23 @@ export final class BigInt { private static toBytes(digits: Array): FixedArray { // 3402 bits per each 1024 symbols for decimal number in string let chunkSize = (((digits.length * BigInt.BITS_PER_1024_DEC) >>> 10) + BigInt.shiftSys) >>> 5 - let bytes: FixedArray = new int[chunkSize as int] + let bytes: FixedArray = new int[Long.toInt(chunkSize)] let position = 0 while (!(digits.length == 0)) { let carry: long = 0 for (let i = 0; i < digits.length; i++) { - let current: long = (digits[i] as long) + carry * (10 as long) + let current: long = Int.toLong(digits[i]) + carry * (10 as long) if (current < BigInt.baseSys) { carry = current digits[i] = 0 continue } - digits[i] = (current >>> BigInt.shiftSys) as Int + digits[i] = Long.toInt(current >>> BigInt.shiftSys) carry = current & BigInt.maskSys } - bytes[position++] = carry as int + bytes[position++] = Long.toInt(carry) while (!(digits.length == 0)) { if (digits[0] == 0) { digits.shift() @@ -1056,18 +1056,18 @@ export final class BigInt { let mulflag: long = 0 let addflag: long = 0 for (let j = len2 - 1; j >= 0; j--) { - let l: long = (lhs[i] as long) & BigInt.maskSys - let r: long = (rhs[j] as long) & BigInt.maskSys + let l: long = Int.toLong(lhs[i]) & BigInt.maskSys + let r: long = Int.toLong(rhs[j]) & BigInt.maskSys let temp1: long = l * r + mulflag mulflag = temp1 / 10 temp1 = temp1 % 10 let temp2: long = product[i + j + 1] + temp1 + addflag - product[i + j + 1] = ((temp2 % 10) as int) + product[i + j + 1] = Long.toInt(temp2 % 10) addflag = temp2 / 10 } - product[i] = (product[i] + mulflag + addflag) as int + product[i] = Long.toInt(product[i] + mulflag + addflag) } if (!(product.length == 0)) { @@ -1097,9 +1097,9 @@ export final class BigInt { // Perform 2's complement for negative numbers. let carry: long = 1 for (let i = 0; i < input.length; i++) { - let sum: long = ((~input[i]) as long) & BigInt.maskSys + let sum: long = Int.toLong(~input[i]) & BigInt.maskSys sum += carry - input[i] = sum as int + input[i] = Long.toInt(sum) carry = sum >>> BigInt.shiftSys } return input @@ -1139,7 +1139,7 @@ export final class BigInt { let buff = 0 as number const bytes = this.bytes for (let i = 0; i < bytes.length; ++i) { - buff += (((bytes[i] as long) & BigInt.maskSys) as double) * Math.pow(BigInt.baseSys, i) + buff += Long.toDouble(Int.toLong(bytes[i]) & BigInt.maskSys) * Math.pow(BigInt.baseSys, i) } return this.sign * buff } @@ -1154,7 +1154,7 @@ export final class BigInt { const bytes = this.bytes const num = Math.min(2, bytes.length) for (let i = 0; i < num; ++i) { - buff += ((bytes[i] as long) & BigInt.maskSys) << i * BigInt.shiftSys + buff += (Int.toLong(bytes[i]) & BigInt.maskSys) << i * BigInt.shiftSys } return this.sign * buff } diff --git a/static_core/plugins/ets/stdlib/escompat/DataView.ets b/static_core/plugins/ets/stdlib/escompat/DataView.ets index 1e6c0d64a6508b749fd3e628ab88f2ec92386cbb..387a6a84d470ff549c17ee0ecc9a7e6501468feb 100644 --- a/static_core/plugins/ets/stdlib/escompat/DataView.ets +++ b/static_core/plugins/ets/stdlib/escompat/DataView.ets @@ -82,7 +82,7 @@ export final class DataView implements ArrayBufferView { * @param byteOffset zero index to read * @returns read value (big endian) */ - public getInt8(byteOffset: int): number { + public getInt8(byteOffset: int): double { return this.getInt8Big(byteOffset) } @@ -99,7 +99,7 @@ export final class DataView implements ArrayBufferView { * @param byteOffset zero index to read * @returns read value (big endian) */ - public getInt8(byteOffset: number): number { + public getInt8(byteOffset: number): double { return this.getInt8Big(byteOffset) } @@ -107,24 +107,24 @@ export final class DataView implements ArrayBufferView { * Sets bytes as they represent given type * @param byteOffset zero index to write (big endian) */ - public setInt8(byteOffset: number, value: number): void { + public setInt8(byteOffset: number, value: double): void { this.setInt8Big(byteOffset, value) } - private getInt8Big(byteOffset: int): number { + private getInt8Big(byteOffset: int): double { if (byteOffset + 1 > this.byteLength_) { throw new RangeError("wrong index") } let res: int = 0; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 1; i++) { - let byteVal = this.actualBuffer.at(startByte + 0 - i) as int; + let byteVal = Byte.toInt(this.actualBuffer.at(startByte + 0 - i)); byteVal &= 0xff - res = (res | byteVal << (8 * i)) as int; + res = Long.toInt(res | byteVal << (8 * i)); } - return (res as byte) as int + return Int.toByte(res) } - private getInt8Big(byteOffset: number): number { - let res = this.getInt8Big(byteOffset as int) + private getInt8Big(byteOffset: number): double { + let res = this.getInt8Big(Double.toInt(byteOffset)) return res } @@ -135,17 +135,17 @@ export final class DataView implements ArrayBufferView { let bits = value; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 1; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + let byteVal = Int.toByte((bits >>> (i * 8)) & 0xff) this.actualBuffer.set(startByte + 0 - i, byteVal) } } - private setInt8Big(byteOffset: number, value: number): void { - let temp: long = value as long; + private setInt8Big(byteOffset: number, value: double): void { + let temp: long = Double.toLong(value); if (temp == Long.MAX_VALUE || temp == Long.MIN_VALUE) { temp = 0; } - const val: int = temp as int; - this.setInt8Big(byteOffset as int, val) + const val: int = Long.toInt(temp); + this.setInt8Big(Double.toInt(byteOffset), val) } // === Uint8 === @@ -154,7 +154,7 @@ export final class DataView implements ArrayBufferView { * @param byteOffset zero index to read * @returns read value (big endian) */ - public getUint8(byteOffset: int): number { + public getUint8(byteOffset: int): double { return this.getUint8Big(byteOffset) } @@ -171,7 +171,7 @@ export final class DataView implements ArrayBufferView { * @param byteOffset zero index to read * @returns read value (big endian) */ - public getUint8(byteOffset: number): number { + public getUint8(byteOffset: number): double { return this.getUint8Big(byteOffset) } @@ -179,24 +179,24 @@ export final class DataView implements ArrayBufferView { * Sets bytes as they represent given type * @param byteOffset zero index to write (big endian) */ - public setUint8(byteOffset: number, value: number): void { + public setUint8(byteOffset: number, value: double): void { this.setUint8Big(byteOffset, value) } - private getUint8Big(byteOffset: int): number { + private getUint8Big(byteOffset: int): double { if (byteOffset + 1 > this.byteLength_) { throw new RangeError("wrong index") } let res: int = 0; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 1; i++) { - let byteVal = this.actualBuffer.at(startByte + 0 - i) as int; + let byteVal = Byte.toInt(this.actualBuffer.at(startByte + 0 - i)); byteVal &= 0xff - res = (res | byteVal << (8 * i)) as int; + res = Long.toInt(res | byteVal << (8 * i)); } return res } - private getUint8Big(byteOffset: number): number { - let res = this.getUint8Big(byteOffset as int) + private getUint8Big(byteOffset: number): double { + let res = this.getUint8Big(Double.toInt(byteOffset)) return res } @@ -207,17 +207,17 @@ export final class DataView implements ArrayBufferView { let bits = value; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 1; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + let byteVal = Int.toByte((bits >>> (i * 8)) & 0xff) this.actualBuffer.set(startByte + 0 - i, byteVal) } } - private setUint8Big(byteOffset: number, value: number): void { - let temp: long = value as long; + private setUint8Big(byteOffset: number, value: double): void { + let temp: long = Double.toLong(value); if (temp == Long.MAX_VALUE || temp == Long.MIN_VALUE) { temp = 0; } - const val: int = temp as int; - this.setUint8Big(byteOffset as int, val) + const val: int = Long.toInt(temp); + this.setUint8Big(Double.toInt(byteOffset), val) } // === Int16 === @@ -226,7 +226,7 @@ export final class DataView implements ArrayBufferView { * @param byteOffset zero index to read * @returns read value (big endian) */ - public getInt16(byteOffset: int): number { + public getInt16(byteOffset: int): double { return this.getInt16Big(byteOffset) } @@ -242,7 +242,7 @@ export final class DataView implements ArrayBufferView { * @param byteOffset zero index to write * @param littleEndian read as little or big endian */ - public setInt16(byteOffset: number, value: number, littleEndian?: boolean): void { + public setInt16(byteOffset: number, value: double, littleEndian?: boolean): void { if (littleEndian !== undefined && littleEndian.valueOf() == true) { this.setInt16Little(byteOffset, value) } else { @@ -269,7 +269,7 @@ export final class DataView implements ArrayBufferView { * @param littleEndian read as little or big endian * @returns read value */ - public getInt16(byteOffset: number, littleEndian?: boolean): number { + public getInt16(byteOffset: number, littleEndian?: boolean): double { if (littleEndian !== undefined && littleEndian.valueOf() == true) { return this.getInt16Little(byteOffset) } else { @@ -283,28 +283,28 @@ export final class DataView implements ArrayBufferView { * @param littleEndian read as little or big endian * @returns read value */ - public getInt16(byteOffset: int, littleEndian: boolean): number { + public getInt16(byteOffset: int, littleEndian: boolean): double { if (littleEndian) { return this.getInt16Little(byteOffset) } else { return this.getInt16Big(byteOffset) } } - private getInt16Little(byteOffset: int): number { + private getInt16Little(byteOffset: int): double { if (byteOffset + 2 > this.byteLength_) { throw new RangeError("wrong index") } let res: int = 0; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 2; i++) { - let byteVal = this.actualBuffer.at(startByte + i) as int; + let byteVal = Byte.toInt(this.actualBuffer.at(startByte + i)); byteVal &= 0xff - res = (res | byteVal << (8 * i)) as int; + res = Long.toInt(res | byteVal << (8 * i)); } - return (res as short) as int + return Int.toShort(res) } - private getInt16Little(byteOffset: number): number { - let res = this.getInt16Little(byteOffset as int) + private getInt16Little(byteOffset: number): double { + let res = this.getInt16Little(Double.toInt(byteOffset)) return res } @@ -315,33 +315,33 @@ export final class DataView implements ArrayBufferView { let bits = value; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 2; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + let byteVal = Int.toByte((bits >>> (i * 8)) & 0xff) this.actualBuffer.set(startByte + i, byteVal) } } - private setInt16Little(byteOffset: number, value: number): void { - let temp: long = value as long; + private setInt16Little(byteOffset: number, value: double): void { + let temp: long = Double.toLong(value); if (temp == Long.MAX_VALUE || temp == Long.MIN_VALUE) { temp = 0; } - const val: int = temp as int; - this.setInt16Little(byteOffset as int, val) + const val: int = Long.toInt(temp); + this.setInt16Little(Double.toInt(byteOffset), val) } - private getInt16Big(byteOffset: int): number { + private getInt16Big(byteOffset: int): double { if (byteOffset + 2 > this.byteLength_) { throw new RangeError("wrong index") } let res: int = 0; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 2; i++) { - let byteVal = this.actualBuffer.at(startByte + 1 - i) as int; + let byteVal = Byte.toInt(this.actualBuffer.at(startByte + 1 - i)); byteVal &= 0xff - res = (res | byteVal << (8 * i)) as int; + res = Long.toInt(res | byteVal << (8 * i)); } - return (res as short) as int + return Int.toShort(res) } - private getInt16Big(byteOffset: number): number { - let res = this.getInt16Big(byteOffset as int) + private getInt16Big(byteOffset: number): double { + let res = this.getInt16Big(Double.toInt(byteOffset)) return res } @@ -352,17 +352,17 @@ export final class DataView implements ArrayBufferView { let bits = value; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 2; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + let byteVal = Int.toByte((bits >>> (i * 8)) & 0xff) this.actualBuffer.set(startByte + 1 - i, byteVal) } } - private setInt16Big(byteOffset: number, value: number): void { - let temp: long = value as long; + private setInt16Big(byteOffset: number, value: double): void { + let temp: long = Double.toLong(value); if (temp == Long.MAX_VALUE || temp == Long.MIN_VALUE) { temp = 0; } - const val: int = temp as int; - this.setInt16Big(byteOffset as int, val) + const val: int = Long.toInt(temp); + this.setInt16Big(Double.toInt(byteOffset), val) } // === Uint16 === @@ -371,7 +371,7 @@ export final class DataView implements ArrayBufferView { * @param byteOffset zero index to read * @returns read value (big endian) */ - public getUint16(byteOffset: int): number { + public getUint16(byteOffset: int): double { return this.getUint16Big(byteOffset) } @@ -387,7 +387,7 @@ export final class DataView implements ArrayBufferView { * @param byteOffset zero index to write * @param littleEndian read as little or big endian */ - public setUint16(byteOffset: number, value: number, littleEndian?: boolean): void { + public setUint16(byteOffset: number, value: double, littleEndian?: boolean): void { if (littleEndian !== undefined && littleEndian.valueOf() == true) { this.setUint16Little(byteOffset, value) } else { @@ -414,7 +414,7 @@ export final class DataView implements ArrayBufferView { * @param littleEndian read as little or big endian * @returns read value */ - public getUint16(byteOffset: number, littleEndian?: boolean): number { + public getUint16(byteOffset: number, littleEndian?: boolean): double { if (littleEndian !== undefined && littleEndian.valueOf() == true) { return this.getUint16Little(byteOffset) } else { @@ -428,28 +428,28 @@ export final class DataView implements ArrayBufferView { * @param littleEndian read as little or big endian * @returns read value */ - public getUint16(byteOffset: int, littleEndian: boolean): number { + public getUint16(byteOffset: int, littleEndian: boolean): double { if (littleEndian) { return this.getUint16Little(byteOffset) } else { return this.getUint16Big(byteOffset) } } - private getUint16Little(byteOffset: int): number { + private getUint16Little(byteOffset: int): double { if (byteOffset + 2 > this.byteLength_) { throw new RangeError("wrong index") } let res: int = 0; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 2; i++) { - let byteVal = this.actualBuffer.at(startByte + i) as int; + let byteVal = Byte.toInt(this.actualBuffer.at(startByte + i)); byteVal &= 0xff - res = (res | byteVal << (8 * i)) as int; + res = Long.toInt(res | byteVal << (8 * i)); } return res } - private getUint16Little(byteOffset: number): number { - let res = this.getUint16Little(byteOffset as int) + private getUint16Little(byteOffset: number): double { + let res = this.getUint16Little(Double.toInt(byteOffset)) return res } @@ -460,33 +460,33 @@ export final class DataView implements ArrayBufferView { let bits = value; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 2; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + let byteVal = Int.toByte((bits >>> (i * 8)) & 0xff) this.actualBuffer.set(startByte + i, byteVal) } } - private setUint16Little(byteOffset: number, value: number): void { - let temp: long = value as long; + private setUint16Little(byteOffset: number, value: double): void { + let temp: long = Double.toLong(value); if (temp == Long.MAX_VALUE || temp == Long.MIN_VALUE) { temp = 0; } - const val: int = temp as int; - this.setUint16Little(byteOffset as int, val) + const val: int = Long.toInt(temp); + this.setUint16Little(Double.toInt(byteOffset), val) } - private getUint16Big(byteOffset: int): number { + private getUint16Big(byteOffset: int): double { if (byteOffset + 2 > this.byteLength_) { throw new RangeError("wrong index") } let res: int = 0; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 2; i++) { - let byteVal = this.actualBuffer.at(startByte + 1 - i) as int; + let byteVal = Byte.toInt(this.actualBuffer.at(startByte + 1 - i)); byteVal &= 0xff - res = (res | byteVal << (8 * i)) as int; + res = Long.toInt(res | byteVal << (8 * i)); } return res } - private getUint16Big(byteOffset: number): number { - let res = this.getUint16Big(byteOffset as int) + private getUint16Big(byteOffset: number): double { + let res = this.getUint16Big(Double.toInt(byteOffset)) return res } @@ -497,17 +497,17 @@ export final class DataView implements ArrayBufferView { let bits = value; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 2; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + let byteVal = Int.toByte((bits >>> (i * 8)) & 0xff) this.actualBuffer.set(startByte + 1 - i, byteVal) } } - private setUint16Big(byteOffset: number, value: number): void { - let temp: long = value as long; + private setUint16Big(byteOffset: number, value: double): void { + let temp: long = Double.toLong(value); if (temp == Long.MAX_VALUE || temp == Long.MIN_VALUE) { temp = 0; } - const val: int = temp as int; - this.setUint16Big(byteOffset as int, val) + const val: int = Long.toInt(temp); + this.setUint16Big(Double.toInt(byteOffset), val) } // === Int32 === @@ -516,7 +516,7 @@ export final class DataView implements ArrayBufferView { * @param byteOffset zero index to read * @returns read value (big endian) */ - public getInt32(byteOffset: int): number { + public getInt32(byteOffset: int): double { return this.getInt32Big(byteOffset) } @@ -532,7 +532,7 @@ export final class DataView implements ArrayBufferView { * @param byteOffset zero index to write * @param littleEndian read as little or big endian */ - public setInt32(byteOffset: number, value: number, littleEndian?: boolean): void { + public setInt32(byteOffset: number, value: double, littleEndian?: boolean): void { if (littleEndian !== undefined && littleEndian.valueOf() == true) { this.setInt32Little(byteOffset, value) } else { @@ -559,7 +559,7 @@ export final class DataView implements ArrayBufferView { * @param littleEndian read as little or big endian * @returns read value */ - public getInt32(byteOffset: number, littleEndian?: boolean): number { + public getInt32(byteOffset: number, littleEndian?: boolean): double { if (littleEndian !== undefined && littleEndian.valueOf() == true) { return this.getInt32Little(byteOffset) } else { @@ -573,28 +573,28 @@ export final class DataView implements ArrayBufferView { * @param littleEndian read as little or big endian * @returns read value */ - public getInt32(byteOffset: int, littleEndian: boolean): number { + public getInt32(byteOffset: int, littleEndian: boolean): double { if (littleEndian) { return this.getInt32Little(byteOffset) } else { return this.getInt32Big(byteOffset) } } - private getInt32Little(byteOffset: int): number { + private getInt32Little(byteOffset: int): double { if (byteOffset + 4 > this.byteLength_) { throw new RangeError("wrong index") } let res: int = 0; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 4; i++) { - let byteVal = this.actualBuffer.at(startByte + i) as int; + let byteVal = Byte.toInt(this.actualBuffer.at(startByte + i)); byteVal &= 0xff - res = (res | byteVal << (8 * i)) as int; + res = Long.toInt(res | byteVal << (8 * i)); } - return (res as int) as int + return Int.toInt(res) } - private getInt32Little(byteOffset: number): number { - let res = this.getInt32Little(byteOffset as int) + private getInt32Little(byteOffset: number): double { + let res = this.getInt32Little(Double.toInt(byteOffset)) return res } @@ -605,33 +605,33 @@ export final class DataView implements ArrayBufferView { let bits = value; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 4; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + let byteVal = Int.toByte((bits >>> (i * 8)) & 0xff) this.actualBuffer.set(startByte + i, byteVal) } } - private setInt32Little(byteOffset: number, value: number): void { - let temp: long = value as long; + private setInt32Little(byteOffset: number, value: double): void { + let temp: long = Double.toLong(value); if (temp == Long.MAX_VALUE || temp == Long.MIN_VALUE) { temp = 0; } - const val: int = temp as int; - this.setInt32Little(byteOffset as int, val) + const val: int = Long.toInt(temp); + this.setInt32Little(Double.toInt(byteOffset), val) } - private getInt32Big(byteOffset: int): number { + private getInt32Big(byteOffset: int): double { if (byteOffset + 4 > this.byteLength_) { throw new RangeError("wrong index") } let res: int = 0; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 4; i++) { - let byteVal = this.actualBuffer.at(startByte + 3 - i) as int; + let byteVal = Byte.toInt(this.actualBuffer.at(startByte + 3 - i)); byteVal &= 0xff - res = (res | byteVal << (8 * i)) as int; + res = Long.toInt(res | byteVal << (8 * i)); } - return (res as int) as int + return Int.toInt(res) } - private getInt32Big(byteOffset: number): number { - let res = this.getInt32Big(byteOffset as int) + private getInt32Big(byteOffset: number): double { + let res = this.getInt32Big(Double.toInt(byteOffset)) return res } @@ -642,17 +642,17 @@ export final class DataView implements ArrayBufferView { let bits = value; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 4; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + let byteVal = Int.toByte((bits >>> (i * 8)) & 0xff) this.actualBuffer.set(startByte + 3 - i, byteVal) } } - private setInt32Big(byteOffset: number, value: number): void { - let temp: long = value as long; + private setInt32Big(byteOffset: number, value: double): void { + let temp: long = Double.toLong(value); if (temp == Long.MAX_VALUE || temp == Long.MIN_VALUE) { temp = 0; } - const val: int = temp as int; - this.setInt32Big(byteOffset as int, val) + const val: int = Long.toInt(temp); + this.setInt32Big(Double.toInt(byteOffset), val) } // === Uint32 === @@ -661,7 +661,7 @@ export final class DataView implements ArrayBufferView { * @param byteOffset zero index to read * @returns read value (big endian) */ - public getUint32(byteOffset: int): number { + public getUint32(byteOffset: int): double { return this.getUint32Big(byteOffset) } @@ -677,7 +677,7 @@ export final class DataView implements ArrayBufferView { * @param byteOffset zero index to write * @param littleEndian read as little or big endian */ - public setUint32(byteOffset: number, value: number, littleEndian?: boolean): void { + public setUint32(byteOffset: number, value: double, littleEndian?: boolean): void { if (littleEndian !== undefined && littleEndian.valueOf() == true) { this.setUint32Little(byteOffset, value) } else { @@ -704,7 +704,7 @@ export final class DataView implements ArrayBufferView { * @param littleEndian read as little or big endian * @returns read value */ - public getUint32(byteOffset: number, littleEndian?: boolean): number { + public getUint32(byteOffset: number, littleEndian?: boolean): double { if (littleEndian !== undefined && littleEndian.valueOf() == true) { return this.getUint32Little(byteOffset) } else { @@ -718,28 +718,28 @@ export final class DataView implements ArrayBufferView { * @param littleEndian read as little or big endian * @returns read value */ - public getUint32(byteOffset: int, littleEndian: boolean): number { + public getUint32(byteOffset: int, littleEndian: boolean): double { if (littleEndian) { return this.getUint32Little(byteOffset) } else { return this.getUint32Big(byteOffset) } } - private getUint32Little(byteOffset: int): number { + private getUint32Little(byteOffset: int): double { if (byteOffset + 4 > this.byteLength_) { throw new RangeError("wrong index") } let res: long = 0; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 4; i++) { - let byteVal = this.actualBuffer.at(startByte + i) as long; + let byteVal = Byte.toLong(this.actualBuffer.at(startByte + i)); byteVal &= 0xff - res = (res | byteVal << (8 * i)) as long; + res = Long.toLong(res | byteVal << (8 * i)); } return res } - private getUint32Little(byteOffset: number): number { - let res = this.getUint32Little(byteOffset as int) + private getUint32Little(byteOffset: number): double { + let res = this.getUint32Little(Double.toInt(byteOffset)) return res } @@ -753,29 +753,29 @@ export final class DataView implements ArrayBufferView { } const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 4; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + let byteVal = Long.toByte((bits >>> (i * 8)) & 0xff) this.actualBuffer.set(startByte + i, byteVal) } } - private setUint32Little(byteOffset: number, value: number): void { - const val: long = value as long; - this.setUint32Little(byteOffset as int, val) + private setUint32Little(byteOffset: number, value: double): void { + const val: long = Double.toLong(value); + this.setUint32Little(Double.toInt(byteOffset), val) } - private getUint32Big(byteOffset: int): number { + private getUint32Big(byteOffset: int): double { if (byteOffset + 4 > this.byteLength_) { throw new RangeError("wrong index") } let res: long = 0; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 4; i++) { - let byteVal = this.actualBuffer.at(startByte + 3 - i) as long; + let byteVal = Byte.toLong(this.actualBuffer.at(startByte + 3 - i)); byteVal &= 0xff - res = (res | byteVal << (8 * i)) as long; + res = Long.toLong(res | byteVal << (8 * i)); } return res } - private getUint32Big(byteOffset: number): number { - let res = this.getUint32Big(byteOffset as int) + private getUint32Big(byteOffset: number): double { + let res = this.getUint32Big(Double.toInt(byteOffset)) return res } @@ -789,13 +789,13 @@ export final class DataView implements ArrayBufferView { } const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 4; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + let byteVal = Long.toByte((bits >>> (i * 8)) & 0xff) this.actualBuffer.set(startByte + 3 - i, byteVal) } } - private setUint32Big(byteOffset: number, value: number): void { - const val: long = value as long; - this.setUint32Big(byteOffset as int, val) + private setUint32Big(byteOffset: number, value: double): void { + const val: long = Double.toLong(value); + this.setUint32Big(Double.toInt(byteOffset), val) } // === Float32 === @@ -804,7 +804,7 @@ export final class DataView implements ArrayBufferView { * @param byteOffset zero index to read * @returns read value (big endian) */ - public getFloat32(byteOffset: int): number { + public getFloat32(byteOffset: int): double { return this.getFloat32Big(byteOffset) } @@ -820,7 +820,7 @@ export final class DataView implements ArrayBufferView { * @param byteOffset zero index to write * @param littleEndian read as little or big endian */ - public setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void { + public setFloat32(byteOffset: number, value: double, littleEndian?: boolean): void { if (littleEndian !== undefined && littleEndian.valueOf() == true) { this.setFloat32Little(byteOffset, value) } else { @@ -847,7 +847,7 @@ export final class DataView implements ArrayBufferView { * @param littleEndian read as little or big endian * @returns read value */ - public getFloat32(byteOffset: number, littleEndian?: boolean): number { + public getFloat32(byteOffset: number, littleEndian?: boolean): double { if (littleEndian !== undefined && littleEndian.valueOf() == true) { return this.getFloat32Little(byteOffset) } else { @@ -861,28 +861,28 @@ export final class DataView implements ArrayBufferView { * @param littleEndian read as little or big endian * @returns read value */ - public getFloat32(byteOffset: int, littleEndian: boolean): number { + public getFloat32(byteOffset: int, littleEndian: boolean): double { if (littleEndian) { return this.getFloat32Little(byteOffset) } else { return this.getFloat32Big(byteOffset) } } - private getFloat32Little(byteOffset: int): number { + private getFloat32Little(byteOffset: int): double { if (byteOffset + 4 > this.byteLength_) { throw new RangeError("wrong index") } let res: int = 0; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 4; i++) { - let byteVal = this.actualBuffer.at(startByte + i) as int; + let byteVal = Byte.toInt(this.actualBuffer.at(startByte + i)); byteVal &= 0xff - res = (res | byteVal << (8 * i)) as int; + res = Long.toInt(res | byteVal << (8 * i)); } return Float.bitCastFromInt(res) } - private getFloat32Little(byteOffset: number): number { - let res = this.getFloat32Little(byteOffset as int) + private getFloat32Little(byteOffset: number): double { + let res = this.getFloat32Little(Double.toInt(byteOffset)) return res } @@ -893,29 +893,29 @@ export final class DataView implements ArrayBufferView { let bits = Float.bitCastToInt(value); const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 4; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + let byteVal = Float.toByte((bits >>> (i * 8)) & 0xff) this.actualBuffer.set(startByte + i, byteVal) } } - private setFloat32Little(byteOffset: number, value: number): void { - const val: float = value as float; - this.setFloat32Little(byteOffset as int, val) + private setFloat32Little(byteOffset: number, value: double): void { + const val: float = Double.toFloat(value); + this.setFloat32Little(Double.toInt(byteOffset), val) } - private getFloat32Big(byteOffset: int): number { + private getFloat32Big(byteOffset: int): double { if (byteOffset + 4 > this.byteLength_) { throw new RangeError("wrong index") } let res: int = 0; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 4; i++) { - let byteVal = this.actualBuffer.at(startByte + 3 - i) as int; + let byteVal = Byte.toInt(this.actualBuffer.at(startByte + 3 - i)); byteVal &= 0xff - res = (res | byteVal << (8 * i)) as int; + res = Long.toInt(res | byteVal << (8 * i)); } return Float.bitCastFromInt(res) } - private getFloat32Big(byteOffset: number): number { - let res = this.getFloat32Big(byteOffset as int) + private getFloat32Big(byteOffset: number): double { + let res = this.getFloat32Big(Double.toInt(byteOffset)) return res } @@ -926,13 +926,13 @@ export final class DataView implements ArrayBufferView { let bits = Float.bitCastToInt(value); const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 4; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + let byteVal = Float.toByte((bits >>> (i * 8)) & 0xff) this.actualBuffer.set(startByte + 3 - i, byteVal) } } - private setFloat32Big(byteOffset: number, value: number): void { - const val: float = value as float; - this.setFloat32Big(byteOffset as int, val) + private setFloat32Big(byteOffset: number, value: double): void { + const val: float = Double.toFloat(value); + this.setFloat32Big(Double.toInt(byteOffset), val) } // === Int64 === @@ -1012,14 +1012,14 @@ export final class DataView implements ArrayBufferView { let res: long = 0; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 8; i++) { - let byteVal = this.actualBuffer.at(startByte + i) as long; + let byteVal = Byte.toLong(this.actualBuffer.at(startByte + i)); byteVal &= 0xff - res = (res | byteVal << (8 * i)) as long; + res = Long.toLong(res | byteVal << (8 * i)); } return new BigInt(res) } private getBigInt64Little(byteOffset: number): bigint { - let res = this.getBigInt64Little(byteOffset as int) + let res = this.getBigInt64Little(Double.toInt(byteOffset)) return res } @@ -1030,13 +1030,13 @@ export final class DataView implements ArrayBufferView { let bits = value; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 8; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + let byteVal = Long.toByte((bits >>> (i * 8)) & 0xff) this.actualBuffer.set(startByte + i, byteVal) } } private setBigInt64Little(byteOffset: number, value: bigint): void { const val: long = value.getLong(); - this.setBigInt64Little(byteOffset as int, val) + this.setBigInt64Little(Double.toInt(byteOffset), val) } private getBigInt64Big(byteOffset: int): bigint { if (byteOffset + 8 > this.byteLength_) { @@ -1045,14 +1045,14 @@ export final class DataView implements ArrayBufferView { let res: long = 0; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 8; i++) { - let byteVal = this.actualBuffer.at(startByte + 7 - i) as long; + let byteVal = Byte.toLong(this.actualBuffer.at(startByte + 7 - i)); byteVal &= 0xff - res = (res | byteVal << (8 * i)) as long; + res = Long.toLong(res | byteVal << (8 * i)); } return new BigInt(res) } private getBigInt64Big(byteOffset: number): bigint { - let res = this.getBigInt64Big(byteOffset as int) + let res = this.getBigInt64Big(Double.toInt(byteOffset)) return res } @@ -1063,13 +1063,13 @@ export final class DataView implements ArrayBufferView { let bits = value; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 8; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + let byteVal = Long.toByte((bits >>> (i * 8)) & 0xff) this.actualBuffer.set(startByte + 7 - i, byteVal) } } private setBigInt64Big(byteOffset: number, value: bigint): void { const val: long = value.getLong(); - this.setBigInt64Big(byteOffset as int, val) + this.setBigInt64Big(Double.toInt(byteOffset), val) } // === Uint64 === @@ -1149,14 +1149,14 @@ export final class DataView implements ArrayBufferView { let res: long = 0; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 8; i++) { - let byteVal = this.actualBuffer.at(startByte + i) as long; + let byteVal = Byte.toLong(this.actualBuffer.at(startByte + i)); byteVal &= 0xff - res = (res | byteVal << (8 * i)) as long; + res = Long.toLong(res | byteVal << (8 * i)); } return DataView.bigintFromULong(res) } private getBigUint64Little(byteOffset: number): bigint { - let res = this.getBigUint64Little(byteOffset as int) + let res = this.getBigUint64Little(Double.toInt(byteOffset)) return res } @@ -1167,13 +1167,13 @@ export final class DataView implements ArrayBufferView { let bits = value; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 8; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + let byteVal = Long.toByte((bits >>> (i * 8)) & 0xff) this.actualBuffer.set(startByte + i, byteVal) } } private setBigUint64Little(byteOffset: number, value: bigint): void { const val: long = value.getLong(); - this.setBigUint64Little(byteOffset as int, val) + this.setBigUint64Little(Double.toInt(byteOffset), val) } private getBigUint64Big(byteOffset: int): bigint { if (byteOffset + 8 > this.byteLength_) { @@ -1182,14 +1182,14 @@ export final class DataView implements ArrayBufferView { let res: long = 0; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 8; i++) { - let byteVal = this.actualBuffer.at(startByte + 7 - i) as long; + let byteVal = Byte.toLong(this.actualBuffer.at(startByte + 7 - i)); byteVal &= 0xff - res = (res | byteVal << (8 * i)) as long; + res = Long.toLong(res | byteVal << (8 * i)); } return DataView.bigintFromULong(res) } private getBigUint64Big(byteOffset: number): bigint { - let res = this.getBigUint64Big(byteOffset as int) + let res = this.getBigUint64Big(Double.toInt(byteOffset)) return res } @@ -1200,13 +1200,13 @@ export final class DataView implements ArrayBufferView { let bits = value; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 8; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + let byteVal = Long.toByte((bits >>> (i * 8)) & 0xff) this.actualBuffer.set(startByte + 7 - i, byteVal) } } private setBigUint64Big(byteOffset: number, value: bigint): void { const val: long = value.getLong(); - this.setBigUint64Big(byteOffset as int, val) + this.setBigUint64Big(Double.toInt(byteOffset), val) } // === Float64 === @@ -1215,7 +1215,7 @@ export final class DataView implements ArrayBufferView { * @param byteOffset zero index to read * @returns read value (big endian) */ - public getFloat64(byteOffset: int): number { + public getFloat64(byteOffset: int): double { return this.getFloat64Big(byteOffset) } @@ -1223,7 +1223,7 @@ export final class DataView implements ArrayBufferView { * Sets bytes as they represent given type * @param byteOffset zero index to write (big endian) */ - public setFloat64(byteOffset: int, value: number): void { + public setFloat64(byteOffset: int, value: double): void { this.setFloat64Big(byteOffset, value) } /** @@ -1231,7 +1231,7 @@ export final class DataView implements ArrayBufferView { * @param byteOffset zero index to write * @param littleEndian read as little or big endian */ - public setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void { + public setFloat64(byteOffset: number, value: double, littleEndian?: boolean): void { if (littleEndian !== undefined && littleEndian.valueOf() == true) { this.setFloat64Little(byteOffset, value) } else { @@ -1244,7 +1244,7 @@ export final class DataView implements ArrayBufferView { * @param byteOffset zero index to write * @param littleEndian read as little or big endian */ - public setFloat64(byteOffset: int, value: number, littleEndian: boolean): void { + public setFloat64(byteOffset: int, value: double, littleEndian: boolean): void { if (littleEndian) { this.setFloat64Little(byteOffset, value) } else { @@ -1258,7 +1258,7 @@ export final class DataView implements ArrayBufferView { * @param littleEndian read as little or big endian * @returns read value */ - public getFloat64(byteOffset: number, littleEndian?: boolean): number { + public getFloat64(byteOffset: number, littleEndian?: boolean): double { if (littleEndian !== undefined && littleEndian.valueOf() == true) { return this.getFloat64Little(byteOffset) } else { @@ -1272,78 +1272,78 @@ export final class DataView implements ArrayBufferView { * @param littleEndian read as little or big endian * @returns read value */ - public getFloat64(byteOffset: int, littleEndian: boolean): number { + public getFloat64(byteOffset: int, littleEndian: boolean): double { if (littleEndian) { return this.getFloat64Little(byteOffset) } else { return this.getFloat64Big(byteOffset) } } - private getFloat64Little(byteOffset: int): number { + private getFloat64Little(byteOffset: int): double { if (byteOffset + 8 > this.byteLength_) { throw new RangeError("wrong index") } let res: long = 0; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 8; i++) { - let byteVal = this.actualBuffer.at(startByte + i) as long; + let byteVal = Byte.toLong(this.actualBuffer.at(startByte + i)); byteVal &= 0xff - res = (res | byteVal << (8 * i)) as long; + res = Long.toLong(res | byteVal << (8 * i)); } return Double.bitCastFromLong(res) } - private getFloat64Little(byteOffset: number): number { - let res = this.getFloat64Little(byteOffset as int) + private getFloat64Little(byteOffset: number): double { + let res = this.getFloat64Little(Double.toInt(byteOffset)) return res } - private setFloat64Little(byteOffset: int, value: number): void { + private setFloat64Little(byteOffset: int, value: double): void { if (byteOffset < 0 || byteOffset + 8.0 > this.byteLength_) { throw new RangeError("wrong index") } let bits = Double.bitCastToLong(value); const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 8; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + let byteVal = Double.toByte((bits >>> (i * 8)) & 0xff) this.actualBuffer.set(startByte + i, byteVal) } } - private setFloat64Little(byteOffset: number, value: number): void { - const val: number = value as number; - this.setFloat64Little(byteOffset as int, val) + private setFloat64Little(byteOffset: number, value: double): void { + const val: double = Double.toDouble(value); + this.setFloat64Little(Double.toInt(byteOffset), val) } - private getFloat64Big(byteOffset: int): number { + private getFloat64Big(byteOffset: int): double { if (byteOffset + 8 > this.byteLength_) { throw new RangeError("wrong index") } let res: long = 0; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 8; i++) { - let byteVal = this.actualBuffer.at(startByte + 7 - i) as long; + let byteVal = Byte.toLong(this.actualBuffer.at(startByte + 7 - i)); byteVal &= 0xff - res = (res | byteVal << (8 * i)) as long; + res = Long.toLong(res | byteVal << (8 * i)); } return Double.bitCastFromLong(res) } - private getFloat64Big(byteOffset: number): number { - let res = this.getFloat64Big(byteOffset as int) + private getFloat64Big(byteOffset: number): double { + let res = this.getFloat64Big(Double.toInt(byteOffset)) return res } - private setFloat64Big(byteOffset: int, value: number): void { + private setFloat64Big(byteOffset: int, value: double): void { if (byteOffset < 0 || byteOffset + 8.0 > this.byteLength_) { throw new RangeError("wrong index") } let bits = Double.bitCastToLong(value); const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < 8; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + let byteVal = Double.toByte((bits >>> (i * 8)) & 0xff) this.actualBuffer.set(startByte + 7 - i, byteVal) } } - private setFloat64Big(byteOffset: number, value: number): void { - const val: number = value as number; - this.setFloat64Big(byteOffset as int, val) + private setFloat64Big(byteOffset: number, value: double): void { + const val: double = Double.toDouble(value); + this.setFloat64Big(Double.toInt(byteOffset), val) } private static bigintFromULong(x: long): bigint { diff --git a/static_core/plugins/ets/stdlib/escompat/Date.ets b/static_core/plugins/ets/stdlib/escompat/Date.ets index 26b3bec8e941c035d3b590828528f70532abad6c..8786a9e6db2d04aff3fbd4b38f6f6da215898f44 100644 --- a/static_core/plugins/ets/stdlib/escompat/Date.ets +++ b/static_core/plugins/ets/stdlib/escompat/Date.ets @@ -57,9 +57,9 @@ const maxDaysInMonth = 31; * This gives a range of 8,640,000,000,000,000 milliseconds * to either side of 01 January, 1970 UTC. */ -const maxDateOffset: long = 8.64e15; +const maxDateOffset: long; -const INVALID_DATE: long = maxDateOffset + 1 +const INVALID_DATE: long; // initialized in _initializerBlock_.ets /** Day names */ @@ -99,7 +99,7 @@ function ecmaDayFromTime(time: long): int { if (time < 0) { time -= msPerDay - 1; } - return (time / msPerDay) as int; + return Long.toInt(time / msPerDay); } /** @@ -121,7 +121,7 @@ function ecmaDaysInYear(year: int): int { * @returns Year, corresponding to the given time. */ function ecmaYearFromTime(time: long): int { - let approx: int = floor(time / msPerDay / 365.2425) as int + 1970 as int; + let approx: int = Double.toInt(floor(time / msPerDay / 365.2425)) + 1970 as int; let yearMs: long = ecmaDayFromYear(approx) * msPerDay; if (yearMs > time) { @@ -148,7 +148,7 @@ function ecmaMonthFromTime(time: long): byte { for (let i = 1; i < 12; i++) { if (dayWithinYear < getFirstDayInMonth(inLeapYear, i)) { - return (i - 1) as byte; + return Int.toByte(i - 1); } } @@ -169,12 +169,12 @@ function ecmaDateFromTime(time: long): byte { for (let i = 1; i < 12; i++) { if (dayWithinYear < getFirstDayInMonth(inLeapYear, i)) { - month = (i - 1) as byte; + month = Int.toByte(i - 1); break; } } - return (dayWithinYear + 1 - getFirstDayInMonth(inLeapYear, month)) as byte; + return Int.toByte(dayWithinYear + 1 - getFirstDayInMonth(inLeapYear, month)); } /** @@ -186,9 +186,9 @@ function ecmaDateFromTime(time: long): byte { */ function ecmaWeekDay(time: long): byte { let day = ecmaDayFromTime (time); - let weekDay = ((day + 4) % 7) as byte; + let weekDay = Int.toByte((day + 4) % 7); - return weekDay >= 0 ? weekDay : (weekDay + 7) as byte; + return weekDay >= 0 ? weekDay : Int.toByte(weekDay + 7); } /** @@ -210,7 +210,7 @@ function ecmaTimeInDayFromTime(time: long): long { */ function ecmaHourFromTime(time: long): byte { let timeInDay = ecmaTimeInDayFromTime(time); - return (timeInDay / msPerHour) as byte; + return Long.toByte(timeInDay / msPerHour); } /** @@ -220,7 +220,7 @@ function ecmaHourFromTime(time: long): byte { */ function ecmaMinFromTime(time: long): byte { let timeInDay = ecmaTimeInDayFromTime(time); - return ((timeInDay / msPerMinute) % minutesPerHour) as byte; + return Long.toByte((timeInDay / msPerMinute) % minutesPerHour); } /** @@ -230,7 +230,7 @@ function ecmaMinFromTime(time: long): byte { */ function ecmaSecFromTime(time: long): byte { let timeInDay = ecmaTimeInDayFromTime(time); - return ((timeInDay / msPerSecond) % secondsPerMinute) as byte; + return Long.toByte((timeInDay / msPerSecond) % secondsPerMinute); } /** @@ -240,7 +240,7 @@ function ecmaSecFromTime(time: long): byte { */ function ecmaMsFromTime(time: long): short { let timeInDay = ecmaTimeInDayFromTime(time); - return (timeInDay % msPerSecond) as short; + return Long.toShort(timeInDay % msPerSecond); } /** @@ -274,10 +274,10 @@ function ecmaMakeTime(hr: long, min: long, sec: long, ms: long): long { * @returns Constructed time in milliseconds. */ function ecmaMakeTime(hr: double, min: double, sec: double, ms: double): long { - let hh = trunc(hr) as long; - let mm = trunc(min) as long; - let ss = trunc(sec) as long; - let mi = trunc(ms) as long; + let hh = Double.toLong(trunc(hr)); + let mm = Double.toLong(trunc(min)); + let ss = Double.toLong(trunc(sec)); + let mi = Double.toLong(trunc(ms)); return ecmaMakeTime(hh, mm, ss, mi); } @@ -304,7 +304,7 @@ function ecmaMakeFullYear(year: long): long { * @returns returns the full year associated with the integer part of year */ function ecmaMakeFullYear(year: double): long { - let y = trunc(year) as long; + let y = Double.toLong(trunc(year)); return ecmaMakeFullYear(y) } @@ -320,14 +320,14 @@ function ecmaMakeFullYear(year: double): long { * @returns Elapsed number of days since Unix Epoch. */ function ecmaMakeDay(year: long, month: long, date: long): long { - let ym = (year + floor(month as double / 12.0 as double)) as int; - let mn = (month % 12) as byte; + let ym = Double.toInt(year + floor(Long.toDouble(month) / 12.0 as double)); + let mn = Long.toByte(month % 12); if (mn < 0) { mn += 12; } - let days: long = (ecmaDayFromYear(ym) as long + getFirstDayInMonth(ecmaInLeapYear(ym), mn) as long + (date as long) - 1); + let days: long = Int.toLong(ecmaDayFromYear(ym)) + Int.toLong(getFirstDayInMonth(ecmaInLeapYear(ym), mn)) + (date as long) - 1; return days; } @@ -344,9 +344,9 @@ function ecmaMakeDay(year: long, month: long, date: long): long { * @returns Elapsed number of days since Unix Epoch. */ function ecmaMakeDay(year: double, month: double, day: double): long { - let y = trunc(year) as long; - let m = trunc(month) as long; - let d = trunc(day) as long; + let y = Double.toLong(trunc(year)); + let m = Double.toLong(trunc(month)); + let d = Double.toLong(trunc(day)); return ecmaMakeDay(y, m, d); } @@ -385,10 +385,10 @@ function ecmaTimeClip(time: long): long throws { * @see ECMA-262, 21.4.1.3, DayFromYear */ function ecmaDayFromYear(year: int): int { - return (365 * (year - 1970) + + return Double.toInt(365 * (year - 1970) + floor((year - 1969) / 4.0) - floor((year - 1901) / 100.0) + - floor((year - 1601) / 400.0)) as int; + floor((year - 1601) / 400.0)); } /** @@ -413,7 +413,7 @@ function ecmaTimeFromYear(year: int): long { * 0 - otherwise */ function ecmaInLeapYear(year: int): byte { - return (ecmaDaysInYear(year) - dayCountInYear) as byte; + return Int.toByte(ecmaDaysInYear(year) - dayCountInYear); } /** @@ -510,7 +510,7 @@ export class Date { if (tzOffset !== undefined) { return date.valueOf() + tzOffset } else { - return date.valueOf() + Date.getLocalTimezoneOffset(date.valueOf() as long) * msPerMinute + return date.valueOf() + Date.getLocalTimezoneOffset(Double.toLong(date.valueOf())) * msPerMinute } } /** @@ -521,7 +521,7 @@ export class Date { * @description Initializes Date instance with current time. */ constructor() { - this.ms = Date.now() as long; + this.ms = Double.toLong(Date.now()); } /** @@ -538,16 +538,16 @@ export class Date { constructor(value: number | string | Date) { if (value instanceof Date) { - this.ms = trunc((value as Date).valueOf() as number) as long + this.ms = Double.toLong(trunc((value as Date).valueOf() as number)) } else if (typeof value == "string") { - this.ms = (Date.parseDateFromString(value as string) as long); + this.ms = Double.toLong(Date.parseDateFromString(value as string)); } else { if (isNaN(value as number)) { this.ms = (maxDateOffset + 1) as long; } else { - this.ms = trunc(value as number) as long; + this.ms = Double.toLong(trunc(value as number)); } } } @@ -632,7 +632,7 @@ export class Date { if (!this.isDateValid()) { return NaN; } - return this.ms as number; + return Long.toDouble(this.ms); } /** @@ -778,9 +778,9 @@ export class Date { public getDate(): number { let localTime = this.ms - this.TZOffset * 60 * msPerSecond; let day: int = ecmaDayFromTime(localTime) - ecmaDayFromYear(ecmaYearFromTime(localTime)); - let inLeapYear = ecmaInLeapYear(this.getFullYear() as int); + let inLeapYear = ecmaInLeapYear(Double.toInt(this.getFullYear())); let firstDay: int = getFirstDayInMonth(inLeapYear, ecmaMonthFromTime(localTime)); - return (day - firstDay + 1) as number; + return Int.toDouble(day - firstDay + 1); } /** @@ -790,7 +790,7 @@ export class Date { */ public setDate(value: byte): void { let day = this.getDate(); - this.ms -= day * msPerDay; + this.ms -= Double.toLong(day * msPerDay); this.ms += value * msPerDay; } @@ -800,8 +800,8 @@ export class Date { * @param value new day. */ public setDate(value: number): number { - this.setDate(value as byte); - return this.ms as number; + this.setDate(Double.toByte(value)); + return Long.toDouble(this.ms); } /** @@ -821,9 +821,9 @@ export class Date { public getUTCDate(): number { let localTime = this.ms; let day: int = ecmaDayFromTime(localTime) - ecmaDayFromYear(ecmaYearFromTime(localTime)); - let inLeapYear = ecmaInLeapYear(this.getFullYear() as int); + let inLeapYear = ecmaInLeapYear(Double.toInt(this.getFullYear())); let firstDay: int = getFirstDayInMonth(inLeapYear, ecmaMonthFromTime(localTime)); - return (day - firstDay + 1) as number; + return Int.toDouble(day - firstDay + 1); } /** @@ -832,7 +832,7 @@ export class Date { * @param value new day. */ public setUTCDate(value: byte): void { - let day = this.getUTCDate() as byte; + let day = Double.toByte(this.getUTCDate()); this.ms -= day * msPerDay; this.ms += value * msPerDay; } @@ -843,8 +843,8 @@ export class Date { * @param value new day. */ public setUTCDate(value: number): number { - this.setUTCDate(value as byte); - return this.ms as number; + this.setUTCDate(Double.toByte(value)); + return Long.toDouble(this.ms); } /** @@ -863,7 +863,7 @@ export class Date { */ public setUTCDay(value: number): number { this.setUTCDate(value); - return this.ms as number; + return Long.toDouble(this.ms); } /** @@ -876,7 +876,7 @@ export class Date { * for the given date, according to local time: 0 for Sunday, 1 for Monday, 2 for Tuesday, and so on. */ public getDay(): number { - return ecmaWeekDay(this.ms - this.TZOffset * 60 * msPerSecond) as number; + return Byte.toDouble(ecmaWeekDay(this.ms - this.TZOffset * 60 * msPerSecond)); } /** @@ -886,7 +886,7 @@ export class Date { * for the given date, according to local time: 0 for Sunday, 1 for Monday, 2 for Tuesday, and so on. */ public getUTCDay(): number { - return ecmaWeekDay(this.ms) as number; + return Byte.toDouble(ecmaWeekDay(this.ms)); } /** @@ -899,7 +899,7 @@ export class Date { * @returns year */ public getYear(): int { - return this.getFullYear() as int; + return Double.toInt(this.getFullYear()); } /** @@ -914,7 +914,7 @@ export class Date { * @returns year */ public getUTCFullYear(): number { - return ecmaYearFromTime(this.ms) as number; + return Int.toDouble(ecmaYearFromTime(this.ms)); } /** @@ -936,7 +936,7 @@ export class Date { */ public getFullYear(): number { let localTime = this.ms - this.TZOffset * 60 * msPerSecond; - return ecmaYearFromTime(localTime) as number; + return Int.toDouble(ecmaYearFromTime(localTime)); } /** @@ -945,14 +945,14 @@ export class Date { * @param value new year */ public setUTCFullYear(value: number, month?: number, date?: number): number { - this.setUTCFullYear(value as int); + this.setUTCFullYear(Double.toInt(value)); if (month !== undefined) { this.setUTCMonth(month.toInt()); } if (date !== undefined) { this.setUTCDate(date.toByte()); } - return this.ms as number; + return Long.toDouble(this.ms); } /** @@ -973,7 +973,7 @@ export class Date { * @param value new year */ public setYear(value: number): void { - this.setYear(value as int) + this.setYear(Double.toInt(value)) } /** @@ -991,14 +991,14 @@ export class Date { * @param value new year */ public setFullYear(value: number, month?: Number, date?: Number): number { - this.setFullYear(value as int); + this.setFullYear(Double.toInt(value)); if (month !== undefined) { this.setMonth(month.toInt()); } if (date !== undefined) { this.setDate(date.toByte()); } - return this.ms as number; + return Long.toDouble(this.ms); } /** @@ -1029,7 +1029,7 @@ export class Date { */ public getHours(): number { let localTime = this.ms - this.TZOffset * 60 * msPerSecond; - return ecmaHourFromTime(localTime) as number; + return Byte.toDouble(ecmaHourFromTime(localTime)); } /** @@ -1038,7 +1038,7 @@ export class Date { * @returns An integer number, between 0 and 23, representing the hour for the given date according to UTC time. */ public getUTCHours(): number { - return ecmaHourFromTime(this.ms) as number; + return Byte.toDouble(ecmaHourFromTime(this.ms)); } /** @@ -1061,7 +1061,7 @@ export class Date { * @param value new hours */ public setHours(value: number, min?: number, sec?: number, ms?: number): number { - this.setHours(value as byte); + this.setHours(Double.toByte(value)); if (min !== undefined) { this.setMinutes(min.toByte()); } @@ -1071,7 +1071,7 @@ export class Date { if (ms !== undefined) { this.setMilliseconds(ms.toShort()); } - return this.ms as number; + return Long.toDouble(this.ms); } /** @@ -1094,7 +1094,7 @@ export class Date { * @param value new hours */ public setUTCHours(value: number, min?: number, sec?: number, ms?: number): number { - this.setUTCHours(value as byte); + this.setUTCHours(Double.toByte(value)); if (min !== undefined) { this.setUTCMinutes(min.toByte()); } @@ -1104,7 +1104,7 @@ export class Date { if (ms !== undefined) { this.setUTCMilliseconds(ms.toShort()); } - return this.ms as number; + return Long.toDouble(this.ms); } /** @@ -1122,7 +1122,7 @@ export class Date { */ public getMilliseconds(): number { let localTime = this.ms - this.TZOffset * 60 * msPerSecond; - return ecmaMsFromTime(localTime) as number; + return Short.toDouble(ecmaMsFromTime(localTime)); } /** @@ -1137,7 +1137,7 @@ export class Date { * which is defined as the midnight at the beginning of January 1, 1970, UTC. */ public static UTC(d: Date): long { - return d.valueOf() as long; + return Double.toLong(d.valueOf()); } /** @@ -1150,7 +1150,7 @@ export class Date { * which is defined as the midnight at the beginning of January 1, 1970, UTC. */ public static UTC(year: number): number { - return ecmaMakeDate(ecmaMakeDay(ecmaMakeFullYear(year), 0.0, 1.0), ecmaMakeTime(0.0, 0.0, 0.0, 0.0)) as number + return Long.toDouble(ecmaMakeDate(ecmaMakeDay(ecmaMakeFullYear(year), 0.0, 1.0), ecmaMakeTime(0.0, 0.0, 0.0, 0.0))) } /** @@ -1176,7 +1176,7 @@ export class Date { */ public static UTC(year: number, month: number, day?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number { - return ecmaMakeDate( + return Long.toDouble(ecmaMakeDate( ecmaMakeDay( ecmaMakeFullYear(year), month, @@ -1188,7 +1188,7 @@ export class Date { seconds != undefined ? seconds as number : 0, ms != undefined ? ms as number : 0 ) - ) as number; + )); } /** @@ -1198,7 +1198,7 @@ export class Date { */ public getUTCMilliseconds(): number { let localTime = this.ms; - return ecmaMsFromTime(localTime) as number; + return Short.toDouble(ecmaMsFromTime(localTime)); } /** @@ -1218,8 +1218,8 @@ export class Date { * @param value new ms */ public setMilliseconds(value: number): number { - this.setMilliseconds(value as short); - return this.ms as number; + this.setMilliseconds(Double.toShort(value)); + return Long.toDouble(this.ms); } /** @@ -1239,8 +1239,8 @@ export class Date { * @param value new ms */ public setUTCMilliseconds(value: number): number { - this.setUTCMilliseconds(value as short); - return this.ms as number; + this.setUTCMilliseconds(Double.toShort(value)); + return Long.toDouble(this.ms); } /** @@ -1258,7 +1258,7 @@ export class Date { */ public getSeconds(): number { let localTime = this.ms - this.TZOffset * 60 * msPerSecond; - return ecmaSecFromTime(localTime) as number; + return Byte.toDouble(ecmaSecFromTime(localTime)); } /** @@ -1267,7 +1267,7 @@ export class Date { * @returns the seconds in the specified date according to universal time. */ public getUTCSeconds(): number { - return ecmaSecFromTime(this.ms) as number; + return Byte.toDouble(ecmaSecFromTime(this.ms)); } /** @@ -1276,11 +1276,11 @@ export class Date { * @param value new seconds */ public setSeconds(value: number, ms?: number): number { - this.setSeconds(value as byte); + this.setSeconds(Double.toByte(value)); if (ms !== undefined) { this.setMilliseconds(ms.toShort()); } - return this.ms as number; + return Long.toDouble(this.ms); } /** @@ -1317,11 +1317,11 @@ export class Date { * @param value new seconds */ public setUTCSeconds(value: number, ms?: number): number { - this.setUTCSeconds(value as byte); + this.setUTCSeconds(Double.toByte(value)); if (ms !== undefined) { this.setUTCMilliseconds(ms.toShort()); } - return this.ms as number; + return Long.toDouble(this.ms); } /** @@ -1339,7 +1339,7 @@ export class Date { */ public getMinutes(): number { let localTime = this.ms - this.TZOffset * 60 * msPerSecond; - return ecmaMinFromTime(localTime) as number; + return Byte.toDouble(ecmaMinFromTime(localTime)); } /** @@ -1362,14 +1362,14 @@ export class Date { * @param value new minutes */ public setUTCMinutes(value: number, sec?: Number, ms?: Number): number { - this.setUTCMinutes(value as byte); + this.setUTCMinutes(Double.toByte(value)); if (sec !== undefined) { this.setUTCSeconds(sec.toByte()); } if (ms !== undefined) { this.setUTCMilliseconds(ms.toShort()); } - return this.ms as number; + return Long.toDouble(this.ms); } /** @@ -1378,7 +1378,7 @@ export class Date { * @returns the minutes in the specified date according to universal time. */ public getUTCMinutes(): number { - return ecmaMinFromTime(this.ms) as number; + return Byte.toDouble(ecmaMinFromTime(this.ms)); } /** @@ -1401,14 +1401,14 @@ export class Date { * @param value new minutes */ public setMinutes(value: number, sec?: number, ms?: number): number { - this.setMinutes(value as byte); + this.setMinutes(Double.toByte(value)); if (sec !== undefined) { this.setSeconds(sec.toByte()); } if (ms !== undefined) { this.setMilliseconds(ms.toShort()); } - return this.ms as number; + return Long.toDouble(this.ms); } /** @@ -1428,7 +1428,7 @@ export class Date { */ public getMonth(): number { let localTime = this.ms - this.TZOffset * 60 * msPerSecond; - return ecmaMonthFromTime(localTime) as number; + return Byte.toDouble(ecmaMonthFromTime(localTime)); } /** @@ -1438,7 +1438,7 @@ export class Date { * 0 corresponds to January, 1 to February, and so on. */ public getUTCMonth(): number { - return ecmaMonthFromTime(this.ms) as number; + return Byte.toDouble(ecmaMonthFromTime(this.ms)); } /** @@ -1447,11 +1447,11 @@ export class Date { * @param month new month */ public setMonth(month: number, date?: number): number { - this.setMonth(month as int); + this.setMonth(Double.toInt(month)); if (date !== undefined) { this.setDate(date.toByte()); } - return this.ms as number; + return Long.toDouble(this.ms); } /** @@ -1460,7 +1460,7 @@ export class Date { * @param month new month */ public setMonth(month: int): void { - let inLeapYear = ecmaInLeapYear(this.getFullYear() as int); + let inLeapYear = ecmaInLeapYear(Double.toInt(this.getFullYear())); let daysNow: int = getFirstDayInMonth(inLeapYear, ecmaMonthFromTime(this.ms - this.TZOffset * 60 * msPerSecond)); let daysNew: int = getFirstDayInMonth(inLeapYear, month); this.ms -= daysNow * msPerDay; @@ -1473,11 +1473,11 @@ export class Date { * @param month new month */ public setUTCMonth(month: number, date?: number): number { - this.setUTCMonth(month as int); + this.setUTCMonth(Double.toInt(month)); if (date !== undefined) { this.setUTCDate(date.toByte()); } - return this.ms as number; + return Long.toDouble(this.ms); } /** @@ -1486,7 +1486,7 @@ export class Date { * @param month new month */ public setUTCMonth(month: int): void { - let inLeapYear = ecmaInLeapYear(this.getFullYear() as int); + let inLeapYear = ecmaInLeapYear(Double.toInt(this.getFullYear())); let daysNow: int = getFirstDayInMonth(inLeapYear, ecmaMonthFromTime(this.ms)); let daysNew: int = getFirstDayInMonth(inLeapYear, month); this.ms -= daysNow * msPerDay; @@ -1530,8 +1530,8 @@ export class Date { * @returns A number representing the milliseconds elapsed between 1 January 1970 00:00:00 UTC and the given date. */ public setTime(value: number): number { - this.setTime(value as long); - return this.ms as number; + this.setTime(Double.toLong(value)); + return Long.toDouble(this.ms); } /** @@ -1565,7 +1565,7 @@ export class Date { * evaluated in the UTC time zone, and the same date as evaluated in the local time zone. */ public getTimezoneOffset(): number { - return this.TZOffset as number; + return Long.toDouble(this.TZOffset); } /** @@ -1575,7 +1575,7 @@ export class Date { * @param value new timezone offset */ public setTimezoneOffset(value: number): number { - return this.setTimezoneOffset(value as int) as number + return this.setTimezoneOffset(Double.toInt(value)) as number } /** @@ -1610,7 +1610,7 @@ export class Date { if (abs(y) < 10) { sb.append("0"); } - sb.append(abs(y) as long); + sb.append(Double.toLong(abs(y))); sb.append("-"); let month = this.getUTCMonth() + 1; if(month < 10){ @@ -1738,9 +1738,9 @@ export class Date { } let sb = new StringBuilder(); - sb.append(dayNames[this.getDay() as int]); + sb.append(dayNames[Double.toInt(this.getDay())]); sb.append(" "); - sb.append(monthNames[this.getMonth() as int]); + sb.append(monthNames[Double.toInt(this.getMonth())]); sb.append(" "); let d = this.getDate(); if (d < 10) { @@ -1761,7 +1761,7 @@ export class Date { if (abs(y) < 10) { sb.append("0"); } - sb.append(abs(y) as long); + sb.append(Double.toLong(abs(y))); return sb.toString(); } @@ -1835,7 +1835,7 @@ export class Date { private toUTCDateString(): string { let sb = new StringBuilder(); - sb.append(dayNames[this.getUTCDay() as int]); + sb.append(dayNames[Double.toInt(this.getUTCDay())]); sb.append(", "); let d = this.getUTCDate(); if (d < 10) { @@ -1843,7 +1843,7 @@ export class Date { } sb.append(d); sb.append(" "); - sb.append(monthNames[this.getUTCMonth() as int]); + sb.append(monthNames[Double.toInt(this.getUTCMonth())]); sb.append(" "); let y = this.getUTCFullYear(); if (y < 0) { @@ -1859,7 +1859,7 @@ export class Date { if (y < 10) { sb.append("0"); } - sb.append(y as long); + sb.append(Double.toLong(y)); return sb.toString(); } @@ -1927,7 +1927,7 @@ class ISODateParser { constructor(dateStr: string) { this.dateStr = dateStr - this.endPos = dateStr.length as int + this.endPos = Double.toInt(dateStr.length) } public parse(): ISODateParseResult { @@ -2024,7 +2024,7 @@ class ISODateParser { } } - const literalValue = Double.parseInt(literalText) as int + const literalValue = Double.toInt(Double.parseInt(literalText)) this.currentPos += length return literalValue @@ -2047,21 +2047,21 @@ class ISODateParser { ? this.dateStr.substring(startPos, startPos + MS_COMPONENT_LENGTH) : this.dateStr.substring(startPos, currentPos).padEnd(MS_COMPONENT_LENGTH, "0") - const millisValue = Double.parseInt(millisText) as int + const millisValue = Double.toInt(Double.parseInt(millisText)) this.currentPos = currentPos return millisValue } private match(expectedToken: string): boolean { - const expectedTokenLength = expectedToken.length as int + const expectedTokenLength = Double.toInt(expectedToken.length) if (this.currentPos + expectedTokenLength > this.endPos) { return false } const actualToken = this.dateStr.substring(this.currentPos, this.currentPos + expectedTokenLength) if (actualToken == expectedToken) { - this.currentPos += actualToken.length + this.currentPos += Double.toInt(actualToken.length) return true } diff --git a/static_core/plugins/ets/stdlib/escompat/Functions.ets b/static_core/plugins/ets/stdlib/escompat/Functions.ets index b51908b7969d9d9b4ea1c2ac7d2bbfa8d890f95b..8f78441668f71e8ed14bb51ff72d50eee1d97956 100644 --- a/static_core/plugins/ets/stdlib/escompat/Functions.ets +++ b/static_core/plugins/ets/stdlib/escompat/Functions.ets @@ -87,7 +87,7 @@ export function decodeURI(uri: string): string { if (unit < 128 && uriSpecialChars[unit]) { ret.append(str.slice(i, i + 3)) } else { - ret.append(unit as char) + ret.append(Int.toChar(unit)) } } ) @@ -137,7 +137,7 @@ function encodeURIImpl(uri: string, ok: boolean[]): string { while (i < uri.getLength()) { let d: int try { - d = uri.codePointAt(i) as int + d = Double.toInt(uri.codePointAt(i) as number) } catch (e) { throw new URIError("malformed URI sequence") } @@ -182,7 +182,7 @@ export function decodeURIComponent(uriComponent: string): string { return unescapeImpl( uriComponent, (str: string, i: int, ret: StringBuilder, unit: int): void => { - ret.append(unit as char) + ret.append(Int.toChar(unit)) } ) } @@ -233,9 +233,9 @@ export function escape(str: string): string { let ret = new StringBuilder() for (let i = 0; i < str.getLength(); i++) { const d = str.charAt(i) - const c = (d as int) & 0xffff + const c = Char.toInt(d) & 0xffff if (c >= c'a' && c <= c'z' || c >= c'A' && c <= c'Z' || c >= c'0' && c <= c'9' || c >= 42 && c <= 47 && c != 44 || c == c'_' || c == c'@') { - ret.append(c as char) + ret.append(Int.toChar(c)) } else { encodeCharAsHex(ret, c) } @@ -282,7 +282,7 @@ function unescapeImpl(str: string, push: (str: string, i: int, ret: StringBuilde let chr0 = encodedURIHexAt(str, i); let chrsCnt: int if ((chr0 & 0x80) == 0) { - push(str, i, ret, chr0 as char) + push(str, i, ret, Int.toChar(chr0)) i += 2 continue } else if ((chr0 & 0xe0) == 0xc0) { @@ -308,7 +308,7 @@ function unescapeImpl(str: string, push: (str: string, i: int, ret: StringBuilde i += chrsCnt * 3 - 1 if (chr0 >= 0 && chr0 <= 0xd7ff || chr0 >= 0xe000 && chr0 <= 0xffff) { - push(str, i, ret, chr0 as char) + push(str, i, ret, Int.toChar(chr0)) } else { ret.append(Char.getHighSurrogate(chr0)) ret.append(Char.getLowSurrogate(chr0)) @@ -353,7 +353,7 @@ export function unescape(str: string): string { ret.append(d) continue } - ret.append(unit as char) + ret.append(Int.toChar(unit)) i += 5 continue } @@ -364,7 +364,7 @@ export function unescape(str: string): string { ret.append(d) continue } - ret.append(unit as char) + ret.append(Int.toChar(unit)) i += 2 continue } diff --git a/static_core/plugins/ets/stdlib/escompat/Global.ets b/static_core/plugins/ets/stdlib/escompat/Global.ets index 58ff59293ba15d67b8bb301b5f0d44b781347c34..4f5400743d3ba7d1c3ea49c1c27dd0a29c7e76b3 100644 --- a/static_core/plugins/ets/stdlib/escompat/Global.ets +++ b/static_core/plugins/ets/stdlib/escompat/Global.ets @@ -71,17 +71,6 @@ export function parseFloat(s: String): number { return Double.parseFloat(s); } -/** - * Checks if Double is `NaN` (not a number) - * - * @param d the Double to test - * - * @returns `true` if the argument is `NaN`, `false` otherwise. - */ -export function isNaN(d: Number): boolean { - return d.isNaN(); -} - /** * Checks if double is `NaN` (not a number) * @@ -90,18 +79,7 @@ export function isNaN(d: Number): boolean { * @returns `true` if the argument is `NaN`, `false` otherwise. */ export function isNaN(d: number): boolean { - return Double.isNaN(d); -} - -/** - * Checks if `Float` value is `NaN` (not a number) - * - * @param f the `Float` value to test - * - * @returns `true` if the argument is `NaN`, `false` otherwise. - */ -export function isNaN(f: Float): boolean { - return f.isNaN(); + return d.isNaN(); } /** @@ -151,53 +129,6 @@ export function isNaN(s: short): boolean { return false; } */ export function isNaN(l: long): boolean { return false; } -/** - * Checks if `Byte` value is `NaN` (not a number) - * - * @param b the `Byte` value to test - * - * @returns unconditionally returns `false`. Integral types can not be `NaN`. - */ -export function isNaN(b: Byte): boolean { return false; } - -/** - * Checks if `Int` value is `NaN` (not a number) - * - * @param i the `Int` value to test - * - * @returns unconditionally returns `false`. Integral types can not be `NaN`. - */ -export function isNaN(i: Int): boolean { return false; } - -/** - * Checks if `Short` value is `NaN` (not a number) - * - * @param s the `Short` value to test - * - * @returns unconditionally returns `false`. Integral types can not be `NaN`. - */ -export function isNaN(s: Short): boolean { return false; } - -/** - * Checks if `Long` value is `NaN` (not a number) - * - * @param l the `Long` value to test - * - * @returns unconditionally returns `false`. Integral types can not be `NaN`. - */ -export function isNaN(l: Long): boolean { return false; } - -/** - * Checks if `Double` value is a floating point value (not a `NaN` or `Infinity`) - * - * @param d the `Double` value to test - * - * @returns `true` if the argument is a floating point value, `false` otherwise. - */ -export function isFinite(d: Number): boolean { - return d.isFinite(); -} - /** * Checks if `double` value is a floating point value (not a `NaN` or `Infinity`) * @@ -206,7 +137,7 @@ export function isFinite(d: Number): boolean { * @returns `true` if the argument is a floating point value, `false` otherwise. */ export function isFinite(d: number): boolean { - return Double.isFinite(d); + return d.isFinite(); } /** @@ -216,19 +147,8 @@ export function isFinite(d: number): boolean { * * @returns `true` if the argument is a floating point value, `false` otherwise. */ -export function isFinite(f: Float): boolean { - return f.isFinite(); -} - -/** - * Checks if `float` value is a floating point value (not a `NaN` or `Infinity`) - * - * @param f the `float` value to test - * - * @returns `true` if the argument is a floating point value, `false` otherwise. - */ export function isFinite(f: float): boolean { - return Float.isFinite(f); + return f.isFinite(); } /** @@ -267,42 +187,6 @@ export function isFinite(s: short): boolean { return true; } */ export function isFinite(l: long): boolean { return true; } -/** - * Checks if `Byte` value is a floating point value (not a `NaN` or `Infinity`) - * - * @param b the `Byte` value to test - * - * @returns unconditionally returns `true`. Integral types can not be `NaN` or `Infinity`. - */ -export function isFinite(b: Byte): boolean { return true; } - -/** - * Checks if `Int` value is a floating point value (not a `NaN` or `Infinity`) - * - * @param i the `Int` value to test - * - * @returns unconditionally returns `true`. Integral types can not be `NaN` or `Infinity`. - */ -export function isFinite(i: Int): boolean { return true; } - -/** - * Checks if `Short` value is a floating point value (not a `NaN` or `Infinity`) - * - * @param s the `Short` value to test - * - * @returns unconditionally returns `true`. Integral types can not be `NaN` or `Infinity`. - */ -export function isFinite(s: Short): boolean { return true; } - -/** - * Checks if `Long` value is a floating point value (not a `NaN` or `Infinity`) - * - * @param l the `Long` value to test - * - * @returns unconditionally returns `true`. Integral types can not be `NaN` or `Infinity`. - */ -export function isFinite(l: Long): boolean { return true; } - /** * Checks if float is similar to an integer value * @@ -311,17 +195,6 @@ export function isFinite(l: Long): boolean { return true; } * @returns boolean - true if the argument is similar to an integer value */ export function isInteger(v: float): boolean { - return Float.isInteger(v); -} - -/** - * Checks if Float is similar to an integer value - * - * @param v the Float to test - * - * @returns boolean - true if the argument is similar to an integer value - */ -export function isInteger(v: Float): boolean { return v.isInteger(); } @@ -333,17 +206,6 @@ export function isInteger(v: Float): boolean { * @returns boolean - true if the argument is similar to an integer value */ export function isInteger(v: number): boolean { - return Double.isInteger(v); -} - -/** - * Checks if Double is similar to an integer value - * - * @param v the Double to test - * - * @returns boolean - true if the argument is similar to an integer value - */ -export function isInteger(v: Number): boolean { return v.isInteger(); } @@ -383,42 +245,6 @@ export function isInteger(s: short): boolean { return true; } */ export function isInteger(l: long): boolean { return true; } -/** - * Checks if `Byte` is similar to an integer value - * - * @param b the `Byte` value to test - * - * @returns boolean - unconditionally returns `true` as integral types are integer. - */ -export function isInteger(b: Byte): boolean { return true; } - -/** - * Checks if `Int` is similar to an integer value - * - * @param i the `Int` value to test - * - * @returns boolean - unconditionally returns `true` as integral types are integer. - */ -export function isInteger(i: Int): boolean { return true; } - -/** - * Checks if `Short` is similar to an integer value - * - * @param s the `Short` value to test - * - * @returns boolean - unconditionally returns `true` as integral types are integer. - */ -export function isInteger(s: Short): boolean { return true; } - -/** - * Checks if `Long` value is similar to an integer value - * - * @param l the `Long` value to test - * - * @returns boolean - unconditionally returns `true` as integral types are integer. - */ -export function isInteger(l: Long): boolean { return true; } - /** * Checks if float is a safe integer value * @@ -427,17 +253,6 @@ export function isInteger(l: Long): boolean { return true; } * @returns boolean - true if the argument is integer and less than Float.MAX_SAFE_INTEGER */ export function isSafeInteger(v: float): boolean { - return Float.isSafeInteger(v); -} - -/** - * Checks if Float is a safe integer value - * - * @param v: Float - the Float to test - * - * @returns boolean - true if the underlying float is a safe integer - */ -export function isSafeInteger(v: Float): boolean { return v.isSafeInteger(); } @@ -449,17 +264,6 @@ export function isSafeInteger(v: Float): boolean { * @returns boolean - true if the argument is integer and less than Double.MAX_SAFE_INTEGER */ export function isSafeInteger(v: number): boolean { - return Double.isSafeInteger(v); -} - -/* - * Checks if Double is a safe integer value - * - * @param v the Double to test - * - * @returns boolean - true if the underlying double is a safe integer - */ -export function isSafeInteger(v: Number): boolean { return v.isSafeInteger(); } @@ -474,17 +278,6 @@ export function isSafeInteger(v: int): boolean { return v <= Float.MAX_SAFE_INTEGER as int; } -/** - * Checks if Int can be represented in float without lossing precision - * - * @param v: Int - the Int to test - * - * @returns boolean - true if the argument is less than Float.MAX_SAFE_INTEGER - */ -export function isSafeInteger(v: Int): boolean { - return v.unboxed() <= Float.MAX_SAFE_INTEGER as int; -} - /** * Checks if long can be represented in double without lossing precision * @@ -493,18 +286,7 @@ export function isSafeInteger(v: Int): boolean { * @returns boolean - true if the argument is less than Double.MAX_SAFE_INTEGER */ export function isSafeInteger(v: long): boolean { - return v <= Double.MAX_SAFE_INTEGER as long; -} - -/** - * Checks if Long can be represented in double without lossing precision - * - * @param v: Long - the Long to test - * - * @returns boolean - true if the argument is less than Double.MAX_SAFE_INTEGER - */ -export function isSafeInteger(v: Long): boolean { - return v.unboxed() <= Double.MAX_SAFE_INTEGER as long; + return v <= Double.toLong(Double.MAX_SAFE_INTEGER); } /** @@ -531,7 +313,7 @@ export function setTimeout(func: Function, delayMs: number, ...args: FixedArray< /** * Print error message on the next cycle. - * + * * @param msg: string - the message to be printed on the next cycle. * @returns number - timer id */ @@ -621,20 +403,20 @@ export function clearInterval(timerId: number): void { function startTimer(func: () => void, delayMs: number, repeat: boolean): number { - const realDelayMs = delayMs as int; + const realDelayMs = Double.toInt(delayMs); if (CoroutineExtras.workerHasExternalScheduler()) { - return startTimerImpl(func as Object, realDelayMs < 0 ? 0 : realDelayMs, repeat) as number; + return startTimerImpl(func as Object, realDelayMs < 0 ? 0 : realDelayMs, repeat).toDouble(); } - return registerTimer(func, realDelayMs < 0 ? 0 : realDelayMs, repeat) as number; + return registerTimer(func, realDelayMs < 0 ? 0 : realDelayMs, repeat).toDouble(); } function stopTimer(timerId: number): void { if (CoroutineExtras.isMainWorker()) { - stopTimerImpl(timerId as int); + stopTimerImpl(Double.toInt(timerId)); return; } - clearTimer(timerId as int); + clearTimer(Double.toInt(timerId)); } native function startTimerImpl(func: Object, delayMs: int, repeat: boolean): int; diff --git a/static_core/plugins/ets/stdlib/escompat/Iterator.ets b/static_core/plugins/ets/stdlib/escompat/Iterator.ets index 5f13bdab6e4c108d68ff33d424d35763706e6696..a7fbbb345bb0aa729686692b5b54c4837909a2f7 100644 --- a/static_core/plugins/ets/stdlib/escompat/Iterator.ets +++ b/static_core/plugins/ets/stdlib/escompat/Iterator.ets @@ -17,7 +17,7 @@ package escompat; export class IteratorResult { done: boolean - value: T | undefined + readonly value: T | undefined constructor() { this.done = true diff --git a/static_core/plugins/ets/stdlib/escompat/Map.ets b/static_core/plugins/ets/stdlib/escompat/Map.ets index 0a17ed5d34336d13b1f97b9eb0080469924f7570..708339f094796812c8091fc0a70b72d76c59ed92 100644 --- a/static_core/plugins/ets/stdlib/escompat/Map.ets +++ b/static_core/plugins/ets/stdlib/escompat/Map.ets @@ -176,7 +176,7 @@ export class Map implements ReadonlyMap { this.buckets = new MapBucket[bucketsCount] entriesBuf.forEach((e: [K, V]) => { - this.set(e[Map.ENTRY_KEY], e[Map.ENTRY_VAL]) + this.set(e[0] as K, e[1] as V) }) } else { const bucketsCount = this.getInitialBucketsCount(entries.actualLength) @@ -185,7 +185,7 @@ export class Map implements ReadonlyMap { if (entries[i] == null) { continue } - this.set(entries[i]![Map.ENTRY_KEY], entries[i]![Map.ENTRY_VAL]) + this.set(entries[i]![0] as K, entries[i]![1] as V) } } } @@ -212,7 +212,7 @@ export class Map implements ReadonlyMap { this.buckets = new MapBucket[bucketsCount] entries.forEach((entry: [K, V]) => { - this.set(entry[Map.ENTRY_KEY], entry[Map.ENTRY_VAL]) + this.set(entry[0] as K, entry[1] as V) }) } @@ -226,7 +226,7 @@ export class Map implements ReadonlyMap { if (values[i] == null) { continue } - this.set(values[i][Map.ENTRY_KEY], values[i][Map.ENTRY_VAL]) + this.set(values[i][0] as K, values[i][1] as V) } } @@ -499,7 +499,7 @@ export class Map implements ReadonlyMap { } } -export class Record extends Map { +export class Record | BaseEnum | BaseEnum, V> extends Map { $_get(k : K) : V | undefined { return super.get(k) } @@ -507,4 +507,4 @@ export class Record extends Map { $_set(k: K, v: V) : void { super.set(k, v) } -} \ No newline at end of file +} diff --git a/static_core/plugins/ets/stdlib/escompat/Math.ets b/static_core/plugins/ets/stdlib/escompat/Math.ets index 81b27b1ea56eec0825721e5170928bd036995b1e..ac375369a0db72ebdede035346c9109a66251ec2 100644 --- a/static_core/plugins/ets/stdlib/escompat/Math.ets +++ b/static_core/plugins/ets/stdlib/escompat/Math.ets @@ -266,9 +266,9 @@ export class Math { /** * Rounding-up argument value to the closest integral power of 2 * Thus, Math.ceilPow2(n) is the least power of 2 that is >= n - * + * * @param n 32-bit integer - * + * * @returns Argument value rounded-up to the closest integral power of 2 * @example * ``` @@ -654,7 +654,7 @@ export class Math { if (isNaN(x)) { return x; } - return sign(x) as double as number; + return Int.toDouble(sign(x)); } /** diff --git a/static_core/plugins/ets/stdlib/escompat/Process.ets b/static_core/plugins/ets/stdlib/escompat/Process.ets index b746616ab9d5820699786b83b30cd26b86258055..b45ffb1465d26f7ce26d96899206d6cc046f2a55 100644 --- a/static_core/plugins/ets/stdlib/escompat/Process.ets +++ b/static_core/plugins/ets/stdlib/escompat/Process.ets @@ -126,7 +126,7 @@ export namespace StdProcess { if (!isInteger(signal as number) || (signal as number) < 1 || (signal as number) > 31) { throw new RangeError("Invalid signal value"); } - killSignal = signal as int; + killSignal = Double.toInt(signal); } this.killImpl(killSignal); } @@ -472,11 +472,15 @@ export namespace StdProcess { let maxBuffer: int = MAX_BUFFER_SIZE; if (options == undefined) { - return [timeout, killSignal, maxBuffer]; + let ret: Array = new Array(3); + ret[0] = timeout + ret[1] = killSignal + ret[2] = maxBuffer + return ret; } if (options.timeout != undefined && options.timeout as number > 0) { - timeout = options.timeout as int; + timeout = Double.toInt(options.timeout as number); } if (options.killSignal != undefined) { @@ -489,18 +493,22 @@ export namespace StdProcess { if (!isInteger(options.killSignal as number) || (options.killSignal as number) < 1 || (options.killSignal as number) > 31) { throw new RangeError("Invalid signal value"); } - killSignal = options.killSignal as int; + killSignal = Double.toInt(options.killSignal as number); } } if (options.maxBuffer != undefined) { - if ((options.maxBuffer as int) < 0) { + if (Double.toInt(options.maxBuffer as number) < 0) { throw new RangeError("Invalid buffer size value"); } - maxBuffer = min(options.maxBuffer as int, MAX_BUFFER_SIZE); + maxBuffer = min(Double.toInt(options.maxBuffer as number), MAX_BUFFER_SIZE); } - return [timeout, killSignal, maxBuffer]; + let ret: Array = new Array(3); + ret[0] = timeout + ret[1] = killSignal + ret[2] = maxBuffer + return ret; } /** @@ -568,4 +576,4 @@ export namespace StdProcess { private static failedJobHandler: RejectedHandler = new RejectedHandler(DEFAULT_JOB_HANDLER_CALLBACK); private static rejectedPromiseHandler: RejectedHandler = new RejectedHandler(DEFAULT_PROMISE_HANDLER_CALLBACK); } -} \ No newline at end of file +} diff --git a/static_core/plugins/ets/stdlib/escompat/Proxy.ets b/static_core/plugins/ets/stdlib/escompat/Proxy.ets index 3b5362dc5971ab1b2d4b047701dfe60da52130d1..54408c44435ebf93de846c2787ac69f977ac5336 100644 --- a/static_core/plugins/ets/stdlib/escompat/Proxy.ets +++ b/static_core/plugins/ets/stdlib/escompat/Proxy.ets @@ -506,8 +506,8 @@ abstract class ArrayProxy extends Array { } const signatureMatch = signature.every((paramType: Type, index: number) => { - const param = methodType.getParameter(index as int) - let tmp = paramType.equals(param.getType()) + const param = methodType.getParameter(Double.toInt(index)) + let tmp = paramType.equals(param.getType()) return tmp }) @@ -528,14 +528,14 @@ abstract class ArrayProxy extends Array { private static readonly POP_METHOD: Method = ArrayProxy.getArrayMethod("pop") private static readonly SHIFT_METHOD: Method = ArrayProxy.getArrayMethod("shift") - private static readonly SPLICE_METHOD_NUM: Method = ArrayProxy.getArrayMethod("splice", Type.of(1.0)) - private static readonly SPLICE_METHOD_INT: Method = ArrayProxy.getArrayMethod("splice", Type.of(1)) + private static readonly SPLICE_METHOD_NUM: Method = ArrayProxy.getArrayMethod("splice", Type.of(1.0 + 0)) + private static readonly SPLICE_METHOD_INT: Method = ArrayProxy.getArrayMethod("splice", Type.of(1 as int)) private static readonly SPLICE_METHOD_INT_INT_ARR: Method = - ArrayProxy.getArrayMethod("splice", Type.of(1), Type.of(1), Type.of(new Array(0))) + ArrayProxy.getArrayMethod("splice", Type.of(1 as int), Type.of(1 as int), Type.of(new Array(0))) private static readonly SPLICE_METHOD_NUM_OBJ_ARR: Method = - ArrayProxy.getArrayMethod("splice", Type.of(1.0), Type.of(new Number(0)), Type.of(new Array(0))) + ArrayProxy.getArrayMethod("splice", Type.of(1.0 + 0), Type.of(new Number(0)), Type.of(new Array(0))) constructor(target: Array, handler: ArrayProxyHandler) { this.target = target diff --git a/static_core/plugins/ets/stdlib/escompat/ReadonlyArrayProxy.ets b/static_core/plugins/ets/stdlib/escompat/ReadonlyArrayProxy.ets index 6352eb9b7b280fd463243d3bb5cfe6bd326cf8fd..68bc28afe4115422fdf4ef32ed6c04b3ed954c47 100644 --- a/static_core/plugins/ets/stdlib/escompat/ReadonlyArrayProxy.ets +++ b/static_core/plugins/ets/stdlib/escompat/ReadonlyArrayProxy.ets @@ -25,7 +25,7 @@ export abstract class DefaultReadonlyArrayProxyHandler implements ReadonlyArr override get(target: ReadonlyArray, name: string): NullishType { if (name == "length") { return target.length - } + } throw new AssertionError("unexpected property: " + name) } @@ -62,7 +62,7 @@ class ReadonlyArrayProxy implements ReadonlyArray { override find(predicate: (value: T, index: number, obj: ReadonlyArray) => boolean): T | undefined { return this.target.find(predicate) - } + } override findLast(predicate: (value: T, index: number, obj: ReadonlyArray) => boolean): T | undefined { return this.target.findLast(predicate) @@ -145,7 +145,7 @@ class ReadonlyArrayProxy implements ReadonlyArray { } override $_get(index: number): T { - return this.handler.get(this.target, index as int) + return this.handler.get(this.target, Double.toInt(index)) } get length(): number { @@ -156,4 +156,4 @@ class ReadonlyArrayProxy implements ReadonlyArray { throw new TypeError("unexpected ReadonlyArray.length value type: " + Type.of(length)) } -} \ No newline at end of file +} diff --git a/static_core/plugins/ets/stdlib/escompat/Reflect.ets b/static_core/plugins/ets/stdlib/escompat/Reflect.ets index 1a0a594fa22df594cb6d041a463a2ce69dc5e226..5a6ca595bbf4bac2fb3415433d57ed184218b847 100644 --- a/static_core/plugins/ets/stdlib/escompat/Reflect.ets +++ b/static_core/plugins/ets/stdlib/escompat/Reflect.ets @@ -87,7 +87,7 @@ export class Reflect { * Gets the property of the record * * @param target Record that contains the property - * + * * @param key name of the property * * @returns property value @@ -123,7 +123,7 @@ export class Reflect { let t = Type.of(target) if (t instanceof ArrayType) { let av = Value.of(target) as ArrayValue - return av.getElement(index as long).getData()! + return av.getElement(Double.toLong(index)).getData()! } else if (t instanceof EnumType) { // NOTE(shumilov-petr): Not implemented throw new Error("Not implemented") @@ -193,9 +193,9 @@ export class Reflect { * @param target Record that contains the property * * @param key name of the property - * + * * @param value of the property - * + * * @returns a Boolean indicating whether or not setting the property was successful */ public static set(target: Record, key: string, value: Object): Boolean { @@ -223,7 +223,7 @@ export class Reflect { } let av = v as ArrayValue try { - av.setElement(index as long, Value.of(value)) + av.setElement(Double.toLong(index), Value.of(value)) } catch (e: Error) { return false } @@ -247,7 +247,7 @@ export class Reflect { * Returns the string keys of the properties of a record * * @param target Record that contains the properties - * + * * @returns as array of the target Record property names */ public static ownKeys(target: Record): string[] { @@ -341,4 +341,3 @@ export class Reflect { return Reflect.isLiteralInitializedInterfaceImpl(target) } } - diff --git a/static_core/plugins/ets/stdlib/escompat/RegExp.ets b/static_core/plugins/ets/stdlib/escompat/RegExp.ets index 8049d76c4fdb45d8dad3e07853b58050324263eb..220b383f43ffa5143643f20da0577359d8369070 100644 --- a/static_core/plugins/ets/stdlib/escompat/RegExp.ets +++ b/static_core/plugins/ets/stdlib/escompat/RegExp.ets @@ -75,7 +75,7 @@ export class RegExpExecArray /*extends Array*/ { * @returns resulting string */ public $_get(index: number): String { - return this.$_get(index as int); + return this.$_get(Double.toInt(index)); } /** @@ -97,7 +97,7 @@ export class RegExpExecArray /*extends Array*/ { * @param val */ public $_set(index: number, val: String) { - return this.$_set(index as int, val); + return this.$_set(Double.toInt(index), val); } get length(): int { @@ -200,7 +200,7 @@ export class RegExpExecArray /*extends Array*/ { } constructor(index: number, input: String, result: FixedArray, indices: FixedArray>) { - this(index as int, input, result, indices) + this(Double.toInt(index), input, result, indices) } } @@ -284,7 +284,7 @@ export class RegExp extends Object { private static $9_: String = "" private groupNames: String[] = [] - private buffer: int[] = [] + private buffer: int[] = new Array() // NOTE(shumilov-petr): Removing the following setter leads to unspecified behaviour of es2panda // The negative test '02.lexical_elements/07.keywords/types_n_12.ets' gets failed if remove this setter @@ -589,7 +589,7 @@ export class RegExp extends Object { let nCaptures = result.length; let matched = result.$_get(0); let matchLength = matched.getLength(); - let position = max(min(result.index, lengthS), 0) as int; + let position = Double.toInt(max(min(result.index, lengthS), 0)); let captures = new UndefinableStringArray(nCaptures); for (let n = 1; n < nCaptures; n++) { let capN = result.$_get(n); @@ -638,14 +638,14 @@ export class RegExp extends Object { let nCaptures = result.length; let matched = result.$_get(0); let matchLength = matched.getLength(); - let position = max(min(result.index, lengthS), 0) as int; + let position = Double.toInt(max(min(result.index, lengthS), 0)); let args = new UndefinableObjectArray(nCaptures); for (let n = 1; n < nCaptures; n++) { let capN = result.$_get(n); args.pushBack(capN) } let namedCaptures: NullishType = /*result.groups*/ undefined; - args.pushBack(new Double(position as double)); + args.pushBack(Int.toDouble(position)); args.pushBack(str) if (namedCaptures != undefined) { args.pushBack(namedCaptures) @@ -673,7 +673,7 @@ export class RegExp extends Object { } else if (limit == 0) { return new String[0] } else { - lim = limit.unboxed() as long + lim = Double.toLong(limit) } let size = str.getLength() if (size == 0) { @@ -691,7 +691,7 @@ export class RegExp extends Object { if (z == null) { lastEnd = RegExp.advanceStringIndex(str, lastEnd, unicodeMatching) } else { - let separatorRight = (splitter.lastIndex < size) ? splitter.lastIndex as int : size + let separatorRight = (splitter.lastIndex < size) ? Double.toInt(splitter.lastIndex) : size if (separatorRight == lastStart) { lastEnd = RegExp.advanceStringIndex(str, lastEnd, unicodeMatching) } else { @@ -808,7 +808,7 @@ export class RegExp extends Object { * @returns new index */ public static advanceStringIndex(s: String, index: number, unicode: boolean): number { - return RegExp.advanceStringIndex(s, index as int, unicode) + return RegExp.advanceStringIndex(s, Double.toInt(index), unicode) } public static $_invoke(pattern: RegExp | String, flags?: String) : RegExp { diff --git a/static_core/plugins/ets/stdlib/escompat/TypedArrays.ets b/static_core/plugins/ets/stdlib/escompat/TypedArrays.ets index 20bfe0620b73bca6a0f147938904a02448cb577e..e2907e71c55f19c842e05e882dced210f7f77ff7 100644 --- a/static_core/plugins/ets/stdlib/escompat/TypedArrays.ets +++ b/static_core/plugins/ets/stdlib/escompat/TypedArrays.ets @@ -22,7 +22,7 @@ class Int8ArrayIteratorKeys implements IterableIterator { private idx: int = 0 constructor(parent: Int8Array) { - this.length = parent.length as int + this.length = Double.toInt(parent.length) } public override $_iterator(): IterableIterator { @@ -33,7 +33,7 @@ class Int8ArrayIteratorKeys implements IterableIterator { if (this.idx < 0 || this.idx >= this.length) { return new IteratorResult() } - return new IteratorResult(false, this.idx++ as number) + return new IteratorResult(false, Int.toDouble(this.idx++)) } } @@ -50,7 +50,7 @@ class Int8ArrayIterator implements IterableIterator { } override next(): IteratorResult { - if (this.idx < 0 || this.idx >= this.parent.length as int) { + if (this.idx < 0 || this.idx >= Double.toInt(this.parent.length)) { return new IteratorResult() } return new IteratorResult(false, new Number(this.parent[this.idx++])) @@ -70,7 +70,7 @@ class Int8ArrayIteratorEntries implements IterableIterator<[Number, Number]> { } override next(): IteratorResult<[Number, Number]> { - if (this.idx < 0 || this.idx >= this.parent.length as int) { + if (this.idx < 0 || this.idx >= Double.toInt(this.parent.length)) { return new IteratorResult<[Number, Number]>() } return new IteratorResult<[Number, Number]>( @@ -84,15 +84,15 @@ class Int8ArrayIteratorEntries implements IterableIterator<[Number, Number]> { * JS Int8Array API-compatible class */ export final class Int8Array implements Iterable, ArrayLike { - public static readonly BYTES_PER_ELEMENT: number = 1 - public readonly BYTES_PER_ELEMENT: number = Int8Array.BYTES_PER_ELEMENT + public static readonly BYTES_PER_ELEMENT: int = 1 + public readonly BYTES_PER_ELEMENT: int = Int8Array.BYTES_PER_ELEMENT internal readonly lengthInt: int /** * Creates an empty Int8Array. */ public constructor() { - this(0 as int) + this(0) } /** @@ -102,9 +102,9 @@ export final class Int8Array implements Iterable, ArrayLike { const items: Object = elements as Object if (items instanceof ArrayLike) { const arr = Types.identity_cast(items as ArrayLike) - this.byteLength = arr.length as int * Int8Array.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int - this.buffer = new ArrayBuffer(this.byteLength as int) + this.byteLength = Double.toInt(arr.length) * Int8Array.BYTES_PER_ELEMENT + this.lengthInt = Double.toInt(arr.length) + this.buffer = new ArrayBuffer(Double.toInt(this.byteLength)) this.byteOffset = 0 for (let i: int = 0; i < this.lengthInt; ++i) { this.setUnsafe(i, arr.$_get(i).toByte()) @@ -143,17 +143,17 @@ export final class Int8Array implements Iterable, ArrayLike { let intLength: int if (length != undefined) { intLength = length.toInt() - if (intLength > intByteLength / Int8Array.BYTES_PER_ELEMENT as int) { + if (intLength > Double.toInt(intByteLength / Int8Array.BYTES_PER_ELEMENT)) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer with byteOffset " + intByteOffset) } } else { - intLength = intByteLength / Int8Array.BYTES_PER_ELEMENT as int + intLength = Double.toInt(intByteLength / Int8Array.BYTES_PER_ELEMENT) } if (intLength < 0) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer") } - if (intLength < intByteLength / Int8Array.BYTES_PER_ELEMENT as int) { - intByteLength = intLength * Int8Array.BYTES_PER_ELEMENT as int + if (intLength < Double.toInt(intByteLength / Int8Array.BYTES_PER_ELEMENT)) { + intByteLength = intLength * Int8Array.BYTES_PER_ELEMENT } this.byteLength = intByteLength this.byteOffset = intByteOffset @@ -161,32 +161,6 @@ export final class Int8Array implements Iterable, ArrayLike { this.buffer = buf } - /** - * Creates an Int8Array with respect to data, byteOffset and length. - * - * @param buf data initializer - * - * @param byteOffset byte offset from begin of the buf - * - * @param length size of elements of type byte in newly created Int8Array - */ - public constructor(buf: ArrayBuffer, byteOffset: Number | undefined) { - this(buf, byteOffset, undefined) - } - - /** - * Creates an Int8Array with respect to data, byteOffset and length. - * - * @param buf data initializer - * - * @param byteOffset byte offset from begin of the buf - * - * @param length size of elements of type byte in newly created Int8Array - */ - public constructor(buf: ArrayBuffer, byteOffset: number, length: number) { - this(buf, new Number(byteOffset), new Number(length)) - } - /** * Creates an Int8Array with respect to data, byteOffset and length. * @@ -232,19 +206,19 @@ export final class Int8Array implements Iterable, ArrayLike { public constructor(buf: ArrayLike | ArrayBuffer) { if (buf instanceof ArrayBuffer) { this.byteLength = (buf as ArrayBuffer).getByteLength() - if (this.byteLength % Int8Array.BYTES_PER_ELEMENT as int != 0) { + if (this.byteLength % Int8Array.BYTES_PER_ELEMENT.toInt() != 0) { throw new RangeError("ArrayBuffer.byteLength should be multiple of 1 as Int8Array.BYTES_PER_ELEMENT") } - this.lengthInt = this.byteLength / Int8Array.BYTES_PER_ELEMENT as int + this.lengthInt = Double.toInt(this.byteLength / Int8Array.BYTES_PER_ELEMENT) this.buffer = buf as ArrayBuffer this.byteOffset = 0 } else if (buf instanceof ArrayLike) { // NOTE (ikorobkov): dealing with this overload is tricky // with banned `instanceof` generic, so it is delegated to array here. Initial idea from Set.ets let arr = Array.from((buf as ArrayLike)) - this.byteLength = arr.length as int * Int8Array.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int - this.buffer = new ArrayBuffer(this.byteLength as int) + this.byteLength = arr.length.toInt() * Int8Array.BYTES_PER_ELEMENT.toInt() + this.lengthInt = arr.length.toInt() + this.buffer = new ArrayBuffer(this.byteLength.toInt()) this.byteOffset = 0 for (let i: int = 0; i < this.lengthInt; ++i) { this.setUnsafe(i, arr.$_get(i).toByte()) @@ -260,7 +234,7 @@ export final class Int8Array implements Iterable, ArrayLike { * @param length data initializer */ public constructor(length: int) { - this(length as number) + this(Int.toDouble(length)) } /** @@ -269,13 +243,13 @@ export final class Int8Array implements Iterable, ArrayLike { * @param length data initializer */ public constructor(length: number) { - if (length < 0 || length > (Int.MAX_VALUE / Int8Array.BYTES_PER_ELEMENT)) { + if (length < 0 || length > Double.toInt(Int.MAX_VALUE / Int8Array.BYTES_PER_ELEMENT)) { throw new TypeError("Type Error: length " + length + " is outside the bounds of the buffer") } - this.lengthInt = length as int - this.byteLength = this.lengthInt * Int8Array.BYTES_PER_ELEMENT as int + this.lengthInt = Double.toInt(length) + this.byteLength = this.lengthInt * Int8Array.BYTES_PER_ELEMENT this.byteOffset = 0 - this.buffer = new ArrayBuffer(this.byteLength as int) + this.buffer = new ArrayBuffer(this.byteLength.toInt()) } /** @@ -284,9 +258,9 @@ export final class Int8Array implements Iterable, ArrayLike { * @param other data initializer */ public constructor(other: Int8Array) { - this.buffer = other.buffer.slice(other.byteOffset as int, (other.byteOffset + other.byteLength) as int) as ArrayBuffer + this.buffer = other.buffer.slice(other.byteOffset.toInt(), (other.byteOffset + other.byteLength).toInt()) as ArrayBuffer this.byteLength = other.byteLength - this.lengthInt = other.length as int + this.lengthInt = Double.toInt(other.length) this.byteOffset = 0 } @@ -296,7 +270,7 @@ export final class Int8Array implements Iterable, ArrayLike { public constructor(numbers: FixedArray) { this(numbers.length) for (let i: int = 0; i < this.lengthInt; ++i) { - this.setUnsafe(i, this.zeroIfInfinity(numbers[i]) as byte) + this.setUnsafe(i, this.zeroIfInfinity(numbers[i]).toByte()) } } @@ -306,20 +280,20 @@ export final class Int8Array implements Iterable, ArrayLike { public constructor(numbers: FixedArray) { this(numbers.length) for (let i: int = 0; i < this.lengthInt; ++i) { - this.setUnsafe(i, this.zeroIfInfinity(numbers[i]) as byte) + this.setUnsafe(i, this.zeroIfInfinity(numbers[i]).toByte()) } } internal zeroIfInfinity(val: number): number { if ((val == Infinity) || (val == -Infinity)) { - return 0 as number + return 0 } - return val as number + return (val).toDouble() } internal zeroIfInfinity(val: byte): byte { if ((val == Infinity) || (val == -Infinity)) { - return 0 as byte + return Int.toByte(0) } return val } @@ -332,7 +306,7 @@ export final class Int8Array implements Iterable, ArrayLike { * @param index index to change */ public $_set(index: number, val: number): void { - this.$_set(index as int, val) + this.$_set(Double.toInt(index), val) } /** @@ -344,7 +318,7 @@ export final class Int8Array implements Iterable, ArrayLike { */ public $_set(index: int, val: number): void { let v = this.zeroIfInfinity(val) - this.$_set(index, v as byte) + this.$_set(index, v.toByte()) } /** @@ -355,7 +329,7 @@ export final class Int8Array implements Iterable, ArrayLike { * @param index index to change */ public $_set(index: number, val: int): void { - this.$_set(index as int, val) + this.$_set(Double.toInt(index), val) } /** @@ -375,7 +349,7 @@ export final class Int8Array implements Iterable, ArrayLike { * @param index index to change */ public $_set(index: number, val: byte): void { - this.$_set(index as int, val) + this.$_set(Double.toInt(index), val) } /** @@ -400,7 +374,7 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns a primitive at index */ public override $_get(index: number): Number { - return this.$_get(index as int) as Number + return this.$_get(Double.toInt(index)) } /** @@ -420,7 +394,7 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns a primitive at index */ public at(index: number): Number | undefined { - return this.at(index as int) + return this.at(Double.toInt(index)) } /** @@ -455,7 +429,7 @@ export final class Int8Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: number, start: number, end?: number): Int8Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(Double.toInt(target), Double.toInt(start), asIntOrDefault(end, this.lengthInt)) } /** @@ -470,7 +444,7 @@ export final class Int8Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: int, start: number, end?: number): Int8Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target, Double.toInt(start), asIntOrDefault(end, this.lengthInt)) } /** @@ -485,7 +459,7 @@ export final class Int8Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: number, start: int, end?: number): Int8Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(Double.toInt(target), start, asIntOrDefault(end, this.lengthInt)) } /** @@ -500,7 +474,7 @@ export final class Int8Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: int, start: int, end?: number): Int8Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target, start, asIntOrDefault(end, this.lengthInt)) } /** @@ -525,7 +499,7 @@ export final class Int8Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} */ public copyWithin(target: number): Int8Array { - return this.copyWithin(target as int) + return this.copyWithin(Double.toInt(target)) } /** @@ -558,7 +532,7 @@ export final class Int8Array implements Iterable, ArrayLike { */ public fill(value: number, start?: number, end?: number): this { value = this.zeroIfInfinity(value) - this.fill(value as byte, asIntOrDefault(start, 0 as int), asIntOrDefault(end, this.lengthInt)) + this.fill(value.toByte(), asIntOrDefault(start, 0), asIntOrDefault(end, this.lengthInt)) return this } @@ -571,20 +545,7 @@ export final class Int8Array implements Iterable, ArrayLike { */ public fill(value: number, start: int, end?: number): this { value = this.zeroIfInfinity(value) - this.fill(value as byte, start as int, asIntOrDefault(end, this.lengthInt)) - return this - } - - /** - * Fills the Int8Array with specified value - * - * @param value new valuy - * - * @returns modified Int8Array - */ - public fill(value: number, start: int, end: number): this { - value = this.zeroIfInfinity(value) - this.fill(value as byte, start as int, end as int) + this.fill(value.toByte(), start, asIntOrDefault(end, this.lengthInt)) return this } @@ -597,7 +558,7 @@ export final class Int8Array implements Iterable, ArrayLike { */ public fill(value: number, start: number, end: int): this { value = this.zeroIfInfinity(value) - this.fill(value as byte, start as int, end as int) + this.fill(value.toByte(), Double.toInt(start), end) return this } @@ -610,7 +571,7 @@ export final class Int8Array implements Iterable, ArrayLike { */ public fill(value: number, start: int, end: int): this { value = this.zeroIfInfinity(value) - this.fill(value as byte, start as int, end as int) + this.fill(value.toByte(), start, end) return this } @@ -622,7 +583,7 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns modified Int8Array */ public fill(value: byte, start?: number, end?: number): this { - this.fill(value, asIntOrDefault(start, 0 as int), asIntOrDefault(end, this.lengthInt)) + this.fill(value, asIntOrDefault(start, 0), asIntOrDefault(end, this.lengthInt)) return this } @@ -634,19 +595,7 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns modified Int8Array */ public fill(value: byte, start: int, end?: number): this { - this.fill(value, start as int, asIntOrDefault(end, this.lengthInt)) - return this - } - - /** - * Fills the Int8Array with specified value - * - * @param value new valuy - * - * @returns modified Int8Array - */ - public fill(value: byte, start: int, end: number): this { - this.fill(value, start as int, end as int) + this.fill(value, start, asIntOrDefault(end, this.lengthInt)) return this } @@ -658,7 +607,7 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns modified Int8Array */ public fill(value: byte, start: number, end: int): this { - this.fill(value, start as int, end as int) + this.fill(value, Double.toInt(start), end) return this } @@ -712,13 +661,13 @@ export final class Int8Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ public set(arr: FixedArray, insertPos: number): void { - const offset = insertPos as int + const offset = Double.toInt(insertPos) if (offset < 0 || offset + arr.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } - for (let i = 0; i < arr.length as int; ++i) { + for (let i = 0; i < Double.toInt(arr.length); ++i) { let v = this.zeroIfInfinity(arr[i]) - this.$_set(offset + i, v as byte) + this.$_set(offset + i, v.toByte()) } } @@ -732,11 +681,11 @@ export final class Int8Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ public set(arr: FixedArray, insertPos: int): void { - const offset = insertPos as int + const offset = insertPos if (offset < 0 || offset + arr.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } - for (let i = 0; i < arr.length as int; ++i) { + for (let i = 0; i < Double.toInt(arr.length); ++i) { let v = this.zeroIfInfinity(arr[i]) this.$_set(offset + i, v) } @@ -748,7 +697,7 @@ export final class Int8Array implements Iterable, ArrayLike { * @param arr array to copy data from */ public set(arr: FixedArray): void { - this.set(arr, 0 as number) + this.set(arr, 0) } /** @@ -757,7 +706,7 @@ export final class Int8Array implements Iterable, ArrayLike { * @param arr array to copy data from */ public set(arr: FixedArray): void { - this.set(arr, 0 as int) + this.set(arr, 0) } public native set(array: Int8Array): void @@ -772,13 +721,13 @@ export final class Int8Array implements Iterable, ArrayLike { * @param offset Optional. The offset into the target array at which to begin writing values from the source array */ public set(array: ArrayLike, offset: number = 0): void { - const insertPos = offset as int + const insertPos = Double.toInt(offset) if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } - for (let i = array.length - 1 as int; i >= 0; --i) { + for (let i = Double.toInt(array.length) - 1; i >= 0; --i) { let v = this.zeroIfInfinity(array[i]) - this.$_set(insertPos + i, v as byte) + this.$_set(insertPos + i, v.toByte()) } } @@ -790,9 +739,9 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns new Int8Array */ public static of(...items: FixedArray): Int8Array { - let res = new Int8Array(items.length as int) + let res = new Int8Array(Double.toInt(items.length)) for (let i: int = 0; i < items.length; i++) { - res.setUnsafe(i, res.zeroIfInfinity(items[i]) as byte) + res.setUnsafe(i, res.zeroIfInfinity(items[i]).toByte()) } return res } @@ -805,9 +754,9 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns new Int8Array */ public static of(...items: FixedArray): Int8Array { - let res = new Int8Array(items.length as int) + let res = new Int8Array(Double.toInt(items.length)) for (let i: int = 0; i < items.length; i++) { - res.setUnsafe(i, items[i] as byte) + res.setUnsafe(i, items[i].toByte()) } return res } @@ -820,7 +769,7 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns new Int8Array */ public static of(...items: FixedArray): Int8Array { - let res = new Int8Array(items.length as int) + let res = new Int8Array(Double.toInt(items.length)) for (let i: int = 0; i < items.length; i++) { res.setUnsafe(i, items[i]) } @@ -835,7 +784,7 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns new Int8Array */ public static of(): Int8Array { - return new Int8Array(0 as int) + return new Int8Array(0) } /** @@ -876,7 +825,7 @@ export final class Int8Array implements Iterable, ArrayLike { if (x.done) { return new Int8Array(result.buffer, 0, i) } - result.setUnsafe(i, result.zeroIfInfinity((mapfn)!(x.value!, i)) as byte) + result.setUnsafe(i, result.zeroIfInfinity((mapfn)!(x.value!, i)).toByte()) } return result } @@ -896,7 +845,7 @@ export final class Int8Array implements Iterable, ArrayLike { } temp = new Int8Array(tb) } - temp.setUnsafe(index[0], temp.zeroIfInfinity((mapfn)!(x, index[0])) as byte) + temp.setUnsafe(index[0], temp.zeroIfInfinity((mapfn)!(x, index[0])).toByte()) index[0]++ }) return new Int8Array(temp.buffer, 0, index[0]) @@ -918,7 +867,7 @@ export final class Int8Array implements Iterable, ArrayLike { const idx : FixedArray = new int[1] idx[0] = 0 iteratorForEach(arrayLike.$_iterator(), (x: T): void => { - res.setUnsafe(idx[0] as int, res.zeroIfInfinity(mapfn(x as T, idx[0] as number)) as byte) + res.setUnsafe(idx[0], res.zeroIfInfinity(mapfn(x as T, Int.toDouble(idx[0])).toByte())) idx[0] += 1 }) return res @@ -950,7 +899,7 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns true if e is in Int8Array, false otherwise */ public includes(searchElement: byte, fromIndex: int): boolean { - return this.indexOf(searchElement as int, fromIndex) != -1 + return this.indexOf(searchElement.toInt(), fromIndex) != -1 } /** @@ -1005,7 +954,7 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns index of element if it presents, -1 otherwise */ public indexOf(searchElement: int, fromIndex: int): number { - return this.indexOfImpl(searchElement as long, fromIndex) + return this.indexOfImpl(Int.toLong(searchElement), fromIndex) } /** @@ -1132,7 +1081,7 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ public lastIndexOf(searchElement: int, fromIndex: int): number { - return this.lastIndexOfImpl(searchElement as long, fromIndex) + return this.lastIndexOfImpl(Int.toLong(searchElement), fromIndex) } /** @@ -1203,22 +1152,7 @@ export final class Int8Array implements Iterable, ArrayLike { * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin?: number, end?: number): Int8Array { - return this.slice(asIntOrDefault(begin, 0 as int), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Creates a slice of current Int8Array using range [begin, end) - * - * @param begin start index to be taken into slice - * - * @param end last index to be taken into slice - * - * @returns a new Int8Array with elements of current Int8Array[begin;end) where end index is excluded - * - * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice - */ - public slice(begin: number, end: number): Int8Array { - return this.slice(begin as int, end as int) + return this.slice(asIntOrDefault(begin, 0), asIntOrDefault(end, this.lengthInt)) } /** @@ -1233,7 +1167,7 @@ export final class Int8Array implements Iterable, ArrayLike { * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin: number, end: int): Int8Array { - return this.slice(begin as int, end as int) + return this.slice(Double.toInt(begin), end) } /** @@ -1248,7 +1182,7 @@ export final class Int8Array implements Iterable, ArrayLike { * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin: int, end: number): Int8Array { - return this.slice(begin as int, end as int) + return this.slice(begin, Double.toInt(end)) } /** @@ -1270,21 +1204,10 @@ export final class Int8Array implements Iterable, ArrayLike { if (count < 0) { count = 0 } - let buf = this.buffer.slice(relStart * Int8Array.BYTES_PER_ELEMENT as int, relEnd * Int8Array.BYTES_PER_ELEMENT as int) as ArrayBuffer + let buf = this.buffer.slice(relStart * Int8Array.BYTES_PER_ELEMENT.toInt(), relEnd * Int8Array.BYTES_PER_ELEMENT.toInt()) as ArrayBuffer return new Int8Array(buf) } - /** - * Creates a slice of current Int8Array using range [begin, this.length). - * - * @param begin start index to be taken into slice - * - * @returns a new Int8Array with elements of current Int8Array[begin, this.length) - */ - public slice(begin: number): Int8Array { - return this.slice(begin as int) - } - /** * Creates a slice of current Int8Array using range [begin, this.length). * @@ -1309,19 +1232,6 @@ export final class Int8Array implements Iterable, ArrayLike { return this.subarray(asIntOrDefault(begin, 0 as int), asIntOrDefault(end, this.lengthInt)) } - /** - * Creates a Int8Array with the same underlying ArrayBuffer - * - * @param begin start index, inclusive - * - * @param end last index, exclusive - * - * @returns new Int8Array with the same underlying ArrayBuffer - */ - public subarray(begin: number, end: number): Int8Array { - return this.subarray(begin as int, end as int) - } - /** * Creates a Int8Array with the same underlying ArrayBuffer * @@ -1332,7 +1242,7 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns new Int8Array with the same underlying ArrayBuffer */ public subarray(begin: number, end: int): Int8Array { - return this.subarray(begin as int, end as int) + return this.subarray(Double.toInt(begin), end) } /** @@ -1345,7 +1255,7 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns new Int8Array with the same underlying ArrayBuffer */ public subarray(begin: int, end: number): Int8Array { - return this.subarray(begin as int, end as int) + return this.subarray(begin, Double.toInt(end)) } /** @@ -1365,7 +1275,7 @@ export final class Int8Array implements Iterable, ArrayLike { if (count < 0) { count = 0 } - return new Int8Array(this.buffer, relStart * Int8Array.BYTES_PER_ELEMENT as int, count) + return new Int8Array(this.buffer, relStart * Int8Array.BYTES_PER_ELEMENT.toInt(), count) } /** @@ -1376,7 +1286,7 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns new Int8Array with the same ArrayBuffer */ public subarray(begin: number): Int8Array { - return this.subarray(begin as int, this.lengthInt) + return this.subarray(begin.toInt(), this.lengthInt) } /** @@ -1387,7 +1297,7 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns new Int8Array with the same ArrayBuffer */ public subarray(begin: int): Int8Array { - return this.subarray(begin as int, this.lengthInt) + return this.subarray(begin, this.lengthInt) } /** @@ -1422,11 +1332,11 @@ export final class Int8Array implements Iterable, ArrayLike { public toLocaleString(): string { let res: StringBuilder = new StringBuilder("") for (let i = 0; i < this.lengthInt - 1; ++i) { - res.append((this.getUnsafe(i) as Number).toLocaleString()) + res.append(new Number(this.getUnsafe(i)).toLocaleString()) res.append(",") } if (this.lengthInt > 0) { - res.append((this.getUnsafe(this.lengthInt - 1) as Number).toLocaleString()) + res.append(new Number(this.getUnsafe(this.lengthInt - 1))).toLocaleString() } return res.toString() } @@ -1486,7 +1396,7 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns an Int8Array with replaced value on index */ public with(index: number, value: number): Int8Array { - return this.with(index as int, value as byte) + return this.with(Double.toInt(index), value.toByte()) } /** @@ -1516,7 +1426,7 @@ export final class Int8Array implements Iterable, ArrayLike { public findLast(fn: (val: number) => boolean): number { let newF: (val: number, index: number, array: Int8Array) => boolean = (val: number, index: number, array: Int8Array): boolean => { return fn(val) } - return this.findLast(newF) as number + return (this.findLast(newF)).toDouble() } /** @@ -1545,8 +1455,13 @@ export final class Int8Array implements Iterable, ArrayLike { arr[i] = this.getUnsafe(i) } let cmp = (l: byte, r: byte): number => { - const result = compareFn!(l as number, r as number) - return result + return (l - r).toDouble() + } + if (compareFn != undefined) { + cmp = (l: byte, r: byte): number => { + const result = compareFn!((l).toDouble(), (r).toDouble()) + return result + } } sort(arr, cmp) for (let i = 0; i < this.lengthInt; ++i) { @@ -1567,7 +1482,7 @@ export final class Int8Array implements Iterable, ArrayLike { */ public some(predicate: (element: number, index: number, array: Int8Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; ++i) { - if (predicate(this.getUnsafe(i) as number, i as number, this)) { + if (predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { return true } } @@ -1592,7 +1507,7 @@ export final class Int8Array implements Iterable, ArrayLike { initialValue: U): U { let accumulatedValue = initialValue for (let i = 0; i < this.lengthInt; ++i) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) } return accumulatedValue } @@ -1614,9 +1529,9 @@ export final class Int8Array implements Iterable, ArrayLike { throw new TypeError("Reduce of empty array with no initial value") } - let accumulatedValue = this.getUnsafe(0) as number + let accumulatedValue = (this.getUnsafe(0)).toDouble() for (let i = 1; i < this.lengthInt; ++i) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) } return accumulatedValue } @@ -1639,7 +1554,7 @@ export final class Int8Array implements Iterable, ArrayLike { initialValue: U): U { let accumulatedValue = initialValue for (let i = this.lengthInt - 1; i >= 0; --i) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) } return accumulatedValue } @@ -1662,9 +1577,9 @@ export final class Int8Array implements Iterable, ArrayLike { throw new TypeError("Reduce of empty array with no initial value") } - let accumulatedValue: number = this.getUnsafe(this.lengthInt - 1) as number + let accumulatedValue: number = (this.getUnsafe(this.lengthInt - 1)).toDouble() for (let i = this.lengthInt - 2; i >= 0; --i) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) } return accumulatedValue } @@ -1677,10 +1592,10 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns a new Int8Array where for each element from current Int8Array fn was applied */ public map(fn: (val: number, index: number, array: Int8Array) => number): Int8Array { - let resBuf = new ArrayBuffer(this.lengthInt * Int8Array.BYTES_PER_ELEMENT as int) - let res = new Int8Array(resBuf, 0, resBuf.getByteLength() / Int8Array.BYTES_PER_ELEMENT as int) + let resBuf = new ArrayBuffer(this.lengthInt * Int8Array.BYTES_PER_ELEMENT) + let res = new Int8Array(resBuf, 0, Double.toInt(resBuf.getByteLength() / Int8Array.BYTES_PER_ELEMENT)) for (let i = 0; i < this.lengthInt; ++i) { - res.set(i, fn(this.getUnsafe(i) as number, i as number, this) as byte) + res.set(i, fn((this.getUnsafe(i)).toDouble(), i.toDouble(), this).toByte()) } return res } @@ -1697,7 +1612,7 @@ export final class Int8Array implements Iterable, ArrayLike { */ public every(predicate: (element: number, index: number, array: Int8Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; ++i) { - if (!predicate(this.getUnsafe(i) as number, i as number, this)) { + if (!predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { return false } } @@ -1715,12 +1630,12 @@ export final class Int8Array implements Iterable, ArrayLike { let markers : FixedArray = new boolean[this.lengthInt] let resLen = 0 for (let i = 0; i < this.lengthInt; ++i) { - markers[i] = fn(this.getUnsafe(i) as number, i as number, this) + markers[i] = fn((this.getUnsafe(i)).toDouble(), i.toDouble(), this) if (markers[i]) { ++resLen } } - let resBuf = new ArrayBuffer(resLen * Int8Array.BYTES_PER_ELEMENT as int) + let resBuf = new ArrayBuffer(resLen * Int8Array.BYTES_PER_ELEMENT) let res = new Int8Array(resBuf, 0) for (let i = 0, j = 0; i < this.lengthInt; ++i) { if (markers[i]) { @@ -1744,8 +1659,8 @@ export final class Int8Array implements Iterable, ArrayLike { public find(predicate: (value: number, index: number, obj: Int8Array) => boolean): number | undefined { for (let i = 0; i < this.lengthInt; ++i) { let val = this.getUnsafe(i) - if (predicate(val as number, i as number, this)) { - return val as number + if (predicate((val).toDouble(), i.toDouble(), this)) { + return (val).toDouble() } } return undefined @@ -1763,11 +1678,11 @@ export final class Int8Array implements Iterable, ArrayLike { */ public findIndex(predicate: (value: number, index: number, obj: Int8Array) => boolean): number { for (let i = 0; i < this.lengthInt; ++i) { - if (predicate(this.getUnsafe(i) as number, i as number, this)) { - return i as number + if (predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { + return i.toDouble() } } - return -1 as number + return (-1).toDouble() } /** @@ -1780,7 +1695,7 @@ export final class Int8Array implements Iterable, ArrayLike { public findLast(fn: (val: number, index: number, array: Int8Array) => boolean): byte { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) - if (fn(val as number, i as number, this)) { + if (fn((val).toDouble(), i.toDouble(), this)) { return val } } @@ -1797,11 +1712,11 @@ export final class Int8Array implements Iterable, ArrayLike { public findLastIndex(fn: (val: number, index: number, array: Int8Array) => boolean): number { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) - if (fn(val as number, i as number, this)) { + if (fn((val).toDouble(), i.toDouble(), this)) { return i } } - return -1 as number + return (-1).toDouble() } /** @@ -1814,7 +1729,7 @@ export final class Int8Array implements Iterable, ArrayLike { */ public forEach(callbackfn: (value: number, index: number, array: Int8Array) => void): void { for (let i = 0; i < this.lengthInt; ++i) { - callbackfn(this.getUnsafe(i) as number, i as number, this) + callbackfn((this.getUnsafe(i)).toDouble(), i.toDouble(), this) } } @@ -1828,35 +1743,35 @@ export final class Int8Array implements Iterable, ArrayLike { } internal getUnsafe(index: int): byte { - let byteIndex = index * Int8Array.BYTES_PER_ELEMENT as int + this.byteOffset as int + let byteIndex = index * Int8Array.BYTES_PER_ELEMENT + Double.toInt(this.byteOffset) let res : byte = 0 let byteVal : byte if (IS_LITTLE_ENDIAN) { - for (let i: int = 0; i < Int8Array.BYTES_PER_ELEMENT as int; ++i) { - byteVal = (this.buffer as ArrayBuffer).at(byteIndex as int + i) - res = (res | byteVal << (8 * i)) as byte + for (let i: int = 0; i < Int8Array.BYTES_PER_ELEMENT.toInt(); ++i) { + byteVal = (this.buffer as ArrayBuffer).at(byteIndex.toInt() + i) + res = (res | byteVal << (8 * i)).toByte() } return res } else { - for (let i: int = 0; i < Int8Array.BYTES_PER_ELEMENT as int; ++i) { - byteVal = this.buffer.at(byteIndex as int + 0 - i) - res = (res | byteVal << (8 * i)) as byte + for (let i: int = 0; i < Int8Array.BYTES_PER_ELEMENT.toInt(); ++i) { + byteVal = this.buffer.at(byteIndex.toInt() + 0 - i) + res = (res | byteVal << (8 * i)).toByte() } return res } } internal setUnsafe(insertPos: int, val: byte): void { - let startByte = insertPos * Int8Array.BYTES_PER_ELEMENT as int + this.byteOffset as int + let startByte = insertPos * Int8Array.BYTES_PER_ELEMENT + Double.toInt(this.byteOffset) let bits = val if (IS_LITTLE_ENDIAN) { - for (let i = 0; i < Int8Array.BYTES_PER_ELEMENT as int; ++i) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + for (let i = 0; i < Int8Array.BYTES_PER_ELEMENT.toInt(); ++i) { + let byteVal = ((bits >>> (i * 8)) & 0xff).toByte() this.buffer.set(startByte + i, byteVal) } } else { - for (let i = 0; i < Int8Array.BYTES_PER_ELEMENT as int; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + for (let i = 0; i < Int8Array.BYTES_PER_ELEMENT.toInt(); i++) { + let byteVal = ((bits >>> (i * 8)) & 0xff).toByte() this.buffer.set(startByte + 0 - i, byteVal) } } @@ -1880,7 +1795,7 @@ class Int16ArrayIteratorKeys implements IterableIterator { private idx: int = 0 constructor(parent: Int16Array) { - this.length = parent.length as int + this.length = Double.toInt(parent.length) } public override $_iterator(): IterableIterator { @@ -1891,7 +1806,7 @@ class Int16ArrayIteratorKeys implements IterableIterator { if (this.idx < 0 || this.idx >= this.length) { return new IteratorResult() } - return new IteratorResult(false, this.idx++ as number) + return new IteratorResult(false, Int.toDouble(this.idx++)) } } @@ -1908,7 +1823,7 @@ class Int16ArrayIterator implements IterableIterator { } override next(): IteratorResult { - if (this.idx < 0 || this.idx >= this.parent.length as int) { + if (this.idx < 0 || this.idx >= Double.toInt(this.parent.length)) { return new IteratorResult() } return new IteratorResult(false, new Number(this.parent[this.idx++])) @@ -1928,7 +1843,7 @@ class Int16ArrayIteratorEntries implements IterableIterator<[Number, Number]> { } override next(): IteratorResult<[Number, Number]> { - if (this.idx < 0 || this.idx >= this.parent.length as int) { + if (this.idx < 0 || this.idx >= Double.toInt(this.parent.length)) { return new IteratorResult<[Number, Number]>() } return new IteratorResult<[Number, Number]>( @@ -1942,15 +1857,15 @@ class Int16ArrayIteratorEntries implements IterableIterator<[Number, Number]> { * JS Int16Array API-compatible class */ export final class Int16Array implements Iterable, ArrayLike { - public static readonly BYTES_PER_ELEMENT: number = 2 - public readonly BYTES_PER_ELEMENT: number = Int16Array.BYTES_PER_ELEMENT + public static readonly BYTES_PER_ELEMENT: int = 2 + public readonly BYTES_PER_ELEMENT: int = Int16Array.BYTES_PER_ELEMENT internal readonly lengthInt: int /** * Creates an empty Int16Array. */ public constructor() { - this(0 as int) + this(0) } /** @@ -1960,9 +1875,9 @@ export final class Int16Array implements Iterable, ArrayLike { const items: Object = elements as Object if (items instanceof ArrayLike) { const arr = Types.identity_cast(items as ArrayLike) - this.byteLength = arr.length as int * Int16Array.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int - this.buffer = new ArrayBuffer(this.byteLength as int) + this.byteLength = Double.toInt(arr.length) * Int16Array.BYTES_PER_ELEMENT + this.lengthInt = Double.toInt(arr.length) + this.buffer = new ArrayBuffer(Double.toInt(this.byteLength)) this.byteOffset = 0 for (let i: int = 0; i < this.lengthInt; ++i) { this.setUnsafe(i, arr.$_get(i).toShort()) @@ -1998,27 +1913,27 @@ export final class Int16Array implements Iterable, ArrayLike { throw new RangeError("Range Error: byteLength " + intByteLength + " is outside the bounds of the buffer with byteOffset " + intByteOffset) } - if (intByteLength % Int16Array.BYTES_PER_ELEMENT as int != 0) { + if (intByteLength % Int16Array.BYTES_PER_ELEMENT.toInt() != 0) { throw new RangeError("ArrayBuffer.byteLength should be multiple of 2 as Int16Array.BYTES_PER_ELEMENT") } - if (intByteOffset % Int16Array.BYTES_PER_ELEMENT as int != 0) { + if (intByteOffset % Int16Array.BYTES_PER_ELEMENT != 0) { throw new RangeError("byteOffset should be multiple of 2 as Int16Array.BYTES_PER_ELEMENT") } let intLength: int if (length != undefined) { intLength = length.toInt() - if (intLength > intByteLength / Int16Array.BYTES_PER_ELEMENT as int) { + if (intLength > Double.toInt(intByteLength / Int16Array.BYTES_PER_ELEMENT)) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer with byteOffset " + intByteOffset) } } else { - intLength = intByteLength / Int16Array.BYTES_PER_ELEMENT as int + intLength = Double.toInt(intByteLength / Int16Array.BYTES_PER_ELEMENT) } if (intLength < 0) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer") } - if (intLength < intByteLength / Int16Array.BYTES_PER_ELEMENT as int) { - intByteLength = intLength * Int16Array.BYTES_PER_ELEMENT as int + if (intLength < Double.toInt(intByteLength / Int16Array.BYTES_PER_ELEMENT)) { + intByteLength = intLength * Int16Array.BYTES_PER_ELEMENT } this.byteLength = intByteLength this.byteOffset = intByteOffset @@ -2026,32 +1941,6 @@ export final class Int16Array implements Iterable, ArrayLike { this.buffer = buf } - /** - * Creates an Int16Array with respect to data, byteOffset and length. - * - * @param buf data initializer - * - * @param byteOffset byte offset from begin of the buf - * - * @param length size of elements of type short in newly created Int16Array - */ - public constructor(buf: ArrayBuffer, byteOffset: Number | undefined) { - this(buf, byteOffset, undefined) - } - - /** - * Creates an Int16Array with respect to data, byteOffset and length. - * - * @param buf data initializer - * - * @param byteOffset byte offset from begin of the buf - * - * @param length size of elements of type short in newly created Int16Array - */ - public constructor(buf: ArrayBuffer, byteOffset: number, length: number) { - this(buf, new Number(byteOffset), new Number(length)) - } - /** * Creates an Int16Array with respect to data, byteOffset and length. * @@ -2097,19 +1986,19 @@ export final class Int16Array implements Iterable, ArrayLike { public constructor(buf: ArrayLike | ArrayBuffer) { if (buf instanceof ArrayBuffer) { this.byteLength = (buf as ArrayBuffer).getByteLength() - if (this.byteLength % Int16Array.BYTES_PER_ELEMENT as int != 0) { + if (this.byteLength % Int16Array.BYTES_PER_ELEMENT.toInt() != 0) { throw new RangeError("ArrayBuffer.byteLength should be multiple of 2 as Int16Array.BYTES_PER_ELEMENT") } - this.lengthInt = this.byteLength / Int16Array.BYTES_PER_ELEMENT as int + this.lengthInt = Double.toInt(this.byteLength / Int16Array.BYTES_PER_ELEMENT) this.buffer = buf as ArrayBuffer this.byteOffset = 0 } else if (buf instanceof ArrayLike) { // NOTE (ikorobkov): dealing with this overload is tricky // with banned `instanceof` generic, so it is delegated to array here. Initial idea from Set.ets let arr = Array.from((buf as ArrayLike)) - this.byteLength = arr.length as int * Int16Array.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int - this.buffer = new ArrayBuffer(this.byteLength as int) + this.byteLength = arr.length.toInt() * Int16Array.BYTES_PER_ELEMENT.toInt() + this.lengthInt = arr.length.toInt() + this.buffer = new ArrayBuffer(this.byteLength.toInt()) this.byteOffset = 0 for (let i: int = 0; i < this.lengthInt; ++i) { this.setUnsafe(i, arr.$_get(i).toShort()) @@ -2125,7 +2014,7 @@ export final class Int16Array implements Iterable, ArrayLike { * @param length data initializer */ public constructor(length: int) { - this(length as number) + this(Int.toDouble(length)) } /** @@ -2134,13 +2023,13 @@ export final class Int16Array implements Iterable, ArrayLike { * @param length data initializer */ public constructor(length: number) { - if (length < 0 || length > (Int.MAX_VALUE / Int16Array.BYTES_PER_ELEMENT)) { + if (length < 0 || length > Double.toInt(Int.MAX_VALUE / Int16Array.BYTES_PER_ELEMENT)) { throw new TypeError("Type Error: length " + length + " is outside the bounds of the buffer") } - this.lengthInt = length as int - this.byteLength = this.lengthInt * Int16Array.BYTES_PER_ELEMENT as int + this.lengthInt = Double.toInt(length) + this.byteLength = this.lengthInt * Int16Array.BYTES_PER_ELEMENT this.byteOffset = 0 - this.buffer = new ArrayBuffer(this.byteLength as int) + this.buffer = new ArrayBuffer(this.byteLength.toInt()) } /** @@ -2149,9 +2038,9 @@ export final class Int16Array implements Iterable, ArrayLike { * @param other data initializer */ public constructor(other: Int16Array) { - this.buffer = other.buffer.slice(other.byteOffset as int, (other.byteOffset + other.byteLength) as int) as ArrayBuffer + this.buffer = other.buffer.slice(other.byteOffset.toInt(), (other.byteOffset + other.byteLength).toInt()) as ArrayBuffer this.byteLength = other.byteLength - this.lengthInt = other.length as int + this.lengthInt = Double.toInt(other.length) this.byteOffset = 0 } @@ -2161,7 +2050,7 @@ export final class Int16Array implements Iterable, ArrayLike { public constructor(numbers: FixedArray) { this(numbers.length) for (let i: int = 0; i < this.lengthInt; ++i) { - this.setUnsafe(i, this.zeroIfInfinity(numbers[i]) as short) + this.setUnsafe(i, this.zeroIfInfinity(numbers[i]).toShort()) } } @@ -2171,20 +2060,20 @@ export final class Int16Array implements Iterable, ArrayLike { public constructor(numbers: FixedArray) { this(numbers.length) for (let i: int = 0; i < this.lengthInt; ++i) { - this.setUnsafe(i, this.zeroIfInfinity(numbers[i]) as short) + this.setUnsafe(i, this.zeroIfInfinity(numbers[i]).toShort()) } } internal zeroIfInfinity(val: number): number { if ((val == Infinity) || (val == -Infinity)) { - return 0 as number + return 0 } - return val as number + return (val).toDouble() } internal zeroIfInfinity(val: short): short { if ((val == Infinity) || (val == -Infinity)) { - return 0 as short + return Int.toShort(0) } return val } @@ -2197,7 +2086,7 @@ export final class Int16Array implements Iterable, ArrayLike { * @param index index to change */ public $_set(index: number, val: number): void { - this.$_set(index as int, val) + this.$_set(Double.toInt(index), val) } /** @@ -2209,7 +2098,7 @@ export final class Int16Array implements Iterable, ArrayLike { */ public $_set(index: int, val: number): void { let v = this.zeroIfInfinity(val) - this.$_set(index, v as short) + this.$_set(index, v.toShort()) } /** @@ -2220,7 +2109,7 @@ export final class Int16Array implements Iterable, ArrayLike { * @param index index to change */ public $_set(index: number, val: int): void { - this.$_set(index as int, val) + this.$_set(Double.toInt(index), val) } /** @@ -2240,7 +2129,7 @@ export final class Int16Array implements Iterable, ArrayLike { * @param index index to change */ public $_set(index: number, val: short): void { - this.$_set(index as int, val) + this.$_set(Double.toInt(index), val) } /** @@ -2265,7 +2154,7 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns a primitive at index */ public override $_get(index: number): Number { - return this.$_get(index as int) as Number + return this.$_get(Double.toInt(index)) } /** @@ -2285,7 +2174,7 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns a primitive at index */ public at(index: number): Number | undefined { - return this.at(index as int) + return this.at(Double.toInt(index)) } /** @@ -2320,7 +2209,7 @@ export final class Int16Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: number, start: number, end?: number): Int16Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(Double.toInt(target), Double.toInt(start), asIntOrDefault(end, this.lengthInt)) } /** @@ -2335,7 +2224,7 @@ export final class Int16Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: int, start: number, end?: number): Int16Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target, Double.toInt(start), asIntOrDefault(end, this.lengthInt)) } /** @@ -2350,7 +2239,7 @@ export final class Int16Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: number, start: int, end?: number): Int16Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(Double.toInt(target), start, asIntOrDefault(end, this.lengthInt)) } /** @@ -2365,7 +2254,7 @@ export final class Int16Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: int, start: int, end?: number): Int16Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target, start, asIntOrDefault(end, this.lengthInt)) } /** @@ -2390,7 +2279,7 @@ export final class Int16Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} */ public copyWithin(target: number): Int16Array { - return this.copyWithin(target as int) + return this.copyWithin(Double.toInt(target)) } /** @@ -2423,7 +2312,7 @@ export final class Int16Array implements Iterable, ArrayLike { */ public fill(value: number, start?: number, end?: number): this { value = this.zeroIfInfinity(value) - this.fill(value as short, asIntOrDefault(start, 0 as int), asIntOrDefault(end, this.lengthInt)) + this.fill(value.toShort(), asIntOrDefault(start, 0), asIntOrDefault(end, this.lengthInt)) return this } @@ -2436,20 +2325,7 @@ export final class Int16Array implements Iterable, ArrayLike { */ public fill(value: number, start: int, end?: number): this { value = this.zeroIfInfinity(value) - this.fill(value as short, start as int, asIntOrDefault(end, this.lengthInt)) - return this - } - - /** - * Fills the Int16Array with specified value - * - * @param value new valuy - * - * @returns modified Int16Array - */ - public fill(value: number, start: int, end: number): this { - value = this.zeroIfInfinity(value) - this.fill(value as short, start as int, end as int) + this.fill(value.toShort(), start, asIntOrDefault(end, this.lengthInt)) return this } @@ -2462,7 +2338,7 @@ export final class Int16Array implements Iterable, ArrayLike { */ public fill(value: number, start: number, end: int): this { value = this.zeroIfInfinity(value) - this.fill(value as short, start as int, end as int) + this.fill(value.toShort(), Double.toInt(start), end) return this } @@ -2475,7 +2351,7 @@ export final class Int16Array implements Iterable, ArrayLike { */ public fill(value: number, start: int, end: int): this { value = this.zeroIfInfinity(value) - this.fill(value as short, start as int, end as int) + this.fill(value.toShort(), start, end) return this } @@ -2487,7 +2363,7 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns modified Int16Array */ public fill(value: short, start?: number, end?: number): this { - this.fill(value, asIntOrDefault(start, 0 as int), asIntOrDefault(end, this.lengthInt)) + this.fill(value, asIntOrDefault(start, 0), asIntOrDefault(end, this.lengthInt)) return this } @@ -2499,19 +2375,7 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns modified Int16Array */ public fill(value: short, start: int, end?: number): this { - this.fill(value, start as int, asIntOrDefault(end, this.lengthInt)) - return this - } - - /** - * Fills the Int16Array with specified value - * - * @param value new valuy - * - * @returns modified Int16Array - */ - public fill(value: short, start: int, end: number): this { - this.fill(value, start as int, end as int) + this.fill(value, start, asIntOrDefault(end, this.lengthInt)) return this } @@ -2523,7 +2387,7 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns modified Int16Array */ public fill(value: short, start: number, end: int): this { - this.fill(value, start as int, end as int) + this.fill(value, Double.toInt(start), end) return this } @@ -2577,13 +2441,13 @@ export final class Int16Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ public set(arr: FixedArray, insertPos: number): void { - const offset = insertPos as int + const offset = Double.toInt(insertPos) if (offset < 0 || offset + arr.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } - for (let i = 0; i < arr.length as int; ++i) { + for (let i = 0; i < Double.toInt(arr.length); ++i) { let v = this.zeroIfInfinity(arr[i]) - this.$_set(offset + i, v as short) + this.$_set(offset + i, v.toShort()) } } @@ -2597,11 +2461,11 @@ export final class Int16Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ public set(arr: FixedArray, insertPos: int): void { - const offset = insertPos as int + const offset = insertPos if (offset < 0 || offset + arr.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } - for (let i = 0; i < arr.length as int; ++i) { + for (let i = 0; i < Double.toInt(arr.length); ++i) { let v = this.zeroIfInfinity(arr[i]) this.$_set(offset + i, v) } @@ -2613,7 +2477,7 @@ export final class Int16Array implements Iterable, ArrayLike { * @param arr array to copy data from */ public set(arr: FixedArray): void { - this.set(arr, 0 as number) + this.set(arr, 0) } /** @@ -2622,7 +2486,7 @@ export final class Int16Array implements Iterable, ArrayLike { * @param arr array to copy data from */ public set(arr: FixedArray): void { - this.set(arr, 0 as int) + this.set(arr, 0) } public native set(array: Int16Array): void @@ -2637,13 +2501,13 @@ export final class Int16Array implements Iterable, ArrayLike { * @param offset Optional. The offset into the target array at which to begin writing values from the source array */ public set(array: ArrayLike, offset: number = 0): void { - const insertPos = offset as int + const insertPos = Double.toInt(offset) if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } - for (let i = array.length - 1 as int; i >= 0; --i) { + for (let i = Double.toInt(array.length) - 1; i >= 0; --i) { let v = this.zeroIfInfinity(array[i]) - this.$_set(insertPos + i, v as short) + this.$_set(insertPos + i, v.toShort()) } } @@ -2655,9 +2519,9 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns new Int16Array */ public static of(...items: FixedArray): Int16Array { - let res = new Int16Array(items.length as int) + let res = new Int16Array(Double.toInt(items.length)) for (let i: int = 0; i < items.length; i++) { - res.setUnsafe(i, res.zeroIfInfinity(items[i]) as short) + res.setUnsafe(i, res.zeroIfInfinity(items[i]).toShort()) } return res } @@ -2670,9 +2534,9 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns new Int16Array */ public static of(...items: FixedArray): Int16Array { - let res = new Int16Array(items.length as int) + let res = new Int16Array(Double.toInt(items.length)) for (let i: int = 0; i < items.length; i++) { - res.setUnsafe(i, items[i] as short) + res.setUnsafe(i, items[i].toShort()) } return res } @@ -2685,7 +2549,7 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns new Int16Array */ public static of(...items: FixedArray): Int16Array { - let res = new Int16Array(items.length as int) + let res = new Int16Array(Double.toInt(items.length)) for (let i: int = 0; i < items.length; i++) { res.setUnsafe(i, items[i]) } @@ -2700,7 +2564,7 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns new Int16Array */ public static of(): Int16Array { - return new Int16Array(0 as int) + return new Int16Array(0) } /** @@ -2741,7 +2605,7 @@ export final class Int16Array implements Iterable, ArrayLike { if (x.done) { return new Int16Array(result.buffer, 0, i) } - result.setUnsafe(i, result.zeroIfInfinity((mapfn)!(x.value!, i)) as short) + result.setUnsafe(i, result.zeroIfInfinity((mapfn)!(x.value!, i)).toShort()) } return result } @@ -2761,7 +2625,7 @@ export final class Int16Array implements Iterable, ArrayLike { } temp = new Int16Array(tb) } - temp.setUnsafe(index[0], temp.zeroIfInfinity((mapfn)!(x, index[0])) as short) + temp.setUnsafe(index[0], temp.zeroIfInfinity((mapfn)!(x, index[0])).toShort()) index[0]++ }) return new Int16Array(temp.buffer, 0, index[0]) @@ -2783,7 +2647,7 @@ export final class Int16Array implements Iterable, ArrayLike { const idx : FixedArray = new int[1] idx[0] = 0 iteratorForEach(arrayLike.$_iterator(), (x: T): void => { - res.setUnsafe(idx[0] as int, res.zeroIfInfinity(mapfn(x as T, idx[0] as number)) as short) + res.setUnsafe(idx[0], res.zeroIfInfinity(mapfn(x as T, Int.toDouble(idx[0])).toShort())) idx[0] += 1 }) return res @@ -2815,7 +2679,7 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns true if e is in Int16Array, false otherwise */ public includes(searchElement: short, fromIndex: int): boolean { - return this.indexOf(searchElement as int, fromIndex) != -1 + return this.indexOf(searchElement.toInt(), fromIndex) != -1 } /** @@ -2870,7 +2734,7 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns index of element if it presents, -1 otherwise */ public indexOf(searchElement: int, fromIndex: int): number { - return this.indexOfImpl(searchElement as long, fromIndex) + return this.indexOfImpl(Int.toLong(searchElement), fromIndex) } /** @@ -2997,7 +2861,7 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ public lastIndexOf(searchElement: int, fromIndex: int): number { - return this.lastIndexOfImpl(searchElement as long, fromIndex) + return this.lastIndexOfImpl(Int.toLong(searchElement), fromIndex) } /** @@ -3068,22 +2932,7 @@ export final class Int16Array implements Iterable, ArrayLike { * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin?: number, end?: number): Int16Array { - return this.slice(asIntOrDefault(begin, 0 as int), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Creates a slice of current Int16Array using range [begin, end) - * - * @param begin start index to be taken into slice - * - * @param end last index to be taken into slice - * - * @returns a new Int16Array with elements of current Int16Array[begin;end) where end index is excluded - * - * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice - */ - public slice(begin: number, end: number): Int16Array { - return this.slice(begin as int, end as int) + return this.slice(asIntOrDefault(begin, 0), asIntOrDefault(end, this.lengthInt)) } /** @@ -3098,7 +2947,7 @@ export final class Int16Array implements Iterable, ArrayLike { * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin: number, end: int): Int16Array { - return this.slice(begin as int, end as int) + return this.slice(Double.toInt(begin), end) } /** @@ -3113,7 +2962,7 @@ export final class Int16Array implements Iterable, ArrayLike { * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin: int, end: number): Int16Array { - return this.slice(begin as int, end as int) + return this.slice(begin, Double.toInt(end)) } /** @@ -3135,21 +2984,10 @@ export final class Int16Array implements Iterable, ArrayLike { if (count < 0) { count = 0 } - let buf = this.buffer.slice(relStart * Int16Array.BYTES_PER_ELEMENT as int, relEnd * Int16Array.BYTES_PER_ELEMENT as int) as ArrayBuffer + let buf = this.buffer.slice(relStart * Int16Array.BYTES_PER_ELEMENT.toInt(), relEnd * Int16Array.BYTES_PER_ELEMENT.toInt()) as ArrayBuffer return new Int16Array(buf) } - /** - * Creates a slice of current Int16Array using range [begin, this.length). - * - * @param begin start index to be taken into slice - * - * @returns a new Int16Array with elements of current Int16Array[begin, this.length) - */ - public slice(begin: number): Int16Array { - return this.slice(begin as int) - } - /** * Creates a slice of current Int16Array using range [begin, this.length). * @@ -3174,19 +3012,6 @@ export final class Int16Array implements Iterable, ArrayLike { return this.subarray(asIntOrDefault(begin, 0 as int), asIntOrDefault(end, this.lengthInt)) } - /** - * Creates a Int16Array with the same underlying ArrayBuffer - * - * @param begin start index, inclusive - * - * @param end last index, exclusive - * - * @returns new Int16Array with the same underlying ArrayBuffer - */ - public subarray(begin: number, end: number): Int16Array { - return this.subarray(begin as int, end as int) - } - /** * Creates a Int16Array with the same underlying ArrayBuffer * @@ -3197,7 +3022,7 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns new Int16Array with the same underlying ArrayBuffer */ public subarray(begin: number, end: int): Int16Array { - return this.subarray(begin as int, end as int) + return this.subarray(Double.toInt(begin), end) } /** @@ -3210,7 +3035,7 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns new Int16Array with the same underlying ArrayBuffer */ public subarray(begin: int, end: number): Int16Array { - return this.subarray(begin as int, end as int) + return this.subarray(begin, Double.toInt(end)) } /** @@ -3230,7 +3055,7 @@ export final class Int16Array implements Iterable, ArrayLike { if (count < 0) { count = 0 } - return new Int16Array(this.buffer, relStart * Int16Array.BYTES_PER_ELEMENT as int, count) + return new Int16Array(this.buffer, relStart * Int16Array.BYTES_PER_ELEMENT.toInt(), count) } /** @@ -3241,7 +3066,7 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns new Int16Array with the same ArrayBuffer */ public subarray(begin: number): Int16Array { - return this.subarray(begin as int, this.lengthInt) + return this.subarray(begin.toInt(), this.lengthInt) } /** @@ -3252,7 +3077,7 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns new Int16Array with the same ArrayBuffer */ public subarray(begin: int): Int16Array { - return this.subarray(begin as int, this.lengthInt) + return this.subarray(begin, this.lengthInt) } /** @@ -3287,11 +3112,11 @@ export final class Int16Array implements Iterable, ArrayLike { public toLocaleString(): string { let res: StringBuilder = new StringBuilder("") for (let i = 0; i < this.lengthInt - 1; ++i) { - res.append((this.getUnsafe(i) as Number).toLocaleString()) + res.append(new Number(this.getUnsafe(i)).toLocaleString()) res.append(",") } if (this.lengthInt > 0) { - res.append((this.getUnsafe(this.lengthInt - 1) as Number).toLocaleString()) + res.append(new Number(this.getUnsafe(this.lengthInt - 1))).toLocaleString() } return res.toString() } @@ -3351,7 +3176,7 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns an Int16Array with replaced value on index */ public with(index: number, value: number): Int16Array { - return this.with(index as int, value as short) + return this.with(Double.toInt(index), value.toShort()) } /** @@ -3381,7 +3206,7 @@ export final class Int16Array implements Iterable, ArrayLike { public findLast(fn: (val: number) => boolean): number { let newF: (val: number, index: number, array: Int16Array) => boolean = (val: number, index: number, array: Int16Array): boolean => { return fn(val) } - return this.findLast(newF) as number + return (this.findLast(newF)).toDouble() } /** @@ -3410,8 +3235,13 @@ export final class Int16Array implements Iterable, ArrayLike { arr[i] = this.getUnsafe(i) } let cmp = (l: short, r: short): number => { - const result = compareFn!(l as number, r as number) - return result + return (l - r).toDouble() + } + if (compareFn != undefined) { + cmp = (l: short, r: short): number => { + const result = compareFn!((l).toDouble(), (r).toDouble()) + return result + } } sort(arr, cmp) for (let i = 0; i < this.lengthInt; ++i) { @@ -3432,7 +3262,7 @@ export final class Int16Array implements Iterable, ArrayLike { */ public some(predicate: (element: number, index: number, array: Int16Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; ++i) { - if (predicate(this.getUnsafe(i) as number, i as number, this)) { + if (predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { return true } } @@ -3457,7 +3287,7 @@ export final class Int16Array implements Iterable, ArrayLike { initialValue: U): U { let accumulatedValue = initialValue for (let i = 0; i < this.lengthInt; ++i) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) } return accumulatedValue } @@ -3479,9 +3309,9 @@ export final class Int16Array implements Iterable, ArrayLike { throw new TypeError("Reduce of empty array with no initial value") } - let accumulatedValue = this.getUnsafe(0) as number + let accumulatedValue = (this.getUnsafe(0)).toDouble() for (let i = 1; i < this.lengthInt; ++i) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) } return accumulatedValue } @@ -3504,7 +3334,7 @@ export final class Int16Array implements Iterable, ArrayLike { initialValue: U): U { let accumulatedValue = initialValue for (let i = this.lengthInt - 1; i >= 0; --i) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) } return accumulatedValue } @@ -3527,9 +3357,9 @@ export final class Int16Array implements Iterable, ArrayLike { throw new TypeError("Reduce of empty array with no initial value") } - let accumulatedValue: number = this.getUnsafe(this.lengthInt - 1) as number + let accumulatedValue: number = (this.getUnsafe(this.lengthInt - 1)).toDouble() for (let i = this.lengthInt - 2; i >= 0; --i) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) } return accumulatedValue } @@ -3542,10 +3372,10 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns a new Int16Array where for each element from current Int16Array fn was applied */ public map(fn: (val: number, index: number, array: Int16Array) => number): Int16Array { - let resBuf = new ArrayBuffer(this.lengthInt * Int16Array.BYTES_PER_ELEMENT as int) - let res = new Int16Array(resBuf, 0, resBuf.getByteLength() / Int16Array.BYTES_PER_ELEMENT as int) + let resBuf = new ArrayBuffer(this.lengthInt * Int16Array.BYTES_PER_ELEMENT) + let res = new Int16Array(resBuf, 0, Double.toInt(resBuf.getByteLength() / Int16Array.BYTES_PER_ELEMENT)) for (let i = 0; i < this.lengthInt; ++i) { - res.set(i, fn(this.getUnsafe(i) as number, i as number, this) as short) + res.set(i, fn((this.getUnsafe(i)).toDouble(), i.toDouble(), this).toShort()) } return res } @@ -3562,7 +3392,7 @@ export final class Int16Array implements Iterable, ArrayLike { */ public every(predicate: (element: number, index: number, array: Int16Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; ++i) { - if (!predicate(this.getUnsafe(i) as number, i as number, this)) { + if (!predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { return false } } @@ -3580,12 +3410,12 @@ export final class Int16Array implements Iterable, ArrayLike { let markers : FixedArray = new boolean[this.lengthInt] let resLen = 0 for (let i = 0; i < this.lengthInt; ++i) { - markers[i] = fn(this.getUnsafe(i) as number, i as number, this) + markers[i] = fn((this.getUnsafe(i)).toDouble(), i.toDouble(), this) if (markers[i]) { ++resLen } } - let resBuf = new ArrayBuffer(resLen * Int16Array.BYTES_PER_ELEMENT as int) + let resBuf = new ArrayBuffer(resLen * Int16Array.BYTES_PER_ELEMENT) let res = new Int16Array(resBuf, 0) for (let i = 0, j = 0; i < this.lengthInt; ++i) { if (markers[i]) { @@ -3609,8 +3439,8 @@ export final class Int16Array implements Iterable, ArrayLike { public find(predicate: (value: number, index: number, obj: Int16Array) => boolean): number | undefined { for (let i = 0; i < this.lengthInt; ++i) { let val = this.getUnsafe(i) - if (predicate(val as number, i as number, this)) { - return val as number + if (predicate((val).toDouble(), i.toDouble(), this)) { + return (val).toDouble() } } return undefined @@ -3628,11 +3458,11 @@ export final class Int16Array implements Iterable, ArrayLike { */ public findIndex(predicate: (value: number, index: number, obj: Int16Array) => boolean): number { for (let i = 0; i < this.lengthInt; ++i) { - if (predicate(this.getUnsafe(i) as number, i as number, this)) { - return i as number + if (predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { + return i.toDouble() } } - return -1 as number + return (-1).toDouble() } /** @@ -3645,7 +3475,7 @@ export final class Int16Array implements Iterable, ArrayLike { public findLast(fn: (val: number, index: number, array: Int16Array) => boolean): short { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) - if (fn(val as number, i as number, this)) { + if (fn((val).toDouble(), i.toDouble(), this)) { return val } } @@ -3662,11 +3492,11 @@ export final class Int16Array implements Iterable, ArrayLike { public findLastIndex(fn: (val: number, index: number, array: Int16Array) => boolean): number { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) - if (fn(val as number, i as number, this)) { + if (fn((val).toDouble(), i.toDouble(), this)) { return i } } - return -1 as number + return (-1).toDouble() } /** @@ -3679,7 +3509,7 @@ export final class Int16Array implements Iterable, ArrayLike { */ public forEach(callbackfn: (value: number, index: number, array: Int16Array) => void): void { for (let i = 0; i < this.lengthInt; ++i) { - callbackfn(this.getUnsafe(i) as number, i as number, this) + callbackfn((this.getUnsafe(i)).toDouble(), i.toDouble(), this) } } @@ -3693,37 +3523,37 @@ export final class Int16Array implements Iterable, ArrayLike { } internal getUnsafe(index: int): short { - let byteIndex = index * Int16Array.BYTES_PER_ELEMENT as int + this.byteOffset as int + let byteIndex = index * Int16Array.BYTES_PER_ELEMENT + Double.toInt(this.byteOffset) let res : short = 0 let byteVal : short if (IS_LITTLE_ENDIAN) { - for (let i: int = 0; i < Int16Array.BYTES_PER_ELEMENT as int; ++i) { - byteVal = (this.buffer as ArrayBuffer).at(byteIndex as int + i) + for (let i: int = 0; i < Int16Array.BYTES_PER_ELEMENT.toInt(); ++i) { + byteVal = (this.buffer as ArrayBuffer).at(byteIndex.toInt() + i) byteVal &= 0xff - res = (res | byteVal << (8 * i)) as short + res = (res | byteVal << (8 * i)).toShort() } return res } else { - for (let i: int = 0; i < Int16Array.BYTES_PER_ELEMENT as int; ++i) { - byteVal = this.buffer.at(byteIndex as int + 1 - i) + for (let i: int = 0; i < Int16Array.BYTES_PER_ELEMENT.toInt(); ++i) { + byteVal = this.buffer.at(byteIndex.toInt() + 1 - i) byteVal &= 0xff - res = (res | byteVal << (8 * i)) as short + res = (res | byteVal << (8 * i)).toShort() } return res } } internal setUnsafe(insertPos: int, val: short): void { - let startByte = insertPos * Int16Array.BYTES_PER_ELEMENT as int + this.byteOffset as int + let startByte = insertPos * Int16Array.BYTES_PER_ELEMENT + Double.toInt(this.byteOffset) let bits = val if (IS_LITTLE_ENDIAN) { - for (let i = 0; i < Int16Array.BYTES_PER_ELEMENT as int; ++i) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + for (let i = 0; i < Int16Array.BYTES_PER_ELEMENT.toInt(); ++i) { + let byteVal = ((bits >>> (i * 8)) & 0xff).toByte() this.buffer.set(startByte + i, byteVal) } } else { - for (let i = 0; i < Int16Array.BYTES_PER_ELEMENT as int; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + for (let i = 0; i < Int16Array.BYTES_PER_ELEMENT.toInt(); i++) { + let byteVal = ((bits >>> (i * 8)) & 0xff).toByte() this.buffer.set(startByte + 1 - i, byteVal) } } @@ -3747,7 +3577,7 @@ class Int32ArrayIteratorKeys implements IterableIterator { private idx: int = 0 constructor(parent: Int32Array) { - this.length = parent.length as int + this.length = Double.toInt(parent.length) } public override $_iterator(): IterableIterator { @@ -3758,7 +3588,7 @@ class Int32ArrayIteratorKeys implements IterableIterator { if (this.idx < 0 || this.idx >= this.length) { return new IteratorResult() } - return new IteratorResult(false, this.idx++ as number) + return new IteratorResult(false, Int.toDouble(this.idx++)) } } @@ -3775,7 +3605,7 @@ class Int32ArrayIterator implements IterableIterator { } override next(): IteratorResult { - if (this.idx < 0 || this.idx >= this.parent.length as int) { + if (this.idx < 0 || this.idx >= Double.toInt(this.parent.length)) { return new IteratorResult() } return new IteratorResult(false, new Number(this.parent[this.idx++])) @@ -3795,7 +3625,7 @@ class Int32ArrayIteratorEntries implements IterableIterator<[Number, Number]> { } override next(): IteratorResult<[Number, Number]> { - if (this.idx < 0 || this.idx >= this.parent.length as int) { + if (this.idx < 0 || this.idx >= Double.toInt(this.parent.length)) { return new IteratorResult<[Number, Number]>() } return new IteratorResult<[Number, Number]>( @@ -3809,15 +3639,15 @@ class Int32ArrayIteratorEntries implements IterableIterator<[Number, Number]> { * JS Int32Array API-compatible class */ export final class Int32Array implements Iterable, ArrayLike { - public static readonly BYTES_PER_ELEMENT: number = 4 - public readonly BYTES_PER_ELEMENT: number = Int32Array.BYTES_PER_ELEMENT + public static readonly BYTES_PER_ELEMENT: int = 4 + public readonly BYTES_PER_ELEMENT: int = Int32Array.BYTES_PER_ELEMENT internal readonly lengthInt: int /** * Creates an empty Int32Array. */ public constructor() { - this(0 as int) + this(0) } /** @@ -3827,9 +3657,9 @@ export final class Int32Array implements Iterable, ArrayLike { const items: Object = elements as Object if (items instanceof ArrayLike) { const arr = Types.identity_cast(items as ArrayLike) - this.byteLength = arr.length as int * Int32Array.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int - this.buffer = new ArrayBuffer(this.byteLength as int) + this.byteLength = Double.toInt(arr.length) * Int32Array.BYTES_PER_ELEMENT + this.lengthInt = Double.toInt(arr.length) + this.buffer = new ArrayBuffer(Double.toInt(this.byteLength)) this.byteOffset = 0 for (let i: int = 0; i < this.lengthInt; ++i) { this.setUnsafe(i, arr.$_get(i).toInt()) @@ -3865,27 +3695,27 @@ export final class Int32Array implements Iterable, ArrayLike { throw new RangeError("Range Error: byteLength " + intByteLength + " is outside the bounds of the buffer with byteOffset " + intByteOffset) } - if (intByteLength % Int32Array.BYTES_PER_ELEMENT as int != 0) { + if (intByteLength % Int32Array.BYTES_PER_ELEMENT.toInt() != 0) { throw new RangeError("ArrayBuffer.byteLength should be multiple of 4 as Int32Array.BYTES_PER_ELEMENT") } - if (intByteOffset % Int32Array.BYTES_PER_ELEMENT as int != 0) { + if (intByteOffset % Int32Array.BYTES_PER_ELEMENT != 0) { throw new RangeError("byteOffset should be multiple of 4 as Int32Array.BYTES_PER_ELEMENT") } let intLength: int if (length != undefined) { intLength = length.toInt() - if (intLength > intByteLength / Int32Array.BYTES_PER_ELEMENT as int) { + if (intLength > Double.toInt(intByteLength / Int32Array.BYTES_PER_ELEMENT)) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer with byteOffset " + intByteOffset) } } else { - intLength = intByteLength / Int32Array.BYTES_PER_ELEMENT as int + intLength = Double.toInt(intByteLength / Int32Array.BYTES_PER_ELEMENT) } if (intLength < 0) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer") } - if (intLength < intByteLength / Int32Array.BYTES_PER_ELEMENT as int) { - intByteLength = intLength * Int32Array.BYTES_PER_ELEMENT as int + if (intLength < Double.toInt(intByteLength / Int32Array.BYTES_PER_ELEMENT)) { + intByteLength = intLength * Int32Array.BYTES_PER_ELEMENT } this.byteLength = intByteLength this.byteOffset = intByteOffset @@ -3893,32 +3723,6 @@ export final class Int32Array implements Iterable, ArrayLike { this.buffer = buf } - /** - * Creates an Int32Array with respect to data, byteOffset and length. - * - * @param buf data initializer - * - * @param byteOffset byte offset from begin of the buf - * - * @param length size of elements of type int in newly created Int32Array - */ - public constructor(buf: ArrayBuffer, byteOffset: Number | undefined) { - this(buf, byteOffset, undefined) - } - - /** - * Creates an Int32Array with respect to data, byteOffset and length. - * - * @param buf data initializer - * - * @param byteOffset byte offset from begin of the buf - * - * @param length size of elements of type int in newly created Int32Array - */ - public constructor(buf: ArrayBuffer, byteOffset: number, length: number) { - this(buf, new Number(byteOffset), new Number(length)) - } - /** * Creates an Int32Array with respect to data, byteOffset and length. * @@ -3964,19 +3768,19 @@ export final class Int32Array implements Iterable, ArrayLike { public constructor(buf: ArrayLike | ArrayBuffer) { if (buf instanceof ArrayBuffer) { this.byteLength = (buf as ArrayBuffer).getByteLength() - if (this.byteLength % Int32Array.BYTES_PER_ELEMENT as int != 0) { + if (this.byteLength % Int32Array.BYTES_PER_ELEMENT.toInt() != 0) { throw new RangeError("ArrayBuffer.byteLength should be multiple of 4 as Int32Array.BYTES_PER_ELEMENT") } - this.lengthInt = this.byteLength / Int32Array.BYTES_PER_ELEMENT as int + this.lengthInt = Double.toInt(this.byteLength / Int32Array.BYTES_PER_ELEMENT) this.buffer = buf as ArrayBuffer this.byteOffset = 0 } else if (buf instanceof ArrayLike) { // NOTE (ikorobkov): dealing with this overload is tricky // with banned `instanceof` generic, so it is delegated to array here. Initial idea from Set.ets let arr = Array.from((buf as ArrayLike)) - this.byteLength = arr.length as int * Int32Array.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int - this.buffer = new ArrayBuffer(this.byteLength as int) + this.byteLength = arr.length.toInt() * Int32Array.BYTES_PER_ELEMENT.toInt() + this.lengthInt = arr.length.toInt() + this.buffer = new ArrayBuffer(this.byteLength.toInt()) this.byteOffset = 0 for (let i: int = 0; i < this.lengthInt; ++i) { this.setUnsafe(i, arr.$_get(i).toInt()) @@ -3992,7 +3796,7 @@ export final class Int32Array implements Iterable, ArrayLike { * @param length data initializer */ public constructor(length: int) { - this(length as number) + this(Int.toDouble(length)) } /** @@ -4001,13 +3805,13 @@ export final class Int32Array implements Iterable, ArrayLike { * @param length data initializer */ public constructor(length: number) { - if (length < 0 || length > (Int.MAX_VALUE / Int32Array.BYTES_PER_ELEMENT)) { + if (length < 0 || length > Double.toInt(Int.MAX_VALUE / Int32Array.BYTES_PER_ELEMENT)) { throw new TypeError("Type Error: length " + length + " is outside the bounds of the buffer") } - this.lengthInt = length as int - this.byteLength = this.lengthInt * Int32Array.BYTES_PER_ELEMENT as int + this.lengthInt = Double.toInt(length) + this.byteLength = this.lengthInt * Int32Array.BYTES_PER_ELEMENT this.byteOffset = 0 - this.buffer = new ArrayBuffer(this.byteLength as int) + this.buffer = new ArrayBuffer(this.byteLength.toInt()) } /** @@ -4016,9 +3820,9 @@ export final class Int32Array implements Iterable, ArrayLike { * @param other data initializer */ public constructor(other: Int32Array) { - this.buffer = other.buffer.slice(other.byteOffset as int, (other.byteOffset + other.byteLength) as int) as ArrayBuffer + this.buffer = other.buffer.slice(other.byteOffset.toInt(), (other.byteOffset + other.byteLength).toInt()) as ArrayBuffer this.byteLength = other.byteLength - this.lengthInt = other.length as int + this.lengthInt = Double.toInt(other.length) this.byteOffset = 0 } @@ -4028,7 +3832,7 @@ export final class Int32Array implements Iterable, ArrayLike { public constructor(numbers: FixedArray) { this(numbers.length) for (let i: int = 0; i < this.lengthInt; ++i) { - this.setUnsafe(i, this.zeroIfInfinity(numbers[i]) as int) + this.setUnsafe(i, this.zeroIfInfinity(numbers[i]).toInt()) } } @@ -4038,20 +3842,20 @@ export final class Int32Array implements Iterable, ArrayLike { public constructor(numbers: FixedArray) { this(numbers.length) for (let i: int = 0; i < this.lengthInt; ++i) { - this.setUnsafe(i, this.zeroIfInfinity(numbers[i]) as int) + this.setUnsafe(i, this.zeroIfInfinity(numbers[i]).toInt()) } } internal zeroIfInfinity(val: number): number { if ((val == Infinity) || (val == -Infinity)) { - return 0 as number + return 0 } - return val as number + return (val).toDouble() } internal zeroIfInfinity(val: int): int { if ((val == Infinity) || (val == -Infinity)) { - return 0 as int + return 0 } return val } @@ -4064,7 +3868,7 @@ export final class Int32Array implements Iterable, ArrayLike { * @param index index to change */ public $_set(index: number, val: number): void { - this.$_set(index as int, val) + this.$_set(Double.toInt(index), val) } /** @@ -4076,7 +3880,7 @@ export final class Int32Array implements Iterable, ArrayLike { */ public $_set(index: int, val: number): void { let v = this.zeroIfInfinity(val) - this.$_set(index, v as int) + this.$_set(index, v.toInt()) } /** @@ -4087,7 +3891,7 @@ export final class Int32Array implements Iterable, ArrayLike { * @param index index to change */ public $_set(index: number, val: int): void { - this.$_set(index as int, val) + this.$_set(Double.toInt(index), val) } /** @@ -4112,7 +3916,7 @@ export final class Int32Array implements Iterable, ArrayLike { * @returns a primitive at index */ public override $_get(index: number): Number { - return this.$_get(index as int) as Number + return this.$_get(Double.toInt(index)) } /** @@ -4132,7 +3936,7 @@ export final class Int32Array implements Iterable, ArrayLike { * @returns a primitive at index */ public at(index: number): Number | undefined { - return this.at(index as int) + return this.at(Double.toInt(index)) } /** @@ -4167,7 +3971,7 @@ export final class Int32Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: number, start: number, end?: number): Int32Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(Double.toInt(target), Double.toInt(start), asIntOrDefault(end, this.lengthInt)) } /** @@ -4182,7 +3986,7 @@ export final class Int32Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: int, start: number, end?: number): Int32Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target, Double.toInt(start), asIntOrDefault(end, this.lengthInt)) } /** @@ -4197,7 +4001,7 @@ export final class Int32Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: number, start: int, end?: number): Int32Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(Double.toInt(target), start, asIntOrDefault(end, this.lengthInt)) } /** @@ -4212,7 +4016,7 @@ export final class Int32Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: int, start: int, end?: number): Int32Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target, start, asIntOrDefault(end, this.lengthInt)) } /** @@ -4237,7 +4041,7 @@ export final class Int32Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} */ public copyWithin(target: number): Int32Array { - return this.copyWithin(target as int) + return this.copyWithin(Double.toInt(target)) } /** @@ -4270,7 +4074,7 @@ export final class Int32Array implements Iterable, ArrayLike { */ public fill(value: number, start?: number, end?: number): this { value = this.zeroIfInfinity(value) - this.fill(value as int, asIntOrDefault(start, 0 as int), asIntOrDefault(end, this.lengthInt)) + this.fill(value.toInt(), asIntOrDefault(start, 0), asIntOrDefault(end, this.lengthInt)) return this } @@ -4283,20 +4087,7 @@ export final class Int32Array implements Iterable, ArrayLike { */ public fill(value: number, start: int, end?: number): this { value = this.zeroIfInfinity(value) - this.fill(value as int, start as int, asIntOrDefault(end, this.lengthInt)) - return this - } - - /** - * Fills the Int32Array with specified value - * - * @param value new valuy - * - * @returns modified Int32Array - */ - public fill(value: number, start: int, end: number): this { - value = this.zeroIfInfinity(value) - this.fill(value as int, start as int, end as int) + this.fill(value.toInt(), start, asIntOrDefault(end, this.lengthInt)) return this } @@ -4309,7 +4100,7 @@ export final class Int32Array implements Iterable, ArrayLike { */ public fill(value: number, start: number, end: int): this { value = this.zeroIfInfinity(value) - this.fill(value as int, start as int, end as int) + this.fill(value.toInt(), Double.toInt(start), end) return this } @@ -4322,7 +4113,7 @@ export final class Int32Array implements Iterable, ArrayLike { */ public fill(value: number, start: int, end: int): this { value = this.zeroIfInfinity(value) - this.fill(value as int, start as int, end as int) + this.fill(value.toInt(), start, end) return this } @@ -4334,7 +4125,7 @@ export final class Int32Array implements Iterable, ArrayLike { * @returns modified Int32Array */ public fill(value: int, start?: number, end?: number): this { - this.fill(value, asIntOrDefault(start, 0 as int), asIntOrDefault(end, this.lengthInt)) + this.fill(value, asIntOrDefault(start, 0), asIntOrDefault(end, this.lengthInt)) return this } @@ -4346,19 +4137,7 @@ export final class Int32Array implements Iterable, ArrayLike { * @returns modified Int32Array */ public fill(value: int, start: int, end?: number): this { - this.fill(value, start as int, asIntOrDefault(end, this.lengthInt)) - return this - } - - /** - * Fills the Int32Array with specified value - * - * @param value new valuy - * - * @returns modified Int32Array - */ - public fill(value: int, start: int, end: number): this { - this.fill(value, start as int, end as int) + this.fill(value, start, asIntOrDefault(end, this.lengthInt)) return this } @@ -4370,7 +4149,7 @@ export final class Int32Array implements Iterable, ArrayLike { * @returns modified Int32Array */ public fill(value: int, start: number, end: int): this { - this.fill(value, start as int, end as int) + this.fill(value, Double.toInt(start), end) return this } @@ -4424,13 +4203,13 @@ export final class Int32Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ public set(arr: FixedArray, insertPos: number): void { - const offset = insertPos as int + const offset = Double.toInt(insertPos) if (offset < 0 || offset + arr.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } - for (let i = 0; i < arr.length as int; ++i) { + for (let i = 0; i < Double.toInt(arr.length); ++i) { let v = this.zeroIfInfinity(arr[i]) - this.$_set(offset + i, v as int) + this.$_set(offset + i, v.toInt()) } } @@ -4444,11 +4223,11 @@ export final class Int32Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ public set(arr: FixedArray, insertPos: int): void { - const offset = insertPos as int + const offset = insertPos if (offset < 0 || offset + arr.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } - for (let i = 0; i < arr.length as int; ++i) { + for (let i = 0; i < Double.toInt(arr.length); ++i) { let v = this.zeroIfInfinity(arr[i]) this.$_set(offset + i, v) } @@ -4460,7 +4239,7 @@ export final class Int32Array implements Iterable, ArrayLike { * @param arr array to copy data from */ public set(arr: FixedArray): void { - this.set(arr, 0 as number) + this.set(arr, 0) } /** @@ -4469,7 +4248,7 @@ export final class Int32Array implements Iterable, ArrayLike { * @param arr array to copy data from */ public set(arr: FixedArray): void { - this.set(arr, 0 as int) + this.set(arr, 0) } public native set(array: Int32Array): void @@ -4484,13 +4263,13 @@ export final class Int32Array implements Iterable, ArrayLike { * @param offset Optional. The offset into the target array at which to begin writing values from the source array */ public set(array: ArrayLike, offset: number = 0): void { - const insertPos = offset as int + const insertPos = Double.toInt(offset) if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } - for (let i = array.length - 1 as int; i >= 0; --i) { + for (let i = Double.toInt(array.length) - 1; i >= 0; --i) { let v = this.zeroIfInfinity(array[i]) - this.$_set(insertPos + i, v as int) + this.$_set(insertPos + i, v.toInt()) } } @@ -4502,9 +4281,9 @@ export final class Int32Array implements Iterable, ArrayLike { * @returns new Int32Array */ public static of(...items: FixedArray): Int32Array { - let res = new Int32Array(items.length as int) + let res = new Int32Array(Double.toInt(items.length)) for (let i: int = 0; i < items.length; i++) { - res.setUnsafe(i, res.zeroIfInfinity(items[i]) as int) + res.setUnsafe(i, res.zeroIfInfinity(items[i]).toInt()) } return res } @@ -4517,7 +4296,7 @@ export final class Int32Array implements Iterable, ArrayLike { * @returns new Int32Array */ public static of(...items: FixedArray): Int32Array { - let res = new Int32Array(items.length as int) + let res = new Int32Array(Double.toInt(items.length)) for (let i: int = 0; i < items.length; i++) { res.setUnsafe(i, items[i]) } @@ -4532,7 +4311,7 @@ export final class Int32Array implements Iterable, ArrayLike { * @returns new Int32Array */ public static of(): Int32Array { - return new Int32Array(0 as int) + return new Int32Array(0) } /** @@ -4573,7 +4352,7 @@ export final class Int32Array implements Iterable, ArrayLike { if (x.done) { return new Int32Array(result.buffer, 0, i) } - result.setUnsafe(i, result.zeroIfInfinity((mapfn)!(x.value!, i)) as int) + result.setUnsafe(i, result.zeroIfInfinity((mapfn)!(x.value!, i)).toInt()) } return result } @@ -4593,7 +4372,7 @@ export final class Int32Array implements Iterable, ArrayLike { } temp = new Int32Array(tb) } - temp.setUnsafe(index[0], temp.zeroIfInfinity((mapfn)!(x, index[0])) as int) + temp.setUnsafe(index[0], temp.zeroIfInfinity((mapfn)!(x, index[0])).toInt()) index[0]++ }) return new Int32Array(temp.buffer, 0, index[0]) @@ -4615,7 +4394,7 @@ export final class Int32Array implements Iterable, ArrayLike { const idx : FixedArray = new int[1] idx[0] = 0 iteratorForEach(arrayLike.$_iterator(), (x: T): void => { - res.setUnsafe(idx[0] as int, res.zeroIfInfinity(mapfn(x as T, idx[0] as number)) as int) + res.setUnsafe(idx[0], res.zeroIfInfinity(mapfn(x as T, Int.toDouble(idx[0])).toInt())) idx[0] += 1 }) return res @@ -4647,7 +4426,7 @@ export final class Int32Array implements Iterable, ArrayLike { * @returns true if e is in Int32Array, false otherwise */ public includes(searchElement: int, fromIndex: int): boolean { - return this.indexOf(searchElement as int, fromIndex) != -1 + return this.indexOf(searchElement.toInt(), fromIndex) != -1 } /** @@ -4702,7 +4481,7 @@ export final class Int32Array implements Iterable, ArrayLike { * @returns index of element if it presents, -1 otherwise */ public indexOf(searchElement: int, fromIndex: int): number { - return this.indexOfImpl(searchElement as long, fromIndex) + return this.indexOfImpl(Int.toLong(searchElement), fromIndex) } /** @@ -4829,7 +4608,7 @@ export final class Int32Array implements Iterable, ArrayLike { * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ public lastIndexOf(searchElement: int, fromIndex: int): number { - return this.lastIndexOfImpl(searchElement as long, fromIndex) + return this.lastIndexOfImpl(Int.toLong(searchElement), fromIndex) } /** @@ -4900,22 +4679,7 @@ export final class Int32Array implements Iterable, ArrayLike { * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin?: number, end?: number): Int32Array { - return this.slice(asIntOrDefault(begin, 0 as int), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Creates a slice of current Int32Array using range [begin, end) - * - * @param begin start index to be taken into slice - * - * @param end last index to be taken into slice - * - * @returns a new Int32Array with elements of current Int32Array[begin;end) where end index is excluded - * - * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice - */ - public slice(begin: number, end: number): Int32Array { - return this.slice(begin as int, end as int) + return this.slice(asIntOrDefault(begin, 0), asIntOrDefault(end, this.lengthInt)) } /** @@ -4930,7 +4694,7 @@ export final class Int32Array implements Iterable, ArrayLike { * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin: number, end: int): Int32Array { - return this.slice(begin as int, end as int) + return this.slice(Double.toInt(begin), end) } /** @@ -4945,7 +4709,7 @@ export final class Int32Array implements Iterable, ArrayLike { * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin: int, end: number): Int32Array { - return this.slice(begin as int, end as int) + return this.slice(begin, Double.toInt(end)) } /** @@ -4967,21 +4731,10 @@ export final class Int32Array implements Iterable, ArrayLike { if (count < 0) { count = 0 } - let buf = this.buffer.slice(relStart * Int32Array.BYTES_PER_ELEMENT as int, relEnd * Int32Array.BYTES_PER_ELEMENT as int) as ArrayBuffer + let buf = this.buffer.slice(relStart * Int32Array.BYTES_PER_ELEMENT.toInt(), relEnd * Int32Array.BYTES_PER_ELEMENT.toInt()) as ArrayBuffer return new Int32Array(buf) } - /** - * Creates a slice of current Int32Array using range [begin, this.length). - * - * @param begin start index to be taken into slice - * - * @returns a new Int32Array with elements of current Int32Array[begin, this.length) - */ - public slice(begin: number): Int32Array { - return this.slice(begin as int) - } - /** * Creates a slice of current Int32Array using range [begin, this.length). * @@ -5006,19 +4759,6 @@ export final class Int32Array implements Iterable, ArrayLike { return this.subarray(asIntOrDefault(begin, 0 as int), asIntOrDefault(end, this.lengthInt)) } - /** - * Creates a Int32Array with the same underlying ArrayBuffer - * - * @param begin start index, inclusive - * - * @param end last index, exclusive - * - * @returns new Int32Array with the same underlying ArrayBuffer - */ - public subarray(begin: number, end: number): Int32Array { - return this.subarray(begin as int, end as int) - } - /** * Creates a Int32Array with the same underlying ArrayBuffer * @@ -5029,7 +4769,7 @@ export final class Int32Array implements Iterable, ArrayLike { * @returns new Int32Array with the same underlying ArrayBuffer */ public subarray(begin: number, end: int): Int32Array { - return this.subarray(begin as int, end as int) + return this.subarray(Double.toInt(begin), end) } /** @@ -5042,7 +4782,7 @@ export final class Int32Array implements Iterable, ArrayLike { * @returns new Int32Array with the same underlying ArrayBuffer */ public subarray(begin: int, end: number): Int32Array { - return this.subarray(begin as int, end as int) + return this.subarray(begin, Double.toInt(end)) } /** @@ -5062,7 +4802,7 @@ export final class Int32Array implements Iterable, ArrayLike { if (count < 0) { count = 0 } - return new Int32Array(this.buffer, relStart * Int32Array.BYTES_PER_ELEMENT as int, count) + return new Int32Array(this.buffer, relStart * Int32Array.BYTES_PER_ELEMENT.toInt(), count) } /** @@ -5073,7 +4813,7 @@ export final class Int32Array implements Iterable, ArrayLike { * @returns new Int32Array with the same ArrayBuffer */ public subarray(begin: number): Int32Array { - return this.subarray(begin as int, this.lengthInt) + return this.subarray(begin.toInt(), this.lengthInt) } /** @@ -5084,7 +4824,7 @@ export final class Int32Array implements Iterable, ArrayLike { * @returns new Int32Array with the same ArrayBuffer */ public subarray(begin: int): Int32Array { - return this.subarray(begin as int, this.lengthInt) + return this.subarray(begin, this.lengthInt) } /** @@ -5119,11 +4859,11 @@ export final class Int32Array implements Iterable, ArrayLike { public toLocaleString(): string { let res: StringBuilder = new StringBuilder("") for (let i = 0; i < this.lengthInt - 1; ++i) { - res.append((this.getUnsafe(i) as Number).toLocaleString()) + res.append(new Number(this.getUnsafe(i)).toLocaleString()) res.append(",") } if (this.lengthInt > 0) { - res.append((this.getUnsafe(this.lengthInt - 1) as Number).toLocaleString()) + res.append(new Number(this.getUnsafe(this.lengthInt - 1))).toLocaleString() } return res.toString() } @@ -5183,7 +4923,7 @@ export final class Int32Array implements Iterable, ArrayLike { * @returns an Int32Array with replaced value on index */ public with(index: number, value: number): Int32Array { - return this.with(index as int, value as int) + return this.with(Double.toInt(index), value.toInt()) } /** @@ -5213,7 +4953,7 @@ export final class Int32Array implements Iterable, ArrayLike { public findLast(fn: (val: number) => boolean): number { let newF: (val: number, index: number, array: Int32Array) => boolean = (val: number, index: number, array: Int32Array): boolean => { return fn(val) } - return this.findLast(newF) as number + return (this.findLast(newF)).toDouble() } /** @@ -5242,8 +4982,13 @@ export final class Int32Array implements Iterable, ArrayLike { arr[i] = this.getUnsafe(i) } let cmp = (l: int, r: int): number => { - const result = compareFn!(l as number, r as number) - return result + return (l - r).toDouble() + } + if (compareFn != undefined) { + cmp = (l: int, r: int): number => { + const result = compareFn!((l).toDouble(), (r).toDouble()) + return result + } } sort(arr, cmp) for (let i = 0; i < this.lengthInt; ++i) { @@ -5264,7 +5009,7 @@ export final class Int32Array implements Iterable, ArrayLike { */ public some(predicate: (element: number, index: number, array: Int32Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; ++i) { - if (predicate(this.getUnsafe(i) as number, i as number, this)) { + if (predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { return true } } @@ -5289,7 +5034,7 @@ export final class Int32Array implements Iterable, ArrayLike { initialValue: U): U { let accumulatedValue = initialValue for (let i = 0; i < this.lengthInt; ++i) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) } return accumulatedValue } @@ -5311,9 +5056,9 @@ export final class Int32Array implements Iterable, ArrayLike { throw new TypeError("Reduce of empty array with no initial value") } - let accumulatedValue = this.getUnsafe(0) as number + let accumulatedValue = (this.getUnsafe(0)).toDouble() for (let i = 1; i < this.lengthInt; ++i) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) } return accumulatedValue } @@ -5336,7 +5081,7 @@ export final class Int32Array implements Iterable, ArrayLike { initialValue: U): U { let accumulatedValue = initialValue for (let i = this.lengthInt - 1; i >= 0; --i) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) } return accumulatedValue } @@ -5359,9 +5104,9 @@ export final class Int32Array implements Iterable, ArrayLike { throw new TypeError("Reduce of empty array with no initial value") } - let accumulatedValue: number = this.getUnsafe(this.lengthInt - 1) as number + let accumulatedValue: number = (this.getUnsafe(this.lengthInt - 1)).toDouble() for (let i = this.lengthInt - 2; i >= 0; --i) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) } return accumulatedValue } @@ -5374,10 +5119,10 @@ export final class Int32Array implements Iterable, ArrayLike { * @returns a new Int32Array where for each element from current Int32Array fn was applied */ public map(fn: (val: number, index: number, array: Int32Array) => number): Int32Array { - let resBuf = new ArrayBuffer(this.lengthInt * Int32Array.BYTES_PER_ELEMENT as int) - let res = new Int32Array(resBuf, 0, resBuf.getByteLength() / Int32Array.BYTES_PER_ELEMENT as int) + let resBuf = new ArrayBuffer(this.lengthInt * Int32Array.BYTES_PER_ELEMENT) + let res = new Int32Array(resBuf, 0, Double.toInt(resBuf.getByteLength() / Int32Array.BYTES_PER_ELEMENT)) for (let i = 0; i < this.lengthInt; ++i) { - res.set(i, fn(this.getUnsafe(i) as number, i as number, this) as int) + res.set(i, fn((this.getUnsafe(i)).toDouble(), i.toDouble(), this).toInt()) } return res } @@ -5394,7 +5139,7 @@ export final class Int32Array implements Iterable, ArrayLike { */ public every(predicate: (element: number, index: number, array: Int32Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; ++i) { - if (!predicate(this.getUnsafe(i) as number, i as number, this)) { + if (!predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { return false } } @@ -5412,12 +5157,12 @@ export final class Int32Array implements Iterable, ArrayLike { let markers : FixedArray = new boolean[this.lengthInt] let resLen = 0 for (let i = 0; i < this.lengthInt; ++i) { - markers[i] = fn(this.getUnsafe(i) as number, i as number, this) + markers[i] = fn((this.getUnsafe(i)).toDouble(), i.toDouble(), this) if (markers[i]) { ++resLen } } - let resBuf = new ArrayBuffer(resLen * Int32Array.BYTES_PER_ELEMENT as int) + let resBuf = new ArrayBuffer(resLen * Int32Array.BYTES_PER_ELEMENT) let res = new Int32Array(resBuf, 0) for (let i = 0, j = 0; i < this.lengthInt; ++i) { if (markers[i]) { @@ -5441,8 +5186,8 @@ export final class Int32Array implements Iterable, ArrayLike { public find(predicate: (value: number, index: number, obj: Int32Array) => boolean): number | undefined { for (let i = 0; i < this.lengthInt; ++i) { let val = this.getUnsafe(i) - if (predicate(val as number, i as number, this)) { - return val as number + if (predicate((val).toDouble(), i.toDouble(), this)) { + return (val).toDouble() } } return undefined @@ -5460,11 +5205,11 @@ export final class Int32Array implements Iterable, ArrayLike { */ public findIndex(predicate: (value: number, index: number, obj: Int32Array) => boolean): number { for (let i = 0; i < this.lengthInt; ++i) { - if (predicate(this.getUnsafe(i) as number, i as number, this)) { - return i as number + if (predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { + return i.toDouble() } } - return -1 as number + return (-1).toDouble() } /** @@ -5477,7 +5222,7 @@ export final class Int32Array implements Iterable, ArrayLike { public findLast(fn: (val: number, index: number, array: Int32Array) => boolean): int { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) - if (fn(val as number, i as number, this)) { + if (fn((val).toDouble(), i.toDouble(), this)) { return val } } @@ -5494,11 +5239,11 @@ export final class Int32Array implements Iterable, ArrayLike { public findLastIndex(fn: (val: number, index: number, array: Int32Array) => boolean): number { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) - if (fn(val as number, i as number, this)) { + if (fn((val).toDouble(), i.toDouble(), this)) { return i } } - return -1 as number + return (-1).toDouble() } /** @@ -5511,7 +5256,7 @@ export final class Int32Array implements Iterable, ArrayLike { */ public forEach(callbackfn: (value: number, index: number, array: Int32Array) => void): void { for (let i = 0; i < this.lengthInt; ++i) { - callbackfn(this.getUnsafe(i) as number, i as number, this) + callbackfn((this.getUnsafe(i)).toDouble(), i.toDouble(), this) } } @@ -5525,37 +5270,37 @@ export final class Int32Array implements Iterable, ArrayLike { } internal getUnsafe(index: int): int { - let byteIndex = index * Int32Array.BYTES_PER_ELEMENT as int + this.byteOffset as int + let byteIndex = index * Int32Array.BYTES_PER_ELEMENT + Double.toInt(this.byteOffset) let res : int = 0 let byteVal : int if (IS_LITTLE_ENDIAN) { - for (let i: int = 0; i < Int32Array.BYTES_PER_ELEMENT as int; ++i) { - byteVal = (this.buffer as ArrayBuffer).at(byteIndex as int + i) + for (let i: int = 0; i < Int32Array.BYTES_PER_ELEMENT.toInt(); ++i) { + byteVal = (this.buffer as ArrayBuffer).at(byteIndex.toInt() + i) byteVal &= 0xff - res = (res | byteVal << (8 * i)) as int + res = (res | byteVal << (8 * i)).toInt() } return res } else { - for (let i: int = 0; i < Int32Array.BYTES_PER_ELEMENT as int; ++i) { - byteVal = this.buffer.at(byteIndex as int + 3 - i) + for (let i: int = 0; i < Int32Array.BYTES_PER_ELEMENT.toInt(); ++i) { + byteVal = this.buffer.at(byteIndex.toInt() + 3 - i) byteVal &= 0xff - res = (res | byteVal << (8 * i)) as int + res = (res | byteVal << (8 * i)).toInt() } return res } } internal setUnsafe(insertPos: int, val: int): void { - let startByte = insertPos * Int32Array.BYTES_PER_ELEMENT as int + this.byteOffset as int + let startByte = insertPos * Int32Array.BYTES_PER_ELEMENT + Double.toInt(this.byteOffset) let bits = val if (IS_LITTLE_ENDIAN) { - for (let i = 0; i < Int32Array.BYTES_PER_ELEMENT as int; ++i) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + for (let i = 0; i < Int32Array.BYTES_PER_ELEMENT.toInt(); ++i) { + let byteVal = ((bits >>> (i * 8)) & 0xff).toByte() this.buffer.set(startByte + i, byteVal) } } else { - for (let i = 0; i < Int32Array.BYTES_PER_ELEMENT as int; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + for (let i = 0; i < Int32Array.BYTES_PER_ELEMENT.toInt(); i++) { + let byteVal = ((bits >>> (i * 8)) & 0xff).toByte() this.buffer.set(startByte + 3 - i, byteVal) } } @@ -5579,7 +5324,7 @@ class BigInt64ArrayIteratorKeys implements IterableIterator { private idx: int = 0 constructor(parent: BigInt64Array) { - this.length = parent.length as int + this.length = Double.toInt(parent.length) } public override $_iterator(): IterableIterator { @@ -5590,7 +5335,7 @@ class BigInt64ArrayIteratorKeys implements IterableIterator { if (this.idx < 0 || this.idx >= this.length) { return new IteratorResult() } - return new IteratorResult(false, this.idx++ as number) + return new IteratorResult(false, Int.toDouble(this.idx++)) } } @@ -5607,7 +5352,7 @@ class BigInt64ArrayIterator implements IterableIterator { } override next(): IteratorResult { - if (this.idx < 0 || this.idx >= this.parent.length as int) { + if (this.idx < 0 || this.idx >= Double.toInt(this.parent.length)) { return new IteratorResult() } return new IteratorResult(false, new BigInt(this.parent[this.idx++])) @@ -5627,7 +5372,7 @@ class BigInt64ArrayIteratorEntries implements IterableIterator<[Number, BigInt]> } override next(): IteratorResult<[Number, BigInt]> { - if (this.idx < 0 || this.idx >= this.parent.length as int) { + if (this.idx < 0 || this.idx >= Double.toInt(this.parent.length)) { return new IteratorResult<[Number, BigInt]>() } return new IteratorResult<[Number, BigInt]>( @@ -5641,15 +5386,15 @@ class BigInt64ArrayIteratorEntries implements IterableIterator<[Number, BigInt]> * JS BigInt64Array API-compatible class */ export final class BigInt64Array implements Iterable, ArrayLike { - public static readonly BYTES_PER_ELEMENT: number = 8 - public readonly BYTES_PER_ELEMENT: number = BigInt64Array.BYTES_PER_ELEMENT + public static readonly BYTES_PER_ELEMENT: int = 8 + public readonly BYTES_PER_ELEMENT: int = BigInt64Array.BYTES_PER_ELEMENT internal readonly lengthInt: int /** * Creates an empty BigInt64Array. */ public constructor() { - this(0 as int) + this(0) } /** @@ -5659,9 +5404,9 @@ export final class BigInt64Array implements Iterable, ArrayLike const items: Object = elements as Object if (items instanceof ArrayLike) { const arr = Types.identity_cast(items as ArrayLike) - this.byteLength = arr.length as int * BigInt64Array.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int - this.buffer = new ArrayBuffer(this.byteLength as int) + this.byteLength = Double.toInt(arr.length) * BigInt64Array.BYTES_PER_ELEMENT + this.lengthInt = Double.toInt(arr.length) + this.buffer = new ArrayBuffer(Double.toInt(this.byteLength)) this.byteOffset = 0 for (let i: int = 0; i < this.lengthInt; ++i) { this.setUnsafe(i, arr.$_get(i).getLong()) @@ -5697,27 +5442,27 @@ export final class BigInt64Array implements Iterable, ArrayLike throw new RangeError("Range Error: byteLength " + intByteLength + " is outside the bounds of the buffer with byteOffset " + intByteOffset) } - if (intByteLength % BigInt64Array.BYTES_PER_ELEMENT as int != 0) { + if (intByteLength % BigInt64Array.BYTES_PER_ELEMENT.toInt() != 0) { throw new RangeError("ArrayBuffer.byteLength should be multiple of 8 as BigInt64Array.BYTES_PER_ELEMENT") } - if (intByteOffset % BigInt64Array.BYTES_PER_ELEMENT as int != 0) { + if (intByteOffset % BigInt64Array.BYTES_PER_ELEMENT != 0) { throw new RangeError("byteOffset should be multiple of 8 as BigInt64Array.BYTES_PER_ELEMENT") } let intLength: int if (length != undefined) { intLength = length.toInt() - if (intLength > intByteLength / BigInt64Array.BYTES_PER_ELEMENT as int) { + if (intLength > Double.toInt(intByteLength / BigInt64Array.BYTES_PER_ELEMENT)) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer with byteOffset " + intByteOffset) } } else { - intLength = intByteLength / BigInt64Array.BYTES_PER_ELEMENT as int + intLength = Double.toInt(intByteLength / BigInt64Array.BYTES_PER_ELEMENT) } if (intLength < 0) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer") } - if (intLength < intByteLength / BigInt64Array.BYTES_PER_ELEMENT as int) { - intByteLength = intLength * BigInt64Array.BYTES_PER_ELEMENT as int + if (intLength < Double.toInt(intByteLength / BigInt64Array.BYTES_PER_ELEMENT)) { + intByteLength = intLength * BigInt64Array.BYTES_PER_ELEMENT } this.byteLength = intByteLength this.byteOffset = intByteOffset @@ -5725,32 +5470,6 @@ export final class BigInt64Array implements Iterable, ArrayLike this.buffer = buf } - /** - * Creates an BigInt64Array with respect to data, byteOffset and length. - * - * @param buf data initializer - * - * @param byteOffset byte offset from begin of the buf - * - * @param length size of elements of type long in newly created BigInt64Array - */ - public constructor(buf: ArrayBuffer, byteOffset: Number | undefined) { - this(buf, byteOffset, undefined) - } - - /** - * Creates an BigInt64Array with respect to data, byteOffset and length. - * - * @param buf data initializer - * - * @param byteOffset byte offset from begin of the buf - * - * @param length size of elements of type long in newly created BigInt64Array - */ - public constructor(buf: ArrayBuffer, byteOffset: number, length: number) { - this(buf, new Number(byteOffset), new Number(length)) - } - /** * Creates an BigInt64Array with respect to data, byteOffset and length. * @@ -5796,19 +5515,19 @@ export final class BigInt64Array implements Iterable, ArrayLike public constructor(buf: ArrayLike | ArrayBuffer) { if (buf instanceof ArrayBuffer) { this.byteLength = (buf as ArrayBuffer).getByteLength() - if (this.byteLength % BigInt64Array.BYTES_PER_ELEMENT as int != 0) { + if (this.byteLength % BigInt64Array.BYTES_PER_ELEMENT.toInt() != 0) { throw new RangeError("ArrayBuffer.byteLength should be multiple of 8 as BigInt64Array.BYTES_PER_ELEMENT") } - this.lengthInt = this.byteLength / BigInt64Array.BYTES_PER_ELEMENT as int + this.lengthInt = Double.toInt(this.byteLength / BigInt64Array.BYTES_PER_ELEMENT) this.buffer = buf as ArrayBuffer this.byteOffset = 0 } else if (buf instanceof ArrayLike) { // NOTE (ikorobkov): dealing with this overload is tricky // with banned `instanceof` generic, so it is delegated to array here. Initial idea from Set.ets let arr = Array.from((buf as ArrayLike)) - this.byteLength = arr.length as int * BigInt64Array.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int - this.buffer = new ArrayBuffer(this.byteLength as int) + this.byteLength = arr.length.toInt() * BigInt64Array.BYTES_PER_ELEMENT.toInt() + this.lengthInt = arr.length.toInt() + this.buffer = new ArrayBuffer(this.byteLength.toInt()) this.byteOffset = 0 for (let i: int = 0; i < this.lengthInt; ++i) { this.setUnsafe(i, arr.$_get(i).toLong()) @@ -5824,7 +5543,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @param length data initializer */ public constructor(length: int) { - this(length as number) + this(Int.toDouble(length)) } /** @@ -5833,13 +5552,13 @@ export final class BigInt64Array implements Iterable, ArrayLike * @param length data initializer */ public constructor(length: number) { - if (length < 0 || length > (Int.MAX_VALUE / BigInt64Array.BYTES_PER_ELEMENT)) { + if (length < 0 || length > Double.toInt(Int.MAX_VALUE / BigInt64Array.BYTES_PER_ELEMENT)) { throw new TypeError("Type Error: length " + length + " is outside the bounds of the buffer") } - this.lengthInt = length as int - this.byteLength = this.lengthInt * BigInt64Array.BYTES_PER_ELEMENT as int + this.lengthInt = Double.toInt(length) + this.byteLength = this.lengthInt * BigInt64Array.BYTES_PER_ELEMENT this.byteOffset = 0 - this.buffer = new ArrayBuffer(this.byteLength as int) + this.buffer = new ArrayBuffer(this.byteLength.toInt()) } /** @@ -5848,9 +5567,9 @@ export final class BigInt64Array implements Iterable, ArrayLike * @param other data initializer */ public constructor(other: BigInt64Array) { - this.buffer = other.buffer.slice(other.byteOffset as int, (other.byteOffset + other.byteLength) as int) as ArrayBuffer + this.buffer = other.buffer.slice(other.byteOffset.toInt(), (other.byteOffset + other.byteLength).toInt()) as ArrayBuffer this.byteLength = other.byteLength - this.lengthInt = other.length as int + this.lengthInt = Double.toInt(other.length) this.byteOffset = 0 } @@ -5860,7 +5579,7 @@ export final class BigInt64Array implements Iterable, ArrayLike public constructor(numbers: FixedArray) { this(numbers.length) for (let i: int = 0; i < this.lengthInt; ++i) { - this.setUnsafe(i, numbers[i] as long) + this.setUnsafe(i, Double.toLong(numbers[i])) } } @@ -5870,7 +5589,7 @@ export final class BigInt64Array implements Iterable, ArrayLike public constructor(numbers: FixedArray) { this(numbers.length) for (let i: int = 0; i < this.lengthInt; ++i) { - this.setUnsafe(i, numbers[i] as long) + this.setUnsafe(i, Int.toLong(numbers[i])) } } @@ -5892,7 +5611,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @param index index to change */ public $_set(index: number, val: BigInt): void { - this.$_set(index as int, val) + this.$_set(Double.toInt(index), val) } /** @@ -5914,7 +5633,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @param index index to change */ public $_set(index: number, val: long): void { - this.$_set(index as int, val) + this.$_set(Double.toInt(index), val) } /** @@ -5939,7 +5658,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns a primitive at index */ public override $_get(index: number): BigInt { - return this.$_get(index as int) as BigInt + return new BigInt(this.$_get(Double.toInt(index))) } /** @@ -5963,7 +5682,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns a primitive at index */ public at(index: number): BigInt | undefined { - return this.at(index as int) + return this.at(Double.toInt(index)) } /** @@ -5998,7 +5717,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: number, start: number, end?: number): BigInt64Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(Double.toInt(target), Double.toInt(start), asIntOrDefault(end, this.lengthInt)) } /** @@ -6013,7 +5732,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: int, start: number, end?: number): BigInt64Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target, Double.toInt(start), asIntOrDefault(end, this.lengthInt)) } /** @@ -6028,7 +5747,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: number, start: int, end?: number): BigInt64Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(Double.toInt(target), start, asIntOrDefault(end, this.lengthInt)) } /** @@ -6043,7 +5762,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: int, start: int, end?: number): BigInt64Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target, start, asIntOrDefault(end, this.lengthInt)) } /** @@ -6068,7 +5787,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} */ public copyWithin(target: number): BigInt64Array { - return this.copyWithin(target as int) + return this.copyWithin(Double.toInt(target)) } /** @@ -6100,7 +5819,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns modified BigInt64Array */ public fill(value: BigInt, start?: number, end?: number): this { - this.fill(value.getLong(), asIntOrDefault(start, 0 as int), asIntOrDefault(end, this.lengthInt)) + this.fill(value.getLong(), asIntOrDefault(start, 0), asIntOrDefault(end, this.lengthInt)) return this } @@ -6112,19 +5831,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns modified BigInt64Array */ public fill(value: BigInt, start: int, end?: number): this { - this.fill(value.getLong(), start as int, asIntOrDefault(end, this.lengthInt)) - return this - } - - /** - * Fills the BigInt64Array with specified value - * - * @param value new valuy - * - * @returns modified BigInt64Array - */ - public fill(value: BigInt, start: int, end: number): this { - this.fill(value.getLong(), start as int, end as int) + this.fill(value.getLong(), start, asIntOrDefault(end, this.lengthInt)) return this } @@ -6136,7 +5843,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns modified BigInt64Array */ public fill(value: BigInt, start: number, end: int): this { - this.fill(value.getLong(), start as int, end as int) + this.fill(value.getLong(), Double.toInt(start), end) return this } @@ -6148,7 +5855,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns modified BigInt64Array */ public fill(value: BigInt, start: int, end: int): this { - this.fill(value.getLong(), start as int, end as int) + this.fill(value.getLong(), start, end) return this } @@ -6160,7 +5867,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns modified BigInt64Array */ public fill(value: long, start?: number, end?: number): this { - this.fill(value, asIntOrDefault(start, 0 as int), asIntOrDefault(end, this.lengthInt)) + this.fill(value, asIntOrDefault(start, 0), asIntOrDefault(end, this.lengthInt)) return this } @@ -6172,19 +5879,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns modified BigInt64Array */ public fill(value: long, start: int, end?: number): this { - this.fill(value, start as int, asIntOrDefault(end, this.lengthInt)) - return this - } - - /** - * Fills the BigInt64Array with specified value - * - * @param value new valuy - * - * @returns modified BigInt64Array - */ - public fill(value: long, start: int, end: number): this { - this.fill(value, start as int, end as int) + this.fill(value, start, asIntOrDefault(end, this.lengthInt)) return this } @@ -6196,7 +5891,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns modified BigInt64Array */ public fill(value: long, start: number, end: int): this { - this.fill(value, start as int, end as int) + this.fill(value, Double.toInt(start), end) return this } @@ -6250,11 +5945,11 @@ export final class BigInt64Array implements Iterable, ArrayLike * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ public set(arr: FixedArray, insertPos: number): void { - const offset = insertPos as int + const offset = Double.toInt(insertPos) if (offset < 0 || offset + arr.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } - for (let i = 0; i < arr.length as int; ++i) { + for (let i = 0; i < Double.toInt(arr.length); ++i) { let truncatedVal: BigInt = BigInt.asIntN(64, arr[i]) this.$_set(offset + i, truncatedVal.getLong()) } @@ -6270,11 +5965,11 @@ export final class BigInt64Array implements Iterable, ArrayLike * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ public set(arr: FixedArray, insertPos: int): void { - const offset = insertPos as int + const offset = insertPos if (offset < 0 || offset + arr.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } - for (let i = 0; i < arr.length as int; ++i) { + for (let i = 0; i < Double.toInt(arr.length); ++i) { this.$_set(offset + i, arr[i]) } } @@ -6285,7 +5980,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @param arr array to copy data from */ public set(arr: FixedArray): void { - this.set(arr, 0 as number) + this.set(arr, 0) } /** @@ -6294,7 +5989,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @param arr array to copy data from */ public set(arr: FixedArray): void { - this.set(arr, 0 as int) + this.set(arr, 0) } public native set(array: BigInt64Array): void @@ -6309,11 +6004,11 @@ export final class BigInt64Array implements Iterable, ArrayLike * @param offset Optional. The offset into the target array at which to begin writing values from the source array */ public set(array: ArrayLike, offset: number = 0): void { - const insertPos = offset as int + const insertPos = Double.toInt(offset) if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } - for (let i = array.length - 1 as int; i >= 0; --i) { + for (let i = Double.toInt(array.length) - 1; i >= 0; --i) { let truncatedVal: BigInt = BigInt.asIntN(64, array[i]) this.$_set(offset + i, truncatedVal.getLong()) } @@ -6327,9 +6022,9 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns new BigInt64Array */ public static of(...items: FixedArray): BigInt64Array { - let res = new BigInt64Array(items.length as int) + let res = new BigInt64Array(Double.toInt(items.length)) for (let i: int = 0; i < items.length; i++) { - res.setUnsafe(i, items[i] as long) + res.setUnsafe(i, items[i].toLong()) } return res } @@ -6342,9 +6037,9 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns new BigInt64Array */ public static of(...items: FixedArray): BigInt64Array { - let res = new BigInt64Array(items.length as int) + let res = new BigInt64Array(Double.toInt(items.length)) for (let i: int = 0; i < items.length; i++) { - res.setUnsafe(i, items[i] as long) + res.setUnsafe(i, items[i].toLong()) } return res } @@ -6357,7 +6052,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns new BigInt64Array */ public static of(...items: FixedArray): BigInt64Array { - let res = new BigInt64Array(items.length as int) + let res = new BigInt64Array(Double.toInt(items.length)) for (let i: int = 0; i < items.length; i++) { res.setUnsafe(i, items[i]) } @@ -6372,7 +6067,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns new BigInt64Array */ public static of(...items: FixedArray): BigInt64Array { - let res = new BigInt64Array(items.length as int) + let res = new BigInt64Array(Double.toInt(items.length)) for (let i: int = 0; i < items.length; i++) { res.setUnsafe(i, items[i].getLong()) } @@ -6387,7 +6082,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns new BigInt64Array */ public static of(): BigInt64Array { - return new BigInt64Array(0 as int) + return new BigInt64Array(0) } /** @@ -6470,7 +6165,7 @@ export final class BigInt64Array implements Iterable, ArrayLike const idx : FixedArray = new int[1] idx[0] = 0 iteratorForEach(arrayLike.$_iterator(), (x: T): void => { - res.setUnsafe(idx[0] as int, mapfn(x as T, idx[0] as number).getLong()) + res.setUnsafe(idx[0], mapfn(x as T, idx[0]).getLong()) idx[0] += 1 }) return res @@ -6499,7 +6194,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns true if e is in BigInt64Array, false otherwise */ public includes(searchElement: long, fromIndex: int): boolean { - return this.indexOf(searchElement as int, fromIndex) != -1 + return this.indexOf(searchElement.toInt(), fromIndex) != -1 } /** @@ -6554,7 +6249,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns index of element if it presents, -1 otherwise */ public indexOf(searchElement: int, fromIndex: int): number { - return this.indexOfImpl(searchElement as long, fromIndex) + return this.indexOfImpl(Int.toLong(searchElement), fromIndex) } /** @@ -6681,7 +6376,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ public lastIndexOf(searchElement: int, fromIndex: int): number { - return this.lastIndexOfImpl(searchElement as long, fromIndex) + return this.lastIndexOfImpl(Int.toLong(searchElement), fromIndex) } /** @@ -6752,22 +6447,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin?: number, end?: number): BigInt64Array { - return this.slice(asIntOrDefault(begin, 0 as int), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Creates a slice of current BigInt64Array using range [begin, end) - * - * @param begin start index to be taken into slice - * - * @param end last index to be taken into slice - * - * @returns a new BigInt64Array with elements of current BigInt64Array[begin;end) where end index is excluded - * - * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice - */ - public slice(begin: number, end: number): BigInt64Array { - return this.slice(begin as int, end as int) + return this.slice(asIntOrDefault(begin, 0), asIntOrDefault(end, this.lengthInt)) } /** @@ -6782,7 +6462,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin: number, end: int): BigInt64Array { - return this.slice(begin as int, end as int) + return this.slice(Double.toInt(begin), end) } /** @@ -6797,7 +6477,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin: int, end: number): BigInt64Array { - return this.slice(begin as int, end as int) + return this.slice(begin, Double.toInt(end)) } /** @@ -6819,21 +6499,10 @@ export final class BigInt64Array implements Iterable, ArrayLike if (count < 0) { count = 0 } - let buf = this.buffer.slice(relStart * BigInt64Array.BYTES_PER_ELEMENT as int, relEnd * BigInt64Array.BYTES_PER_ELEMENT as int) as ArrayBuffer + let buf = this.buffer.slice(relStart * BigInt64Array.BYTES_PER_ELEMENT.toInt(), relEnd * BigInt64Array.BYTES_PER_ELEMENT.toInt()) as ArrayBuffer return new BigInt64Array(buf) } - /** - * Creates a slice of current BigInt64Array using range [begin, this.length). - * - * @param begin start index to be taken into slice - * - * @returns a new BigInt64Array with elements of current BigInt64Array[begin, this.length) - */ - public slice(begin: number): BigInt64Array { - return this.slice(begin as int) - } - /** * Creates a slice of current BigInt64Array using range [begin, this.length). * @@ -6858,19 +6527,6 @@ export final class BigInt64Array implements Iterable, ArrayLike return this.subarray(asIntOrDefault(begin, 0 as int), asIntOrDefault(end, this.lengthInt)) } - /** - * Creates a BigInt64Array with the same underlying ArrayBuffer - * - * @param begin start index, inclusive - * - * @param end last index, exclusive - * - * @returns new BigInt64Array with the same underlying ArrayBuffer - */ - public subarray(begin: number, end: number): BigInt64Array { - return this.subarray(begin as int, end as int) - } - /** * Creates a BigInt64Array with the same underlying ArrayBuffer * @@ -6881,7 +6537,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns new BigInt64Array with the same underlying ArrayBuffer */ public subarray(begin: number, end: int): BigInt64Array { - return this.subarray(begin as int, end as int) + return this.subarray(Double.toInt(begin), end) } /** @@ -6894,7 +6550,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns new BigInt64Array with the same underlying ArrayBuffer */ public subarray(begin: int, end: number): BigInt64Array { - return this.subarray(begin as int, end as int) + return this.subarray(begin, Double.toInt(end)) } /** @@ -6914,7 +6570,7 @@ export final class BigInt64Array implements Iterable, ArrayLike if (count < 0) { count = 0 } - return new BigInt64Array(this.buffer, relStart * BigInt64Array.BYTES_PER_ELEMENT as int, count) + return new BigInt64Array(this.buffer, relStart * BigInt64Array.BYTES_PER_ELEMENT.toInt(), count) } /** @@ -6925,7 +6581,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns new BigInt64Array with the same ArrayBuffer */ public subarray(begin: number): BigInt64Array { - return this.subarray(begin as int, this.lengthInt) + return this.subarray(begin.toInt(), this.lengthInt) } /** @@ -6936,7 +6592,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns new BigInt64Array with the same ArrayBuffer */ public subarray(begin: int): BigInt64Array { - return this.subarray(begin as int, this.lengthInt) + return this.subarray(begin, this.lengthInt) } /** @@ -7035,7 +6691,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns an BigInt64Array with replaced value on index */ public with(index: number, value: BigInt): BigInt64Array { - return this.with(index as int, value.getLong()) + return this.with(Double.toInt(index), value.getLong()) } /** @@ -7094,11 +6750,16 @@ export final class BigInt64Array implements Iterable, ArrayLike arr[i] = this.getUnsafe(i) } let cmp = (l: long, r: long): number => { - const result = compareFn!(new BigInt(l), new BigInt(r)) - if (result instanceof BigInt) { - return (result as BigInt).getLong() - } else { - return result as number + return (l - r).toDouble() + } + if (compareFn != undefined) { + cmp = (l: long, r: long): number => { + const result = compareFn!(new BigInt(l), new BigInt(r)) + if (result instanceof BigInt) { + return result.getLong() + } else { + return result as number + } } } sort(arr, cmp) @@ -7120,7 +6781,7 @@ export final class BigInt64Array implements Iterable, ArrayLike */ public some(predicate: (element: BigInt, index: number, array: BigInt64Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; ++i) { - if (predicate(new BigInt(this.getUnsafe(i)), i as number, this)) { + if (predicate(new BigInt(this.getUnsafe(i)), i.toDouble(), this)) { return true } } @@ -7145,7 +6806,7 @@ export final class BigInt64Array implements Iterable, ArrayLike initialValue: U): U { let accumulatedValue = initialValue for (let i = 0; i < this.lengthInt; ++i) { - accumulatedValue = callbackfn(accumulatedValue, new BigInt(this.getUnsafe(i)), i as number, this) + accumulatedValue = callbackfn(accumulatedValue, new BigInt(this.getUnsafe(i)), i.toDouble(), this) } return accumulatedValue } @@ -7169,7 +6830,7 @@ export final class BigInt64Array implements Iterable, ArrayLike let accumulatedValue = new BigInt(this.getUnsafe(0)) for (let i = 1; i < this.lengthInt; ++i) { - accumulatedValue = callbackfn(accumulatedValue, new BigInt(this.getUnsafe(i)), i as number, this) + accumulatedValue = callbackfn(accumulatedValue, new BigInt(this.getUnsafe(i)), i.toDouble(), this) } return accumulatedValue } @@ -7192,7 +6853,7 @@ export final class BigInt64Array implements Iterable, ArrayLike initialValue: U): U { let accumulatedValue = initialValue for (let i = this.lengthInt - 1; i >= 0; --i) { - accumulatedValue = callbackfn(accumulatedValue, new BigInt(this.getUnsafe(i)), i as number, this) + accumulatedValue = callbackfn(accumulatedValue, new BigInt(this.getUnsafe(i)), i.toDouble(), this) } return accumulatedValue } @@ -7217,7 +6878,7 @@ export final class BigInt64Array implements Iterable, ArrayLike let accumulatedValue: BigInt = new BigInt(this.getUnsafe(this.lengthInt - 1)) for (let i = this.lengthInt - 2; i >= 0; --i) { - accumulatedValue = callbackfn(accumulatedValue, new BigInt(this.getUnsafe(i)), i as number, this) + accumulatedValue = callbackfn(accumulatedValue, new BigInt(this.getUnsafe(i)), i.toDouble(), this) } return accumulatedValue } @@ -7230,10 +6891,10 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns a new BigInt64Array where for each element from current BigInt64Array fn was applied */ public map(fn: (val: BigInt, index: number, array: BigInt64Array) => BigInt): BigInt64Array { - let resBuf = new ArrayBuffer(this.lengthInt * BigInt64Array.BYTES_PER_ELEMENT as int) - let res = new BigInt64Array(resBuf, 0, resBuf.getByteLength() / BigInt64Array.BYTES_PER_ELEMENT as int) + let resBuf = new ArrayBuffer(this.lengthInt * BigInt64Array.BYTES_PER_ELEMENT) + let res = new BigInt64Array(resBuf, 0, Double.toInt(resBuf.getByteLength() / BigInt64Array.BYTES_PER_ELEMENT)) for (let i = 0; i < this.lengthInt; ++i) { - res.set(i, fn(new BigInt(this.getUnsafe(i)), i as number, this).getLong()) + res.set(i, fn(new BigInt(this.getUnsafe(i)), i.toDouble(), this).getLong()) } return res } @@ -7250,7 +6911,7 @@ export final class BigInt64Array implements Iterable, ArrayLike */ public every(predicate: (element: BigInt, index: number, array: BigInt64Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; ++i) { - if (!predicate(new BigInt(this.getUnsafe(i)), i as number, this)) { + if (!predicate(new BigInt(this.getUnsafe(i)), i.toDouble(), this)) { return false } } @@ -7268,12 +6929,12 @@ export final class BigInt64Array implements Iterable, ArrayLike let markers : FixedArray = new boolean[this.lengthInt] let resLen = 0 for (let i = 0; i < this.lengthInt; ++i) { - markers[i] = fn(new BigInt(this.getUnsafe(i)), i as number, this) + markers[i] = fn(new BigInt(this.getUnsafe(i)), i.toDouble(), this) if (markers[i]) { ++resLen } } - let resBuf = new ArrayBuffer(resLen * BigInt64Array.BYTES_PER_ELEMENT as int) + let resBuf = new ArrayBuffer(resLen * BigInt64Array.BYTES_PER_ELEMENT) let res = new BigInt64Array(resBuf, 0) for (let i = 0, j = 0; i < this.lengthInt; ++i) { if (markers[i]) { @@ -7297,7 +6958,7 @@ export final class BigInt64Array implements Iterable, ArrayLike public find(predicate: (value: BigInt, index: number, obj: BigInt64Array) => boolean): BigInt | undefined { for (let i = 0; i < this.lengthInt; ++i) { let val = this.getUnsafe(i) - if (predicate(new BigInt(val), i as number, this)) { + if (predicate(new BigInt(val), i.toDouble(), this)) { return new BigInt(val) } } @@ -7316,11 +6977,11 @@ export final class BigInt64Array implements Iterable, ArrayLike */ public findIndex(predicate: (value: BigInt, index: number, obj: BigInt64Array) => boolean): number { for (let i = 0; i < this.lengthInt; ++i) { - if (predicate(new BigInt(this.getUnsafe(i)), i as number, this)) { - return i as number + if (predicate(new BigInt(this.getUnsafe(i)), i.toDouble(), this)) { + return i.toDouble() } } - return -1 as number + return (-1).toDouble() } /** @@ -7333,7 +6994,7 @@ export final class BigInt64Array implements Iterable, ArrayLike public findLast(fn: (val: BigInt, index: number, array: BigInt64Array) => boolean): long { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) - if (fn(new BigInt(val), i as number, this)) { + if (fn(new BigInt(val), i.toDouble(), this)) { return val } } @@ -7350,11 +7011,11 @@ export final class BigInt64Array implements Iterable, ArrayLike public findLastIndex(fn: (val: BigInt, index: number, array: BigInt64Array) => boolean): number { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) - if (fn(new BigInt(val), i as number, this)) { + if (fn(new BigInt(val), i.toDouble(), this)) { return i } } - return -1 as number + return (-1).toDouble() } /** @@ -7367,7 +7028,7 @@ export final class BigInt64Array implements Iterable, ArrayLike */ public forEach(callbackfn: (value: BigInt, index: number, array: BigInt64Array) => void): void { for (let i = 0; i < this.lengthInt; ++i) { - callbackfn(new BigInt(this.getUnsafe(i)), i as number, this) + callbackfn(new BigInt(this.getUnsafe(i)), i.toDouble(), this) } } @@ -7381,37 +7042,37 @@ export final class BigInt64Array implements Iterable, ArrayLike } internal getUnsafe(index: int): long { - let byteIndex = index * BigInt64Array.BYTES_PER_ELEMENT as int + this.byteOffset as int + let byteIndex = index * BigInt64Array.BYTES_PER_ELEMENT + Double.toInt(this.byteOffset) let res : long = 0 let byteVal : long if (IS_LITTLE_ENDIAN) { - for (let i: int = 0; i < BigInt64Array.BYTES_PER_ELEMENT as int; ++i) { - byteVal = (this.buffer as ArrayBuffer).at(byteIndex as int + i) + for (let i: int = 0; i < BigInt64Array.BYTES_PER_ELEMENT.toInt(); ++i) { + byteVal = (this.buffer as ArrayBuffer).at(byteIndex.toInt() + i) byteVal &= 0xff - res = (res | byteVal << (8 * i)) as long + res = (res | byteVal << (8 * i)).toLong() } return res } else { - for (let i: int = 0; i < BigInt64Array.BYTES_PER_ELEMENT as int; ++i) { - byteVal = this.buffer.at(byteIndex as int + 7 - i) + for (let i: int = 0; i < BigInt64Array.BYTES_PER_ELEMENT.toInt(); ++i) { + byteVal = this.buffer.at(byteIndex.toInt() + 7 - i) byteVal &= 0xff - res = (res | byteVal << (8 * i)) as long + res = (res | byteVal << (8 * i)).toLong() } return res } } internal setUnsafe(insertPos: int, val: long): void { - let startByte = insertPos * BigInt64Array.BYTES_PER_ELEMENT as int + this.byteOffset as int + let startByte = insertPos * BigInt64Array.BYTES_PER_ELEMENT + Double.toInt(this.byteOffset) let bits = val if (IS_LITTLE_ENDIAN) { - for (let i = 0; i < BigInt64Array.BYTES_PER_ELEMENT as int; ++i) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + for (let i = 0; i < BigInt64Array.BYTES_PER_ELEMENT.toInt(); ++i) { + let byteVal = ((bits >>> (i * 8)) & 0xff).toByte() this.buffer.set(startByte + i, byteVal) } } else { - for (let i = 0; i < BigInt64Array.BYTES_PER_ELEMENT as int; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + for (let i = 0; i < BigInt64Array.BYTES_PER_ELEMENT.toInt(); i++) { + let byteVal = ((bits >>> (i * 8)) & 0xff).toByte() this.buffer.set(startByte + 7 - i, byteVal) } } @@ -7435,7 +7096,7 @@ class Float32ArrayIteratorKeys implements IterableIterator { private idx: int = 0 constructor(parent: Float32Array) { - this.length = parent.length as int + this.length = Double.toInt(parent.length) } public override $_iterator(): IterableIterator { @@ -7446,7 +7107,7 @@ class Float32ArrayIteratorKeys implements IterableIterator { if (this.idx < 0 || this.idx >= this.length) { return new IteratorResult() } - return new IteratorResult(false, this.idx++ as number) + return new IteratorResult(false, Int.toDouble(this.idx++)) } } @@ -7463,7 +7124,7 @@ class Float32ArrayIterator implements IterableIterator { } override next(): IteratorResult { - if (this.idx < 0 || this.idx >= this.parent.length as int) { + if (this.idx < 0 || this.idx >= Double.toInt(this.parent.length)) { return new IteratorResult() } return new IteratorResult(false, new Number(this.parent[this.idx++])) @@ -7483,7 +7144,7 @@ class Float32ArrayIteratorEntries implements IterableIterator<[Number, Number]> } override next(): IteratorResult<[Number, Number]> { - if (this.idx < 0 || this.idx >= this.parent.length as int) { + if (this.idx < 0 || this.idx >= Double.toInt(this.parent.length)) { return new IteratorResult<[Number, Number]>() } return new IteratorResult<[Number, Number]>( @@ -7497,15 +7158,15 @@ class Float32ArrayIteratorEntries implements IterableIterator<[Number, Number]> * JS Float32Array API-compatible class */ export final class Float32Array implements Iterable, ArrayLike { - public static readonly BYTES_PER_ELEMENT: number = 4 - public readonly BYTES_PER_ELEMENT: number = Float32Array.BYTES_PER_ELEMENT + public static readonly BYTES_PER_ELEMENT: int = 4 + public readonly BYTES_PER_ELEMENT: int = Float32Array.BYTES_PER_ELEMENT internal readonly lengthInt: int /** * Creates an empty Float32Array. */ public constructor() { - this(0 as int) + this(0) } /** @@ -7515,9 +7176,9 @@ export final class Float32Array implements Iterable, ArrayLike { const items: Object = elements as Object if (items instanceof ArrayLike) { const arr = Types.identity_cast(items as ArrayLike) - this.byteLength = arr.length as int * Float32Array.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int - this.buffer = new ArrayBuffer(this.byteLength as int) + this.byteLength = Double.toInt(arr.length) * Float32Array.BYTES_PER_ELEMENT + this.lengthInt = Double.toInt(arr.length) + this.buffer = new ArrayBuffer(Double.toInt(this.byteLength)) this.byteOffset = 0 for (let i: int = 0; i < this.lengthInt; ++i) { this.setUnsafe(i, arr.$_get(i).toFloat()) @@ -7553,27 +7214,27 @@ export final class Float32Array implements Iterable, ArrayLike { throw new RangeError("Range Error: byteLength " + intByteLength + " is outside the bounds of the buffer with byteOffset " + intByteOffset) } - if (intByteLength % Float32Array.BYTES_PER_ELEMENT as int != 0) { + if (intByteLength % Float32Array.BYTES_PER_ELEMENT.toInt() != 0) { throw new RangeError("ArrayBuffer.byteLength should be multiple of 4 as Float32Array.BYTES_PER_ELEMENT") } - if (intByteOffset % Float32Array.BYTES_PER_ELEMENT as int != 0) { + if (intByteOffset % Float32Array.BYTES_PER_ELEMENT != 0) { throw new RangeError("byteOffset should be multiple of 4 as Float32Array.BYTES_PER_ELEMENT") } let intLength: int if (length != undefined) { intLength = length.toInt() - if (intLength > intByteLength / Float32Array.BYTES_PER_ELEMENT as int) { + if (intLength > Double.toInt(intByteLength / Float32Array.BYTES_PER_ELEMENT)) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer with byteOffset " + intByteOffset) } } else { - intLength = intByteLength / Float32Array.BYTES_PER_ELEMENT as int + intLength = Double.toInt(intByteLength / Float32Array.BYTES_PER_ELEMENT) } if (intLength < 0) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer") } - if (intLength < intByteLength / Float32Array.BYTES_PER_ELEMENT as int) { - intByteLength = intLength * Float32Array.BYTES_PER_ELEMENT as int + if (intLength < Double.toInt(intByteLength / Float32Array.BYTES_PER_ELEMENT)) { + intByteLength = intLength * Float32Array.BYTES_PER_ELEMENT } this.byteLength = intByteLength this.byteOffset = intByteOffset @@ -7581,32 +7242,6 @@ export final class Float32Array implements Iterable, ArrayLike { this.buffer = buf } - /** - * Creates an Float32Array with respect to data, byteOffset and length. - * - * @param buf data initializer - * - * @param byteOffset byte offset from begin of the buf - * - * @param length size of elements of type float in newly created Float32Array - */ - public constructor(buf: ArrayBuffer, byteOffset: Number | undefined) { - this(buf, byteOffset, undefined) - } - - /** - * Creates an Float32Array with respect to data, byteOffset and length. - * - * @param buf data initializer - * - * @param byteOffset byte offset from begin of the buf - * - * @param length size of elements of type float in newly created Float32Array - */ - public constructor(buf: ArrayBuffer, byteOffset: number, length: number) { - this(buf, new Number(byteOffset), new Number(length)) - } - /** * Creates an Float32Array with respect to data, byteOffset and length. * @@ -7652,19 +7287,19 @@ export final class Float32Array implements Iterable, ArrayLike { public constructor(buf: ArrayLike | ArrayBuffer) { if (buf instanceof ArrayBuffer) { this.byteLength = (buf as ArrayBuffer).getByteLength() - if (this.byteLength % Float32Array.BYTES_PER_ELEMENT as int != 0) { + if (this.byteLength % Float32Array.BYTES_PER_ELEMENT.toInt() != 0) { throw new RangeError("ArrayBuffer.byteLength should be multiple of 4 as Float32Array.BYTES_PER_ELEMENT") } - this.lengthInt = this.byteLength / Float32Array.BYTES_PER_ELEMENT as int + this.lengthInt = Double.toInt(this.byteLength / Float32Array.BYTES_PER_ELEMENT) this.buffer = buf as ArrayBuffer this.byteOffset = 0 } else if (buf instanceof ArrayLike) { // NOTE (ikorobkov): dealing with this overload is tricky // with banned `instanceof` generic, so it is delegated to array here. Initial idea from Set.ets let arr = Array.from((buf as ArrayLike)) - this.byteLength = arr.length as int * Float32Array.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int - this.buffer = new ArrayBuffer(this.byteLength as int) + this.byteLength = arr.length.toInt() * Float32Array.BYTES_PER_ELEMENT.toInt() + this.lengthInt = arr.length.toInt() + this.buffer = new ArrayBuffer(this.byteLength.toInt()) this.byteOffset = 0 for (let i: int = 0; i < this.lengthInt; ++i) { this.setUnsafe(i, arr.$_get(i).toFloat()) @@ -7680,7 +7315,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @param length data initializer */ public constructor(length: int) { - this(length as number) + this(Int.toDouble(length)) } /** @@ -7689,13 +7324,13 @@ export final class Float32Array implements Iterable, ArrayLike { * @param length data initializer */ public constructor(length: number) { - if (length < 0 || length > (Int.MAX_VALUE / Float32Array.BYTES_PER_ELEMENT)) { + if (length < 0 || length > Double.toInt(Int.MAX_VALUE / Float32Array.BYTES_PER_ELEMENT)) { throw new TypeError("Type Error: length " + length + " is outside the bounds of the buffer") } - this.lengthInt = length as int - this.byteLength = this.lengthInt * Float32Array.BYTES_PER_ELEMENT as int + this.lengthInt = Double.toInt(length) + this.byteLength = this.lengthInt * Float32Array.BYTES_PER_ELEMENT this.byteOffset = 0 - this.buffer = new ArrayBuffer(this.byteLength as int) + this.buffer = new ArrayBuffer(this.byteLength.toInt()) } /** @@ -7704,9 +7339,9 @@ export final class Float32Array implements Iterable, ArrayLike { * @param other data initializer */ public constructor(other: Float32Array) { - this.buffer = other.buffer.slice(other.byteOffset as int, (other.byteOffset + other.byteLength) as int) as ArrayBuffer + this.buffer = other.buffer.slice(other.byteOffset.toInt(), (other.byteOffset + other.byteLength).toInt()) as ArrayBuffer this.byteLength = other.byteLength - this.lengthInt = other.length as int + this.lengthInt = Double.toInt(other.length) this.byteOffset = 0 } @@ -7716,7 +7351,7 @@ export final class Float32Array implements Iterable, ArrayLike { public constructor(numbers: FixedArray) { this(numbers.length) for (let i: int = 0; i < this.lengthInt; ++i) { - this.setUnsafe(i, numbers[i] as float) + this.setUnsafe(i, numbers[i].toFloat()) } } @@ -7726,7 +7361,7 @@ export final class Float32Array implements Iterable, ArrayLike { public constructor(numbers: FixedArray) { this(numbers.length) for (let i: int = 0; i < this.lengthInt; ++i) { - this.setUnsafe(i, numbers[i] as float) + this.setUnsafe(i, numbers[i].toFloat()) } } @@ -7738,7 +7373,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @param index index to change */ public $_set(index: number, val: number): void { - this.$_set(index as int, val) + this.$_set(Double.toInt(index), val) } /** @@ -7749,7 +7384,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @param index index to change */ public $_set(index: int, val: number): void { - this.$_set(index, val as float) + this.$_set(index, val.toFloat()) } /** @@ -7760,7 +7395,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @param index index to change */ public $_set(index: number, val: float): void { - this.$_set(index as int, val) + this.$_set(Double.toInt(index), val) } /** @@ -7785,7 +7420,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns a primitive at index */ public override $_get(index: number): Number { - return this.$_get(index as int) as Number + return this.$_get(Double.toInt(index)) } /** @@ -7805,7 +7440,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns a primitive at index */ public at(index: number): Number | undefined { - return this.at(index as int) + return this.at(Double.toInt(index)) } /** @@ -7840,7 +7475,7 @@ export final class Float32Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: number, start: number, end?: number): Float32Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(Double.toInt(target), Double.toInt(start), asIntOrDefault(end, this.lengthInt)) } /** @@ -7855,7 +7490,7 @@ export final class Float32Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: int, start: number, end?: number): Float32Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target, Double.toInt(start), asIntOrDefault(end, this.lengthInt)) } /** @@ -7870,7 +7505,7 @@ export final class Float32Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: number, start: int, end?: number): Float32Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(Double.toInt(target), start, asIntOrDefault(end, this.lengthInt)) } /** @@ -7885,7 +7520,7 @@ export final class Float32Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: int, start: int, end?: number): Float32Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target, start, asIntOrDefault(end, this.lengthInt)) } /** @@ -7910,7 +7545,7 @@ export final class Float32Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} */ public copyWithin(target: number): Float32Array { - return this.copyWithin(target as int) + return this.copyWithin(Double.toInt(target)) } /** @@ -7942,7 +7577,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns modified Float32Array */ public fill(value: number, start?: number, end?: number): this { - this.fill(value as float, asIntOrDefault(start, 0 as int), asIntOrDefault(end, this.lengthInt)) + this.fill(value.toFloat(), asIntOrDefault(start, 0), asIntOrDefault(end, this.lengthInt)) return this } @@ -7954,19 +7589,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns modified Float32Array */ public fill(value: number, start: int, end?: number): this { - this.fill(value as float, start as int, asIntOrDefault(end, this.lengthInt)) - return this - } - - /** - * Fills the Float32Array with specified value - * - * @param value new valuy - * - * @returns modified Float32Array - */ - public fill(value: number, start: int, end: number): this { - this.fill(value as float, start as int, end as int) + this.fill(value.toFloat(), start, asIntOrDefault(end, this.lengthInt)) return this } @@ -7978,7 +7601,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns modified Float32Array */ public fill(value: number, start: number, end: int): this { - this.fill(value as float, start as int, end as int) + this.fill(value.toFloat(), Double.toInt(start), end) return this } @@ -7990,7 +7613,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns modified Float32Array */ public fill(value: number, start: int, end: int): this { - this.fill(value as float, start as int, end as int) + this.fill(value.toFloat(), start, end) return this } @@ -8002,7 +7625,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns modified Float32Array */ public fill(value: float, start?: number, end?: number): this { - this.fill(value, asIntOrDefault(start, 0 as int), asIntOrDefault(end, this.lengthInt)) + this.fill(value, asIntOrDefault(start, 0), asIntOrDefault(end, this.lengthInt)) return this } @@ -8014,19 +7637,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns modified Float32Array */ public fill(value: float, start: int, end?: number): this { - this.fill(value, start as int, asIntOrDefault(end, this.lengthInt)) - return this - } - - /** - * Fills the Float32Array with specified value - * - * @param value new valuy - * - * @returns modified Float32Array - */ - public fill(value: float, start: int, end: number): this { - this.fill(value, start as int, end as int) + this.fill(value, start, asIntOrDefault(end, this.lengthInt)) return this } @@ -8038,7 +7649,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns modified Float32Array */ public fill(value: float, start: number, end: int): this { - this.fill(value, start as int, end as int) + this.fill(value, Double.toInt(start), end) return this } @@ -8092,12 +7703,12 @@ export final class Float32Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ public set(arr: FixedArray, insertPos: number): void { - const offset = insertPos as int + const offset = Double.toInt(insertPos) if (offset < 0 || offset + arr.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } - for (let i = 0; i < arr.length as int; ++i) { - this.$_set(offset + i, arr[i] as float) + for (let i = 0; i < Double.toInt(arr.length); ++i) { + this.$_set(offset + i, arr[i].toFloat()) } } @@ -8111,11 +7722,11 @@ export final class Float32Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ public set(arr: FixedArray, insertPos: int): void { - const offset = insertPos as int + const offset = insertPos if (offset < 0 || offset + arr.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } - for (let i = 0; i < arr.length as int; ++i) { + for (let i = 0; i < Double.toInt(arr.length); ++i) { this.$_set(offset + i, arr[i]) } } @@ -8126,7 +7737,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @param arr array to copy data from */ public set(arr: FixedArray): void { - this.set(arr, 0 as number) + this.set(arr, 0) } /** @@ -8135,7 +7746,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @param arr array to copy data from */ public set(arr: FixedArray): void { - this.set(arr, 0 as int) + this.set(arr, 0) } public native set(array: Float32Array): void @@ -8150,12 +7761,12 @@ export final class Float32Array implements Iterable, ArrayLike { * @param offset Optional. The offset into the target array at which to begin writing values from the source array */ public set(array: ArrayLike, offset: number = 0): void { - const insertPos = offset as int + const insertPos = Double.toInt(offset) if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } - for (let i = array.length - 1 as int; i >= 0; --i) { - this.$_set(insertPos + i, array[i] as float) + for (let i = Double.toInt(array.length) - 1; i >= 0; --i) { + this.$_set(insertPos + i, array[i].toFloat()) } } @@ -8167,9 +7778,9 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns new Float32Array */ public static of(...items: FixedArray): Float32Array { - let res = new Float32Array(items.length as int) + let res = new Float32Array(Double.toInt(items.length)) for (let i: int = 0; i < items.length; i++) { - res.setUnsafe(i, items[i] as float) + res.setUnsafe(i, items[i].toFloat()) } return res } @@ -8182,9 +7793,9 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns new Float32Array */ public static of(...items: FixedArray): Float32Array { - let res = new Float32Array(items.length as int) + let res = new Float32Array(Double.toInt(items.length)) for (let i: int = 0; i < items.length; i++) { - res.setUnsafe(i, items[i] as float) + res.setUnsafe(i, items[i].toFloat()) } return res } @@ -8197,7 +7808,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns new Float32Array */ public static of(...items: FixedArray): Float32Array { - let res = new Float32Array(items.length as int) + let res = new Float32Array(Double.toInt(items.length)) for (let i: int = 0; i < items.length; i++) { res.setUnsafe(i, items[i]) } @@ -8212,7 +7823,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns new Float32Array */ public static of(): Float32Array { - return new Float32Array(0 as int) + return new Float32Array(0) } /** @@ -8253,7 +7864,7 @@ export final class Float32Array implements Iterable, ArrayLike { if (x.done) { return new Float32Array(result.buffer, 0, i) } - result.setUnsafe(i, (mapfn)!(x.value!, i) as float) + result.setUnsafe(i, (mapfn)!(x.value!, i).toFloat()) } return result } @@ -8273,7 +7884,7 @@ export final class Float32Array implements Iterable, ArrayLike { } temp = new Float32Array(tb) } - temp.setUnsafe(index[0], (mapfn)!(x, index[0]) as float) + temp.setUnsafe(index[0], (mapfn)!(x, index[0]).toFloat()) index[0]++ }) return new Float32Array(temp.buffer, 0, index[0]) @@ -8295,7 +7906,7 @@ export final class Float32Array implements Iterable, ArrayLike { const idx : FixedArray = new int[1] idx[0] = 0 iteratorForEach(arrayLike.$_iterator(), (x: T): void => { - res.setUnsafe(idx[0] as int, mapfn(x as T, idx[0] as number) as float) + res.setUnsafe(idx[0], mapfn(x as T, idx[0]).toFloat()) idx[0] += 1 }) return res @@ -8333,7 +7944,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns true if e is in Float32Array, false otherwise */ public includes(searchElement: float, fromIndex: int): boolean { - return this.indexOf(searchElement as int, fromIndex) != -1 + return this.indexOf(searchElement.toInt(), fromIndex) != -1 } /** @@ -8388,7 +7999,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns index of element if it presents, -1 otherwise */ public indexOf(searchElement: int, fromIndex: int): number { - return this.indexOfImpl(searchElement as long, fromIndex) + return this.indexOfImpl(Int.toLong(searchElement), fromIndex) } /** @@ -8515,7 +8126,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ public lastIndexOf(searchElement: int, fromIndex: int): number { - return this.lastIndexOfImpl(searchElement as long, fromIndex) + return this.lastIndexOfImpl(Int.toLong(searchElement), fromIndex) } /** @@ -8586,22 +8197,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin?: number, end?: number): Float32Array { - return this.slice(asIntOrDefault(begin, 0 as int), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Creates a slice of current Float32Array using range [begin, end) - * - * @param begin start index to be taken into slice - * - * @param end last index to be taken into slice - * - * @returns a new Float32Array with elements of current Float32Array[begin;end) where end index is excluded - * - * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice - */ - public slice(begin: number, end: number): Float32Array { - return this.slice(begin as int, end as int) + return this.slice(asIntOrDefault(begin, 0), asIntOrDefault(end, this.lengthInt)) } /** @@ -8616,7 +8212,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin: number, end: int): Float32Array { - return this.slice(begin as int, end as int) + return this.slice(Double.toInt(begin), end) } /** @@ -8631,7 +8227,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin: int, end: number): Float32Array { - return this.slice(begin as int, end as int) + return this.slice(begin, Double.toInt(end)) } /** @@ -8653,21 +8249,10 @@ export final class Float32Array implements Iterable, ArrayLike { if (count < 0) { count = 0 } - let buf = this.buffer.slice(relStart * Float32Array.BYTES_PER_ELEMENT as int, relEnd * Float32Array.BYTES_PER_ELEMENT as int) as ArrayBuffer + let buf = this.buffer.slice(relStart * Float32Array.BYTES_PER_ELEMENT.toInt(), relEnd * Float32Array.BYTES_PER_ELEMENT.toInt()) as ArrayBuffer return new Float32Array(buf) } - /** - * Creates a slice of current Float32Array using range [begin, this.length). - * - * @param begin start index to be taken into slice - * - * @returns a new Float32Array with elements of current Float32Array[begin, this.length) - */ - public slice(begin: number): Float32Array { - return this.slice(begin as int) - } - /** * Creates a slice of current Float32Array using range [begin, this.length). * @@ -8692,19 +8277,6 @@ export final class Float32Array implements Iterable, ArrayLike { return this.subarray(asIntOrDefault(begin, 0 as int), asIntOrDefault(end, this.lengthInt)) } - /** - * Creates a Float32Array with the same underlying ArrayBuffer - * - * @param begin start index, inclusive - * - * @param end last index, exclusive - * - * @returns new Float32Array with the same underlying ArrayBuffer - */ - public subarray(begin: number, end: number): Float32Array { - return this.subarray(begin as int, end as int) - } - /** * Creates a Float32Array with the same underlying ArrayBuffer * @@ -8715,7 +8287,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns new Float32Array with the same underlying ArrayBuffer */ public subarray(begin: number, end: int): Float32Array { - return this.subarray(begin as int, end as int) + return this.subarray(Double.toInt(begin), end) } /** @@ -8728,7 +8300,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns new Float32Array with the same underlying ArrayBuffer */ public subarray(begin: int, end: number): Float32Array { - return this.subarray(begin as int, end as int) + return this.subarray(begin, Double.toInt(end)) } /** @@ -8748,7 +8320,7 @@ export final class Float32Array implements Iterable, ArrayLike { if (count < 0) { count = 0 } - return new Float32Array(this.buffer, relStart * Float32Array.BYTES_PER_ELEMENT as int, count) + return new Float32Array(this.buffer, relStart * Float32Array.BYTES_PER_ELEMENT.toInt(), count) } /** @@ -8759,7 +8331,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns new Float32Array with the same ArrayBuffer */ public subarray(begin: number): Float32Array { - return this.subarray(begin as int, this.lengthInt) + return this.subarray(begin.toInt(), this.lengthInt) } /** @@ -8770,7 +8342,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns new Float32Array with the same ArrayBuffer */ public subarray(begin: int): Float32Array { - return this.subarray(begin as int, this.lengthInt) + return this.subarray(begin, this.lengthInt) } /** @@ -8805,11 +8377,11 @@ export final class Float32Array implements Iterable, ArrayLike { public toLocaleString(): string { let res: StringBuilder = new StringBuilder("") for (let i = 0; i < this.lengthInt - 1; ++i) { - res.append((this.getUnsafe(i) as Number).toLocaleString()) + res.append(new Number(this.getUnsafe(i)).toLocaleString()) res.append(",") } if (this.lengthInt > 0) { - res.append((this.getUnsafe(this.lengthInt - 1) as Number).toLocaleString()) + res.append(new Number(this.getUnsafe(this.lengthInt - 1))).toLocaleString() } return res.toString() } @@ -8869,7 +8441,7 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns an Float32Array with replaced value on index */ public with(index: number, value: number): Float32Array { - return this.with(index as int, value as float) + return this.with(Double.toInt(index), value.toFloat()) } /** @@ -8899,7 +8471,7 @@ export final class Float32Array implements Iterable, ArrayLike { public findLast(fn: (val: number) => boolean): number { let newF: (val: number, index: number, array: Float32Array) => boolean = (val: number, index: number, array: Float32Array): boolean => { return fn(val) } - return this.findLast(newF) as number + return (this.findLast(newF)).toDouble() } /** @@ -8928,8 +8500,13 @@ export final class Float32Array implements Iterable, ArrayLike { arr[i] = this.getUnsafe(i) } let cmp = (l: float, r: float): number => { - const result = compareFn!(l as number, r as number) - return result + return (l - r).toDouble() + } + if (compareFn != undefined) { + cmp = (l: float, r: float): number => { + const result = compareFn!((l).toDouble(), (r).toDouble()) + return result + } } sort(arr, cmp) for (let i = 0; i < this.lengthInt; ++i) { @@ -8950,7 +8527,7 @@ export final class Float32Array implements Iterable, ArrayLike { */ public some(predicate: (element: number, index: number, array: Float32Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; ++i) { - if (predicate(this.getUnsafe(i) as number, i as number, this)) { + if (predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { return true } } @@ -8975,7 +8552,7 @@ export final class Float32Array implements Iterable, ArrayLike { initialValue: U): U { let accumulatedValue = initialValue for (let i = 0; i < this.lengthInt; ++i) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) } return accumulatedValue } @@ -8997,9 +8574,9 @@ export final class Float32Array implements Iterable, ArrayLike { throw new TypeError("Reduce of empty array with no initial value") } - let accumulatedValue = this.getUnsafe(0) as number + let accumulatedValue = (this.getUnsafe(0)).toDouble() for (let i = 1; i < this.lengthInt; ++i) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) } return accumulatedValue } @@ -9022,7 +8599,7 @@ export final class Float32Array implements Iterable, ArrayLike { initialValue: U): U { let accumulatedValue = initialValue for (let i = this.lengthInt - 1; i >= 0; --i) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) } return accumulatedValue } @@ -9045,9 +8622,9 @@ export final class Float32Array implements Iterable, ArrayLike { throw new TypeError("Reduce of empty array with no initial value") } - let accumulatedValue: number = this.getUnsafe(this.lengthInt - 1) as number + let accumulatedValue: number = (this.getUnsafe(this.lengthInt - 1)).toDouble() for (let i = this.lengthInt - 2; i >= 0; --i) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) } return accumulatedValue } @@ -9060,10 +8637,10 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns a new Float32Array where for each element from current Float32Array fn was applied */ public map(fn: (val: number, index: number, array: Float32Array) => number): Float32Array { - let resBuf = new ArrayBuffer(this.lengthInt * Float32Array.BYTES_PER_ELEMENT as int) - let res = new Float32Array(resBuf, 0, resBuf.getByteLength() / Float32Array.BYTES_PER_ELEMENT as int) + let resBuf = new ArrayBuffer(this.lengthInt * Float32Array.BYTES_PER_ELEMENT) + let res = new Float32Array(resBuf, 0, Double.toInt(resBuf.getByteLength() / Float32Array.BYTES_PER_ELEMENT)) for (let i = 0; i < this.lengthInt; ++i) { - res.set(i, fn(this.getUnsafe(i) as number, i as number, this) as float) + res.set(i, fn((this.getUnsafe(i)).toDouble(), i.toDouble(), this).toFloat()) } return res } @@ -9080,7 +8657,7 @@ export final class Float32Array implements Iterable, ArrayLike { */ public every(predicate: (element: number, index: number, array: Float32Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; ++i) { - if (!predicate(this.getUnsafe(i) as number, i as number, this)) { + if (!predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { return false } } @@ -9098,12 +8675,12 @@ export final class Float32Array implements Iterable, ArrayLike { let markers : FixedArray = new boolean[this.lengthInt] let resLen = 0 for (let i = 0; i < this.lengthInt; ++i) { - markers[i] = fn(this.getUnsafe(i) as number, i as number, this) + markers[i] = fn((this.getUnsafe(i)).toDouble(), i.toDouble(), this) if (markers[i]) { ++resLen } } - let resBuf = new ArrayBuffer(resLen * Float32Array.BYTES_PER_ELEMENT as int) + let resBuf = new ArrayBuffer(resLen * Float32Array.BYTES_PER_ELEMENT) let res = new Float32Array(resBuf, 0) for (let i = 0, j = 0; i < this.lengthInt; ++i) { if (markers[i]) { @@ -9127,8 +8704,8 @@ export final class Float32Array implements Iterable, ArrayLike { public find(predicate: (value: number, index: number, obj: Float32Array) => boolean): number | undefined { for (let i = 0; i < this.lengthInt; ++i) { let val = this.getUnsafe(i) - if (predicate(val as number, i as number, this)) { - return val as number + if (predicate((val).toDouble(), i.toDouble(), this)) { + return (val).toDouble() } } return undefined @@ -9146,11 +8723,11 @@ export final class Float32Array implements Iterable, ArrayLike { */ public findIndex(predicate: (value: number, index: number, obj: Float32Array) => boolean): number { for (let i = 0; i < this.lengthInt; ++i) { - if (predicate(this.getUnsafe(i) as number, i as number, this)) { - return i as number + if (predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { + return i.toDouble() } } - return -1 as number + return (-1).toDouble() } /** @@ -9163,7 +8740,7 @@ export final class Float32Array implements Iterable, ArrayLike { public findLast(fn: (val: number, index: number, array: Float32Array) => boolean): float { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) - if (fn(val as number, i as number, this)) { + if (fn((val).toDouble(), i.toDouble(), this)) { return val } } @@ -9180,11 +8757,11 @@ export final class Float32Array implements Iterable, ArrayLike { public findLastIndex(fn: (val: number, index: number, array: Float32Array) => boolean): number { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) - if (fn(val as number, i as number, this)) { + if (fn((val).toDouble(), i.toDouble(), this)) { return i } } - return -1 as number + return (-1).toDouble() } /** @@ -9197,7 +8774,7 @@ export final class Float32Array implements Iterable, ArrayLike { */ public forEach(callbackfn: (value: number, index: number, array: Float32Array) => void): void { for (let i = 0; i < this.lengthInt; ++i) { - callbackfn(this.getUnsafe(i) as number, i as number, this) + callbackfn((this.getUnsafe(i)).toDouble(), i.toDouble(), this) } } @@ -9211,37 +8788,37 @@ export final class Float32Array implements Iterable, ArrayLike { } internal getUnsafe(index: int): float { - let byteIndex = index * Float32Array.BYTES_PER_ELEMENT as int + this.byteOffset as int + let byteIndex = index * Float32Array.BYTES_PER_ELEMENT + Double.toInt(this.byteOffset) let res : int = 0 let byteVal : int if (IS_LITTLE_ENDIAN) { - for (let i: int = 0; i < Float32Array.BYTES_PER_ELEMENT as int; ++i) { - byteVal = (this.buffer as ArrayBuffer).at(byteIndex as int + i) + for (let i: int = 0; i < Float32Array.BYTES_PER_ELEMENT.toInt(); ++i) { + byteVal = (this.buffer as ArrayBuffer).at(byteIndex.toInt() + i) byteVal &= 0xff - res = (res | byteVal << (8 * i)) as int + res = (res | byteVal << (8 * i)).toInt() } return Float.bitCastFromInt(res) } else { - for (let i: int = 0; i < Float32Array.BYTES_PER_ELEMENT as int; ++i) { - byteVal = this.buffer.at(byteIndex as int + 3 - i) + for (let i: int = 0; i < Float32Array.BYTES_PER_ELEMENT.toInt(); ++i) { + byteVal = this.buffer.at(byteIndex.toInt() + 3 - i) byteVal &= 0xff - res = (res | byteVal << (8 * i)) as int + res = (res | byteVal << (8 * i)).toInt() } return Float.bitCastFromInt(res) } } internal setUnsafe(insertPos: int, val: float): void { - let startByte = insertPos * Float32Array.BYTES_PER_ELEMENT as int + this.byteOffset as int + let startByte = insertPos * Float32Array.BYTES_PER_ELEMENT + Double.toInt(this.byteOffset) let bits = Float.bitCastToInt(val) if (IS_LITTLE_ENDIAN) { - for (let i = 0; i < Float32Array.BYTES_PER_ELEMENT as int; ++i) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + for (let i = 0; i < Float32Array.BYTES_PER_ELEMENT.toInt(); ++i) { + let byteVal = ((bits >>> (i * 8)) & 0xff).toByte() this.buffer.set(startByte + i, byteVal) } } else { - for (let i = 0; i < Float32Array.BYTES_PER_ELEMENT as int; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + for (let i = 0; i < Float32Array.BYTES_PER_ELEMENT.toInt(); i++) { + let byteVal = ((bits >>> (i * 8)) & 0xff).toByte() this.buffer.set(startByte + 3 - i, byteVal) } } @@ -9265,7 +8842,7 @@ class Float64ArrayIteratorKeys implements IterableIterator { private idx: int = 0 constructor(parent: Float64Array) { - this.length = parent.length as int + this.length = Double.toInt(parent.length) } public override $_iterator(): IterableIterator { @@ -9276,7 +8853,7 @@ class Float64ArrayIteratorKeys implements IterableIterator { if (this.idx < 0 || this.idx >= this.length) { return new IteratorResult() } - return new IteratorResult(false, this.idx++ as number) + return new IteratorResult(false, Int.toDouble(this.idx++)) } } @@ -9293,7 +8870,7 @@ class Float64ArrayIterator implements IterableIterator { } override next(): IteratorResult { - if (this.idx < 0 || this.idx >= this.parent.length as int) { + if (this.idx < 0 || this.idx >= Double.toInt(this.parent.length)) { return new IteratorResult() } return new IteratorResult(false, new Number(this.parent[this.idx++])) @@ -9313,7 +8890,7 @@ class Float64ArrayIteratorEntries implements IterableIterator<[Number, Number]> } override next(): IteratorResult<[Number, Number]> { - if (this.idx < 0 || this.idx >= this.parent.length as int) { + if (this.idx < 0 || this.idx >= Double.toInt(this.parent.length)) { return new IteratorResult<[Number, Number]>() } return new IteratorResult<[Number, Number]>( @@ -9327,15 +8904,15 @@ class Float64ArrayIteratorEntries implements IterableIterator<[Number, Number]> * JS Float64Array API-compatible class */ export final class Float64Array implements Iterable, ArrayLike { - public static readonly BYTES_PER_ELEMENT: number = 8 - public readonly BYTES_PER_ELEMENT: number = Float64Array.BYTES_PER_ELEMENT + public static readonly BYTES_PER_ELEMENT: int = 8 + public readonly BYTES_PER_ELEMENT: int = Float64Array.BYTES_PER_ELEMENT internal readonly lengthInt: int /** * Creates an empty Float64Array. */ public constructor() { - this(0 as int) + this(0) } /** @@ -9345,9 +8922,9 @@ export final class Float64Array implements Iterable, ArrayLike { const items: Object = elements as Object if (items instanceof ArrayLike) { const arr = Types.identity_cast(items as ArrayLike) - this.byteLength = arr.length as int * Float64Array.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int - this.buffer = new ArrayBuffer(this.byteLength as int) + this.byteLength = Double.toInt(arr.length) * Float64Array.BYTES_PER_ELEMENT + this.lengthInt = Double.toInt(arr.length) + this.buffer = new ArrayBuffer(Double.toInt(this.byteLength)) this.byteOffset = 0 for (let i: int = 0; i < this.lengthInt; ++i) { this.setUnsafe(i, arr.$_get(i).toDouble()) @@ -9383,27 +8960,27 @@ export final class Float64Array implements Iterable, ArrayLike { throw new RangeError("Range Error: byteLength " + intByteLength + " is outside the bounds of the buffer with byteOffset " + intByteOffset) } - if (intByteLength % Float64Array.BYTES_PER_ELEMENT as int != 0) { + if (intByteLength % Float64Array.BYTES_PER_ELEMENT.toInt() != 0) { throw new RangeError("ArrayBuffer.byteLength should be multiple of 8 as Float64Array.BYTES_PER_ELEMENT") } - if (intByteOffset % Float64Array.BYTES_PER_ELEMENT as int != 0) { + if (intByteOffset % Float64Array.BYTES_PER_ELEMENT != 0) { throw new RangeError("byteOffset should be multiple of 8 as Float64Array.BYTES_PER_ELEMENT") } let intLength: int if (length != undefined) { intLength = length.toInt() - if (intLength > intByteLength / Float64Array.BYTES_PER_ELEMENT as int) { + if (intLength > Double.toInt(intByteLength / Float64Array.BYTES_PER_ELEMENT)) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer with byteOffset " + intByteOffset) } } else { - intLength = intByteLength / Float64Array.BYTES_PER_ELEMENT as int + intLength = Double.toInt(intByteLength / Float64Array.BYTES_PER_ELEMENT) } if (intLength < 0) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer") } - if (intLength < intByteLength / Float64Array.BYTES_PER_ELEMENT as int) { - intByteLength = intLength * Float64Array.BYTES_PER_ELEMENT as int + if (intLength < Double.toInt(intByteLength / Float64Array.BYTES_PER_ELEMENT)) { + intByteLength = intLength * Float64Array.BYTES_PER_ELEMENT } this.byteLength = intByteLength this.byteOffset = intByteOffset @@ -9411,32 +8988,6 @@ export final class Float64Array implements Iterable, ArrayLike { this.buffer = buf } - /** - * Creates an Float64Array with respect to data, byteOffset and length. - * - * @param buf data initializer - * - * @param byteOffset byte offset from begin of the buf - * - * @param length size of elements of type double in newly created Float64Array - */ - public constructor(buf: ArrayBuffer, byteOffset: Number | undefined) { - this(buf, byteOffset, undefined) - } - - /** - * Creates an Float64Array with respect to data, byteOffset and length. - * - * @param buf data initializer - * - * @param byteOffset byte offset from begin of the buf - * - * @param length size of elements of type double in newly created Float64Array - */ - public constructor(buf: ArrayBuffer, byteOffset: number, length: number) { - this(buf, new Number(byteOffset), new Number(length)) - } - /** * Creates an Float64Array with respect to data, byteOffset and length. * @@ -9482,19 +9033,19 @@ export final class Float64Array implements Iterable, ArrayLike { public constructor(buf: ArrayLike | ArrayBuffer) { if (buf instanceof ArrayBuffer) { this.byteLength = (buf as ArrayBuffer).getByteLength() - if (this.byteLength % Float64Array.BYTES_PER_ELEMENT as int != 0) { + if (this.byteLength % Float64Array.BYTES_PER_ELEMENT.toInt() != 0) { throw new RangeError("ArrayBuffer.byteLength should be multiple of 8 as Float64Array.BYTES_PER_ELEMENT") } - this.lengthInt = this.byteLength / Float64Array.BYTES_PER_ELEMENT as int + this.lengthInt = Double.toInt(this.byteLength / Float64Array.BYTES_PER_ELEMENT) this.buffer = buf as ArrayBuffer this.byteOffset = 0 } else if (buf instanceof ArrayLike) { // NOTE (ikorobkov): dealing with this overload is tricky // with banned `instanceof` generic, so it is delegated to array here. Initial idea from Set.ets let arr = Array.from((buf as ArrayLike)) - this.byteLength = arr.length as int * Float64Array.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int - this.buffer = new ArrayBuffer(this.byteLength as int) + this.byteLength = arr.length.toInt() * Float64Array.BYTES_PER_ELEMENT.toInt() + this.lengthInt = arr.length.toInt() + this.buffer = new ArrayBuffer(this.byteLength.toInt()) this.byteOffset = 0 for (let i: int = 0; i < this.lengthInt; ++i) { this.setUnsafe(i, arr.$_get(i).toDouble()) @@ -9510,7 +9061,7 @@ export final class Float64Array implements Iterable, ArrayLike { * @param length data initializer */ public constructor(length: int) { - this(length as number) + this(Int.toDouble(length)) } /** @@ -9519,13 +9070,13 @@ export final class Float64Array implements Iterable, ArrayLike { * @param length data initializer */ public constructor(length: number) { - if (length < 0 || length > (Int.MAX_VALUE / Float64Array.BYTES_PER_ELEMENT)) { + if (length < 0 || length > Double.toInt(Int.MAX_VALUE / Float64Array.BYTES_PER_ELEMENT)) { throw new TypeError("Type Error: length " + length + " is outside the bounds of the buffer") } - this.lengthInt = length as int - this.byteLength = this.lengthInt * Float64Array.BYTES_PER_ELEMENT as int + this.lengthInt = Double.toInt(length) + this.byteLength = this.lengthInt * Float64Array.BYTES_PER_ELEMENT this.byteOffset = 0 - this.buffer = new ArrayBuffer(this.byteLength as int) + this.buffer = new ArrayBuffer(this.byteLength.toInt()) } /** @@ -9534,9 +9085,9 @@ export final class Float64Array implements Iterable, ArrayLike { * @param other data initializer */ public constructor(other: Float64Array) { - this.buffer = other.buffer.slice(other.byteOffset as int, (other.byteOffset + other.byteLength) as int) as ArrayBuffer + this.buffer = other.buffer.slice(other.byteOffset.toInt(), (other.byteOffset + other.byteLength).toInt()) as ArrayBuffer this.byteLength = other.byteLength - this.lengthInt = other.length as int + this.lengthInt = Double.toInt(other.length) this.byteOffset = 0 } @@ -9546,7 +9097,7 @@ export final class Float64Array implements Iterable, ArrayLike { public constructor(numbers: FixedArray) { this(numbers.length) for (let i: int = 0; i < this.lengthInt; ++i) { - this.setUnsafe(i, numbers[i] as double) + this.setUnsafe(i, numbers[i].toDouble()) } } @@ -9556,7 +9107,7 @@ export final class Float64Array implements Iterable, ArrayLike { public constructor(numbers: FixedArray) { this(numbers.length) for (let i: int = 0; i < this.lengthInt; ++i) { - this.setUnsafe(i, numbers[i] as double) + this.setUnsafe(i, numbers[i].toDouble()) } } @@ -9568,7 +9119,7 @@ export final class Float64Array implements Iterable, ArrayLike { * @param index index to change */ public $_set(index: number, val: double): void { - this.$_set(index as int, val) + this.$_set(Double.toInt(index), val) } /** @@ -9593,7 +9144,7 @@ export final class Float64Array implements Iterable, ArrayLike { * @returns a primitive at index */ public override $_get(index: number): Number { - return this.$_get(index as int) as Number + return this.$_get(Double.toInt(index)) } /** @@ -9613,7 +9164,7 @@ export final class Float64Array implements Iterable, ArrayLike { * @returns a primitive at index */ public at(index: number): Number | undefined { - return this.at(index as int) + return this.at(Double.toInt(index)) } /** @@ -9648,7 +9199,7 @@ export final class Float64Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: number, start: number, end?: number): Float64Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(Double.toInt(target), Double.toInt(start), asIntOrDefault(end, this.lengthInt)) } /** @@ -9663,7 +9214,7 @@ export final class Float64Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: int, start: number, end?: number): Float64Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target, Double.toInt(start), asIntOrDefault(end, this.lengthInt)) } /** @@ -9678,7 +9229,7 @@ export final class Float64Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: number, start: int, end?: number): Float64Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(Double.toInt(target), start, asIntOrDefault(end, this.lengthInt)) } /** @@ -9693,7 +9244,7 @@ export final class Float64Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: int, start: int, end?: number): Float64Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target, start, asIntOrDefault(end, this.lengthInt)) } /** @@ -9718,7 +9269,7 @@ export final class Float64Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} */ public copyWithin(target: number): Float64Array { - return this.copyWithin(target as int) + return this.copyWithin(Double.toInt(target)) } /** @@ -9750,7 +9301,7 @@ export final class Float64Array implements Iterable, ArrayLike { * @returns modified Float64Array */ public fill(value: number, start?: number, end?: number): this { - this.fill(value as double, asIntOrDefault(start, 0 as int), asIntOrDefault(end, this.lengthInt)) + this.fill(value.toDouble(), asIntOrDefault(start, 0), asIntOrDefault(end, this.lengthInt)) return this } @@ -9762,19 +9313,7 @@ export final class Float64Array implements Iterable, ArrayLike { * @returns modified Float64Array */ public fill(value: number, start: int, end?: number): this { - this.fill(value as double, start as int, asIntOrDefault(end, this.lengthInt)) - return this - } - - /** - * Fills the Float64Array with specified value - * - * @param value new valuy - * - * @returns modified Float64Array - */ - public fill(value: number, start: int, end: number): this { - this.fill(value as double, start as int, end as int) + this.fill(value.toDouble(), start, asIntOrDefault(end, this.lengthInt)) return this } @@ -9786,7 +9325,7 @@ export final class Float64Array implements Iterable, ArrayLike { * @returns modified Float64Array */ public fill(value: number, start: number, end: int): this { - this.fill(value as double, start as int, end as int) + this.fill(value.toDouble(), Double.toInt(start), end) return this } @@ -9840,12 +9379,12 @@ export final class Float64Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ public set(arr: FixedArray, insertPos: number): void { - const offset = insertPos as int + const offset = Double.toInt(insertPos) if (offset < 0 || offset + arr.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } - for (let i = 0; i < arr.length as int; ++i) { - this.$_set(offset + i, arr[i] as double) + for (let i = 0; i < Double.toInt(arr.length); ++i) { + this.$_set(offset + i, arr[i].toDouble()) } } @@ -9859,11 +9398,11 @@ export final class Float64Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ public set(arr: FixedArray, insertPos: int): void { - const offset = insertPos as int + const offset = insertPos if (offset < 0 || offset + arr.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } - for (let i = 0; i < arr.length as int; ++i) { + for (let i = 0; i < Double.toInt(arr.length); ++i) { this.$_set(offset + i, arr[i]) } } @@ -9874,7 +9413,7 @@ export final class Float64Array implements Iterable, ArrayLike { * @param arr array to copy data from */ public set(arr: FixedArray): void { - this.set(arr, 0 as int) + this.set(arr, 0) } public native set(array: Float64Array): void @@ -9889,12 +9428,12 @@ export final class Float64Array implements Iterable, ArrayLike { * @param offset Optional. The offset into the target array at which to begin writing values from the source array */ public set(array: ArrayLike, offset: number = 0): void { - const insertPos = offset as int + const insertPos = Double.toInt(offset) if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } - for (let i = array.length - 1 as int; i >= 0; --i) { - this.$_set(insertPos + i, array[i] as double) + for (let i = Double.toInt(array.length) - 1; i >= 0; --i) { + this.$_set(insertPos + i, array[i].toDouble()) } } @@ -9906,7 +9445,7 @@ export final class Float64Array implements Iterable, ArrayLike { * @returns new Float64Array */ public static of(...items: FixedArray): Float64Array { - let res = new Float64Array(items.length as int) + let res = new Float64Array(Double.toInt(items.length)) for (let i: int = 0; i < items.length; i++) { res.setUnsafe(i, items[i]) } @@ -9921,9 +9460,9 @@ export final class Float64Array implements Iterable, ArrayLike { * @returns new Float64Array */ public static of(...items: FixedArray): Float64Array { - let res = new Float64Array(items.length as int) + let res = new Float64Array(Double.toInt(items.length)) for (let i: int = 0; i < items.length; i++) { - res.setUnsafe(i, items[i] as double) + res.setUnsafe(i, items[i].toDouble()) } return res } @@ -9936,7 +9475,7 @@ export final class Float64Array implements Iterable, ArrayLike { * @returns new Float64Array */ public static of(): Float64Array { - return new Float64Array(0 as int) + return new Float64Array(0) } /** @@ -9977,7 +9516,7 @@ export final class Float64Array implements Iterable, ArrayLike { if (x.done) { return new Float64Array(result.buffer, 0, i) } - result.setUnsafe(i, (mapfn)!(x.value!, i) as double) + result.setUnsafe(i, (mapfn)!(x.value!, i).toDouble()) } return result } @@ -9997,7 +9536,7 @@ export final class Float64Array implements Iterable, ArrayLike { } temp = new Float64Array(tb) } - temp.setUnsafe(index[0], (mapfn)!(x, index[0]) as double) + temp.setUnsafe(index[0], (mapfn)!(x, index[0]).toDouble()) index[0]++ }) return new Float64Array(temp.buffer, 0, index[0]) @@ -10019,7 +9558,7 @@ export final class Float64Array implements Iterable, ArrayLike { const idx : FixedArray = new int[1] idx[0] = 0 iteratorForEach(arrayLike.$_iterator(), (x: T): void => { - res.setUnsafe(idx[0] as int, mapfn(x as T, idx[0] as number) as double) + res.setUnsafe(idx[0], mapfn(x as T, idx[0]).toDouble()) idx[0] += 1 }) return res @@ -10086,7 +9625,7 @@ export final class Float64Array implements Iterable, ArrayLike { * @returns index of element if it presents, -1 otherwise */ public indexOf(searchElement: int, fromIndex: int): number { - return this.indexOfImpl(searchElement as long, fromIndex) + return this.indexOfImpl(Int.toLong(searchElement), fromIndex) } /** @@ -10213,7 +9752,7 @@ export final class Float64Array implements Iterable, ArrayLike { * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ public lastIndexOf(searchElement: int, fromIndex: int): number { - return this.lastIndexOfImpl(searchElement as long, fromIndex) + return this.lastIndexOfImpl(Int.toLong(searchElement), fromIndex) } /** @@ -10284,22 +9823,7 @@ export final class Float64Array implements Iterable, ArrayLike { * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin?: number, end?: number): Float64Array { - return this.slice(asIntOrDefault(begin, 0 as int), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Creates a slice of current Float64Array using range [begin, end) - * - * @param begin start index to be taken into slice - * - * @param end last index to be taken into slice - * - * @returns a new Float64Array with elements of current Float64Array[begin;end) where end index is excluded - * - * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice - */ - public slice(begin: number, end: number): Float64Array { - return this.slice(begin as int, end as int) + return this.slice(asIntOrDefault(begin, 0), asIntOrDefault(end, this.lengthInt)) } /** @@ -10314,7 +9838,7 @@ export final class Float64Array implements Iterable, ArrayLike { * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin: number, end: int): Float64Array { - return this.slice(begin as int, end as int) + return this.slice(Double.toInt(begin), end) } /** @@ -10329,7 +9853,7 @@ export final class Float64Array implements Iterable, ArrayLike { * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin: int, end: number): Float64Array { - return this.slice(begin as int, end as int) + return this.slice(begin, Double.toInt(end)) } /** @@ -10351,21 +9875,10 @@ export final class Float64Array implements Iterable, ArrayLike { if (count < 0) { count = 0 } - let buf = this.buffer.slice(relStart * Float64Array.BYTES_PER_ELEMENT as int, relEnd * Float64Array.BYTES_PER_ELEMENT as int) as ArrayBuffer + let buf = this.buffer.slice(relStart * Float64Array.BYTES_PER_ELEMENT.toInt(), relEnd * Float64Array.BYTES_PER_ELEMENT.toInt()) as ArrayBuffer return new Float64Array(buf) } - /** - * Creates a slice of current Float64Array using range [begin, this.length). - * - * @param begin start index to be taken into slice - * - * @returns a new Float64Array with elements of current Float64Array[begin, this.length) - */ - public slice(begin: number): Float64Array { - return this.slice(begin as int) - } - /** * Creates a slice of current Float64Array using range [begin, this.length). * @@ -10390,19 +9903,6 @@ export final class Float64Array implements Iterable, ArrayLike { return this.subarray(asIntOrDefault(begin, 0 as int), asIntOrDefault(end, this.lengthInt)) } - /** - * Creates a Float64Array with the same underlying ArrayBuffer - * - * @param begin start index, inclusive - * - * @param end last index, exclusive - * - * @returns new Float64Array with the same underlying ArrayBuffer - */ - public subarray(begin: number, end: number): Float64Array { - return this.subarray(begin as int, end as int) - } - /** * Creates a Float64Array with the same underlying ArrayBuffer * @@ -10413,7 +9913,7 @@ export final class Float64Array implements Iterable, ArrayLike { * @returns new Float64Array with the same underlying ArrayBuffer */ public subarray(begin: number, end: int): Float64Array { - return this.subarray(begin as int, end as int) + return this.subarray(Double.toInt(begin), end) } /** @@ -10426,7 +9926,7 @@ export final class Float64Array implements Iterable, ArrayLike { * @returns new Float64Array with the same underlying ArrayBuffer */ public subarray(begin: int, end: number): Float64Array { - return this.subarray(begin as int, end as int) + return this.subarray(begin, Double.toInt(end)) } /** @@ -10446,7 +9946,7 @@ export final class Float64Array implements Iterable, ArrayLike { if (count < 0) { count = 0 } - return new Float64Array(this.buffer, relStart * Float64Array.BYTES_PER_ELEMENT as int, count) + return new Float64Array(this.buffer, relStart * Float64Array.BYTES_PER_ELEMENT.toInt(), count) } /** @@ -10457,7 +9957,7 @@ export final class Float64Array implements Iterable, ArrayLike { * @returns new Float64Array with the same ArrayBuffer */ public subarray(begin: number): Float64Array { - return this.subarray(begin as int, this.lengthInt) + return this.subarray(begin.toInt(), this.lengthInt) } /** @@ -10468,7 +9968,7 @@ export final class Float64Array implements Iterable, ArrayLike { * @returns new Float64Array with the same ArrayBuffer */ public subarray(begin: int): Float64Array { - return this.subarray(begin as int, this.lengthInt) + return this.subarray(begin, this.lengthInt) } /** @@ -10503,11 +10003,11 @@ export final class Float64Array implements Iterable, ArrayLike { public toLocaleString(): string { let res: StringBuilder = new StringBuilder("") for (let i = 0; i < this.lengthInt - 1; ++i) { - res.append((this.getUnsafe(i) as Number).toLocaleString()) + res.append(new Number(this.getUnsafe(i)).toLocaleString()) res.append(",") } if (this.lengthInt > 0) { - res.append((this.getUnsafe(this.lengthInt - 1) as Number).toLocaleString()) + res.append(new Number(this.getUnsafe(this.lengthInt - 1))).toLocaleString() } return res.toString() } @@ -10567,7 +10067,7 @@ export final class Float64Array implements Iterable, ArrayLike { * @returns an Float64Array with replaced value on index */ public with(index: number, value: number): Float64Array { - return this.with(index as int, value as double) + return this.with(Double.toInt(index), value.toDouble()) } /** @@ -10597,7 +10097,7 @@ export final class Float64Array implements Iterable, ArrayLike { public findLast(fn: (val: number) => boolean): number { let newF: (val: number, index: number, array: Float64Array) => boolean = (val: number, index: number, array: Float64Array): boolean => { return fn(val) } - return this.findLast(newF) as number + return (this.findLast(newF)).toDouble() } /** @@ -10626,8 +10126,13 @@ export final class Float64Array implements Iterable, ArrayLike { arr[i] = this.getUnsafe(i) } let cmp = (l: double, r: double): number => { - const result = compareFn!(l as number, r as number) - return result + return (l - r).toDouble() + } + if (compareFn != undefined) { + cmp = (l: double, r: double): number => { + const result = compareFn!((l).toDouble(), (r).toDouble()) + return result + } } sort(arr, cmp) for (let i = 0; i < this.lengthInt; ++i) { @@ -10648,7 +10153,7 @@ export final class Float64Array implements Iterable, ArrayLike { */ public some(predicate: (element: number, index: number, array: Float64Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; ++i) { - if (predicate(this.getUnsafe(i) as number, i as number, this)) { + if (predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { return true } } @@ -10673,7 +10178,7 @@ export final class Float64Array implements Iterable, ArrayLike { initialValue: U): U { let accumulatedValue = initialValue for (let i = 0; i < this.lengthInt; ++i) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) } return accumulatedValue } @@ -10695,9 +10200,9 @@ export final class Float64Array implements Iterable, ArrayLike { throw new TypeError("Reduce of empty array with no initial value") } - let accumulatedValue = this.getUnsafe(0) as number + let accumulatedValue = (this.getUnsafe(0)).toDouble() for (let i = 1; i < this.lengthInt; ++i) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) } return accumulatedValue } @@ -10720,7 +10225,7 @@ export final class Float64Array implements Iterable, ArrayLike { initialValue: U): U { let accumulatedValue = initialValue for (let i = this.lengthInt - 1; i >= 0; --i) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) } return accumulatedValue } @@ -10743,9 +10248,9 @@ export final class Float64Array implements Iterable, ArrayLike { throw new TypeError("Reduce of empty array with no initial value") } - let accumulatedValue: number = this.getUnsafe(this.lengthInt - 1) as number + let accumulatedValue: number = (this.getUnsafe(this.lengthInt - 1)).toDouble() for (let i = this.lengthInt - 2; i >= 0; --i) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) } return accumulatedValue } @@ -10758,10 +10263,10 @@ export final class Float64Array implements Iterable, ArrayLike { * @returns a new Float64Array where for each element from current Float64Array fn was applied */ public map(fn: (val: number, index: number, array: Float64Array) => number): Float64Array { - let resBuf = new ArrayBuffer(this.lengthInt * Float64Array.BYTES_PER_ELEMENT as int) - let res = new Float64Array(resBuf, 0, resBuf.getByteLength() / Float64Array.BYTES_PER_ELEMENT as int) + let resBuf = new ArrayBuffer(this.lengthInt * Float64Array.BYTES_PER_ELEMENT) + let res = new Float64Array(resBuf, 0, Double.toInt(resBuf.getByteLength() / Float64Array.BYTES_PER_ELEMENT)) for (let i = 0; i < this.lengthInt; ++i) { - res.set(i, fn(this.getUnsafe(i) as number, i as number, this) as double) + res.set(i, fn((this.getUnsafe(i)).toDouble(), i.toDouble(), this).toDouble()) } return res } @@ -10778,7 +10283,7 @@ export final class Float64Array implements Iterable, ArrayLike { */ public every(predicate: (element: number, index: number, array: Float64Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; ++i) { - if (!predicate(this.getUnsafe(i) as number, i as number, this)) { + if (!predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { return false } } @@ -10796,12 +10301,12 @@ export final class Float64Array implements Iterable, ArrayLike { let markers : FixedArray = new boolean[this.lengthInt] let resLen = 0 for (let i = 0; i < this.lengthInt; ++i) { - markers[i] = fn(this.getUnsafe(i) as number, i as number, this) + markers[i] = fn((this.getUnsafe(i)).toDouble(), i.toDouble(), this) if (markers[i]) { ++resLen } } - let resBuf = new ArrayBuffer(resLen * Float64Array.BYTES_PER_ELEMENT as int) + let resBuf = new ArrayBuffer(resLen * Float64Array.BYTES_PER_ELEMENT) let res = new Float64Array(resBuf, 0) for (let i = 0, j = 0; i < this.lengthInt; ++i) { if (markers[i]) { @@ -10825,8 +10330,8 @@ export final class Float64Array implements Iterable, ArrayLike { public find(predicate: (value: number, index: number, obj: Float64Array) => boolean): number | undefined { for (let i = 0; i < this.lengthInt; ++i) { let val = this.getUnsafe(i) - if (predicate(val as number, i as number, this)) { - return val as number + if (predicate((val).toDouble(), i.toDouble(), this)) { + return (val).toDouble() } } return undefined @@ -10844,11 +10349,11 @@ export final class Float64Array implements Iterable, ArrayLike { */ public findIndex(predicate: (value: number, index: number, obj: Float64Array) => boolean): number { for (let i = 0; i < this.lengthInt; ++i) { - if (predicate(this.getUnsafe(i) as number, i as number, this)) { - return i as number + if (predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { + return i.toDouble() } } - return -1 as number + return (-1).toDouble() } /** @@ -10861,7 +10366,7 @@ export final class Float64Array implements Iterable, ArrayLike { public findLast(fn: (val: number, index: number, array: Float64Array) => boolean): double { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) - if (fn(val as number, i as number, this)) { + if (fn((val).toDouble(), i.toDouble(), this)) { return val } } @@ -10878,11 +10383,11 @@ export final class Float64Array implements Iterable, ArrayLike { public findLastIndex(fn: (val: number, index: number, array: Float64Array) => boolean): number { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) - if (fn(val as number, i as number, this)) { + if (fn((val).toDouble(), i.toDouble(), this)) { return i } } - return -1 as number + return (-1).toDouble() } /** @@ -10895,7 +10400,7 @@ export final class Float64Array implements Iterable, ArrayLike { */ public forEach(callbackfn: (value: number, index: number, array: Float64Array) => void): void { for (let i = 0; i < this.lengthInt; ++i) { - callbackfn(this.getUnsafe(i) as number, i as number, this) + callbackfn((this.getUnsafe(i)).toDouble(), i.toDouble(), this) } } @@ -10909,37 +10414,37 @@ export final class Float64Array implements Iterable, ArrayLike { } internal getUnsafe(index: int): double { - let byteIndex = index * Float64Array.BYTES_PER_ELEMENT as int + this.byteOffset as int + let byteIndex = index * Float64Array.BYTES_PER_ELEMENT + Double.toInt(this.byteOffset) let res : long = 0 let byteVal : long if (IS_LITTLE_ENDIAN) { - for (let i: int = 0; i < Float64Array.BYTES_PER_ELEMENT as int; ++i) { - byteVal = (this.buffer as ArrayBuffer).at(byteIndex as int + i) + for (let i: int = 0; i < Float64Array.BYTES_PER_ELEMENT.toInt(); ++i) { + byteVal = (this.buffer as ArrayBuffer).at(byteIndex.toInt() + i) byteVal &= 0xff - res = (res | byteVal << (8 * i)) as long + res = (res | byteVal << (8 * i)).toLong() } return Double.bitCastFromLong(res) } else { - for (let i: int = 0; i < Float64Array.BYTES_PER_ELEMENT as int; ++i) { - byteVal = this.buffer.at(byteIndex as int + 7 - i) + for (let i: int = 0; i < Float64Array.BYTES_PER_ELEMENT.toInt(); ++i) { + byteVal = this.buffer.at(byteIndex.toInt() + 7 - i) byteVal &= 0xff - res = (res | byteVal << (8 * i)) as long + res = (res | byteVal << (8 * i)).toLong() } return Double.bitCastFromLong(res) } } internal setUnsafe(insertPos: int, val: double): void { - let startByte = insertPos * Float64Array.BYTES_PER_ELEMENT as int + this.byteOffset as int + let startByte = insertPos * Float64Array.BYTES_PER_ELEMENT + Double.toInt(this.byteOffset) let bits = Double.bitCastToLong(val) if (IS_LITTLE_ENDIAN) { - for (let i = 0; i < Float64Array.BYTES_PER_ELEMENT as int; ++i) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + for (let i = 0; i < Float64Array.BYTES_PER_ELEMENT.toInt(); ++i) { + let byteVal = ((bits >>> (i * 8)) & 0xff).toByte() this.buffer.set(startByte + i, byteVal) } } else { - for (let i = 0; i < Float64Array.BYTES_PER_ELEMENT as int; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + for (let i = 0; i < Float64Array.BYTES_PER_ELEMENT.toInt(); i++) { + let byteVal = ((bits >>> (i * 8)) & 0xff).toByte() this.buffer.set(startByte + 7 - i, byteVal) } } diff --git a/static_core/plugins/ets/stdlib/escompat/TypedUArrays.ets b/static_core/plugins/ets/stdlib/escompat/TypedUArrays.ets index 2bc1ebaab422916d410821be6a8ef21989792009..b3194569b665bbc32eac91cae50795c5936154fa 100644 --- a/static_core/plugins/ets/stdlib/escompat/TypedUArrays.ets +++ b/static_core/plugins/ets/stdlib/escompat/TypedUArrays.ets @@ -24,7 +24,7 @@ class Uint8ClampedArrayIteratorKeys implements IterableIterator { private idx: int = 0 constructor(parent: Uint8ClampedArray) { - this.length = parent.length as int + this.length = parent.length.toInt() } public override $_iterator(): IterableIterator { @@ -35,7 +35,7 @@ class Uint8ClampedArrayIteratorKeys implements IterableIterator { if (this.idx < 0 || this.idx >= this.length) { return new IteratorResult() } - return new IteratorResult(false, this.idx++ as number) + return new IteratorResult(false, Int.toDouble(this.idx++)) } } @@ -86,8 +86,8 @@ class Uint8ClampedArrayIteratorEntries implements IterableIterator<[Number, Numb * JS Uint8ClampedArray API-compatible class */ export final class Uint8ClampedArray implements Iterable, ArrayLike { - public static readonly BYTES_PER_ELEMENT: number = 1 - public readonly BYTES_PER_ELEMENT: number = Uint8ClampedArray.BYTES_PER_ELEMENT + public static readonly BYTES_PER_ELEMENT: int = 1 + public readonly BYTES_PER_ELEMENT: int = Uint8ClampedArray.BYTES_PER_ELEMENT /** Underlying Buffer */ public readonly buffer: ArrayBuffer @@ -100,7 +100,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike, ArrayLike(items as ArrayLike) - this.byteLengthInt = arr.length as int * Uint8ClampedArray.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int + this.byteLengthInt = arr.length.toInt() * Uint8ClampedArray.BYTES_PER_ELEMENT + this.lengthInt = arr.length.toInt() this.buffer = new ArrayBuffer(this.byteLengthInt) this.byteOffsetInt = 0 for (let i: int = 0; i < this.lengthInt; ++i) { - this.setUnsafeClamp(i, arr.$_get(i) as int) + this.setUnsafeClamp(i, arr.$_get(i).toInt()) } } else { let x = Uint8ClampedArray.from(elements) @@ -151,17 +151,17 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike intByteLength / Uint8ClampedArray.BYTES_PER_ELEMENT as int) { + if (intLength > intByteLength / Uint8ClampedArray.BYTES_PER_ELEMENT) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer with byteOffset " + intByteOffset) } } else { - intLength = intByteLength / Uint8ClampedArray.BYTES_PER_ELEMENT as int + intLength = intByteLength / Uint8ClampedArray.BYTES_PER_ELEMENT } if (intLength < 0) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer") } - if (intLength < intByteLength / Uint8ClampedArray.BYTES_PER_ELEMENT as int) { - intByteLength = intLength * Uint8ClampedArray.BYTES_PER_ELEMENT as int + if (intLength < intByteLength / Uint8ClampedArray.BYTES_PER_ELEMENT) { + intByteLength = intLength * Uint8ClampedArray.BYTES_PER_ELEMENT } this.byteLengthInt = intByteLength this.byteOffsetInt = intByteOffset @@ -169,30 +169,6 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike, ArrayLike, ArrayLike | ArrayBuffer) { if (buf instanceof ArrayBuffer) { this.byteLengthInt = (buf as ArrayBuffer).getByteLength() - if (this.byteLengthInt % Uint8ClampedArray.BYTES_PER_ELEMENT as int != 0) { + if (this.byteLengthInt % Uint8ClampedArray.BYTES_PER_ELEMENT.toInt() != 0) { throw new RangeError("ArrayBuffer.byteLength should be multiple of int as Uint8ClampedArray.BYTES_PER_ELEMENT") } - this.lengthInt = this.byteLengthInt / Uint8ClampedArray.BYTES_PER_ELEMENT as int + this.lengthInt = this.byteLengthInt / Uint8ClampedArray.BYTES_PER_ELEMENT this.buffer = buf as ArrayBuffer this.byteOffsetInt = 0 } else if (buf instanceof ArrayLike) { // NOTE (ikorobkov): dealing with this overload is tricky // with banned `instanceof` generic, so it is delegated to array here. Initial idea from Set.ets let arr = Array.from((buf as ArrayLike)) - this.byteLengthInt = arr.length as int * Uint8ClampedArray.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int + this.byteLengthInt = arr.length.toInt() * Uint8ClampedArray.BYTES_PER_ELEMENT + this.lengthInt = arr.length.toInt() this.buffer = new ArrayBuffer(this.byteLengthInt) this.byteOffsetInt = 0 for (let i: int = 0; i < this.lengthInt; ++i) { @@ -264,7 +240,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike, ArrayLike (Int.MAX_VALUE / Uint8ClampedArray.BYTES_PER_ELEMENT)) { throw new TypeError("Type Error: length " + length + " is outside the bounds of the buffer") } - this.lengthInt = length as int - this.byteLengthInt = this.lengthInt * Uint8ClampedArray.BYTES_PER_ELEMENT as int + this.lengthInt = length.toInt() + this.byteLengthInt = this.lengthInt * Uint8ClampedArray.BYTES_PER_ELEMENT this.byteOffsetInt = 0 this.buffer = new ArrayBuffer(this.byteLengthInt) } @@ -288,9 +264,9 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike, ArrayLike) { this(numbers.length) for (let i: int = 0; i < this.lengthInt; ++i) { - this.setUnsafeClamp(i, numbers[i] as int) + this.setUnsafeClamp(i, numbers[i].toInt()) } } @@ -310,7 +286,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike) { this(numbers.length) for (let i: int = 0; i < this.lengthInt; ++i) { - this.setUnsafeClamp(i, numbers[i] as int) + this.setUnsafeClamp(i, numbers[i].toInt()) } } @@ -331,7 +307,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, insertPos1: number): void { - const insertPos = insertPos1 as int + const insertPos = insertPos1.toInt() if (insertPos < 0 || insertPos + arr.length > this.lengthInt) { throw new RangeError("set(insertPos: int, arr: FixedArray): size of arr is greater than Uint8ClampedArray.length") } for (let i = 0; i < arr.length; i++) { - this.setUnsafeClamp(insertPos as int + i as int, arr[i] as int) + this.setUnsafeClamp(insertPos.toInt() + i.toInt(), arr[i].toInt()) } } @@ -758,12 +710,12 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike, offset: number = 0): void { - const insertPos = offset as int + const insertPos = offset.toInt() if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } for (let i = array.length - 1; i >= 0; --i) { - this.setUnsafeClamp(insertPos as int + i as int, array[i] as int) + this.setUnsafeClamp(insertPos.toInt() + i.toInt(), array[i].toInt()) } } @@ -775,9 +727,9 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike): Uint8ClampedArray { - let res = new Uint8ClampedArray(items.length as int) + let res = new Uint8ClampedArray(items.length.toInt()) for (let i: int = 0; i < items.length; i++) { - res.setUnsafeClamp(i, items[i] as int) + res.setUnsafeClamp(i, items[i].toInt()) } return res } @@ -790,7 +742,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike): Uint8ClampedArray { - let res = new Uint8ClampedArray(items.length as int) + let res = new Uint8ClampedArray(items.length.toInt()) for (let i: int = 0; i < items.length; i++) { res.setUnsafeClamp(i, items[i]) } @@ -805,9 +757,9 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike): Uint8ClampedArray { - let res = new Uint8ClampedArray(items.length as int) + let res = new Uint8ClampedArray(items.length.toInt()) for (let i: int = 0; i < items.length; i++) { - res.setUnsafeClamp(i, items[i] as int) + res.setUnsafeClamp(i, items[i].toInt()) } return res } @@ -820,7 +772,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike, ArrayLike, ArrayLike, ArrayLike = new int[1] idx[0] = 0 iteratorForEach(arrayLike.$_iterator(), (x: T): void => { - res.setUnsafeClamp(idx[0], mapfn(x as T, idx[0] as number) as int) + res.setUnsafeClamp(idx[0], mapfn(x as T, idx[0].toDouble()).toInt()) idx[0] += 1 }) return res @@ -932,7 +884,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike { - const result = compareFn!(l as number, r as number) - return result + return (l - r).toDouble() + } + if (compareFn != undefined) { + cmp = (l: int, r: int): number => { + const result = compareFn!(l.toDouble(), r.toDouble()) + return result + } } sort(arr, cmp) for (let i = 0; i < this.lengthInt; ++i) { @@ -1325,20 +1256,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike 0) { - res.append((this.getUnsafe(this.lengthInt - 1) as Number).toLocaleString()) + res.append((this.getUnsafe(this.lengthInt - 1).toDouble()).toLocaleString()) } return res.toString() } @@ -1496,7 +1403,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike, ArrayLike boolean): boolean { for (let i = 0; i < this.lengthInt; i++) { - if (predicate(this.getUnsafe(i) as number, i as number, this)) { + if (predicate(this.getUnsafe(i).toDouble(), i, this)) { return true } } @@ -1553,7 +1460,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike, ArrayLike, ArrayLike= 0; i--) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i).toDouble(), i, this) } return accumulatedValue } @@ -1622,9 +1529,9 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike= 0; i--) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i).toDouble(), i, this) } return accumulatedValue } @@ -1637,11 +1544,11 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike number): Uint8ClampedArray { - let resBuf = new ArrayBuffer(this.lengthInt * Uint8ClampedArray.BYTES_PER_ELEMENT as int) + let resBuf = new ArrayBuffer(this.lengthInt * Uint8ClampedArray.BYTES_PER_ELEMENT) let res = new Uint8ClampedArray(resBuf) for (let i = 0; i < this.lengthInt; i++) { - const fnRes = fn(this.getUnsafe(i) as number, i as number, this) - res.setUnsafeClamp(i, fnRes as int) + const fnRes = fn(this.getUnsafe(i).toDouble(), i, this) + res.setUnsafeClamp(i, fnRes.toInt()) } return res } @@ -1658,7 +1565,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike boolean): boolean { for (let i = 0; i < this.lengthInt; i++) { - if (!predicate(this.getUnsafe(i) as number, i as number, this)) { + if (!predicate(this.getUnsafe(i).toDouble(), i, this)) { return false } } @@ -1676,7 +1583,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike = new boolean[this.lengthInt] let resLen = 0 for (let i = 0; i < this.lengthInt; i++) { - markers[i] = fn(this.getUnsafe(i) as number, i as number, this) + markers[i] = fn(this.getUnsafe(i).toDouble(), i, this) if (markers[i]) { ++resLen } @@ -1703,8 +1610,8 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike boolean): number | undefined { for (let i = 0; i < this.lengthInt; i++) { - let val = this.getUnsafe(i) as number - if (predicate(val, i as number, this)) { + let val = this.getUnsafe(i).toDouble() + if (predicate(val, i, this)) { return val } } @@ -1723,11 +1630,11 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike boolean): number { for (let i = 0; i < this.lengthInt; i++) { - if (predicate(this.getUnsafe(i) as number, i as number, this)) { - return i as number + if (predicate(this.getUnsafe(i).toDouble(), i, this)) { + return i } } - return -1 as number + return -1 } /** @@ -1739,8 +1646,8 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike boolean): number { for (let i = this.lengthInt - 1; i >= 0; i--) { - let val = this.getUnsafe(i) as number - if (fn(val, i as number, this)) { + let val = this.getUnsafe(i).toDouble() + if (fn(val, i, this)) { return val } } @@ -1756,11 +1663,11 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike boolean): number { for (let i = this.lengthInt - 1; i >= 0; i--) { - if (fn(this.getUnsafe(i) as number, i as number, this)) { - return i as number + if (fn(this.getUnsafe(i).toDouble(), i, this)) { + return i } } - return -1 as number + return -1 } /** @@ -1773,7 +1680,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike void): void { for (let i = 0; i < this.lengthInt; i++) { - callbackfn(this.getUnsafe(i) as number, i as number, this) + callbackfn(this.getUnsafe(i).toDouble(), i.toDouble(), this) } } @@ -1819,17 +1726,17 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike, ArrayLike> 8 } } else { - for (let i = 0; i < Uint8ClampedArray.BYTES_PER_ELEMENT as int; i++) { - this.buffer.set(index + 0 - i, (val & 0xff) as byte) + for (let i = 0; i < Uint8ClampedArray.BYTES_PER_ELEMENT.toInt(); i++) { + this.buffer.set(index + 0 - i, (val & 0xff).toByte()) val = val >> 8 } } @@ -1860,7 +1767,7 @@ class Uint8ArrayIteratorKeys implements IterableIterator { private idx: int = 0 constructor(parent: Uint8Array) { - this.length = parent.length as int + this.length = parent.length.toInt() } public override $_iterator(): IterableIterator { @@ -1871,7 +1778,7 @@ class Uint8ArrayIteratorKeys implements IterableIterator { if (this.idx < 0 || this.idx >= this.length) { return new IteratorResult() } - return new IteratorResult(false, this.idx++ as number) + return new IteratorResult(false, Int.toDouble(this.idx++)) } } @@ -1922,8 +1829,8 @@ class Uint8ArrayIteratorEntries implements IterableIterator<[Number, Number]> { * JS Uint8Array API-compatible class */ export final class Uint8Array implements Iterable, ArrayLike { - public static readonly BYTES_PER_ELEMENT: number = 1 - public readonly BYTES_PER_ELEMENT: number = Uint8Array.BYTES_PER_ELEMENT + public static readonly BYTES_PER_ELEMENT: int = 1 + public readonly BYTES_PER_ELEMENT: int = Uint8Array.BYTES_PER_ELEMENT /** Underlying Buffer */ public readonly buffer: ArrayBuffer @@ -1936,7 +1843,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * Creates an empty Uint8Array. */ public constructor() { - this(0 as int) + this(0) } /** @@ -1946,12 +1853,12 @@ export final class Uint8Array implements Iterable, ArrayLike { const items: Object = elements as Object if (items instanceof ArrayLike) { const arr = Types.identity_cast(items as ArrayLike) - this.byteLengthInt = arr.length as int * Uint8Array.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int + this.byteLengthInt = arr.length.toInt() * Uint8Array.BYTES_PER_ELEMENT + this.lengthInt = arr.length.toInt() this.buffer = new ArrayBuffer(this.byteLengthInt) this.byteOffsetInt = 0 for (let i: int = 0; i < this.lengthInt; ++i) { - this.setUnsafeClamp(i, this.zeroIfInfinity(arr.$_get(i)) as int) + this.setUnsafeClamp(i, this.zeroIfInfinity(arr.$_get(i)).toInt()) } } else { let x = Uint8Array.from(elements) @@ -1987,17 +1894,17 @@ export final class Uint8Array implements Iterable, ArrayLike { let intLength: int if (length != undefined) { intLength = length.toInt() - if (intLength > intByteLength / Uint8Array.BYTES_PER_ELEMENT as int) { + if (intLength > intByteLength / Uint8Array.BYTES_PER_ELEMENT) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer with byteOffset " + intByteOffset) } } else { - intLength = intByteLength / Uint8Array.BYTES_PER_ELEMENT as int + intLength = intByteLength / Uint8Array.BYTES_PER_ELEMENT } if (intLength < 0) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer") } - if (intLength < intByteLength / Uint8Array.BYTES_PER_ELEMENT as int) { - intByteLength = intLength * Uint8Array.BYTES_PER_ELEMENT as int + if (intLength < intByteLength / Uint8Array.BYTES_PER_ELEMENT) { + intByteLength = intLength * Uint8Array.BYTES_PER_ELEMENT } this.byteLengthInt = intByteLength this.byteOffsetInt = intByteOffset @@ -2005,30 +1912,6 @@ export final class Uint8Array implements Iterable, ArrayLike { this.buffer = buf } - /** - * Creates an Uint8Array with respect to data, byteOffset and length. - * - * @param buf data initializer - * - * @param byteOffset byte offset from begin of the buf - */ - public constructor(buf: ArrayBuffer, byteOffset: Number | undefined) { - this(buf, byteOffset, undefined) - } - - /** - * Creates an Uint8Array with respect to data, byteOffset and length. - * - * @param buf data initializer - * - * @param byteOffset byte offset from begin of the buf - * - * @param length size of elements of type int in newly created Uint8Array - */ - public constructor(buf: ArrayBuffer, byteOffset: number, length: number) { - this(buf, new Number(byteOffset), new Number(length)) - } - /** * Creates an Uint8Array with respect to buf and byteOffset. * @@ -2049,7 +1932,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * * @param length size of elements of type int in newly created Uint8Array */ - public constructor(buf: ArrayBuffer, byteOffset: int, length: int) { + public constructor(buf: ArrayBufferLike, byteOffset: int, length: int) { this(buf, new Number(byteOffset), new Number(length)) } @@ -2072,18 +1955,18 @@ export final class Uint8Array implements Iterable, ArrayLike { public constructor(buf: ArrayLike | ArrayBuffer) { if (buf instanceof ArrayBuffer) { this.byteLengthInt = (buf as ArrayBuffer).getByteLength() - if (this.byteLengthInt % Uint8Array.BYTES_PER_ELEMENT as int != 0) { + if (this.byteLengthInt % Uint8Array.BYTES_PER_ELEMENT.toInt() != 0) { throw new RangeError("ArrayBuffer.byteLength should be multiple of int as Uint8Array.BYTES_PER_ELEMENT") } - this.lengthInt = this.byteLengthInt / Uint8Array.BYTES_PER_ELEMENT as int + this.lengthInt = this.byteLengthInt / Uint8Array.BYTES_PER_ELEMENT this.buffer = buf as ArrayBuffer this.byteOffsetInt = 0 } else if (buf instanceof ArrayLike) { // NOTE (ikorobkov): dealing with this overload is tricky // with banned `instanceof` generic, so it is delegated to array here. Initial idea from Set.ets let arr = Array.from((buf as ArrayLike)) - this.byteLengthInt = arr.length as int * Uint8Array.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int + this.byteLengthInt = arr.length.toInt() * Uint8Array.BYTES_PER_ELEMENT + this.lengthInt = arr.length.toInt() this.buffer = new ArrayBuffer(this.byteLengthInt) this.byteOffsetInt = 0 for (let i: int = 0; i < this.lengthInt; ++i) { @@ -2100,7 +1983,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @param length data initializer */ public constructor(length: int) { - this(length as number) + this(length.toDouble()) } /** @@ -2112,8 +1995,8 @@ export final class Uint8Array implements Iterable, ArrayLike { if (length < 0 || length > (Int.MAX_VALUE / Uint8Array.BYTES_PER_ELEMENT)) { throw new TypeError("Type Error: length " + length + " is outside the bounds of the buffer") } - this.lengthInt = length as int - this.byteLengthInt = this.lengthInt * Uint8Array.BYTES_PER_ELEMENT as int + this.lengthInt = length.toInt() + this.byteLengthInt = this.lengthInt * Uint8Array.BYTES_PER_ELEMENT this.byteOffsetInt = 0 this.buffer = new ArrayBuffer(this.byteLengthInt) } @@ -2124,9 +2007,9 @@ export final class Uint8Array implements Iterable, ArrayLike { * @param other data initializer */ public constructor(other: Uint8Array) { - this.buffer = other.buffer.slice(other.byteOffset as int, (other.byteOffset + other.byteLength) as int) as ArrayBuffer - this.byteLengthInt = other.byteLength as int - this.lengthInt = other.length as int + this.buffer = other.buffer.slice(other.byteOffset.toInt(), (other.byteOffset + other.byteLength).toInt()) as ArrayBuffer + this.byteLengthInt = other.byteLength.toInt() + this.lengthInt = other.length.toInt() this.byteOffsetInt = 0 } @@ -2136,7 +2019,7 @@ export final class Uint8Array implements Iterable, ArrayLike { public constructor(numbers: FixedArray) { this(numbers.length) for (let i: int = 0; i < this.lengthInt; ++i) { - this.setUnsafeClamp(i, this.zeroIfInfinity(numbers[i]) as int) + this.setUnsafeClamp(i, this.zeroIfInfinity(numbers[i]).toInt()) } } @@ -2146,19 +2029,19 @@ export final class Uint8Array implements Iterable, ArrayLike { public constructor(numbers: FixedArray) { this(numbers.length) for (let i: int = 0; i < this.lengthInt; ++i) { - this.setUnsafeClamp(i, this.zeroIfInfinity(numbers[i]) as int) + this.setUnsafeClamp(i, this.zeroIfInfinity(numbers[i]).toInt()) } } internal zeroIfInfinity(val: number): number { if ((val == Infinity) || (val == -Infinity)) { - return 0 as number + return 0 } - return val as number + return val } internal zeroIfInfinity(val: int): int { if ((val == Infinity) || (val == -Infinity)) { - return 0 as int + return 0 } return val } @@ -2180,7 +2063,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @returns a primitive at index */ public at(index: number): Number | undefined { - return this.at(index as int) + return this.at(index.toInt()) } /** @@ -2211,7 +2094,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @returns a primitive at index */ public override $_get(index: number): Number { - return this.$_get(index as int) as Number + return this.$_get(index.toInt()).toDouble() } /** @@ -2231,7 +2114,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @param index index to change */ public $_set(index: number, val: number): void { - this.$_set(index as int, val) + this.$_set(index.toInt(), val) } /** @@ -2243,7 +2126,7 @@ export final class Uint8Array implements Iterable, ArrayLike { */ public $_set(index: int, val: number): void { let v = this.zeroIfInfinity(val) - this.$_set(index, v as int) + this.$_set(index, v.toInt()) } /** @@ -2254,7 +2137,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @param index index to change */ public $_set(index: number, val: int): void { - this.$_set(index as int, val) + this.$_set(index.toInt(), val) } /** @@ -2278,7 +2161,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: number, start: number, end?: number): Uint8Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -2293,7 +2176,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: int, start: number, end?: number): Uint8Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -2308,7 +2191,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: number, start: int, end?: number): Uint8Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -2323,7 +2206,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: int, start: int, end?: number): Uint8Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -2348,7 +2231,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} */ public copyWithin(target: number): Uint8Array { - return this.copyWithin(target as int) + return this.copyWithin(target.toInt()) } /** @@ -2381,7 +2264,7 @@ export final class Uint8Array implements Iterable, ArrayLike { */ public fill(value: number, start?: number, end?: number): Uint8Array { value = this.zeroIfInfinity(value) - this.fill(value as int, asIntOrDefault(start, 0 as int), asIntOrDefault(end, this.lengthInt)) + this.fill(value.toInt(), asIntOrDefault(start, 0), asIntOrDefault(end, this.lengthInt)) return this } @@ -2394,20 +2277,7 @@ export final class Uint8Array implements Iterable, ArrayLike { */ public fill(value: number, start: int, end?: number): Uint8Array { value = this.zeroIfInfinity(value) - this.fill(value as int, start as int, asIntOrDefault(end, this.lengthInt)) - return this - } - - /** - * Fills the Uint8Array with specified value - * - * @param value new value - * - * @returns modified Uint8Array - */ - public fill(value: number, start: int, end: number): Uint8Array { - value = this.zeroIfInfinity(value) - this.fill(value as int, start as int, end as int) + this.fill(value.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) return this } @@ -2420,7 +2290,7 @@ export final class Uint8Array implements Iterable, ArrayLike { */ public fill(value: number, start: number, end: int): Uint8Array { value = this.zeroIfInfinity(value) - this.fill(value as int, start as int, end as int) + this.fill(value.toInt(), start.toInt(), end.toInt()) return this } @@ -2433,7 +2303,7 @@ export final class Uint8Array implements Iterable, ArrayLike { */ public fill(value: number, start: int, end: int): Uint8Array { value = this.zeroIfInfinity(value) - this.fill(value as int, start as int, end as int) + this.fill(value.toInt(), start.toInt(), end.toInt()) return this } @@ -2445,7 +2315,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @returns modified Uint8Array */ public fill(value: int, start?: number, end?: number): Uint8Array { - this.fill(value, asIntOrDefault(start, 0 as int), asIntOrDefault(end, this.lengthInt)) + this.fill(value, asIntOrDefault(start, 0), asIntOrDefault(end, this.lengthInt)) return this } @@ -2457,19 +2327,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @returns modified Uint8Array */ public fill(value: int, start: int, end?: number): Uint8Array { - this.fill(value, start as int, asIntOrDefault(end, this.lengthInt)) - return this - } - - /** - * Fills the Uint8Array with specified value - * - * @param value new value - * - * @returns modified Uint8Array - */ - public fill(value: int, start: int, end: number): Uint8Array { - this.fill(value, start as int, end as int) + this.fill(value, start.toInt(), asIntOrDefault(end, this.lengthInt)) return this } @@ -2481,7 +2339,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @returns modified Uint8Array */ public fill(value: int, start: number, end: int): Uint8Array { - this.fill(value, start as int, end as int) + this.fill(value, start.toInt(), end.toInt()) return this } @@ -2509,7 +2367,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @param index index to change */ public set(insertPos: number, val: number): void { - this.$_set(insertPos as int, val) + this.$_set(insertPos.toInt(), val) } /** @@ -2520,7 +2378,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @param index index to change */ public set(insertPos: int, val: number): void { - this.$_set(insertPos as int, val) + this.$_set(insertPos.toInt(), val) } /** @@ -2531,7 +2389,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @param index index to change */ public set(insertPos: number, val: int): void { - this.$_set(insertPos as int, val) + this.$_set(insertPos.toInt(), val) } /** @@ -2542,7 +2400,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @param index index to change */ public set(insertPos: int, val: int): void { - this.$_set(insertPos as int, val) + this.$_set(insertPos.toInt(), val) } /** @@ -2555,13 +2413,13 @@ export final class Uint8Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ public set(arr: FixedArray, insertPos1: number): void { - const insertPos = insertPos1 as int + const insertPos = insertPos1.toInt() if (insertPos < 0 || insertPos + arr.length > this.lengthInt) { throw new RangeError("set(insertPos: int, arr: FixedArray): size of arr is greater than Uint8Array.length") } for (let i = 0; i < arr.length; i++) { let v = this.zeroIfInfinity(arr[i]) - this.setUnsafeClamp(insertPos as int + i as int, v as int) + this.setUnsafeClamp(insertPos.toInt() + i.toInt(), v.toInt()) } } @@ -2614,13 +2472,13 @@ export final class Uint8Array implements Iterable, ArrayLike { * @param offset Optional. The offset into the target array at which to begin writing values from the source array */ public set(array: ArrayLike, offset: number = 0): void { - const insertPos = offset as int + const insertPos = offset.toInt() if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } for (let i = array.length - 1; i >= 0; --i) { let v = this.zeroIfInfinity(array[i]) - this.setUnsafeClamp(insertPos as int + i as int, v as int) + this.setUnsafeClamp(insertPos.toInt() + i.toInt(), v.toInt()) } } @@ -2632,9 +2490,9 @@ export final class Uint8Array implements Iterable, ArrayLike { * @returns new Uint8Array */ public static of(...items: FixedArray): Uint8Array { - let res = new Uint8Array(items.length as int) + let res = new Uint8Array(items.length.toInt()) for (let i: int = 0; i < items.length; i++) { - res.setUnsafeClamp(i, res.zeroIfInfinity(items[i]) as int) + res.setUnsafeClamp(i, res.zeroIfInfinity(items[i]).toInt()) } return res } @@ -2647,7 +2505,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @returns new Uint8Array */ public static of(...items: FixedArray): Uint8Array { - let res = new Uint8Array(items.length as int) + let res = new Uint8Array(items.length.toInt()) for (let i: int = 0; i < items.length; i++) { res.setUnsafeClamp(i, items[i]) } @@ -2662,9 +2520,9 @@ export final class Uint8Array implements Iterable, ArrayLike { * @returns new Uint8Array */ public static of(...items: FixedArray): Uint8Array { - let res = new Uint8Array(items.length as int) + let res = new Uint8Array(items.length.toInt()) for (let i: int = 0; i < items.length; i++) { - res.setUnsafeClamp(i, items[i] as int) + res.setUnsafeClamp(i, items[i].toInt()) } return res } @@ -2677,7 +2535,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @returns new Uint8Array */ public static of(): Uint8Array { - return new Uint8Array(0 as int) + return new Uint8Array(0) } /** @@ -2718,7 +2576,7 @@ export final class Uint8Array implements Iterable, ArrayLike { if (x.done) { return new Uint8Array(result.buffer, 0, i) } - result.setUnsafeClamp(i, result.zeroIfInfinity((mapfn)!(x.value!, i)) as int) + result.setUnsafeClamp(i, result.zeroIfInfinity((mapfn)!(x.value!, i)).toInt()) } return result } @@ -2738,7 +2596,7 @@ export final class Uint8Array implements Iterable, ArrayLike { } temp = new Uint8Array(tb) } - temp.setUnsafeClamp(index[0], temp.zeroIfInfinity((mapfn)!(x, index[0])) as int) + temp.setUnsafeClamp(index[0], temp.zeroIfInfinity((mapfn)!(x, index[0])).toInt()) index[0]++ }) @@ -2760,7 +2618,7 @@ export final class Uint8Array implements Iterable, ArrayLike { const idx : FixedArray = new int[1] idx[0] = 0 iteratorForEach(arrayLike.$_iterator(), (x: T): void => { - res.setUnsafeClamp(idx[0], res.zeroIfInfinity(mapfn(x as T, idx[0] as number)) as int) + res.setUnsafeClamp(idx[0], res.zeroIfInfinity(mapfn(x as T, idx[0].toDouble())).toInt()) idx[0] += 1 }) return res @@ -2789,7 +2647,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @returns true if searchElement is in Uint8Array, false otherwise */ public includes(searchElement: int, fromIndex: int): boolean { - return this.indexOf(searchElement as int, fromIndex) != -1 + return this.indexOf(searchElement.toInt(), fromIndex) != -1 } /** @@ -2802,7 +2660,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @returns true if searchElement is in Uint8Array, false otherwise */ public includes(searchElement: int): boolean { - return this.indexOf(searchElement as int, 0) != -1 + return this.indexOf(searchElement.toInt(), 0) != -1 } /** @@ -2844,7 +2702,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @returns index of element if it presents, -1 otherwise */ public indexOf(searchElement: int, fromIndex: int): number { - return this.indexOfImpl(searchElement as long, fromIndex) + return this.indexOfImpl(Int.toLong(searchElement), fromIndex) } /** @@ -2972,7 +2830,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ public lastIndexOf(searchElement: int, fromIndex: int): number { - return this.lastIndexOfImpl(searchElement as long, fromIndex) + return this.lastIndexOfImpl(Int.toLong(searchElement), fromIndex) } /** @@ -3043,22 +2901,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin?: number, end?: number): Uint8Array { - return this.slice(asIntOrDefault(begin, 0 as int), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Creates a slice of current Uint8Array using range [begin, end) - * - * @param begin start index to be taken into slice - * - * @param end last index to be taken into slice - * - * @returns a new Uint8Array with elements of current Uint8Array[begin;end) where end index is excluded - * - * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice - */ - public slice(begin: number, end: number): Uint8Array { - return this.slice(begin as int, end as int) + return this.slice(asIntOrDefault(begin, 0), asIntOrDefault(end, this.lengthInt)) } /** @@ -3073,7 +2916,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin: number, end: int): Uint8Array { - return this.slice(begin as int, end as int) + return this.slice(begin.toInt(), end.toInt()) } /** @@ -3088,7 +2931,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin: int, end: number): Uint8Array { - return this.slice(begin as int, end as int) + return this.slice(begin.toInt(), end.toInt()) } /** @@ -3110,21 +2953,10 @@ export final class Uint8Array implements Iterable, ArrayLike { if (count < 0) { count = 0 } - let buf = this.buffer.slice(relStart * Uint8Array.BYTES_PER_ELEMENT as int, relEnd * Uint8Array.BYTES_PER_ELEMENT as int) as ArrayBuffer + let buf = this.buffer.slice(relStart * Uint8Array.BYTES_PER_ELEMENT.toInt(), relEnd * Uint8Array.BYTES_PER_ELEMENT.toInt()) as ArrayBuffer return new Uint8Array(buf) } - /** - * Creates a slice of current Uint8Array using range [begin, this.lengthInt). - * - * @param begin start index to be taken into slice - * - * @returns a new Uint8Array with elements of current Uint8Array[begin, this.lengthInt) - */ - public slice(begin: number): Uint8Array { - return this.slice(begin as int) - } - /** * Creates a slice of current Uint8Array using range [begin, this.lengthInt). * @@ -3162,8 +2994,13 @@ export final class Uint8Array implements Iterable, ArrayLike { arr[i] = this.getUnsafe(i) } let cmp = (l: int, r: int): number => { - const result = compareFn!(l as number, r as number) - return result + return (l - r).toDouble() + } + if (compareFn != undefined) { + cmp = (l: int, r: int): number => { + const result = compareFn!(l.toDouble(), r.toDouble()) + return result + } } sort(arr, cmp) for (let i = 0; i < this.lengthInt; ++i) { @@ -3182,20 +3019,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @returns new Uint8Array with the same underlying Buffer */ public subarray(begin?: number, end?: number): Uint8Array { - return this.subarray(asIntOrDefault(begin, 0 as int), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Creates a Uint8Array with the same underlying Buffer - * - * @param begin start index, inclusive - * - * @param end last index, exclusive - * - * @returns new Uint8Array with the same underlying Buffer - */ - public subarray(begin: number, end: number): Uint8Array { - return this.subarray(begin as int, end as int) + return this.subarray(asIntOrDefault(begin, 0), asIntOrDefault(end, this.lengthInt)) } /** @@ -3208,7 +3032,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @returns new Uint8Array with the same underlying Buffer */ public subarray(begin: number, end: int): Uint8Array { - return this.subarray(begin as int, end as int) + return this.subarray(begin.toInt(), end.toInt()) } /** @@ -3221,7 +3045,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @returns new Uint8Array with the same underlying Buffer */ public subarray(begin: int, end: number): Uint8Array { - return this.subarray(begin as int, end as int) + return this.subarray(begin.toInt(), end.toInt()) } /** @@ -3241,18 +3065,7 @@ export final class Uint8Array implements Iterable, ArrayLike { if (count < 0) { count = 0 } - return new Uint8Array(this.buffer, relStart * Uint8Array.BYTES_PER_ELEMENT as int, count) - } - - /** - * Creates a Uint8Array with the same Buffer - * - * @param begin start index, inclusive - * - * @returns new Uint8Array with the same Buffer - */ - public subarray(begin: number): Uint8Array { - return this.subarray(begin as int, this.lengthInt) + return new Uint8Array(this.buffer, relStart * Uint8Array.BYTES_PER_ELEMENT, count) } /** @@ -3298,11 +3111,11 @@ export final class Uint8Array implements Iterable, ArrayLike { public toLocaleString(): string { let res: StringBuilder = new StringBuilder("") for (let i = 0; i < this.lengthInt - 1; ++i) { - res.append((this.getUnsafe(i) as Number).toLocaleString()) + res.append((this.getUnsafe(i).toDouble()).toLocaleString()) res.append(",") } if (this.lengthInt > 0) { - res.append((this.getUnsafe(this.lengthInt - 1) as Number).toLocaleString()) + res.append((this.getUnsafe(this.lengthInt - 1).toDouble()).toLocaleString()) } return res.toString() } @@ -3353,7 +3166,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @returns an Uint8Array with replaced value on index */ public with(index: number, value: number): Uint8Array { - return this.with(index as int, value as int) + return this.with(index.toInt(), value.toInt()) } /** @@ -3385,7 +3198,7 @@ export final class Uint8Array implements Iterable, ArrayLike { */ public some(predicate: (element: number, index: number, array: Uint8Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; i++) { - if (predicate(this.getUnsafe(i) as number, i as number, this)) { + if (predicate(this.getUnsafe(i).toDouble(), i, this)) { return true } } @@ -3410,7 +3223,7 @@ export final class Uint8Array implements Iterable, ArrayLike { initialValue: U): U { let accumulatedValue = initialValue for (let i = 0; i < this.lengthInt; i++) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i).toDouble(), i, this) } return accumulatedValue } @@ -3432,9 +3245,9 @@ export final class Uint8Array implements Iterable, ArrayLike { throw new TypeError("Reduce of empty array with no initial value") } - let accumulatedValue = this.$_get(0) as number + let accumulatedValue = this.$_get(0).toDouble() for (let i = 1; i < this.lengthInt; i++) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i).toDouble(), i, this) } return accumulatedValue } @@ -3457,7 +3270,7 @@ export final class Uint8Array implements Iterable, ArrayLike { initialValue: U): U { let accumulatedValue = initialValue for (let i = this.lengthInt - 1; i >= 0; i--) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i).toDouble(), i, this) } return accumulatedValue } @@ -3479,9 +3292,9 @@ export final class Uint8Array implements Iterable, ArrayLike { throw new TypeError("Reduce of empty array with no initial value") } - let accumulatedValue: number = this.$_get(this.lengthInt - 1) as number + let accumulatedValue: number = this.$_get(this.lengthInt - 1).toDouble() for (let i = this.lengthInt - 2; i >= 0; i--) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i).toDouble(), i, this) } return accumulatedValue } @@ -3494,11 +3307,11 @@ export final class Uint8Array implements Iterable, ArrayLike { * @returns a new Uint8Array where for each element from current Uint8Array fn was applied */ public map(fn: (val: number, index: number, array: Uint8Array) => number): Uint8Array { - let resBuf = new ArrayBuffer(this.lengthInt * Uint8Array.BYTES_PER_ELEMENT as int) + let resBuf = new ArrayBuffer(this.lengthInt * Uint8Array.BYTES_PER_ELEMENT) let res = new Uint8Array(resBuf) for (let i = 0; i < this.lengthInt; i++) { - const fnRes = fn(this.getUnsafe(i) as number, i as number, this) - res.setUnsafeClamp(i, fnRes as int) + const fnRes = fn(this.getUnsafe(i).toDouble(), i, this) + res.setUnsafeClamp(i, fnRes.toInt()) } return res } @@ -3515,7 +3328,7 @@ export final class Uint8Array implements Iterable, ArrayLike { */ public every(predicate: (element: number, index: number, array: Uint8Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; i++) { - if (!predicate(this.getUnsafe(i) as number, i as number, this)) { + if (!predicate(this.getUnsafe(i).toDouble(), i, this)) { return false } } @@ -3533,7 +3346,7 @@ export final class Uint8Array implements Iterable, ArrayLike { let markers : FixedArray = new boolean[this.lengthInt] let resLen = 0 for (let i = 0; i < this.lengthInt; i++) { - markers[i] = fn(this.getUnsafe(i) as number, i as number, this) + markers[i] = fn(this.getUnsafe(i).toDouble(), i, this) if (markers[i]) { ++resLen } @@ -3560,8 +3373,8 @@ export final class Uint8Array implements Iterable, ArrayLike { */ public find(predicate: (value: number, index: number, array: Uint8Array) => boolean): number | undefined { for (let i = 0; i < this.lengthInt; i++) { - let val = this.getUnsafe(i) as number - if (predicate(val, i as number, this)) { + let val = this.getUnsafe(i).toDouble() + if (predicate(val, i, this)) { return val } } @@ -3580,11 +3393,11 @@ export final class Uint8Array implements Iterable, ArrayLike { */ public findIndex(predicate: (value: number, index: number, obj: Uint8Array) => boolean): number { for (let i = 0; i < this.lengthInt; i++) { - if (predicate(this.getUnsafe(i) as number, i as number, this)) { - return i as number + if (predicate(this.getUnsafe(i).toDouble(), i, this)) { + return i } } - return -1 as number + return -1 } /** @@ -3596,8 +3409,8 @@ export final class Uint8Array implements Iterable, ArrayLike { */ public findLast(fn: (val: number, index: number, array: Uint8Array) => boolean): number { for (let i = this.lengthInt - 1; i >= 0; i--) { - let val = this.getUnsafe(i) as number - if (fn(val, i as number, this)) { + let val = this.getUnsafe(i).toDouble() + if (fn(val, i, this)) { return val } } @@ -3613,11 +3426,11 @@ export final class Uint8Array implements Iterable, ArrayLike { */ public findLastIndex(fn: (val: number, index: number, array: Uint8Array) => boolean): number { for (let i = this.lengthInt - 1; i >= 0; i--) { - if (fn(this.getUnsafe(i) as number, i as number, this)) { - return i as number + if (fn(this.getUnsafe(i).toDouble(), i, this)) { + return i } } - return -1 as number + return -1 } /** @@ -3630,7 +3443,7 @@ export final class Uint8Array implements Iterable, ArrayLike { */ public forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void): void { for (let i = 0; i < this.lengthInt; i++) { - callbackfn(this.getUnsafe(i) as number, i as number, this) + callbackfn(this.getUnsafe(i).toDouble(), i.toDouble(), this) } } @@ -3670,17 +3483,17 @@ export final class Uint8Array implements Iterable, ArrayLike { } internal getUnsafe(index: int): int { - index = index * Uint8Array.BYTES_PER_ELEMENT as int + this.byteOffsetInt + index = index * Uint8Array.BYTES_PER_ELEMENT + this.byteOffsetInt let res: int = 0 if (IS_LITTLE_ENDIAN) { - for (let i = 0; i < Uint8Array.BYTES_PER_ELEMENT as int; i++) { - let el = this.buffer.at(index + i) as int + for (let i = 0; i < Uint8Array.BYTES_PER_ELEMENT.toInt(); i++) { + let el = this.buffer.at(index + i).toInt() el &= 0xff res |= el << (8 * i) } } else { - for (let i = 0; i < Uint8Array.BYTES_PER_ELEMENT as int; i++) { - let el = this.buffer.at(index + 0 - i) as int + for (let i = 0; i < Uint8Array.BYTES_PER_ELEMENT.toInt(); i++) { + let el = this.buffer.at(index + 0 - i).toInt() el &= 0xff res |= el << (8 * i) } @@ -3689,16 +3502,16 @@ export final class Uint8Array implements Iterable, ArrayLike { } internal setUnsafe(index: int, val: int): void { - index = index * Uint8Array.BYTES_PER_ELEMENT as int + this.byteOffsetInt + index = index * Uint8Array.BYTES_PER_ELEMENT + this.byteOffsetInt let res: int = 0 if (IS_LITTLE_ENDIAN) { - for (let i = 0; i < Uint8Array.BYTES_PER_ELEMENT as int; i++) { - this.buffer.set(index + i, (val & 0xff) as byte) + for (let i = 0; i < Uint8Array.BYTES_PER_ELEMENT.toInt(); i++) { + this.buffer.set(index + i, (val & 0xff).toByte()) val = val >> 8 } } else { - for (let i = 0; i < Uint8Array.BYTES_PER_ELEMENT as int; i++) { - this.buffer.set(index + 0 - i, (val & 0xff) as byte) + for (let i = 0; i < Uint8Array.BYTES_PER_ELEMENT.toInt(); i++) { + this.buffer.set(index + 0 - i, (val & 0xff).toByte()) val = val >> 8 } } @@ -3711,7 +3524,7 @@ class Uint16ArrayIteratorKeys implements IterableIterator { private idx: int = 0 constructor(parent: Uint16Array) { - this.length = parent.length as int + this.length = parent.length.toInt() } public override $_iterator(): IterableIterator { @@ -3722,7 +3535,7 @@ class Uint16ArrayIteratorKeys implements IterableIterator { if (this.idx < 0 || this.idx >= this.length) { return new IteratorResult() } - return new IteratorResult(false, this.idx++ as number) + return new IteratorResult(false, Int.toDouble(this.idx++)) } } @@ -3773,8 +3586,8 @@ class Uint16ArrayIteratorEntries implements IterableIterator<[Number, Number]> { * JS Uint16Array API-compatible class */ export final class Uint16Array implements Iterable, ArrayLike { - public static readonly BYTES_PER_ELEMENT: number = 2 - public readonly BYTES_PER_ELEMENT: number = Uint16Array.BYTES_PER_ELEMENT + public static readonly BYTES_PER_ELEMENT: int = 2 + public readonly BYTES_PER_ELEMENT: int = Uint16Array.BYTES_PER_ELEMENT /** Underlying Buffer */ public readonly buffer: ArrayBuffer @@ -3787,7 +3600,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * Creates an empty Uint16Array. */ public constructor() { - this(0 as int) + this(0) } /** @@ -3797,12 +3610,12 @@ export final class Uint16Array implements Iterable, ArrayLike { const items: Object = elements as Object if (items instanceof ArrayLike) { const arr = Types.identity_cast(items as ArrayLike) - this.byteLengthInt = arr.length as int * Uint16Array.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int + this.byteLengthInt = arr.length.toInt() * Uint16Array.BYTES_PER_ELEMENT + this.lengthInt = arr.length.toInt() this.buffer = new ArrayBuffer(this.byteLengthInt) this.byteOffsetInt = 0 for (let i: int = 0; i < this.lengthInt; ++i) { - this.setUnsafeClamp(i, this.zeroIfInfinity(arr.$_get(i)) as int) + this.setUnsafeClamp(i, this.zeroIfInfinity(arr.$_get(i)).toInt()) } } else { let x = Uint16Array.from(elements) @@ -3835,27 +3648,27 @@ export final class Uint16Array implements Iterable, ArrayLike { throw new RangeError("Range Error: byteLength " + intByteLength + " is outside the bounds of the buffer with byteOffset " + intByteOffset) } - if (intByteLength % Uint16Array.BYTES_PER_ELEMENT as int != 0) { + if (intByteLength % Uint16Array.BYTES_PER_ELEMENT.toInt() != 0) { throw new RangeError("ArrayBuffer.byteLength should be multiple of 2 as Uint16Array.BYTES_PER_ELEMENT") } - if (intByteOffset % Uint16Array.BYTES_PER_ELEMENT as int != 0) { + if (intByteOffset % Uint16Array.BYTES_PER_ELEMENT != 0) { throw new RangeError("byteOffset should be multiple of 2 as Uint16Array.BYTES_PER_ELEMENT") } let intLength: int if (length != undefined) { intLength = length.toInt() - if (intLength > intByteLength / Uint16Array.BYTES_PER_ELEMENT as int) { + if (intLength > intByteLength / Uint16Array.BYTES_PER_ELEMENT) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer with byteOffset " + intByteOffset) } } else { - intLength = intByteLength / Uint16Array.BYTES_PER_ELEMENT as int + intLength = intByteLength / Uint16Array.BYTES_PER_ELEMENT } if (intLength < 0) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer") } - if (intLength < intByteLength / Uint16Array.BYTES_PER_ELEMENT as int) { - intByteLength = intLength * Uint16Array.BYTES_PER_ELEMENT as int + if (intLength < intByteLength / Uint16Array.BYTES_PER_ELEMENT) { + intByteLength = intLength * Uint16Array.BYTES_PER_ELEMENT } this.byteLengthInt = intByteLength this.byteOffsetInt = intByteOffset @@ -3863,30 +3676,6 @@ export final class Uint16Array implements Iterable, ArrayLike { this.buffer = buf } - /** - * Creates an Uint16Array with respect to data, byteOffset and length. - * - * @param buf data initializer - * - * @param byteOffset byte offset from begin of the buf - */ - public constructor(buf: ArrayBuffer, byteOffset: Number | undefined) { - this(buf, byteOffset, undefined) - } - - /** - * Creates an Uint16Array with respect to data, byteOffset and length. - * - * @param buf data initializer - * - * @param byteOffset byte offset from begin of the buf - * - * @param length size of elements of type int in newly created Uint16Array - */ - public constructor(buf: ArrayBuffer, byteOffset: number, length: number) { - this(buf, new Number(byteOffset), new Number(length)) - } - /** * Creates an Uint16Array with respect to buf and byteOffset. * @@ -3907,7 +3696,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * * @param length size of elements of type int in newly created Uint16Array */ - public constructor(buf: ArrayBuffer, byteOffset: int, length: int) { + public constructor(buf: ArrayBufferLike, byteOffset: int, length: int) { this(buf, new Number(byteOffset), new Number(length)) } @@ -3930,18 +3719,18 @@ export final class Uint16Array implements Iterable, ArrayLike { public constructor(buf: ArrayLike | ArrayBuffer) { if (buf instanceof ArrayBuffer) { this.byteLengthInt = (buf as ArrayBuffer).getByteLength() - if (this.byteLengthInt % Uint16Array.BYTES_PER_ELEMENT as int != 0) { + if (this.byteLengthInt % Uint16Array.BYTES_PER_ELEMENT.toInt() != 0) { throw new RangeError("ArrayBuffer.byteLength should be multiple of int as Uint16Array.BYTES_PER_ELEMENT") } - this.lengthInt = this.byteLengthInt / Uint16Array.BYTES_PER_ELEMENT as int + this.lengthInt = this.byteLengthInt / Uint16Array.BYTES_PER_ELEMENT this.buffer = buf as ArrayBuffer this.byteOffsetInt = 0 } else if (buf instanceof ArrayLike) { // NOTE (ikorobkov): dealing with this overload is tricky // with banned `instanceof` generic, so it is delegated to array here. Initial idea from Set.ets let arr = Array.from((buf as ArrayLike)) - this.byteLengthInt = arr.length as int * Uint16Array.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int + this.byteLengthInt = arr.length.toInt() * Uint16Array.BYTES_PER_ELEMENT + this.lengthInt = arr.length.toInt() this.buffer = new ArrayBuffer(this.byteLengthInt) this.byteOffsetInt = 0 for (let i: int = 0; i < this.lengthInt; ++i) { @@ -3958,7 +3747,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @param length data initializer */ public constructor(length: int) { - this(length as number) + this(length.toDouble()) } /** @@ -3970,8 +3759,8 @@ export final class Uint16Array implements Iterable, ArrayLike { if (length < 0 || length > (Int.MAX_VALUE / Uint16Array.BYTES_PER_ELEMENT)) { throw new TypeError("Type Error: length " + length + " is outside the bounds of the buffer") } - this.lengthInt = length as int - this.byteLengthInt = this.lengthInt * Uint16Array.BYTES_PER_ELEMENT as int + this.lengthInt = length.toInt() + this.byteLengthInt = this.lengthInt * Uint16Array.BYTES_PER_ELEMENT this.byteOffsetInt = 0 this.buffer = new ArrayBuffer(this.byteLengthInt) } @@ -3982,9 +3771,9 @@ export final class Uint16Array implements Iterable, ArrayLike { * @param other data initializer */ public constructor(other: Uint16Array) { - this.buffer = other.buffer.slice(other.byteOffset as int, (other.byteOffset + other.byteLength) as int) as ArrayBuffer - this.byteLengthInt = other.byteLength as int - this.lengthInt = other.length as int + this.buffer = other.buffer.slice(other.byteOffset.toInt(), (other.byteOffset + other.byteLength).toInt()) as ArrayBuffer + this.byteLengthInt = other.byteLength.toInt() + this.lengthInt = other.length.toInt() this.byteOffsetInt = 0 } @@ -3994,7 +3783,7 @@ export final class Uint16Array implements Iterable, ArrayLike { public constructor(numbers: FixedArray) { this(numbers.length) for (let i: int = 0; i < this.lengthInt; ++i) { - this.setUnsafeClamp(i, this.zeroIfInfinity(numbers[i]) as int) + this.setUnsafeClamp(i, this.zeroIfInfinity(numbers[i]).toInt()) } } @@ -4004,19 +3793,19 @@ export final class Uint16Array implements Iterable, ArrayLike { public constructor(numbers: FixedArray) { this(numbers.length) for (let i: int = 0; i < this.lengthInt; ++i) { - this.setUnsafeClamp(i, this.zeroIfInfinity(numbers[i]) as int) + this.setUnsafeClamp(i, this.zeroIfInfinity(numbers[i]).toInt()) } } internal zeroIfInfinity(val: number): number { if ((val == Infinity) || (val == -Infinity)) { - return 0 as number + return 0 } - return val as number + return val } internal zeroIfInfinity(val: int): int { if ((val == Infinity) || (val == -Infinity)) { - return 0 as int + return 0 } return val } @@ -4038,7 +3827,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @returns a primitive at index */ public at(index: number): Number | undefined { - return this.at(index as int) + return this.at(index.toInt()) } /** @@ -4069,7 +3858,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @returns a primitive at index */ public override $_get(index: number): Number { - return this.$_get(index as int) as Number + return this.$_get(index.toInt()).toDouble() } /** @@ -4089,7 +3878,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @param index index to change */ public $_set(index: number, val: number): void { - this.$_set(index as int, val) + this.$_set(index.toInt(), val) } /** @@ -4101,7 +3890,7 @@ export final class Uint16Array implements Iterable, ArrayLike { */ public $_set(index: int, val: number): void { let v = this.zeroIfInfinity(val) - this.$_set(index, v as int) + this.$_set(index, v.toInt()) } /** @@ -4112,7 +3901,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @param index index to change */ public $_set(index: number, val: int): void { - this.$_set(index as int, val) + this.$_set(index.toInt(), val) } /** @@ -4136,7 +3925,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: number, start: number, end?: number): Uint16Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -4151,7 +3940,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: int, start: number, end?: number): Uint16Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -4166,7 +3955,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: number, start: int, end?: number): Uint16Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -4181,7 +3970,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: int, start: int, end?: number): Uint16Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -4206,7 +3995,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} */ public copyWithin(target: number): Uint16Array { - return this.copyWithin(target as int) + return this.copyWithin(target.toInt()) } /** @@ -4239,7 +4028,7 @@ export final class Uint16Array implements Iterable, ArrayLike { */ public fill(value: number, start?: number, end?: number): Uint16Array { value = this.zeroIfInfinity(value) - this.fill(value as int, asIntOrDefault(start, 0 as int), asIntOrDefault(end, this.lengthInt)) + this.fill(value.toInt(), asIntOrDefault(start, 0), asIntOrDefault(end, this.lengthInt)) return this } @@ -4252,20 +4041,7 @@ export final class Uint16Array implements Iterable, ArrayLike { */ public fill(value: number, start: int, end?: number): Uint16Array { value = this.zeroIfInfinity(value) - this.fill(value as int, start as int, asIntOrDefault(end, this.lengthInt)) - return this - } - - /** - * Fills the Uint16Array with specified value - * - * @param value new value - * - * @returns modified Uint16Array - */ - public fill(value: number, start: int, end: number): Uint16Array { - value = this.zeroIfInfinity(value) - this.fill(value as int, start as int, end as int) + this.fill(value.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) return this } @@ -4278,7 +4054,7 @@ export final class Uint16Array implements Iterable, ArrayLike { */ public fill(value: number, start: number, end: int): Uint16Array { value = this.zeroIfInfinity(value) - this.fill(value as int, start as int, end as int) + this.fill(value.toInt(), start.toInt(), end.toInt()) return this } @@ -4291,7 +4067,7 @@ export final class Uint16Array implements Iterable, ArrayLike { */ public fill(value: number, start: int, end: int): Uint16Array { value = this.zeroIfInfinity(value) - this.fill(value as int, start as int, end as int) + this.fill(value.toInt(), start.toInt(), end.toInt()) return this } @@ -4303,7 +4079,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @returns modified Uint16Array */ public fill(value: int, start?: number, end?: number): Uint16Array { - this.fill(value, asIntOrDefault(start, 0 as int), asIntOrDefault(end, this.lengthInt)) + this.fill(value, asIntOrDefault(start, 0), asIntOrDefault(end, this.lengthInt)) return this } @@ -4315,19 +4091,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @returns modified Uint16Array */ public fill(value: int, start: int, end?: number): Uint16Array { - this.fill(value, start as int, asIntOrDefault(end, this.lengthInt)) - return this - } - - /** - * Fills the Uint16Array with specified value - * - * @param value new value - * - * @returns modified Uint16Array - */ - public fill(value: int, start: int, end: number): Uint16Array { - this.fill(value, start as int, end as int) + this.fill(value, start.toInt(), asIntOrDefault(end, this.lengthInt)) return this } @@ -4339,7 +4103,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @returns modified Uint16Array */ public fill(value: int, start: number, end: int): Uint16Array { - this.fill(value, start as int, end as int) + this.fill(value, start.toInt(), end.toInt()) return this } @@ -4367,7 +4131,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @param index index to change */ public set(insertPos: number, val: number): void { - this.$_set(insertPos as int, val) + this.$_set(insertPos.toInt(), val) } /** @@ -4378,7 +4142,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @param index index to change */ public set(insertPos: int, val: number): void { - this.$_set(insertPos as int, val) + this.$_set(insertPos.toInt(), val) } /** @@ -4389,7 +4153,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @param index index to change */ public set(insertPos: number, val: int): void { - this.$_set(insertPos as int, val) + this.$_set(insertPos.toInt(), val) } /** @@ -4400,7 +4164,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @param index index to change */ public set(insertPos: int, val: int): void { - this.$_set(insertPos as int, val) + this.$_set(insertPos.toInt(), val) } /** @@ -4413,13 +4177,13 @@ export final class Uint16Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ public set(arr: FixedArray, insertPos1: number): void { - const insertPos = insertPos1 as int + const insertPos = insertPos1.toInt() if (insertPos < 0 || insertPos + arr.length > this.lengthInt) { throw new RangeError("set(insertPos: int, arr: FixedArray): size of arr is greater than Uint16Array.length") } for (let i = 0; i < arr.length; i++) { let v = this.zeroIfInfinity(arr[i]) - this.setUnsafeClamp(insertPos as int + i as int, v as int) + this.setUnsafeClamp(insertPos.toInt() + i.toInt(), v.toInt()) } } @@ -4472,13 +4236,13 @@ export final class Uint16Array implements Iterable, ArrayLike { * @param offset Optional. The offset into the target array at which to begin writing values from the source array */ public set(array: ArrayLike, offset: number = 0): void { - const insertPos = offset as int + const insertPos = offset.toInt() if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } for (let i = array.length - 1; i >= 0; --i) { let v = this.zeroIfInfinity(array[i]) - this.setUnsafeClamp(insertPos as int + i as int, v as int) + this.setUnsafeClamp(insertPos.toInt() + i.toInt(), v.toInt()) } } @@ -4490,9 +4254,9 @@ export final class Uint16Array implements Iterable, ArrayLike { * @returns new Uint16Array */ public static of(...items: FixedArray): Uint16Array { - let res = new Uint16Array(items.length as int) + let res = new Uint16Array(items.length.toInt()) for (let i: int = 0; i < items.length; i++) { - res.setUnsafeClamp(i, res.zeroIfInfinity(items[i]) as int) + res.setUnsafeClamp(i, res.zeroIfInfinity(items[i]).toInt()) } return res } @@ -4505,7 +4269,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @returns new Uint16Array */ public static of(...items: FixedArray): Uint16Array { - let res = new Uint16Array(items.length as int) + let res = new Uint16Array(items.length.toInt()) for (let i: int = 0; i < items.length; i++) { res.setUnsafeClamp(i, items[i]) } @@ -4520,7 +4284,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @returns new Uint16Array */ public static of(): Uint16Array { - return new Uint16Array(0 as int) + return new Uint16Array(0) } /** @@ -4561,7 +4325,7 @@ export final class Uint16Array implements Iterable, ArrayLike { if (x.done) { return new Uint16Array(result.buffer, 0, i) } - result.setUnsafeClamp(i, result.zeroIfInfinity((mapfn)!(x.value!, i)) as int) + result.setUnsafeClamp(i, result.zeroIfInfinity((mapfn)!(x.value!, i)).toInt()) } return result } @@ -4581,7 +4345,7 @@ export final class Uint16Array implements Iterable, ArrayLike { } temp = new Uint16Array(tb) } - temp.setUnsafeClamp(index[0], temp.zeroIfInfinity((mapfn)!(x, index[0])) as int) + temp.setUnsafeClamp(index[0], temp.zeroIfInfinity((mapfn)!(x, index[0])).toInt()) index[0]++ }) @@ -4603,7 +4367,7 @@ export final class Uint16Array implements Iterable, ArrayLike { const idx : FixedArray = new int[1] idx[0] = 0 iteratorForEach(arrayLike.$_iterator(), (x: T): void => { - res.setUnsafeClamp(idx[0], res.zeroIfInfinity(mapfn(x as T, idx[0] as number)) as int) + res.setUnsafeClamp(idx[0], res.zeroIfInfinity(mapfn(x as T, idx[0].toDouble())).toInt()) idx[0] += 1 }) return res @@ -4632,7 +4396,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @returns true if searchElement is in Uint16Array, false otherwise */ public includes(searchElement: int, fromIndex: int): boolean { - return this.indexOf(searchElement as int, fromIndex) != -1 + return this.indexOf(searchElement.toInt(), fromIndex) != -1 } /** @@ -4645,7 +4409,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @returns true if searchElement is in Uint16Array, false otherwise */ public includes(searchElement: int): boolean { - return this.indexOf(searchElement as int, 0) != -1 + return this.indexOf(searchElement.toInt(), 0) != -1 } /** @@ -4687,7 +4451,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @returns index of element if it presents, -1 otherwise */ public indexOf(searchElement: int, fromIndex: int): number { - return this.indexOfImpl(searchElement as long, fromIndex) + return this.indexOfImpl(Int.toLong(searchElement), fromIndex) } /** @@ -4815,7 +4579,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ public lastIndexOf(searchElement: int, fromIndex: int): number { - return this.lastIndexOfImpl(searchElement as long, fromIndex) + return this.lastIndexOfImpl(Int.toLong(searchElement), fromIndex) } /** @@ -4886,22 +4650,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin?: number, end?: number): Uint16Array { - return this.slice(asIntOrDefault(begin, 0 as int), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Creates a slice of current Uint16Array using range [begin, end) - * - * @param begin start index to be taken into slice - * - * @param end last index to be taken into slice - * - * @returns a new Uint16Array with elements of current Uint16Array[begin;end) where end index is excluded - * - * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice - */ - public slice(begin: number, end: number): Uint16Array { - return this.slice(begin as int, end as int) + return this.slice(asIntOrDefault(begin, 0), asIntOrDefault(end, this.lengthInt)) } /** @@ -4916,7 +4665,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin: number, end: int): Uint16Array { - return this.slice(begin as int, end as int) + return this.slice(begin.toInt(), end.toInt()) } /** @@ -4931,7 +4680,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin: int, end: number): Uint16Array { - return this.slice(begin as int, end as int) + return this.slice(begin.toInt(), end.toInt()) } /** @@ -4953,21 +4702,10 @@ export final class Uint16Array implements Iterable, ArrayLike { if (count < 0) { count = 0 } - let buf = this.buffer.slice(relStart * Uint16Array.BYTES_PER_ELEMENT as int, relEnd * Uint16Array.BYTES_PER_ELEMENT as int) as ArrayBuffer + let buf = this.buffer.slice(relStart * Uint16Array.BYTES_PER_ELEMENT.toInt(), relEnd * Uint16Array.BYTES_PER_ELEMENT.toInt()) as ArrayBuffer return new Uint16Array(buf) } - /** - * Creates a slice of current Uint16Array using range [begin, this.lengthInt). - * - * @param begin start index to be taken into slice - * - * @returns a new Uint16Array with elements of current Uint16Array[begin, this.lengthInt) - */ - public slice(begin: number): Uint16Array { - return this.slice(begin as int) - } - /** * Creates a slice of current Uint16Array using range [begin, this.lengthInt). * @@ -5005,8 +4743,13 @@ export final class Uint16Array implements Iterable, ArrayLike { arr[i] = this.getUnsafe(i) } let cmp = (l: int, r: int): number => { - const result = compareFn!(l as number, r as number) - return result + return (l - r).toDouble() + } + if (compareFn != undefined) { + cmp = (l: int, r: int): number => { + const result = compareFn!(l.toDouble(), r.toDouble()) + return result + } } sort(arr, cmp) for (let i = 0; i < this.lengthInt; ++i) { @@ -5025,20 +4768,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @returns new Uint16Array with the same underlying Buffer */ public subarray(begin?: number, end?: number): Uint16Array { - return this.subarray(asIntOrDefault(begin, 0 as int), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Creates a Uint16Array with the same underlying Buffer - * - * @param begin start index, inclusive - * - * @param end last index, exclusive - * - * @returns new Uint16Array with the same underlying Buffer - */ - public subarray(begin: number, end: number): Uint16Array { - return this.subarray(begin as int, end as int) + return this.subarray(asIntOrDefault(begin, 0), asIntOrDefault(end, this.lengthInt)) } /** @@ -5051,7 +4781,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @returns new Uint16Array with the same underlying Buffer */ public subarray(begin: number, end: int): Uint16Array { - return this.subarray(begin as int, end as int) + return this.subarray(begin.toInt(), end.toInt()) } /** @@ -5064,7 +4794,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @returns new Uint16Array with the same underlying Buffer */ public subarray(begin: int, end: number): Uint16Array { - return this.subarray(begin as int, end as int) + return this.subarray(begin.toInt(), end.toInt()) } /** @@ -5084,18 +4814,7 @@ export final class Uint16Array implements Iterable, ArrayLike { if (count < 0) { count = 0 } - return new Uint16Array(this.buffer, relStart * Uint16Array.BYTES_PER_ELEMENT as int, count) - } - - /** - * Creates a Uint16Array with the same Buffer - * - * @param begin start index, inclusive - * - * @returns new Uint16Array with the same Buffer - */ - public subarray(begin: number): Uint16Array { - return this.subarray(begin as int, this.lengthInt) + return new Uint16Array(this.buffer, relStart * Uint16Array.BYTES_PER_ELEMENT, count) } /** @@ -5141,11 +4860,11 @@ export final class Uint16Array implements Iterable, ArrayLike { public toLocaleString(): string { let res: StringBuilder = new StringBuilder("") for (let i = 0; i < this.lengthInt - 1; ++i) { - res.append((this.getUnsafe(i) as Number).toLocaleString()) + res.append((this.getUnsafe(i).toDouble()).toLocaleString()) res.append(",") } if (this.lengthInt > 0) { - res.append((this.getUnsafe(this.lengthInt - 1) as Number).toLocaleString()) + res.append((this.getUnsafe(this.lengthInt - 1).toDouble()).toLocaleString()) } return res.toString() } @@ -5196,7 +4915,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @returns an Uint16Array with replaced value on index */ public with(index: number, value: number): Uint16Array { - return this.with(index as int, value as int) + return this.with(index.toInt(), value.toInt()) } /** @@ -5228,7 +4947,7 @@ export final class Uint16Array implements Iterable, ArrayLike { */ public some(predicate: (element: number, index: number, array: Uint16Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; i++) { - if (predicate(this.getUnsafe(i) as number, i as number, this)) { + if (predicate(this.getUnsafe(i).toDouble(), i, this)) { return true } } @@ -5253,7 +4972,7 @@ export final class Uint16Array implements Iterable, ArrayLike { initialValue: U): U { let accumulatedValue = initialValue for (let i = 0; i < this.lengthInt; i++) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i).toDouble(), i, this) } return accumulatedValue } @@ -5275,9 +4994,9 @@ export final class Uint16Array implements Iterable, ArrayLike { throw new TypeError("Reduce of empty array with no initial value") } - let accumulatedValue = this.$_get(0) as number + let accumulatedValue = this.$_get(0).toDouble() for (let i = 1; i < this.lengthInt; i++) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i).toDouble(), i, this) } return accumulatedValue } @@ -5300,7 +5019,7 @@ export final class Uint16Array implements Iterable, ArrayLike { initialValue: U): U { let accumulatedValue = initialValue for (let i = this.lengthInt - 1; i >= 0; i--) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i).toDouble(), i, this) } return accumulatedValue } @@ -5322,9 +5041,9 @@ export final class Uint16Array implements Iterable, ArrayLike { throw new TypeError("Reduce of empty array with no initial value") } - let accumulatedValue: number = this.$_get(this.lengthInt - 1) as number + let accumulatedValue: number = this.$_get(this.lengthInt - 1).toDouble() for (let i = this.lengthInt - 2; i >= 0; i--) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i).toDouble(), i, this) } return accumulatedValue } @@ -5337,11 +5056,11 @@ export final class Uint16Array implements Iterable, ArrayLike { * @returns a new Uint16Array where for each element from current Uint16Array fn was applied */ public map(fn: (val: number, index: number, array: Uint16Array) => number): Uint16Array { - let resBuf = new ArrayBuffer(this.lengthInt * Uint16Array.BYTES_PER_ELEMENT as int) + let resBuf = new ArrayBuffer(this.lengthInt * Uint16Array.BYTES_PER_ELEMENT) let res = new Uint16Array(resBuf) for (let i = 0; i < this.lengthInt; i++) { - const fnRes = fn(this.getUnsafe(i) as number, i as number, this) - res.setUnsafeClamp(i, fnRes as int) + const fnRes = fn(this.getUnsafe(i).toDouble(), i, this) + res.setUnsafeClamp(i, fnRes.toInt()) } return res } @@ -5358,7 +5077,7 @@ export final class Uint16Array implements Iterable, ArrayLike { */ public every(predicate: (element: number, index: number, array: Uint16Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; i++) { - if (!predicate(this.getUnsafe(i) as number, i as number, this)) { + if (!predicate(this.getUnsafe(i).toDouble(), i, this)) { return false } } @@ -5376,7 +5095,7 @@ export final class Uint16Array implements Iterable, ArrayLike { let markers : FixedArray = new boolean[this.lengthInt] let resLen = 0 for (let i = 0; i < this.lengthInt; i++) { - markers[i] = fn(this.getUnsafe(i) as number, i as number, this) + markers[i] = fn(this.getUnsafe(i).toDouble(), i, this) if (markers[i]) { ++resLen } @@ -5403,8 +5122,8 @@ export final class Uint16Array implements Iterable, ArrayLike { */ public find(predicate: (value: number, index: number, array: Uint16Array) => boolean): number | undefined { for (let i = 0; i < this.lengthInt; i++) { - let val = this.getUnsafe(i) as number - if (predicate(val, i as number, this)) { + let val = this.getUnsafe(i).toDouble() + if (predicate(val, i, this)) { return val } } @@ -5423,11 +5142,11 @@ export final class Uint16Array implements Iterable, ArrayLike { */ public findIndex(predicate: (value: number, index: number, obj: Uint16Array) => boolean): number { for (let i = 0; i < this.lengthInt; i++) { - if (predicate(this.getUnsafe(i) as number, i as number, this)) { - return i as number + if (predicate(this.getUnsafe(i).toDouble(), i, this)) { + return i } } - return -1 as number + return -1 } /** @@ -5439,8 +5158,8 @@ export final class Uint16Array implements Iterable, ArrayLike { */ public findLast(fn: (val: number, index: number, array: Uint16Array) => boolean): number { for (let i = this.lengthInt - 1; i >= 0; i--) { - let val = this.getUnsafe(i) as number - if (fn(val, i as number, this)) { + let val = this.getUnsafe(i).toDouble() + if (fn(val, i, this)) { return val } } @@ -5456,11 +5175,11 @@ export final class Uint16Array implements Iterable, ArrayLike { */ public findLastIndex(fn: (val: number, index: number, array: Uint16Array) => boolean): number { for (let i = this.lengthInt - 1; i >= 0; i--) { - if (fn(this.getUnsafe(i) as number, i as number, this)) { - return i as number + if (fn(this.getUnsafe(i).toDouble(), i, this)) { + return i } } - return -1 as number + return -1 } /** @@ -5473,7 +5192,7 @@ export final class Uint16Array implements Iterable, ArrayLike { */ public forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void): void { for (let i = 0; i < this.lengthInt; i++) { - callbackfn(this.getUnsafe(i) as number, i as number, this) + callbackfn(this.getUnsafe(i).toDouble(), i.toDouble(), this) } } @@ -5513,17 +5232,17 @@ export final class Uint16Array implements Iterable, ArrayLike { } internal getUnsafe(index: int): int { - index = index * Uint16Array.BYTES_PER_ELEMENT as int + this.byteOffsetInt + index = index * Uint16Array.BYTES_PER_ELEMENT + this.byteOffsetInt let res: int = 0 if (IS_LITTLE_ENDIAN) { - for (let i = 0; i < Uint16Array.BYTES_PER_ELEMENT as int; i++) { - let el = this.buffer.at(index + i) as int + for (let i = 0; i < Uint16Array.BYTES_PER_ELEMENT.toInt(); i++) { + let el = this.buffer.at(index + i).toInt() el &= 0xff res |= el << (8 * i) } } else { - for (let i = 0; i < Uint16Array.BYTES_PER_ELEMENT as int; i++) { - let el = this.buffer.at(index + 1 - i) as int + for (let i = 0; i < Uint16Array.BYTES_PER_ELEMENT.toInt(); i++) { + let el = this.buffer.at(index + 1 - i).toInt() el &= 0xff res |= el << (8 * i) } @@ -5532,16 +5251,16 @@ export final class Uint16Array implements Iterable, ArrayLike { } internal setUnsafe(index: int, val: int): void { - index = index * Uint16Array.BYTES_PER_ELEMENT as int + this.byteOffsetInt + index = index * Uint16Array.BYTES_PER_ELEMENT + this.byteOffsetInt let res: int = 0 if (IS_LITTLE_ENDIAN) { - for (let i = 0; i < Uint16Array.BYTES_PER_ELEMENT as int; i++) { - this.buffer.set(index + i, (val & 0xff) as byte) + for (let i = 0; i < Uint16Array.BYTES_PER_ELEMENT.toInt(); i++) { + this.buffer.set(index + i, (val & 0xff).toByte()) val = val >> 8 } } else { - for (let i = 0; i < Uint16Array.BYTES_PER_ELEMENT as int; i++) { - this.buffer.set(index + 1 - i, (val & 0xff) as byte) + for (let i = 0; i < Uint16Array.BYTES_PER_ELEMENT.toInt(); i++) { + this.buffer.set(index + 1 - i, (val & 0xff).toByte()) val = val >> 8 } } @@ -5554,7 +5273,7 @@ class Uint32ArrayIteratorKeys implements IterableIterator { private idx: int = 0 constructor(parent: Uint32Array) { - this.length = parent.length as int + this.length = parent.length.toInt() } public override $_iterator(): IterableIterator { @@ -5565,7 +5284,7 @@ class Uint32ArrayIteratorKeys implements IterableIterator { if (this.idx < 0 || this.idx >= this.length) { return new IteratorResult() } - return new IteratorResult(false, this.idx++ as number) + return new IteratorResult(false, Int.toDouble(this.idx++)) } } @@ -5616,8 +5335,8 @@ class Uint32ArrayIteratorEntries implements IterableIterator<[Number, Number]> { * JS Uint32Array API-compatible class */ export final class Uint32Array implements Iterable, ArrayLike { - public static readonly BYTES_PER_ELEMENT: number = 4 - public readonly BYTES_PER_ELEMENT: number = Uint32Array.BYTES_PER_ELEMENT + public static readonly BYTES_PER_ELEMENT: int = 4 + public readonly BYTES_PER_ELEMENT: int = Uint32Array.BYTES_PER_ELEMENT /** Underlying Buffer */ public readonly buffer: ArrayBuffer @@ -5630,7 +5349,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * Creates an empty Uint32Array. */ public constructor() { - this(0 as int) + this(0) } /** @@ -5640,12 +5359,12 @@ export final class Uint32Array implements Iterable, ArrayLike { const items: Object = elements as Object if (items instanceof ArrayLike) { const arr = Types.identity_cast(items as ArrayLike) - this.byteLengthInt = arr.length as int * Uint32Array.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int + this.byteLengthInt = arr.length.toInt() * Uint32Array.BYTES_PER_ELEMENT + this.lengthInt = arr.length.toInt() this.buffer = new ArrayBuffer(this.byteLengthInt) this.byteOffsetInt = 0 for (let i: int = 0; i < this.lengthInt; ++i) { - this.setUnsafeClamp(i, this.zeroIfInfinity(arr.$_get(i)) as long) + this.setUnsafeClamp(i, this.zeroIfInfinity(arr.$_get(i)).toLong()) } } else { let x = Uint32Array.from(elements) @@ -5678,27 +5397,27 @@ export final class Uint32Array implements Iterable, ArrayLike { throw new RangeError("Range Error: byteLength " + intByteLength + " is outside the bounds of the buffer with byteOffset " + intByteOffset) } - if (intByteLength % Uint32Array.BYTES_PER_ELEMENT as int != 0) { + if (intByteLength % Uint32Array.BYTES_PER_ELEMENT.toInt() != 0) { throw new RangeError("ArrayBuffer.byteLength should be multiple of 4 as Uint32Array.BYTES_PER_ELEMENT") } - if (intByteOffset % Uint32Array.BYTES_PER_ELEMENT as int != 0) { + if (intByteOffset % Uint32Array.BYTES_PER_ELEMENT != 0) { throw new RangeError("byteOffset should be multiple of 4 as Uint32Array.BYTES_PER_ELEMENT") } let intLength: int if (length != undefined) { intLength = length.toInt() - if (intLength > intByteLength / Uint32Array.BYTES_PER_ELEMENT as int) { + if (intLength > intByteLength / Uint32Array.BYTES_PER_ELEMENT) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer with byteOffset " + intByteOffset) } } else { - intLength = intByteLength / Uint32Array.BYTES_PER_ELEMENT as int + intLength = intByteLength / Uint32Array.BYTES_PER_ELEMENT } if (intLength < 0) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer") } - if (intLength < intByteLength / Uint32Array.BYTES_PER_ELEMENT as int) { - intByteLength = intLength * Uint32Array.BYTES_PER_ELEMENT as int + if (intLength < intByteLength / Uint32Array.BYTES_PER_ELEMENT) { + intByteLength = intLength * Uint32Array.BYTES_PER_ELEMENT } this.byteLengthInt = intByteLength this.byteOffsetInt = intByteOffset @@ -5706,30 +5425,6 @@ export final class Uint32Array implements Iterable, ArrayLike { this.buffer = buf } - /** - * Creates an Uint32Array with respect to data, byteOffset and length. - * - * @param buf data initializer - * - * @param byteOffset byte offset from begin of the buf - */ - public constructor(buf: ArrayBuffer, byteOffset: Number | undefined) { - this(buf, byteOffset, undefined) - } - - /** - * Creates an Uint32Array with respect to data, byteOffset and length. - * - * @param buf data initializer - * - * @param byteOffset byte offset from begin of the buf - * - * @param length size of elements of type long in newly created Uint32Array - */ - public constructor(buf: ArrayBuffer, byteOffset: number, length: number) { - this(buf, new Number(byteOffset), new Number(length)) - } - /** * Creates an Uint32Array with respect to buf and byteOffset. * @@ -5750,7 +5445,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * * @param length size of elements of type long in newly created Uint32Array */ - public constructor(buf: ArrayBuffer, byteOffset: int, length: int) { + public constructor(buf: ArrayBufferLike, byteOffset: int, length: int) { this(buf, new Number(byteOffset), new Number(length)) } @@ -5773,18 +5468,18 @@ export final class Uint32Array implements Iterable, ArrayLike { public constructor(buf: ArrayLike | ArrayBuffer) { if (buf instanceof ArrayBuffer) { this.byteLengthInt = (buf as ArrayBuffer).getByteLength() - if (this.byteLengthInt % Uint32Array.BYTES_PER_ELEMENT as int != 0) { + if (this.byteLengthInt % Uint32Array.BYTES_PER_ELEMENT.toInt() != 0) { throw new RangeError("ArrayBuffer.byteLength should be multiple of long as Uint32Array.BYTES_PER_ELEMENT") } - this.lengthInt = this.byteLengthInt / Uint32Array.BYTES_PER_ELEMENT as int + this.lengthInt = this.byteLengthInt / Uint32Array.BYTES_PER_ELEMENT this.buffer = buf as ArrayBuffer this.byteOffsetInt = 0 } else if (buf instanceof ArrayLike) { // NOTE (ikorobkov): dealing with this overload is tricky // with banned `instanceof` generic, so it is delegated to array here. Initial idea from Set.ets let arr = Array.from((buf as ArrayLike)) - this.byteLengthInt = arr.length as int * Uint32Array.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int + this.byteLengthInt = arr.length.toInt() * Uint32Array.BYTES_PER_ELEMENT + this.lengthInt = arr.length.toInt() this.buffer = new ArrayBuffer(this.byteLengthInt) this.byteOffsetInt = 0 for (let i: int = 0; i < this.lengthInt; ++i) { @@ -5801,7 +5496,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @param length data initializer */ public constructor(length: int) { - this(length as number) + this(length.toDouble()) } /** @@ -5813,8 +5508,8 @@ export final class Uint32Array implements Iterable, ArrayLike { if (length < 0 || length > (Int.MAX_VALUE / Uint32Array.BYTES_PER_ELEMENT)) { throw new TypeError("Type Error: length " + length + " is outside the bounds of the buffer") } - this.lengthInt = length as int - this.byteLengthInt = this.lengthInt * Uint32Array.BYTES_PER_ELEMENT as int + this.lengthInt = length.toInt() + this.byteLengthInt = this.lengthInt * Uint32Array.BYTES_PER_ELEMENT this.byteOffsetInt = 0 this.buffer = new ArrayBuffer(this.byteLengthInt) } @@ -5825,9 +5520,9 @@ export final class Uint32Array implements Iterable, ArrayLike { * @param other data initializer */ public constructor(other: Uint32Array) { - this.buffer = other.buffer.slice(other.byteOffset as int, (other.byteOffset + other.byteLength) as int) as ArrayBuffer - this.byteLengthInt = other.byteLength as int - this.lengthInt = other.length as int + this.buffer = other.buffer.slice(other.byteOffset.toInt(), (other.byteOffset + other.byteLength).toInt()) as ArrayBuffer + this.byteLengthInt = other.byteLength.toInt() + this.lengthInt = other.length.toInt() this.byteOffsetInt = 0 } @@ -5837,7 +5532,7 @@ export final class Uint32Array implements Iterable, ArrayLike { public constructor(numbers: FixedArray) { this(numbers.length) for (let i: int = 0; i < this.lengthInt; ++i) { - this.setUnsafeClamp(i, this.zeroIfInfinity(numbers[i]) as long) + this.setUnsafeClamp(i, this.zeroIfInfinity(numbers[i]).toLong()) } } @@ -5847,19 +5542,19 @@ export final class Uint32Array implements Iterable, ArrayLike { public constructor(numbers: FixedArray) { this(numbers.length) for (let i: int = 0; i < this.lengthInt; ++i) { - this.setUnsafeClamp(i, this.zeroIfInfinity(numbers[i]) as long) + this.setUnsafeClamp(i, this.zeroIfInfinity(numbers[i]).toLong()) } } internal zeroIfInfinity(val: number): number { if ((val == Infinity) || (val == -Infinity)) { - return 0 as number + return 0 } - return val as number + return val } internal zeroIfInfinity(val: long): long { if ((val == Infinity) || (val == -Infinity)) { - return 0 as long + return 0 } return val } @@ -5881,7 +5576,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @returns a primitive at index */ public at(index: number): Number | undefined { - return this.at(index as int) + return this.at(index.toInt()) } /** @@ -5912,7 +5607,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @returns a primitive at index */ public override $_get(index: number): Number { - return this.$_get(index as int) as Number + return this.$_get(index.toInt()).toDouble() } /** @@ -5932,7 +5627,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @param index index to change */ public $_set(index: number, val: number): void { - this.$_set(index as int, val) + this.$_set(index.toInt(), val) } /** @@ -5944,7 +5639,7 @@ export final class Uint32Array implements Iterable, ArrayLike { */ public $_set(index: int, val: number): void { let v = this.zeroIfInfinity(val) - this.$_set(index, v as long) + this.$_set(index, v.toLong()) } /** @@ -5955,7 +5650,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @param index index to change */ public $_set(index: number, val: long): void { - this.$_set(index as int, val) + this.$_set(index.toInt(), val) } /** @@ -5975,7 +5670,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @param index index to change */ public $_set(index: number, val: int): void { - this.$_set(index as int, val as int) + this.$_set(index.toInt(), val.toInt()) } /** @@ -5999,7 +5694,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: number, start: number, end?: number): Uint32Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -6014,7 +5709,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: int, start: number, end?: number): Uint32Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -6029,7 +5724,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: number, start: int, end?: number): Uint32Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -6044,7 +5739,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: int, start: int, end?: number): Uint32Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -6069,7 +5764,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} */ public copyWithin(target: number): Uint32Array { - return this.copyWithin(target as int) + return this.copyWithin(target.toInt()) } /** @@ -6102,7 +5797,7 @@ export final class Uint32Array implements Iterable, ArrayLike { */ public fill(value: number, start?: number, end?: number): Uint32Array { value = this.zeroIfInfinity(value) - this.fill(value as long, asIntOrDefault(start, 0 as int), asIntOrDefault(end, this.lengthInt)) + this.fill(value.toLong(), asIntOrDefault(start, 0), asIntOrDefault(end, this.lengthInt)) return this } @@ -6115,20 +5810,7 @@ export final class Uint32Array implements Iterable, ArrayLike { */ public fill(value: number, start: int, end?: number): Uint32Array { value = this.zeroIfInfinity(value) - this.fill(value as long, start as int, asIntOrDefault(end, this.lengthInt)) - return this - } - - /** - * Fills the Uint32Array with specified value - * - * @param value new value - * - * @returns modified Uint32Array - */ - public fill(value: number, start: int, end: number): Uint32Array { - value = this.zeroIfInfinity(value) - this.fill(value as long, start as int, end as int) + this.fill(value.toLong(), start.toInt(), asIntOrDefault(end, this.lengthInt)) return this } @@ -6141,7 +5823,7 @@ export final class Uint32Array implements Iterable, ArrayLike { */ public fill(value: number, start: number, end: int): Uint32Array { value = this.zeroIfInfinity(value) - this.fill(value as long, start as int, end as int) + this.fill(value.toLong(), start.toInt(), end.toInt()) return this } @@ -6154,7 +5836,7 @@ export final class Uint32Array implements Iterable, ArrayLike { */ public fill(value: number, start: int, end: int): Uint32Array { value = this.zeroIfInfinity(value) - this.fill(value as long, start as int, end as int) + this.fill(value.toLong(), start.toInt(), end.toInt()) return this } @@ -6166,7 +5848,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @returns modified Uint32Array */ public fill(value: long, start?: number, end?: number): Uint32Array { - this.fill(value, asIntOrDefault(start, 0 as int), asIntOrDefault(end, this.lengthInt)) + this.fill(value, asIntOrDefault(start, 0), asIntOrDefault(end, this.lengthInt)) return this } @@ -6178,19 +5860,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @returns modified Uint32Array */ public fill(value: long, start: int, end?: number): Uint32Array { - this.fill(value, start as int, asIntOrDefault(end, this.lengthInt)) - return this - } - - /** - * Fills the Uint32Array with specified value - * - * @param value new value - * - * @returns modified Uint32Array - */ - public fill(value: long, start: int, end: number): Uint32Array { - this.fill(value, start as int, end as int) + this.fill(value, start.toInt(), asIntOrDefault(end, this.lengthInt)) return this } @@ -6202,7 +5872,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @returns modified Uint32Array */ public fill(value: long, start: number, end: int): Uint32Array { - this.fill(value, start as int, end as int) + this.fill(value, start.toInt(), end.toInt()) return this } @@ -6230,7 +5900,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @param index index to change */ public set(insertPos: number, val: number): void { - this.$_set(insertPos as int, val) + this.$_set(insertPos.toInt(), val) } /** @@ -6241,7 +5911,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @param index index to change */ public set(insertPos: int, val: number): void { - this.$_set(insertPos as int, val) + this.$_set(insertPos.toInt(), val) } /** @@ -6252,7 +5922,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @param index index to change */ public set(insertPos: number, val: long): void { - this.$_set(insertPos as int, val) + this.$_set(insertPos.toInt(), val) } /** @@ -6263,7 +5933,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @param index index to change */ public set(insertPos: int, val: long): void { - this.$_set(insertPos as int, val) + this.$_set(insertPos.toInt(), val) } /** @@ -6276,13 +5946,13 @@ export final class Uint32Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ public set(arr: FixedArray, insertPos1: number): void { - const insertPos = insertPos1 as int + const insertPos = insertPos1.toInt() if (insertPos < 0 || insertPos + arr.length > this.lengthInt) { throw new RangeError("set(insertPos: int, arr: FixedArray): size of arr is greater than Uint32Array.length") } for (let i = 0; i < arr.length; i++) { let v = this.zeroIfInfinity(arr[i]) - this.setUnsafeClamp(insertPos as int + i as int, v as long) + this.setUnsafeClamp(insertPos.toInt() + i.toInt(), v.toLong()) } } @@ -6335,13 +6005,13 @@ export final class Uint32Array implements Iterable, ArrayLike { * @param offset Optional. The offset into the target array at which to begin writing values from the source array */ public set(array: ArrayLike, offset: number = 0): void { - const insertPos = offset as int + const insertPos = offset.toInt() if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } for (let i = array.length - 1; i >= 0; --i) { let v = this.zeroIfInfinity(array[i]) - this.setUnsafeClamp(insertPos as int + i as int, v as long) + this.setUnsafeClamp(insertPos.toInt() + i.toInt(), v.toLong()) } } @@ -6353,9 +6023,9 @@ export final class Uint32Array implements Iterable, ArrayLike { * @returns new Uint32Array */ public static of(...items: FixedArray): Uint32Array { - let res = new Uint32Array(items.length as int) + let res = new Uint32Array(items.length.toInt()) for (let i: int = 0; i < items.length; i++) { - res.setUnsafeClamp(i, res.zeroIfInfinity(items[i]) as long) + res.setUnsafeClamp(i, res.zeroIfInfinity(items[i]).toLong()) } return res } @@ -6368,9 +6038,9 @@ export final class Uint32Array implements Iterable, ArrayLike { * @returns new Uint32Array */ public static of(...items: FixedArray): Uint32Array { - let res = new Uint32Array(items.length as int) + let res = new Uint32Array(items.length.toInt()) for (let i: int = 0; i < items.length; i++) { - res.setUnsafeClamp(i, items[i] as long) + res.setUnsafeClamp(i, items[i].toLong()) } return res } @@ -6383,7 +6053,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @returns new Uint32Array */ public static of(...items: FixedArray): Uint32Array { - let res = new Uint32Array(items.length as int) + let res = new Uint32Array(items.length.toInt()) for (let i: int = 0; i < items.length; i++) { res.setUnsafeClamp(i, items[i]) } @@ -6398,7 +6068,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @returns new Uint32Array */ public static of(): Uint32Array { - return new Uint32Array(0 as int) + return new Uint32Array(0) } /** @@ -6439,7 +6109,7 @@ export final class Uint32Array implements Iterable, ArrayLike { if (x.done) { return new Uint32Array(result.buffer, 0, i) } - result.setUnsafeClamp(i, result.zeroIfInfinity((mapfn)!(x.value!, i)) as long) + result.setUnsafeClamp(i, result.zeroIfInfinity((mapfn)!(x.value!, i)).toLong()) } return result } @@ -6459,7 +6129,7 @@ export final class Uint32Array implements Iterable, ArrayLike { } temp = new Uint32Array(tb) } - temp.setUnsafeClamp(index[0], temp.zeroIfInfinity((mapfn)!(x, index[0])) as long) + temp.setUnsafeClamp(index[0], temp.zeroIfInfinity((mapfn)!(x, index[0])).toLong()) index[0]++ }) @@ -6481,7 +6151,7 @@ export final class Uint32Array implements Iterable, ArrayLike { const idx : FixedArray = new int[1] idx[0] = 0 iteratorForEach(arrayLike.$_iterator(), (x: T): void => { - res.setUnsafeClamp(idx[0], res.zeroIfInfinity(mapfn(x as T, idx[0] as number)) as long) + res.setUnsafeClamp(idx[0], res.zeroIfInfinity(mapfn(x as T, idx[0].toDouble())).toLong()) idx[0] += 1 }) return res @@ -6510,7 +6180,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @returns true if searchElement is in Uint32Array, false otherwise */ public includes(searchElement: long, fromIndex: int): boolean { - return this.indexOf(searchElement as int, fromIndex) != -1 + return this.indexOf(searchElement.toInt(), fromIndex) != -1 } /** @@ -6523,7 +6193,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @returns true if searchElement is in Uint32Array, false otherwise */ public includes(searchElement: long): boolean { - return this.indexOf(searchElement as int, 0) != -1 + return this.indexOf(searchElement.toInt(), 0) != -1 } /** @@ -6565,7 +6235,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @returns index of element if it presents, -1 otherwise */ public indexOf(searchElement: int, fromIndex: int): number { - return this.indexOfImpl(searchElement as long, fromIndex) + return this.indexOfImpl(Int.toLong(searchElement), fromIndex) } /** @@ -6693,7 +6363,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ public lastIndexOf(searchElement: int, fromIndex: int): number { - return this.lastIndexOfImpl(searchElement as long, fromIndex) + return this.lastIndexOfImpl(Int.toLong(searchElement), fromIndex) } /** @@ -6764,22 +6434,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin?: number, end?: number): Uint32Array { - return this.slice(asIntOrDefault(begin, 0 as int), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Creates a slice of current Uint32Array using range [begin, end) - * - * @param begin start index to be taken into slice - * - * @param end last index to be taken into slice - * - * @returns a new Uint32Array with elements of current Uint32Array[begin;end) where end index is excluded - * - * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice - */ - public slice(begin: number, end: number): Uint32Array { - return this.slice(begin as int, end as int) + return this.slice(asIntOrDefault(begin, 0), asIntOrDefault(end, this.lengthInt)) } /** @@ -6794,7 +6449,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin: number, end: int): Uint32Array { - return this.slice(begin as int, end as int) + return this.slice(begin.toInt(), end.toInt()) } /** @@ -6809,7 +6464,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin: int, end: number): Uint32Array { - return this.slice(begin as int, end as int) + return this.slice(begin.toInt(), end.toInt()) } /** @@ -6831,21 +6486,10 @@ export final class Uint32Array implements Iterable, ArrayLike { if (count < 0) { count = 0 } - let buf = this.buffer.slice(relStart * Uint32Array.BYTES_PER_ELEMENT as int, relEnd * Uint32Array.BYTES_PER_ELEMENT as int) as ArrayBuffer + let buf = this.buffer.slice(relStart * Uint32Array.BYTES_PER_ELEMENT.toInt(), relEnd * Uint32Array.BYTES_PER_ELEMENT.toInt()) as ArrayBuffer return new Uint32Array(buf) } - /** - * Creates a slice of current Uint32Array using range [begin, this.lengthInt). - * - * @param begin start index to be taken into slice - * - * @returns a new Uint32Array with elements of current Uint32Array[begin, this.lengthInt) - */ - public slice(begin: number): Uint32Array { - return this.slice(begin as int) - } - /** * Creates a slice of current Uint32Array using range [begin, this.lengthInt). * @@ -6883,8 +6527,13 @@ export final class Uint32Array implements Iterable, ArrayLike { arr[i] = this.getUnsafe(i) } let cmp = (l: long, r: long): number => { - const result = compareFn!(l as number, r as number) - return result + return (l - r).toDouble() + } + if (compareFn != undefined) { + cmp = (l: long, r: long): number => { + const result = compareFn!(l.toDouble(), r.toDouble()) + return result + } } sort(arr, cmp) for (let i = 0; i < this.lengthInt; ++i) { @@ -6903,20 +6552,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @returns new Uint32Array with the same underlying Buffer */ public subarray(begin?: number, end?: number): Uint32Array { - return this.subarray(asIntOrDefault(begin, 0 as int), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Creates a Uint32Array with the same underlying Buffer - * - * @param begin start index, inclusive - * - * @param end last index, exclusive - * - * @returns new Uint32Array with the same underlying Buffer - */ - public subarray(begin: number, end: number): Uint32Array { - return this.subarray(begin as int, end as int) + return this.subarray(asIntOrDefault(begin, 0), asIntOrDefault(end, this.lengthInt)) } /** @@ -6929,7 +6565,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @returns new Uint32Array with the same underlying Buffer */ public subarray(begin: number, end: int): Uint32Array { - return this.subarray(begin as int, end as int) + return this.subarray(begin.toInt(), end.toInt()) } /** @@ -6942,7 +6578,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @returns new Uint32Array with the same underlying Buffer */ public subarray(begin: int, end: number): Uint32Array { - return this.subarray(begin as int, end as int) + return this.subarray(begin.toInt(), end.toInt()) } /** @@ -6962,18 +6598,7 @@ export final class Uint32Array implements Iterable, ArrayLike { if (count < 0) { count = 0 } - return new Uint32Array(this.buffer, relStart * Uint32Array.BYTES_PER_ELEMENT as int, count) - } - - /** - * Creates a Uint32Array with the same Buffer - * - * @param begin start index, inclusive - * - * @returns new Uint32Array with the same Buffer - */ - public subarray(begin: number): Uint32Array { - return this.subarray(begin as int, this.lengthInt) + return new Uint32Array(this.buffer, relStart * Uint32Array.BYTES_PER_ELEMENT, count) } /** @@ -7019,11 +6644,11 @@ export final class Uint32Array implements Iterable, ArrayLike { public toLocaleString(): string { let res: StringBuilder = new StringBuilder("") for (let i = 0; i < this.lengthInt - 1; ++i) { - res.append((this.getUnsafe(i) as Number).toLocaleString()) + res.append((this.getUnsafe(i).toDouble()).toLocaleString()) res.append(",") } if (this.lengthInt > 0) { - res.append((this.getUnsafe(this.lengthInt - 1) as Number).toLocaleString()) + res.append((this.getUnsafe(this.lengthInt - 1).toDouble()).toLocaleString()) } return res.toString() } @@ -7074,7 +6699,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @returns an Uint32Array with replaced value on index */ public with(index: number, value: number): Uint32Array { - return this.with(index as int, value as long) + return this.with(index.toInt(), value.toLong()) } /** @@ -7106,7 +6731,7 @@ export final class Uint32Array implements Iterable, ArrayLike { */ public some(predicate: (element: number, index: number, array: Uint32Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; i++) { - if (predicate(this.getUnsafe(i) as number, i as number, this)) { + if (predicate(this.getUnsafe(i).toDouble(), i, this)) { return true } } @@ -7131,7 +6756,7 @@ export final class Uint32Array implements Iterable, ArrayLike { initialValue: U): U { let accumulatedValue = initialValue for (let i = 0; i < this.lengthInt; i++) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i).toDouble(), i, this) } return accumulatedValue } @@ -7153,9 +6778,9 @@ export final class Uint32Array implements Iterable, ArrayLike { throw new TypeError("Reduce of empty array with no initial value") } - let accumulatedValue = this.$_get(0) as number + let accumulatedValue = this.$_get(0).toDouble() for (let i = 1; i < this.lengthInt; i++) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i).toDouble(), i, this) } return accumulatedValue } @@ -7178,7 +6803,7 @@ export final class Uint32Array implements Iterable, ArrayLike { initialValue: U): U { let accumulatedValue = initialValue for (let i = this.lengthInt - 1; i >= 0; i--) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i).toDouble(), i, this) } return accumulatedValue } @@ -7200,9 +6825,9 @@ export final class Uint32Array implements Iterable, ArrayLike { throw new TypeError("Reduce of empty array with no initial value") } - let accumulatedValue: number = this.$_get(this.lengthInt - 1) as number + let accumulatedValue: number = this.$_get(this.lengthInt - 1).toDouble() for (let i = this.lengthInt - 2; i >= 0; i--) { - accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i) as number, i as number, this) + accumulatedValue = callbackfn(accumulatedValue, this.getUnsafe(i).toDouble(), i, this) } return accumulatedValue } @@ -7215,11 +6840,11 @@ export final class Uint32Array implements Iterable, ArrayLike { * @returns a new Uint32Array where for each element from current Uint32Array fn was applied */ public map(fn: (val: number, index: number, array: Uint32Array) => number): Uint32Array { - let resBuf = new ArrayBuffer(this.lengthInt * Uint32Array.BYTES_PER_ELEMENT as int) + let resBuf = new ArrayBuffer(this.lengthInt * Uint32Array.BYTES_PER_ELEMENT) let res = new Uint32Array(resBuf) for (let i = 0; i < this.lengthInt; i++) { - const fnRes = fn(this.getUnsafe(i) as number, i as number, this) - res.setUnsafeClamp(i, fnRes as long) + const fnRes = fn(this.getUnsafe(i).toDouble(), i, this) + res.setUnsafeClamp(i, fnRes.toLong()) } return res } @@ -7236,7 +6861,7 @@ export final class Uint32Array implements Iterable, ArrayLike { */ public every(predicate: (element: number, index: number, array: Uint32Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; i++) { - if (!predicate(this.getUnsafe(i) as number, i as number, this)) { + if (!predicate(this.getUnsafe(i).toDouble(), i, this)) { return false } } @@ -7254,7 +6879,7 @@ export final class Uint32Array implements Iterable, ArrayLike { let markers : FixedArray = new boolean[this.lengthInt] let resLen = 0 for (let i = 0; i < this.lengthInt; i++) { - markers[i] = fn(this.getUnsafe(i) as number, i as number, this) + markers[i] = fn(this.getUnsafe(i).toDouble(), i, this) if (markers[i]) { ++resLen } @@ -7281,8 +6906,8 @@ export final class Uint32Array implements Iterable, ArrayLike { */ public find(predicate: (value: number, index: number, array: Uint32Array) => boolean): number | undefined { for (let i = 0; i < this.lengthInt; i++) { - let val = this.getUnsafe(i) as number - if (predicate(val, i as number, this)) { + let val = this.getUnsafe(i).toDouble() + if (predicate(val, i, this)) { return val } } @@ -7301,11 +6926,11 @@ export final class Uint32Array implements Iterable, ArrayLike { */ public findIndex(predicate: (value: number, index: number, obj: Uint32Array) => boolean): number { for (let i = 0; i < this.lengthInt; i++) { - if (predicate(this.getUnsafe(i) as number, i as number, this)) { - return i as number + if (predicate(this.getUnsafe(i).toDouble(), i, this)) { + return i } } - return -1 as number + return -1 } /** @@ -7317,8 +6942,8 @@ export final class Uint32Array implements Iterable, ArrayLike { */ public findLast(fn: (val: number, index: number, array: Uint32Array) => boolean): number { for (let i = this.lengthInt - 1; i >= 0; i--) { - let val = this.getUnsafe(i) as number - if (fn(val, i as number, this)) { + let val = this.getUnsafe(i).toDouble() + if (fn(val, i, this)) { return val } } @@ -7334,11 +6959,11 @@ export final class Uint32Array implements Iterable, ArrayLike { */ public findLastIndex(fn: (val: number, index: number, array: Uint32Array) => boolean): number { for (let i = this.lengthInt - 1; i >= 0; i--) { - if (fn(this.getUnsafe(i) as number, i as number, this)) { - return i as number + if (fn(this.getUnsafe(i).toDouble(), i, this)) { + return i } } - return -1 as number + return -1 } /** @@ -7351,7 +6976,7 @@ export final class Uint32Array implements Iterable, ArrayLike { */ public forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void): void { for (let i = 0; i < this.lengthInt; i++) { - callbackfn(this.getUnsafe(i) as number, i as number, this) + callbackfn(this.getUnsafe(i).toDouble(), i.toDouble(), this) } } @@ -7391,17 +7016,17 @@ export final class Uint32Array implements Iterable, ArrayLike { } internal getUnsafe(index: int): long { - index = index * Uint32Array.BYTES_PER_ELEMENT as int + this.byteOffsetInt + index = index * Uint32Array.BYTES_PER_ELEMENT + this.byteOffsetInt let res: long = 0 if (IS_LITTLE_ENDIAN) { - for (let i = 0; i < Uint32Array.BYTES_PER_ELEMENT as int; i++) { - let el = this.buffer.at(index + i) as long + for (let i = 0; i < Uint32Array.BYTES_PER_ELEMENT.toInt(); i++) { + let el = this.buffer.at(index + i).toLong() el &= 0xff res |= el << (8 * i) } } else { - for (let i = 0; i < Uint32Array.BYTES_PER_ELEMENT as int; i++) { - let el = this.buffer.at(index + 3 - i) as long + for (let i = 0; i < Uint32Array.BYTES_PER_ELEMENT.toInt(); i++) { + let el = this.buffer.at(index + 3 - i).toLong() el &= 0xff res |= el << (8 * i) } @@ -7410,16 +7035,16 @@ export final class Uint32Array implements Iterable, ArrayLike { } internal setUnsafe(index: int, val: long): void { - index = index * Uint32Array.BYTES_PER_ELEMENT as int + this.byteOffsetInt + index = index * Uint32Array.BYTES_PER_ELEMENT + this.byteOffsetInt let res: long = 0 if (IS_LITTLE_ENDIAN) { - for (let i = 0; i < Uint32Array.BYTES_PER_ELEMENT as int; i++) { - this.buffer.set(index + i, (val & 0xff) as byte) + for (let i = 0; i < Uint32Array.BYTES_PER_ELEMENT.toInt(); i++) { + this.buffer.set(index + i, (val & 0xff).toByte()) val = val >> 8 } } else { - for (let i = 0; i < Uint32Array.BYTES_PER_ELEMENT as int; i++) { - this.buffer.set(index + 3 - i, (val & 0xff) as byte) + for (let i = 0; i < Uint32Array.BYTES_PER_ELEMENT.toInt(); i++) { + this.buffer.set(index + 3 - i, (val & 0xff).toByte()) val = val >> 8 } } @@ -7432,7 +7057,7 @@ class BigUint64ArrayIteratorKeys implements IterableIterator { private idx: int = 0 constructor(parent: BigUint64Array) { - this.length = parent.length as int + this.length = parent.length.toInt() } public override $_iterator(): IterableIterator { @@ -7443,7 +7068,7 @@ class BigUint64ArrayIteratorKeys implements IterableIterator { if (this.idx < 0 || this.idx >= this.length) { return new IteratorResult() } - return new IteratorResult(false, this.idx++ as number) + return new IteratorResult(false, Int.toDouble(this.idx++)) } } @@ -7494,8 +7119,8 @@ class BigUint64ArrayIteratorEntries implements IterableIterator<[Number, BigInt] * JS BigUint64Array API-compatible class */ export final class BigUint64Array implements Iterable, ArrayLike { - public static readonly BYTES_PER_ELEMENT: number = 8 - public readonly BYTES_PER_ELEMENT: number = BigUint64Array.BYTES_PER_ELEMENT + public static readonly BYTES_PER_ELEMENT: int = 8 + public readonly BYTES_PER_ELEMENT: int = BigUint64Array.BYTES_PER_ELEMENT /** Underlying Buffer */ public readonly buffer: ArrayBuffer @@ -7508,7 +7133,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * Creates an empty BigUint64Array. */ public constructor() { - this(0 as int) + this(0) } /** @@ -7518,8 +7143,8 @@ export final class BigUint64Array implements Iterable, ArrayLike const items: Object = elements as Object if (items instanceof ArrayLike) { const arr = Types.identity_cast(items as ArrayLike) - this.byteLengthInt = arr.length as int * BigUint64Array.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int + this.byteLengthInt = arr.length.toInt() * BigUint64Array.BYTES_PER_ELEMENT + this.lengthInt = arr.length.toInt() this.buffer = new ArrayBuffer(this.byteLengthInt) this.byteOffsetInt = 0 for (let i: int = 0; i < this.lengthInt; ++i) { @@ -7556,27 +7181,27 @@ export final class BigUint64Array implements Iterable, ArrayLike throw new RangeError("Range Error: byteLength " + intByteLength + " is outside the bounds of the buffer with byteOffset " + intByteOffset) } - if (intByteLength % BigUint64Array.BYTES_PER_ELEMENT as int != 0) { + if (intByteLength % BigUint64Array.BYTES_PER_ELEMENT.toInt() != 0) { throw new RangeError("ArrayBuffer.byteLength should be multiple of 8 as BigUint64Array.BYTES_PER_ELEMENT") } - if (intByteOffset % BigUint64Array.BYTES_PER_ELEMENT as int != 0) { + if (intByteOffset % BigUint64Array.BYTES_PER_ELEMENT != 0) { throw new RangeError("byteOffset should be multiple of 8 as BigUint64Array.BYTES_PER_ELEMENT") } let intLength: int if (length != undefined) { intLength = length.toInt() - if (intLength > intByteLength / BigUint64Array.BYTES_PER_ELEMENT as int) { + if (intLength > intByteLength / BigUint64Array.BYTES_PER_ELEMENT) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer with byteOffset " + intByteOffset) } } else { - intLength = intByteLength / BigUint64Array.BYTES_PER_ELEMENT as int + intLength = intByteLength / BigUint64Array.BYTES_PER_ELEMENT } if (intLength < 0) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer") } - if (intLength < intByteLength / BigUint64Array.BYTES_PER_ELEMENT as int) { - intByteLength = intLength * BigUint64Array.BYTES_PER_ELEMENT as int + if (intLength < intByteLength / BigUint64Array.BYTES_PER_ELEMENT) { + intByteLength = intLength * BigUint64Array.BYTES_PER_ELEMENT } this.byteLengthInt = intByteLength this.byteOffsetInt = intByteOffset @@ -7584,30 +7209,6 @@ export final class BigUint64Array implements Iterable, ArrayLike this.buffer = buf } - /** - * Creates an BigUint64Array with respect to data, byteOffset and length. - * - * @param buf data initializer - * - * @param byteOffset byte offset from begin of the buf - */ - public constructor(buf: ArrayBuffer, byteOffset: Number | undefined) { - this(buf, byteOffset, undefined) - } - - /** - * Creates an BigUint64Array with respect to data, byteOffset and length. - * - * @param buf data initializer - * - * @param byteOffset byte offset from begin of the buf - * - * @param length size of elements of type long in newly created BigUint64Array - */ - public constructor(buf: ArrayBuffer, byteOffset: number, length: number) { - this(buf, new Number(byteOffset), new Number(length)) - } - /** * Creates an BigUint64Array with respect to buf and byteOffset. * @@ -7628,7 +7229,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * * @param length size of elements of type long in newly created BigUint64Array */ - public constructor(buf: ArrayBuffer, byteOffset: int, length: int) { + public constructor(buf: ArrayBufferLike, byteOffset: int, length: int) { this(buf, new Number(byteOffset), new Number(length)) } @@ -7651,18 +7252,18 @@ export final class BigUint64Array implements Iterable, ArrayLike public constructor(buf: ArrayLike | ArrayBuffer) { if (buf instanceof ArrayBuffer) { this.byteLengthInt = (buf as ArrayBuffer).getByteLength() - if (this.byteLengthInt % BigUint64Array.BYTES_PER_ELEMENT as int != 0) { + if (this.byteLengthInt % BigUint64Array.BYTES_PER_ELEMENT.toInt() != 0) { throw new RangeError("ArrayBuffer.byteLength should be multiple of long as BigUint64Array.BYTES_PER_ELEMENT") } - this.lengthInt = this.byteLengthInt / BigUint64Array.BYTES_PER_ELEMENT as int + this.lengthInt = this.byteLengthInt / BigUint64Array.BYTES_PER_ELEMENT this.buffer = buf as ArrayBuffer this.byteOffsetInt = 0 } else if (buf instanceof ArrayLike) { // NOTE (ikorobkov): dealing with this overload is tricky // with banned `instanceof` generic, so it is delegated to array here. Initial idea from Set.ets let arr = Array.from((buf as ArrayLike)) - this.byteLengthInt = arr.length as int * BigUint64Array.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int + this.byteLengthInt = arr.length.toInt() * BigUint64Array.BYTES_PER_ELEMENT + this.lengthInt = arr.length.toInt() this.buffer = new ArrayBuffer(this.byteLengthInt) this.byteOffsetInt = 0 for (let i: int = 0; i < this.lengthInt; ++i) { @@ -7679,7 +7280,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @param length data initializer */ public constructor(length: int) { - this(length as number) + this(length.toDouble()) } /** @@ -7691,8 +7292,8 @@ export final class BigUint64Array implements Iterable, ArrayLike if (length < 0 || length > (Int.MAX_VALUE / BigUint64Array.BYTES_PER_ELEMENT)) { throw new TypeError("Type Error: length " + length + " is outside the bounds of the buffer") } - this.lengthInt = length as int - this.byteLengthInt = this.lengthInt * BigUint64Array.BYTES_PER_ELEMENT as int + this.lengthInt = length.toInt() + this.byteLengthInt = this.lengthInt * BigUint64Array.BYTES_PER_ELEMENT this.byteOffsetInt = 0 this.buffer = new ArrayBuffer(this.byteLengthInt) } @@ -7703,9 +7304,9 @@ export final class BigUint64Array implements Iterable, ArrayLike * @param other data initializer */ public constructor(other: BigUint64Array) { - this.buffer = other.buffer.slice(other.byteOffset as int, (other.byteOffset + other.byteLength) as int) as ArrayBuffer - this.byteLengthInt = other.byteLength as int - this.lengthInt = other.length as int + this.buffer = other.buffer.slice(other.byteOffset.toInt(), (other.byteOffset + other.byteLength).toInt()) as ArrayBuffer + this.byteLengthInt = other.byteLength.toInt() + this.lengthInt = other.length.toInt() this.byteOffsetInt = 0 } @@ -7756,7 +7357,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns a primitive at index */ public at(index: number): BigInt | undefined { - return this.at(index as int) + return this.at(index.toInt()) } /** @@ -7787,7 +7388,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns a primitive at index */ public override $_get(index: number): BigInt { - return this.$_get(index as int) as BigInt + return new BigInt(this.$_get(index.toInt())) } /** @@ -7810,7 +7411,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @param index index to change */ public $_set(index: number, val: BigInt): void { - this.$_set(index as int, val) + this.$_set(index.toInt(), val) } /** @@ -7832,7 +7433,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @param index index to change */ public $_set(index: number, val: long): void { - this.$_set(index as int, val) + this.$_set(index.toInt(), val) } /** @@ -7852,7 +7453,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @param index index to change */ public $_set(index: number, val: int): void { - this.$_set(index as int, val as int) + this.$_set(index.toInt(), val.toInt()) } /** @@ -7876,7 +7477,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: number, start: number, end?: number): BigUint64Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -7891,7 +7492,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: int, start: number, end?: number): BigUint64Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -7906,7 +7507,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: number, start: int, end?: number): BigUint64Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -7921,7 +7522,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: int, start: int, end?: number): BigUint64Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -7946,7 +7547,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} */ public copyWithin(target: number): BigUint64Array { - return this.copyWithin(target as int) + return this.copyWithin(target.toInt()) } /** @@ -7978,7 +7579,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns modified BigUint64Array */ public fill(value: BigInt, start?: number, end?: number): BigUint64Array { - this.fill(value.getULong(), asIntOrDefault(start, 0 as int), asIntOrDefault(end, this.lengthInt)) + this.fill(value.getULong(), asIntOrDefault(start, 0), asIntOrDefault(end, this.lengthInt)) return this } @@ -7990,19 +7591,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns modified BigUint64Array */ public fill(value: BigInt, start: int, end?: number): BigUint64Array { - this.fill(value.getULong(), start as int, asIntOrDefault(end, this.lengthInt)) - return this - } - - /** - * Fills the BigUint64Array with specified value - * - * @param value new value - * - * @returns modified BigUint64Array - */ - public fill(value: BigInt, start: int, end: number): BigUint64Array { - this.fill(value.getULong(), start as int, end as int) + this.fill(value.getULong(), start.toInt(), asIntOrDefault(end, this.lengthInt)) return this } @@ -8014,7 +7603,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns modified BigUint64Array */ public fill(value: BigInt, start: number, end: int): BigUint64Array { - this.fill(value.getULong(), start as int, end as int) + this.fill(value.getULong(), start.toInt(), end.toInt()) return this } @@ -8026,7 +7615,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns modified BigUint64Array */ public fill(value: BigInt, start: int, end: int): BigUint64Array { - this.fill(value.getULong(), start as int, end as int) + this.fill(value.getULong(), start.toInt(), end.toInt()) return this } @@ -8038,7 +7627,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns modified BigUint64Array */ public fill(value: long, start?: number, end?: number): BigUint64Array { - this.fill(value, asIntOrDefault(start, 0 as int), asIntOrDefault(end, this.lengthInt)) + this.fill(value, asIntOrDefault(start, 0), asIntOrDefault(end, this.lengthInt)) return this } @@ -8050,19 +7639,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns modified BigUint64Array */ public fill(value: long, start: int, end?: number): BigUint64Array { - this.fill(value, start as int, asIntOrDefault(end, this.lengthInt)) - return this - } - - /** - * Fills the BigUint64Array with specified value - * - * @param value new value - * - * @returns modified BigUint64Array - */ - public fill(value: long, start: int, end: number): BigUint64Array { - this.fill(value, start as int, end as int) + this.fill(value, start.toInt(), asIntOrDefault(end, this.lengthInt)) return this } @@ -8074,7 +7651,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns modified BigUint64Array */ public fill(value: long, start: number, end: int): BigUint64Array { - this.fill(value, start as int, end as int) + this.fill(value, start.toInt(), end.toInt()) return this } @@ -8102,7 +7679,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @param index index to change */ public set(insertPos: number, val: BigInt): void { - this.$_set(insertPos as int, val) + this.$_set(insertPos.toInt(), val) } /** @@ -8113,7 +7690,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @param index index to change */ public set(insertPos: int, val: BigInt): void { - this.$_set(insertPos as int, val) + this.$_set(insertPos.toInt(), val) } /** @@ -8124,7 +7701,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @param index index to change */ public set(insertPos: number, val: long): void { - this.$_set(insertPos as int, val) + this.$_set(insertPos.toInt(), val) } /** @@ -8135,7 +7712,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @param index index to change */ public set(insertPos: int, val: long): void { - this.$_set(insertPos as int, val) + this.$_set(insertPos.toInt(), val) } /** @@ -8148,12 +7725,12 @@ export final class BigUint64Array implements Iterable, ArrayLike * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ public set(arr: FixedArray, insertPos1: number): void { - const insertPos = insertPos1 as int + const insertPos = insertPos1.toInt() if (insertPos < 0 || insertPos + arr.length > this.lengthInt) { throw new RangeError("set(insertPos: int, arr: FixedArray): size of arr is greater than BigUint64Array.length") } for (let i = 0; i < arr.length; i++) { - this.setUnsafeClamp(insertPos as int + i as int, arr[i].getULong()) + this.setUnsafeClamp(insertPos.toInt() + i.toInt(), arr[i].getULong()) } } @@ -8205,12 +7782,12 @@ export final class BigUint64Array implements Iterable, ArrayLike * @param offset Optional. The offset into the target array at which to begin writing values from the source array */ public set(array: ArrayLike, offset: number = 0): void { - const insertPos = offset as int + const insertPos = offset.toInt() if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } for (let i = array.length - 1; i >= 0; --i) { - this.setUnsafeClamp(insertPos as int + i as int, array[i].getULong()) + this.setUnsafeClamp(insertPos.toInt() + i.toInt(), array[i].getULong()) } } @@ -8222,7 +7799,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns new BigUint64Array */ public static of(...items: FixedArray): BigUint64Array { - let res = new BigUint64Array(items.length as int) + let res = new BigUint64Array(items.length.toInt()) for (let i: int = 0; i < items.length; i++) { res.setUnsafeClamp(i, (new BigInt(items[i])).getULong()) } @@ -8237,9 +7814,9 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns new BigUint64Array */ public static of(...items: FixedArray): BigUint64Array { - let res = new BigUint64Array(items.length as int) + let res = new BigUint64Array(items.length.toInt()) for (let i: int = 0; i < items.length; i++) { - res.setUnsafeClamp(i, items[i] as long) + res.setUnsafeClamp(i, items[i].toLong()) } return res } @@ -8252,7 +7829,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns new BigUint64Array */ public static of(...items: FixedArray): BigUint64Array { - let res = new BigUint64Array(items.length as int) + let res = new BigUint64Array(items.length.toInt()) for (let i: int = 0; i < items.length; i++) { res.setUnsafeClamp(i, items[i]) } @@ -8267,7 +7844,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns new BigUint64Array */ public static of(...items: FixedArray): BigUint64Array { - let res = new BigUint64Array(items.length as int) + let res = new BigUint64Array(items.length.toInt()) for (let i: int = 0; i < items.length; i++) { res.setUnsafeClamp(i, items[i].getULong()) } @@ -8282,7 +7859,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns new BigUint64Array */ public static of(): BigUint64Array { - return new BigUint64Array(0 as int) + return new BigUint64Array(0) } /** @@ -8365,7 +7942,7 @@ export final class BigUint64Array implements Iterable, ArrayLike const idx : FixedArray = new int[1] idx[0] = 0 iteratorForEach(arrayLike.$_iterator(), (x: T): void => { - res.setUnsafeClamp(idx[0], (mapfn(x as T, idx[0] as number)).getULong()) + res.setUnsafeClamp(idx[0], (mapfn(x as T, idx[0].toDouble())).getULong()) idx[0] += 1 }) return res @@ -8394,7 +7971,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns true if searchElement is in BigUint64Array, false otherwise */ public includes(searchElement: long, fromIndex: int): boolean { - return this.indexOf(searchElement as int, fromIndex) != -1 + return this.indexOf(searchElement.toInt(), fromIndex) != -1 } /** @@ -8407,7 +7984,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns true if searchElement is in BigUint64Array, false otherwise */ public includes(searchElement: long): boolean { - return this.indexOf(searchElement as int, 0) != -1 + return this.indexOf(searchElement.toInt(), 0) != -1 } /** @@ -8449,7 +8026,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns index of element if it presents, -1 otherwise */ public indexOf(searchElement: int, fromIndex: int): number { - return this.indexOfImpl(searchElement as long, fromIndex) + return this.indexOfImpl(Int.toLong(searchElement), fromIndex) } /** @@ -8577,7 +8154,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ public lastIndexOf(searchElement: int, fromIndex: int): number { - return this.lastIndexOfImpl(searchElement as long, fromIndex) + return this.lastIndexOfImpl(Int.toLong(searchElement), fromIndex) } /** @@ -8648,22 +8225,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin?: number, end?: number): BigUint64Array { - return this.slice(asIntOrDefault(begin, 0 as int), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Creates a slice of current BigUint64Array using range [begin, end) - * - * @param begin start index to be taken into slice - * - * @param end last index to be taken into slice - * - * @returns a new BigUint64Array with elements of current BigUint64Array[begin;end) where end index is excluded - * - * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice - */ - public slice(begin: number, end: number): BigUint64Array { - return this.slice(begin as int, end as int) + return this.slice(asIntOrDefault(begin, 0), asIntOrDefault(end, this.lengthInt)) } /** @@ -8678,7 +8240,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin: number, end: int): BigUint64Array { - return this.slice(begin as int, end as int) + return this.slice(begin.toInt(), end.toInt()) } /** @@ -8693,7 +8255,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin: int, end: number): BigUint64Array { - return this.slice(begin as int, end as int) + return this.slice(begin.toInt(), end.toInt()) } /** @@ -8715,21 +8277,10 @@ export final class BigUint64Array implements Iterable, ArrayLike if (count < 0) { count = 0 } - let buf = this.buffer.slice(relStart * BigUint64Array.BYTES_PER_ELEMENT as int, relEnd * BigUint64Array.BYTES_PER_ELEMENT as int) as ArrayBuffer + let buf = this.buffer.slice(relStart * BigUint64Array.BYTES_PER_ELEMENT.toInt(), relEnd * BigUint64Array.BYTES_PER_ELEMENT.toInt()) as ArrayBuffer return new BigUint64Array(buf) } - /** - * Creates a slice of current BigUint64Array using range [begin, this.lengthInt). - * - * @param begin start index to be taken into slice - * - * @returns a new BigUint64Array with elements of current BigUint64Array[begin, this.lengthInt) - */ - public slice(begin: number): BigUint64Array { - return this.slice(begin as int) - } - /** * Creates a slice of current BigUint64Array using range [begin, this.lengthInt). * @@ -8767,11 +8318,16 @@ export final class BigUint64Array implements Iterable, ArrayLike arr[i] = this.getUnsafe(i) } let cmp = (l: long, r: long): number => { - const result = compareFn!(new BigInt(l), new BigInt(r)) - if (result instanceof BigInt) { - return (result as BigInt).getLong() - } else { - return result as number + return (l - r).toDouble() + } + if (compareFn != undefined) { + cmp = (l: long, r: long): number => { + const result = compareFn!(new BigInt(l), new BigInt(r)) + if (result instanceof BigInt) { + return (result as BigInt).getLong() + } else { + return result.toDouble() + } } } sort(arr, cmp) @@ -8791,20 +8347,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns new BigUint64Array with the same underlying Buffer */ public subarray(begin?: number, end?: number): BigUint64Array { - return this.subarray(asIntOrDefault(begin, 0 as int), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Creates a BigUint64Array with the same underlying Buffer - * - * @param begin start index, inclusive - * - * @param end last index, exclusive - * - * @returns new BigUint64Array with the same underlying Buffer - */ - public subarray(begin: number, end: number): BigUint64Array { - return this.subarray(begin as int, end as int) + return this.subarray(asIntOrDefault(begin, 0), asIntOrDefault(end, this.lengthInt)) } /** @@ -8817,7 +8360,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns new BigUint64Array with the same underlying Buffer */ public subarray(begin: number, end: int): BigUint64Array { - return this.subarray(begin as int, end as int) + return this.subarray(begin.toInt(), end.toInt()) } /** @@ -8830,7 +8373,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns new BigUint64Array with the same underlying Buffer */ public subarray(begin: int, end: number): BigUint64Array { - return this.subarray(begin as int, end as int) + return this.subarray(begin.toInt(), end.toInt()) } /** @@ -8850,18 +8393,7 @@ export final class BigUint64Array implements Iterable, ArrayLike if (count < 0) { count = 0 } - return new BigUint64Array(this.buffer, relStart * BigUint64Array.BYTES_PER_ELEMENT as int, count) - } - - /** - * Creates a BigUint64Array with the same Buffer - * - * @param begin start index, inclusive - * - * @returns new BigUint64Array with the same Buffer - */ - public subarray(begin: number): BigUint64Array { - return this.subarray(begin as int, this.lengthInt) + return new BigUint64Array(this.buffer, relStart * BigUint64Array.BYTES_PER_ELEMENT, count) } /** @@ -8962,7 +8494,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns an BigUint64Array with replaced value on index */ public with(index: number, value: BigInt): BigUint64Array { - return this.with(index as int, value.getULong()) + return this.with(index.toInt(), value.getULong()) } /** @@ -8994,7 +8526,7 @@ export final class BigUint64Array implements Iterable, ArrayLike */ public some(predicate: (element: BigInt, index: number, array: BigUint64Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; i++) { - if (predicate(new BigInt(this.getUnsafe(i)), i as number, this)) { + if (predicate(new BigInt(this.getUnsafe(i)), i, this)) { return true } } @@ -9019,7 +8551,7 @@ export final class BigUint64Array implements Iterable, ArrayLike initialValue: U): U { let accumulatedValue = initialValue for (let i = 0; i < this.lengthInt; i++) { - accumulatedValue = callbackfn(accumulatedValue, new BigInt(this.getUnsafe(i)), i as number, this) + accumulatedValue = callbackfn(accumulatedValue, new BigInt(this.getUnsafe(i)), i, this) } return accumulatedValue } @@ -9043,7 +8575,7 @@ export final class BigUint64Array implements Iterable, ArrayLike let accumulatedValue = new BigInt(this.$_get(0)) for (let i = 1; i < this.lengthInt; i++) { - accumulatedValue = callbackfn(accumulatedValue, new BigInt(this.getUnsafe(i)), i as number, this) + accumulatedValue = callbackfn(accumulatedValue, new BigInt(this.getUnsafe(i)), i, this) } return accumulatedValue } @@ -9066,7 +8598,7 @@ export final class BigUint64Array implements Iterable, ArrayLike initialValue: U): U { let accumulatedValue = initialValue for (let i = this.lengthInt - 1; i >= 0; i--) { - accumulatedValue = callbackfn(accumulatedValue, new BigInt(this.getUnsafe(i)), i as number, this) + accumulatedValue = callbackfn(accumulatedValue, new BigInt(this.getUnsafe(i)), i, this) } return accumulatedValue } @@ -9090,7 +8622,7 @@ export final class BigUint64Array implements Iterable, ArrayLike let accumulatedValue: BigInt = new BigInt(this.$_get(this.lengthInt - 1)) for (let i = this.lengthInt - 2; i >= 0; i--) { - accumulatedValue = callbackfn(accumulatedValue, new BigInt(this.getUnsafe(i)), i as number, this) + accumulatedValue = callbackfn(accumulatedValue, new BigInt(this.getUnsafe(i)), i, this) } return accumulatedValue } @@ -9103,10 +8635,10 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns a new BigUint64Array where for each element from current BigUint64Array fn was applied */ public map(fn: (val: BigInt, index: number, array: BigUint64Array) => BigInt): BigUint64Array { - let resBuf = new ArrayBuffer(this.lengthInt * BigUint64Array.BYTES_PER_ELEMENT as int) + let resBuf = new ArrayBuffer(this.lengthInt * BigUint64Array.BYTES_PER_ELEMENT) let res = new BigUint64Array(resBuf) for (let i = 0; i < this.lengthInt; i++) { - const fnRes = fn(new BigInt(this.getUnsafe(i)), i as number, this) + const fnRes = fn(new BigInt(this.getUnsafe(i)), i, this) res.setUnsafeClamp(i, fnRes.getULong()) } return res @@ -9124,7 +8656,7 @@ export final class BigUint64Array implements Iterable, ArrayLike */ public every(predicate: (element: BigInt, index: number, array: BigUint64Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; i++) { - if (!predicate(new BigInt(this.getUnsafe(i)), i as number, this)) { + if (!predicate(new BigInt(this.getUnsafe(i)), i, this)) { return false } } @@ -9142,7 +8674,7 @@ export final class BigUint64Array implements Iterable, ArrayLike let markers : FixedArray = new boolean[this.lengthInt] let resLen = 0 for (let i = 0; i < this.lengthInt; i++) { - markers[i] = fn(new BigInt(this.getUnsafe(i)), i as number, this) + markers[i] = fn(new BigInt(this.getUnsafe(i)), i, this) if (markers[i]) { ++resLen } @@ -9170,7 +8702,7 @@ export final class BigUint64Array implements Iterable, ArrayLike public find(predicate: (value: BigInt, index: number, array: BigUint64Array) => boolean): BigInt | undefined { for (let i = 0; i < this.lengthInt; i++) { let val = new BigInt(this.getUnsafe(i)) - if (predicate(val, i as number, this)) { + if (predicate(val, i, this)) { return val } } @@ -9189,11 +8721,11 @@ export final class BigUint64Array implements Iterable, ArrayLike */ public findIndex(predicate: (value: BigInt, index: number, obj: BigUint64Array) => boolean): number { for (let i = 0; i < this.lengthInt; i++) { - if (predicate(new BigInt(this.getUnsafe(i)), i as number, this)) { - return i as number + if (predicate(new BigInt(this.getUnsafe(i)), i, this)) { + return i } } - return -1 as number + return -1 } /** @@ -9206,7 +8738,7 @@ export final class BigUint64Array implements Iterable, ArrayLike public findLast(fn: (val: BigInt, index: number, array: BigUint64Array) => boolean): BigInt { for (let i = this.lengthInt - 1; i >= 0; i--) { let val = new BigInt(this.getUnsafe(i)) - if (fn(val, i as number, this)) { + if (fn(val, i, this)) { return val } } @@ -9222,11 +8754,11 @@ export final class BigUint64Array implements Iterable, ArrayLike */ public findLastIndex(fn: (val: BigInt, index: number, array: BigUint64Array) => boolean): number { for (let i = this.lengthInt - 1; i >= 0; i--) { - if (fn(new BigInt(this.getUnsafe(i)), i as number, this)) { - return i as number + if (fn(new BigInt(this.getUnsafe(i)), i, this)) { + return i } } - return -1 as number + return -1 } /** @@ -9239,7 +8771,7 @@ export final class BigUint64Array implements Iterable, ArrayLike */ public forEach(callbackfn: (value: BigInt, index: number, array: BigUint64Array) => void): void { for (let i = 0; i < this.lengthInt; i++) { - callbackfn(new BigInt(this.getUnsafe(i)), i as number, this) + callbackfn(new BigInt(this.getUnsafe(i)), i.toDouble(), this) } } @@ -9279,17 +8811,17 @@ export final class BigUint64Array implements Iterable, ArrayLike } internal getUnsafe(index: int): long { - index = index * BigUint64Array.BYTES_PER_ELEMENT as int + this.byteOffsetInt + index = index * BigUint64Array.BYTES_PER_ELEMENT + this.byteOffsetInt let res: long = 0 if (IS_LITTLE_ENDIAN) { - for (let i = 0; i < BigUint64Array.BYTES_PER_ELEMENT as int; i++) { - let el = this.buffer.at(index + i) as long + for (let i = 0; i < BigUint64Array.BYTES_PER_ELEMENT.toInt(); i++) { + let el = this.buffer.at(index + i).toLong() el &= 0xff res |= el << (8 * i) } } else { - for (let i = 0; i < BigUint64Array.BYTES_PER_ELEMENT as int; i++) { - let el = this.buffer.at(index + 7 - i) as long + for (let i = 0; i < BigUint64Array.BYTES_PER_ELEMENT.toInt(); i++) { + let el = this.buffer.at(index + 7 - i).toLong() el &= 0xff res |= el << (8 * i) } @@ -9298,16 +8830,16 @@ export final class BigUint64Array implements Iterable, ArrayLike } internal setUnsafe(index: int, val: long): void { - index = index * BigUint64Array.BYTES_PER_ELEMENT as int + this.byteOffsetInt + index = index * BigUint64Array.BYTES_PER_ELEMENT + this.byteOffsetInt let res: long = 0 if (IS_LITTLE_ENDIAN) { - for (let i = 0; i < BigUint64Array.BYTES_PER_ELEMENT as int; i++) { - this.buffer.set(index + i, (val & 0xff) as byte) + for (let i = 0; i < BigUint64Array.BYTES_PER_ELEMENT.toInt(); i++) { + this.buffer.set(index + i, (val & 0xff).toByte()) val = val >> 8 } } else { - for (let i = 0; i < BigUint64Array.BYTES_PER_ELEMENT as int; i++) { - this.buffer.set(index + 7 - i, (val & 0xff) as byte) + for (let i = 0; i < BigUint64Array.BYTES_PER_ELEMENT.toInt(); i++) { + this.buffer.set(index + 7 - i, (val & 0xff).toByte()) val = val >> 8 } } diff --git a/static_core/plugins/ets/stdlib/escompat/WeakMap.ets b/static_core/plugins/ets/stdlib/escompat/WeakMap.ets index 66a0786af2aedd458952fb7bc97db0028669d0a2..25be82707bf81c3434abb7e31fe68f4a83204e48 100644 --- a/static_core/plugins/ets/stdlib/escompat/WeakMap.ets +++ b/static_core/plugins/ets/stdlib/escompat/WeakMap.ets @@ -51,7 +51,7 @@ export final class WeakMap { if (entries != null) { for (const entry of entries) { - this.set(entry[WeakMap.KEY], entry[WeakMap.VAL]) + this.set(entry[0] as K, entry[1] as V) } } } @@ -63,7 +63,7 @@ export final class WeakMap { this(null) iteratorForEach<[K, V]>(entries.$_iterator(), (entry: [K, V]) => { - this.set(entry[WeakMap.KEY], entry[WeakMap.VAL]) + this.set(entry[0] as K, entry[1] as V) }) } diff --git a/static_core/plugins/ets/stdlib/escompat/_initializerBlock_.ets b/static_core/plugins/ets/stdlib/escompat/_initializerBlock_.ets index 298a87ad76777b8445c20b5bfc7cb7e22e985fb2..7b1ded4b077de37a3d6a5a93019fdf570ba69551 100644 --- a/static_core/plugins/ets/stdlib/escompat/_initializerBlock_.ets +++ b/static_core/plugins/ets/stdlib/escompat/_initializerBlock_.ets @@ -48,4 +48,7 @@ static { firstDayInMonthNormal = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]; firstDayInMonthLeap = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335]; + + maxDateOffset = 8.64e15.toLong(); + INVALID_DATE = maxDateOffset + 1; } diff --git a/static_core/plugins/ets/stdlib/escompat/deepcopy.ets b/static_core/plugins/ets/stdlib/escompat/deepcopy.ets index 48f514b21e095bf2cb1280b596439328449e649d..3954a835fa007d33bab6eaacac9868969458bb07 100644 --- a/static_core/plugins/ets/stdlib/escompat/deepcopy.ets +++ b/static_core/plugins/ets/stdlib/escompat/deepcopy.ets @@ -114,9 +114,9 @@ class DeepCloner { const fieldName = objEntry![DeepCloner.OBJ_ENTRY_NAME] const field = objType.getFieldByName(fieldName as String) - const objFieldValueCopy = this.clone(objEntry![DeepCloner.OBJ_ENTRY_VALUE]) + const objFieldValueCopy = this.clone(objEntry![1]) if (field.getType().assignableFrom(Type.of(objFieldValueCopy))) { - objCopyValue.setFieldByName(fieldName as String, Value.of(objFieldValueCopy)) + objCopyValue.setFieldByName(fieldName as string, Value.of(objFieldValueCopy) as Value) } } @@ -132,7 +132,7 @@ class DeepCloner { } const arrayValue = Value.of(array) as ArrayValue - const arrayLength: int = arrayValue.getLength() as int + const arrayLength: int = Double.toInt(arrayValue.getLength()) const arrayCopy = arrayType.make(arrayLength) this.copies.set(array, arrayCopy) @@ -208,4 +208,4 @@ class DeepCloner { return mapCopy } -} \ No newline at end of file +} diff --git a/static_core/plugins/ets/stdlib/escompat/json.ets b/static_core/plugins/ets/stdlib/escompat/json.ets index 1afae73d28b22f0d75089ba2495e2d52cb21be46..463e16a441f792730ff65e9e020d5d00dab2b599 100644 --- a/static_core/plugins/ets/stdlib/escompat/json.ets +++ b/static_core/plugins/ets/stdlib/escompat/json.ets @@ -141,7 +141,7 @@ export class JSON { * @returns String - JSON representation of byte */ public static stringify(d: String): String { - let sb = new StringBuilder([c'\"']) + let sb = new StringBuilder([c'\"'] as FixedArray) let len = d.getLength() let prevChar: char = 0 @@ -279,7 +279,7 @@ export class JSON { if (space > JSON.JSON_SPACE_INDENT_LIMIT) { spacesCount = JSON.JSON_SPACE_INDENT_LIMIT } else { - spacesCount = space as int + spacesCount = Double.toInt(space) } } @@ -563,7 +563,7 @@ export class JSON { } let jsonValue = JSONParser.parse(text) - const parsingResult = new JSONValueParser(reviver, bigIntMode).parse(jsonValue, type) as T + const parsingResult = new JSONValueParser(reviver, bigIntMode as int).parse(jsonValue, type) as T if (reviver !== undefined) { return reviver("", parsingResult) as T @@ -895,8 +895,8 @@ class JSONWriter { for (let fieldIdx = 0; fieldIdx < writableFields.length; fieldIdx++) { const fieldTypeValuePair = writableFields[fieldIdx] - const objField = fieldTypeValuePair[FIELD_TYPE] - const objFieldValue = fieldTypeValuePair[FIELD_VALUE] + const objField = fieldTypeValuePair[0] as Field + const objFieldValue = fieldTypeValuePair[1] as Value const objToDump = this.useReplacer ? this.replacer!(objField.getName(), objFieldValue.getData()) : objFieldValue.getData() fieldDumped = this.writeField(objField.getName(), objToDump, fieldDumped) @@ -961,7 +961,7 @@ class JSONWriter { this.indentLevel += 1 } - const arrayLength = arrayValue.getLength() as int + const arrayLength = Long.toInt(arrayValue.getLength()) if (arrayLength > 0) { const array: Object = arrayValue.getData()! @@ -1041,7 +1041,7 @@ class JSONWriter { if (array.length > 0) { this.path.add(array) - const lastElementIndex = (array.length as int) - 1 + const lastElementIndex = Double.toInt(array.length) for (let idx = 0; idx < lastElementIndex; idx++) { this.writeObjectsArrayElement(array[idx], idx) @@ -1448,7 +1448,7 @@ class JSONValueParser { private parseArray(jVal: JSONArray, aType: ArrayType): Object | null { let len = jVal.values.length - let arr = aType.make(len as int) as FixedArray + let arr = aType.make(Double.toInt(len)) as FixedArray let setArrayElementFn = (a: FixedArray, i: int, v: NullishType) => { a[i] = v } @@ -1494,7 +1494,7 @@ export class JSONObject extends JSONValue { } public override toString(): String { - let res = new StringBuilder([JSONObject.START_CHAR]) + let res = new StringBuilder([JSONObject.START_CHAR] as FixedArray) for (let i = 0; i < this.keys_.length - 1; ++i) { res.append("" + this.keys_.at(i) + JSONObject.SEPARATOR + this.values.at(i) + JSONObject.DELIMETER) } @@ -1513,7 +1513,7 @@ export class JSONArray extends JSONValue { readonly static SEPARATOR = c',' public override toString(): String { - let res = new StringBuilder([JSONArray.START_CHAR]) + let res = new StringBuilder([JSONArray.START_CHAR] as FixedArray) for (let i = 0; i < this.values.length - 1; ++i) { res.append("" + this.values.at(i) + JSONArray.SEPARATOR) } diff --git a/static_core/plugins/ets/stdlib/escompat/taskpool.ets b/static_core/plugins/ets/stdlib/escompat/taskpool.ets index 0580907128ace01a7ee0627e777afc11fd8d4119..e9c2c1e5e01ab5f723f640bbfbe48433fb4ce3ca 100644 --- a/static_core/plugins/ets/stdlib/escompat/taskpool.ets +++ b/static_core/plugins/ets/stdlib/escompat/taskpool.ets @@ -150,7 +150,7 @@ export namespace taskpool { /** * Register a callback and call it when the task is enqueued - * + * * @param callback Callback to be registered and executed when the task is enqueued * @throws Error if task is executed. It does not support the registration of listeners */ @@ -161,7 +161,7 @@ export namespace taskpool { /** * Register a callback and call it before the task execution - * + * * @param callback Callback to be registered and executed before the task execution * @throws Error if task is executed. It does not support the registration of listeners */ @@ -172,7 +172,7 @@ export namespace taskpool { /** * Register a callback and call it when the task fails to execute - * + * * @param callback Callback to be registered and executed when the task fails to execute * @throws Error if task is executed. It does not support the registration of listeners */ @@ -183,7 +183,7 @@ export namespace taskpool { /** * Register a callback and call it when the task successfully executed - * + * * @param callback Callback to be registered and executed when the task successfully executed * @throws Error if task is executed. It does not support the registration of listeners */ @@ -239,7 +239,7 @@ export namespace taskpool { * - no parameters * - this task or argument tasks executed * - this task or argument tasks have not dependencies - * - this task does not depend on an argument task + * - this task does not depend on an argument task */ removeDependency(...tasks: Task[]): void { if (tasks.length == 0) { @@ -247,7 +247,7 @@ export namespace taskpool { } if (!this.isDependent) { throw new Error("taskpool:: task has no dependency"); - } + } if (this.isSubmitted) { throw new Error("taskpool:: executedTask cannot removeDependency"); } @@ -297,7 +297,7 @@ export namespace taskpool { } /** - * Register a callback for this task to receive and handle data from the taskpool task + * Register a callback for this task to receive and handle data from the taskpool task */ onReceiveData(callback?: Function): void { this.onReceiveCallback = callback; @@ -325,7 +325,7 @@ export namespace taskpool { /** * Check that the task can be executed as common task - * @throws Error if the task can not be executed as common task + * @throws Error if the task can not be executed as common task * @see taskpool.execute */ internal checkExecution(): void { @@ -695,7 +695,7 @@ export namespace taskpool { /** * Generate unique identifier for the group * @see TaskGroup.constructor - * @return unique group identifier for a new Taskgroup instance + * @return unique group identifier for a new Taskgroup instance */ private static native generateGroupId(): long; @@ -747,8 +747,9 @@ export namespace taskpool { const taskRunner = (value: NullishType): NullishType => { return task.execute(); }; - this.impl.seqPromise = task.getOnReceivePromise(this.impl.seqPromise.then(taskRunner, (error: Error) : void => { + this.impl.seqPromise = task.getOnReceivePromise(this.impl.seqPromise.then(taskRunner, (error) => { taskRunner(undefined); + return new Promise((resolve, reject) => {}); } )); return this.impl.seqPromise; } @@ -865,7 +866,7 @@ export namespace taskpool { /** * Execute a concurrent task - * + * * @param task The task for executing * @returns Promise for result of executed task */ @@ -897,7 +898,7 @@ export namespace taskpool { if (group.isTaskAlreadySubmitted) { throw new Error("taskpool:: groupTask has been executed"); } - let tasksCount = group.tasks.length as int; + const tasksCount = Double.toInt(group.tasks.length); if (tasksCount == 0) { return Promise.resolve>(new Array()); } @@ -1028,7 +1029,7 @@ export namespace taskpool { * Terminate a long task. * * @param longTask The long task for terminating - * @note This method is needed for compatibilty with OHOS API. For coroutines in static ArkTS it is not required + * @note This method is needed for compatibilty with OHOS API. For coroutines in static ArkTS it is not required */ export function terminateTask(longTask: LongTask): void {} @@ -1070,7 +1071,7 @@ export namespace taskpool { threadInfo.priority = worker!.currentPriority; let tasks = workerToTasks.get(worker.workerId); if (tasks != undefined) { - let tasksCount : int = tasks.size as int; + let tasksCount : int = Double.toInt(tasks.size); const taskIds: number[] = new number[tasksCount]; let currentIndex: int = 0; tasks.forEach((task: Task) => { @@ -1085,7 +1086,7 @@ export namespace taskpool { workerToTasks.forEach((tasks: Set, workerId: int) => { const threadInfo: ThreadInfo = new ThreadInfo(); threadInfo.tid = workerId; - const tasksCount: int = tasks.size as int; + const tasksCount: int = Double.toInt(tasks.size); if (tasksCount == 0) { threadInfos.push(threadInfo); return; @@ -1107,13 +1108,13 @@ export namespace taskpool { } ConcurrencyHelpers.mutexUnlock(mutex); const Info: TaskPoolInfo = new TaskPoolInfo(); - const taskInfosRes: TaskInfo[] = new TaskInfo[taskInfos.length as int]; - const threadInfosRes: ThreadInfo[] = new ThreadInfo[threadInfos.length as int]; + const taskInfosRes: TaskInfo[] = new TaskInfo[Double.toInt(taskInfos.length)]; + const threadInfosRes: ThreadInfo[] = new ThreadInfo[Double.toInt(threadInfos.length)]; taskInfos.forEach((taskInfo: TaskInfo, index: number) => { - taskInfosRes[index as int] = taskInfo; + taskInfosRes[Double.toInt(index)] = taskInfo; }); threadInfos.forEach((threadInfo: ThreadInfo, index: number) => { - threadInfosRes[index as int] = threadInfo; + threadInfosRes[Double.toInt(index)] = threadInfo; }); Info.taskInfos = taskInfosRes; Info.threadInfos = threadInfosRes; @@ -1139,7 +1140,7 @@ export namespace taskpool { * @brief Submit group of tasks to the taskpool on the execute method * @see taskpool.execute * @param groupId identifier of the submitted group - * @param tasksCount count of tasks in the passed group + * @param tasksCount count of tasks in the passed group */ function taskGroupSubmitted(groupId: long, tasksCount: int): void { ConcurrencyHelpers.mutexLock(mutex); @@ -1402,7 +1403,7 @@ export namespace taskpool { function getTaskImpl(tasksQueue: Array): Task | undefined { let task: Task | undefined = undefined; - let len = tasksQueue.length as int; + let len = Double.toInt(tasksQueue.length); for (let i = 0; i < len; ++i) { task = tasksQueue.shift(); if (task?.taskDependenciesCount == 0) { diff --git a/static_core/plugins/ets/stdlib/std/concurrency/AsyncLockManager.ets b/static_core/plugins/ets/stdlib/std/concurrency/AsyncLockManager.ets index b88a5fdf5f756af19a17af92e1b64997dc561f4f..cf86241bb1758002c04f84dc0b41e18df97655e8 100644 --- a/static_core/plugins/ets/stdlib/std/concurrency/AsyncLockManager.ets +++ b/static_core/plugins/ets/stdlib/std/concurrency/AsyncLockManager.ets @@ -69,7 +69,7 @@ class AsyncLockManager { */ public queryAll(): AsyncLockState[] { ConcurrencyHelpers.mutexLock(this.mutex); - let result = new AsyncLockState[this.locks.size as int]; // Statement "as int" to be removed after fixing issue 19773. + let result = new AsyncLockState[Double.toInt(this.locks.size)]; // Statement "as int" to be removed after fixing issue 19773. let idx = 0; this.locks.forEach((val: AsyncLock, key: string): void => { result[idx++] = val.query(); @@ -100,7 +100,7 @@ export class AsyncLockState { } private toArray(set: Set) : AsyncLockInfo[] { - let array = new AsyncLockInfo[set.size as int]; // Statement "as int" to be removed after fixing issue 19773. + let array = new AsyncLockInfo[Double.toInt(set.size)]; // Statement "as int" to be removed after fixing issue 19773. let idx = 0; set.forEach((val: AsyncLockInfo): void => { array[idx++] = val; diff --git a/static_core/plugins/ets/stdlib/std/containers/ConcurrentHashMap.ets b/static_core/plugins/ets/stdlib/std/containers/ConcurrentHashMap.ets index 53aece13de7c9e28d51fa036d64ae85a5c497457..873ca6916a99e59d678832b77c54e704cb316a59 100644 --- a/static_core/plugins/ets/stdlib/std/containers/ConcurrentHashMap.ets +++ b/static_core/plugins/ets/stdlib/std/containers/ConcurrentHashMap.ets @@ -274,7 +274,7 @@ export class ConcurrentHashMap implements ReadonlyMap { * @param entries initial ArrayLike */ constructor(entries: ArrayLike<[K, V]>) { - const bucketsCount = this.getInitialBucketsCount(entries.length as Int); + const bucketsCount = this.getInitialBucketsCount(Double.toInt(entries.length)); this.buckets = new ConcurrentHashMapBucket < K, V > [bucketsCount]; this.bucketMutex = new (Object | undefined)[bucketsCount]; for (let i = 0; i < entries.length; ++i) { @@ -309,7 +309,7 @@ export class ConcurrentHashMap implements ReadonlyMap { * @param map another map */ constructor(map: Map) { - const bucketsCount = this.getInitialBucketsCount(map.size as int); + const bucketsCount = this.getInitialBucketsCount(Double.toInt(map.size)); this.buckets = new ConcurrentHashMapBucket[bucketsCount]; this.bucketMutex = new (Object | undefined)[bucketsCount]; diff --git a/static_core/plugins/ets/stdlib/std/core/Boolean.ets b/static_core/plugins/ets/stdlib/std/core/Boolean.ets index 19539571a8d1c00cd468df1e5490eca18ee49aa3..e56f3e8b580e209920c8f9428bde8d38070e1986 100644 --- a/static_core/plugins/ets/stdlib/std/core/Boolean.ets +++ b/static_core/plugins/ets/stdlib/std/core/Boolean.ets @@ -186,6 +186,26 @@ export final class Boolean extends Object implements Comparable { */ public static readonly FALSE = new Boolean(false); + /** + * Returns the primitive as boolean value + * + * @param value value to cast + * + * @returns casted value + */ + public static toBoolean(value: boolean): boolean { + return value; + } + + /** + * Returns value of this instance + * + * @returns value as boolean + */ + public toBoolean(): boolean { + return this.value; + } + /** * Static method that converts primitive boolean to boxed version * diff --git a/static_core/plugins/ets/stdlib/std/core/Box.ets b/static_core/plugins/ets/stdlib/std/core/Box.ets index 6328eac2f5f542ef255570bda6735d5da2aa8a2c..7ae9dd8e31f904ddf1a901912d17ddaab13d5219 100644 --- a/static_core/plugins/ets/stdlib/std/core/Box.ets +++ b/static_core/plugins/ets/stdlib/std/core/Box.ets @@ -281,7 +281,7 @@ export class FloatBox { private value: float; public constructor() { - this.value = 0.0; + this.value = 0.0f; } public constructor(value: float) { diff --git a/static_core/plugins/ets/stdlib/std/core/BuiltinArray.ets b/static_core/plugins/ets/stdlib/std/core/BuiltinArray.ets index 0a030ae9777701b01abc38ff2733f323de62449d..c5ea2a67a6bf9cd564331a728e61e27064959ab5 100644 --- a/static_core/plugins/ets/stdlib/std/core/BuiltinArray.ets +++ b/static_core/plugins/ets/stdlib/std/core/BuiltinArray.ets @@ -21,7 +21,7 @@ function asIntOrDefault(n: Number | undefined, def: int): int { if (n === undefined) { return def } - return (n! as Object as Number) as number as int; + return Double.toInt(n!); } function normalizeIndex(idx: int, len: int): int { @@ -60,7 +60,7 @@ class BuiltinArrayKeysIterator implements IterableIterator { this.isDone = true return new IteratorResult() } - return new IteratorResult(this.idx++ as number) + return new IteratorResult(Int.toDouble(this.idx++)) } override $_iterator(): IterableIterator { @@ -88,7 +88,7 @@ function cloneArray(self: FixedArray): FixedArray { * Returns undefined if `index` < `-length()` or `index` >= `length()`. */ export function at(self: FixedArray, index: number): Boolean | undefined { - return at(self, index as int) + return at(self, Double.toInt(index)) } /** @@ -105,7 +105,7 @@ export function at(self: FixedArray, index: number): Boolean | undefine export function concat(self: FixedArray, ...items: FixedArray>): FixedArray { let totalAdd = self.length; for (let i = 0; i < items.length; i++) { - totalAdd += items[i].length as int + totalAdd += Double.toInt(items[i].length) } const buf : FixedArray = new boolean[totalAdd]; @@ -117,7 +117,7 @@ export function concat(self: FixedArray, ...items: FixedArray, index: int): Boolean | undefined { * @returns this array after transformation */ export function copyWithin(self: FixedArray, target: number, start: number, end?: Number): FixedArray { - copyWithin(self, target as int, start as int, asIntOrDefault(end, self.length)); + copyWithin(self, Double.toInt(target), Double.toInt(start), asIntOrDefault(end, self.length)); return self; } @@ -287,7 +287,7 @@ export function find(self: FixedArray, predicate: (value: boolean, inde if (res == -1) { return undefined } - return self[res as int]; + return self[Double.toInt(res)]; } /** @@ -302,7 +302,7 @@ export function find(self: FixedArray, predicate: (value: boolean, inde */ export function findIndex(self: FixedArray, predicate: (value: boolean, index: number, array: FixedArray) => boolean): number { for (let i = 0; i < self.length; i++) { - if (predicate(self[i], i as number, self)) { + if (predicate(self[i], Int.toDouble(i), self)) { return i; } } @@ -320,7 +320,7 @@ export function findIndex(self: FixedArray, predicate: (value: boolean, export function findLast(self: FixedArray, predicate: (elem: boolean, index: number, array: FixedArray) => boolean): Boolean | undefined { for (let i = self.length - 1; i >= 0; i--) { const val = self[i]; - if (predicate(val, i as number, self)) { + if (predicate(val, Int.toDouble(i), self)) { return val; } } @@ -338,7 +338,7 @@ export function findLast(self: FixedArray, predicate: (elem: boolean, i */ export function every(self: FixedArray, predicate: (value: boolean, index: number, array: FixedArray) => boolean): boolean { for (let i = 0; i < self.length; i++) { - if (!predicate(self[i], i as number, self)) { + if (!predicate(self[i], Int.toDouble(i), self)) { return false } } @@ -356,7 +356,7 @@ export function every(self: FixedArray, predicate: (value: boolean, ind */ export function some(self: FixedArray, predicate: (value: boolean, index: number, array: FixedArray) => boolean): boolean { for (let i = 0; i < self.length; i++) { - if (predicate(self[i], i as number, self)) { + if (predicate(self[i], Int.toDouble(i), self)) { return true } } @@ -374,7 +374,7 @@ export function some(self: FixedArray, predicate: (value: boolean, inde */ export function findLastIndex(self: FixedArray, predicate: (element: boolean, index: number, array: FixedArray) => boolean): number { for (let i = self.length - 1; i >= 0; i--) { - if (predicate(self[i], i as number, self)) { + if (predicate(self[i], Int.toDouble(i), self)) { return i } } @@ -394,7 +394,7 @@ export function reduce(self: FixedArray, callbackfn: (previousValue: bo } let acc: boolean = self[0]; for (let i = 1; i < self.length; i++) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -411,7 +411,7 @@ export function reduce(self: FixedArray, callbackfn: (previousValue: bo export function reduce(self: FixedArray, callbackfn: (previousValue: U, currentValue: boolean, index: number, array: FixedArray) => U, initialValue: U): U { let acc = initialValue for (let i = 0; i < self.length; i++) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -428,7 +428,7 @@ export function reduce(self: FixedArray, callbackfn: (prev export function reduceRight(self: FixedArray, callbackfn: (previousValue: U, currentValue: boolean, index: number, array: FixedArray) => U, initialValue: U): U { let acc = initialValue for (let i = self.length - 1; i >= 0; i--) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -441,7 +441,7 @@ export function reduceRight(self: FixedArray, callbackfn: (previousV export function forEach(self: FixedArray, callbackfn: (value: boolean, index: number, array: FixedArray) => void): void { const len0 = self.length; for (let i = 0; i < len0; i++) { - callbackfn(self[i], i as number, self) + callbackfn(self[i], Int.toDouble(i), self) } } @@ -496,7 +496,7 @@ export function slice(self: FixedArray, start: int, end: int): FixedArr * @returns `Array` instance, constructed from extracted elements of `this` instance. */ export function slice(self: FixedArray, start: int): FixedArray { - return slice(self, start, Int.MAX_VALUE as int); + return slice(self, start, Int.MAX_VALUE); } /** @@ -650,7 +650,7 @@ export function toSpliced(self: FixedArray, start?: Number, delete?: Nu */ export function toSpliced(self: FixedArray, start: number, delete: number, ...items: FixedArray): FixedArray { const len = self.length; - return toSpliced(self, start as int, delete as int, ...items) + return toSpliced(self, Double.toInt(start), Double.toInt(delete), ...items) } /** @@ -820,7 +820,7 @@ export function toReversed(self: FixedArray): FixedArray { * @returns a new Array with the element at the given index replaced with the given value */ export function with(self: FixedArray, index: number, value: boolean): FixedArray { - return with(self, index as int, value) + return with(self, Double.toInt(index), value) } /** @@ -870,7 +870,7 @@ export function map(self: FixedArray, callbackfn: (value: boolean, inde const len = self.length; let res : FixedArray = new boolean[len]; for (let i = 0; i < len; i++) { - res[i] = callbackfn(self[i], i as number, self); + res[i] = callbackfn(self[i], Int.toDouble(i), self); } return res; } @@ -888,7 +888,7 @@ export function reduceRight(self: FixedArray, callbackfn: (previousValu } let acc: boolean = self[self.length - 1]; for (let i = self.length - 2; i >= 0; i--) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -996,7 +996,7 @@ class ArrayValuesIterator_boolean implements IterableIterator { } public __Iterator_getLength(): int { - return this.parent.length as int + return Double.toInt(this.parent.length) } } @@ -1015,7 +1015,7 @@ class ArrayEntriesIterator_boolean implements IterableIterator<[number, boolean] return new IteratorResult<[number, boolean]>() } const i = this.idx++; - const vl: [number, boolean] = [i as number, this.parent[i]] + const vl: [number, boolean] = [Int.toDouble(i), this.parent[i]] return new IteratorResult<[number, boolean]>(vl); } @@ -1024,7 +1024,7 @@ class ArrayEntriesIterator_boolean implements IterableIterator<[number, boolean] } public __Iterator_getLength(): int { - return this.parent.length as int + return Double.toInt(this.parent.length) } } @@ -1048,7 +1048,7 @@ function cloneArray(self: FixedArray): FixedArray { * Returns undefined if `index` < `-length()` or `index` >= `length()`. */ export function at(self: FixedArray, index: number): Byte | undefined { - return at(self, index as int) + return at(self, Double.toInt(index)) } /** @@ -1065,7 +1065,7 @@ export function at(self: FixedArray, index: number): Byte | undefined { export function concat(self: FixedArray, ...items: FixedArray>): FixedArray { let totalAdd = self.length; for (let i = 0; i < items.length; i++) { - totalAdd += items[i].length as int + totalAdd += Double.toInt(items[i].length) } const buf : FixedArray = new byte[totalAdd]; @@ -1077,7 +1077,7 @@ export function concat(self: FixedArray, ...items: FixedArray, index: int): Byte | undefined { * @returns this array after transformation */ export function copyWithin(self: FixedArray, target: number, start: number, end?: Number): FixedArray { - copyWithin(self, target as int, start as int, asIntOrDefault(end, self.length)); + copyWithin(self, Double.toInt(target), Double.toInt(start), asIntOrDefault(end, self.length)); return self; } @@ -1247,7 +1247,7 @@ export function find(self: FixedArray, predicate: (value: byte, index: num if (res == -1) { return undefined } - return self[res as int]; + return self[Double.toInt(res)]; } /** @@ -1262,7 +1262,7 @@ export function find(self: FixedArray, predicate: (value: byte, index: num */ export function findIndex(self: FixedArray, predicate: (value: byte, index: number, array: FixedArray) => boolean): number { for (let i = 0; i < self.length; i++) { - if (predicate(self[i], i as number, self)) { + if (predicate(self[i], Int.toDouble(i), self)) { return i; } } @@ -1280,7 +1280,7 @@ export function findIndex(self: FixedArray, predicate: (value: byte, index export function findLast(self: FixedArray, predicate: (elem: byte, index: number, array: FixedArray) => boolean): Byte | undefined { for (let i = self.length - 1; i >= 0; i--) { const val = self[i]; - if (predicate(val, i as number, self)) { + if (predicate(val, Int.toDouble(i), self)) { return val; } } @@ -1298,7 +1298,7 @@ export function findLast(self: FixedArray, predicate: (elem: byte, index: */ export function every(self: FixedArray, predicate: (value: byte, index: number, array: FixedArray) => boolean): boolean { for (let i = 0; i < self.length; i++) { - if (!predicate(self[i], i as number, self)) { + if (!predicate(self[i], Int.toDouble(i), self)) { return false } } @@ -1316,7 +1316,7 @@ export function every(self: FixedArray, predicate: (value: byte, index: nu */ export function some(self: FixedArray, predicate: (value: byte, index: number, array: FixedArray) => boolean): boolean { for (let i = 0; i < self.length; i++) { - if (predicate(self[i], i as number, self)) { + if (predicate(self[i], Int.toDouble(i), self)) { return true } } @@ -1334,7 +1334,7 @@ export function some(self: FixedArray, predicate: (value: byte, index: num */ export function findLastIndex(self: FixedArray, predicate: (element: byte, index: number, array: FixedArray) => boolean): number { for (let i = self.length - 1; i >= 0; i--) { - if (predicate(self[i], i as number, self)) { + if (predicate(self[i], Int.toDouble(i), self)) { return i } } @@ -1354,7 +1354,7 @@ export function reduce(self: FixedArray, callbackfn: (previousValue: byte, } let acc: byte = self[0]; for (let i = 1; i < self.length; i++) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -1371,7 +1371,7 @@ export function reduce(self: FixedArray, callbackfn: (previousValue: byte, export function reduce(self: FixedArray, callbackfn: (previousValue: U, currentValue: byte, index: number, array: FixedArray) => U, initialValue: U): U { let acc = initialValue for (let i = 0; i < self.length; i++) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -1388,7 +1388,7 @@ export function reduce(self: FixedArray, callbackfn: (previousVa export function reduceRight(self: FixedArray, callbackfn: (previousValue: U, currentValue: byte, index: number, array: FixedArray) => U, initialValue: U): U { let acc = initialValue for (let i = self.length - 1; i >= 0; i--) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -1401,7 +1401,7 @@ export function reduceRight(self: FixedArray, callbackfn: (previousValu export function forEach(self: FixedArray, callbackfn: (value: byte, index: number, array: FixedArray) => void): void { const len0 = self.length; for (let i = 0; i < len0; i++) { - callbackfn(self[i], i as number, self) + callbackfn(self[i], Int.toDouble(i), self) } } @@ -1456,7 +1456,7 @@ export function slice(self: FixedArray, start: int, end: int): FixedArray< * @returns `Array` instance, constructed from extracted elements of `this` instance. */ export function slice(self: FixedArray, start: int): FixedArray { - return slice(self, start, Int.MAX_VALUE as int); + return slice(self, start, Int.MAX_VALUE); } /** @@ -1610,7 +1610,7 @@ export function toSpliced(self: FixedArray, start?: Number, delete?: Numbe */ export function toSpliced(self: FixedArray, start: number, delete: number, ...items: FixedArray): FixedArray { const len = self.length; - return toSpliced(self, start as int, delete as int, ...items) + return toSpliced(self, Double.toInt(start), Double.toInt(delete), ...items) } /** @@ -1780,7 +1780,7 @@ export function toReversed(self: FixedArray): FixedArray { * @returns a new Array with the element at the given index replaced with the given value */ export function with(self: FixedArray, index: number, value: byte): FixedArray { - return with(self, index as int, value) + return with(self, Double.toInt(index), value) } /** @@ -1830,7 +1830,7 @@ export function map(self: FixedArray, callbackfn: (value: byte, index: num const len = self.length; let res : FixedArray = new byte[len]; for (let i = 0; i < len; i++) { - res[i] = callbackfn(self[i], i as number, self); + res[i] = callbackfn(self[i], Int.toDouble(i), self); } return res; } @@ -1848,7 +1848,7 @@ export function reduceRight(self: FixedArray, callbackfn: (previousValue: } let acc: byte = self[self.length - 1]; for (let i = self.length - 2; i >= 0; i--) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -1956,7 +1956,7 @@ class ArrayValuesIterator_byte implements IterableIterator { } public __Iterator_getLength(): int { - return this.parent.length as int + return Double.toInt(this.parent.length) } } @@ -1975,7 +1975,7 @@ class ArrayEntriesIterator_byte implements IterableIterator<[number, byte]> { return new IteratorResult<[number, byte]>() } const i = this.idx++; - const vl: [number, byte] = [i as number, this.parent[i]] + const vl: [number, byte] = [Int.toDouble(i), this.parent[i]] return new IteratorResult<[number, byte]>(vl); } @@ -1984,7 +1984,7 @@ class ArrayEntriesIterator_byte implements IterableIterator<[number, byte]> { } public __Iterator_getLength(): int { - return this.parent.length as int + return Double.toInt(this.parent.length) } } @@ -2008,7 +2008,7 @@ function cloneArray(self: FixedArray): FixedArray { * Returns undefined if `index` < `-length()` or `index` >= `length()`. */ export function at(self: FixedArray, index: number): Short | undefined { - return at(self, index as int) + return at(self, Double.toInt(index)) } /** @@ -2025,7 +2025,7 @@ export function at(self: FixedArray, index: number): Short | undefined { export function concat(self: FixedArray, ...items: FixedArray>): FixedArray { let totalAdd = self.length; for (let i = 0; i < items.length; i++) { - totalAdd += items[i].length as int + totalAdd += Double.toInt(items[i].length) } const buf : FixedArray = new short[totalAdd]; @@ -2037,7 +2037,7 @@ export function concat(self: FixedArray, ...items: FixedArray, index: int): Short | undefined { * @returns this array after transformation */ export function copyWithin(self: FixedArray, target: number, start: number, end?: Number): FixedArray { - copyWithin(self, target as int, start as int, asIntOrDefault(end, self.length)); + copyWithin(self, Double.toInt(target), Double.toInt(start), asIntOrDefault(end, self.length)); return self; } @@ -2207,7 +2207,7 @@ export function find(self: FixedArray, predicate: (value: short, index: n if (res == -1) { return undefined } - return self[res as int]; + return self[Double.toInt(res)]; } /** @@ -2222,7 +2222,7 @@ export function find(self: FixedArray, predicate: (value: short, index: n */ export function findIndex(self: FixedArray, predicate: (value: short, index: number, array: FixedArray) => boolean): number { for (let i = 0; i < self.length; i++) { - if (predicate(self[i], i as number, self)) { + if (predicate(self[i], Int.toDouble(i), self)) { return i; } } @@ -2240,7 +2240,7 @@ export function findIndex(self: FixedArray, predicate: (value: short, ind export function findLast(self: FixedArray, predicate: (elem: short, index: number, array: FixedArray) => boolean): Short | undefined { for (let i = self.length - 1; i >= 0; i--) { const val = self[i]; - if (predicate(val, i as number, self)) { + if (predicate(val, Int.toDouble(i), self)) { return val; } } @@ -2258,7 +2258,7 @@ export function findLast(self: FixedArray, predicate: (elem: short, index */ export function every(self: FixedArray, predicate: (value: short, index: number, array: FixedArray) => boolean): boolean { for (let i = 0; i < self.length; i++) { - if (!predicate(self[i], i as number, self)) { + if (!predicate(self[i], Int.toDouble(i), self)) { return false } } @@ -2276,7 +2276,7 @@ export function every(self: FixedArray, predicate: (value: short, index: */ export function some(self: FixedArray, predicate: (value: short, index: number, array: FixedArray) => boolean): boolean { for (let i = 0; i < self.length; i++) { - if (predicate(self[i], i as number, self)) { + if (predicate(self[i], Int.toDouble(i), self)) { return true } } @@ -2294,7 +2294,7 @@ export function some(self: FixedArray, predicate: (value: short, index: n */ export function findLastIndex(self: FixedArray, predicate: (element: short, index: number, array: FixedArray) => boolean): number { for (let i = self.length - 1; i >= 0; i--) { - if (predicate(self[i], i as number, self)) { + if (predicate(self[i], Int.toDouble(i), self)) { return i } } @@ -2314,7 +2314,7 @@ export function reduce(self: FixedArray, callbackfn: (previousValue: shor } let acc: short = self[0]; for (let i = 1; i < self.length; i++) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -2331,7 +2331,7 @@ export function reduce(self: FixedArray, callbackfn: (previousValue: shor export function reduce(self: FixedArray, callbackfn: (previousValue: U, currentValue: short, index: number, array: FixedArray) => U, initialValue: U): U { let acc = initialValue for (let i = 0; i < self.length; i++) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -2348,7 +2348,7 @@ export function reduce(self: FixedArray, callbackfn: (previous export function reduceRight(self: FixedArray, callbackfn: (previousValue: U, currentValue: short, index: number, array: FixedArray) => U, initialValue: U): U { let acc = initialValue for (let i = self.length - 1; i >= 0; i--) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -2361,7 +2361,7 @@ export function reduceRight(self: FixedArray, callbackfn: (previousVal export function forEach(self: FixedArray, callbackfn: (value: short, index: number, array: FixedArray) => void): void { const len0 = self.length; for (let i = 0; i < len0; i++) { - callbackfn(self[i], i as number, self) + callbackfn(self[i], Int.toDouble(i), self) } } @@ -2416,7 +2416,7 @@ export function slice(self: FixedArray, start: int, end: int): FixedArray * @returns `Array` instance, constructed from extracted elements of `this` instance. */ export function slice(self: FixedArray, start: int): FixedArray { - return slice(self, start, Int.MAX_VALUE as int); + return slice(self, start, Int.MAX_VALUE); } /** @@ -2570,7 +2570,7 @@ export function toSpliced(self: FixedArray, start?: Number, delete?: Numb */ export function toSpliced(self: FixedArray, start: number, delete: number, ...items: FixedArray): FixedArray { const len = self.length; - return toSpliced(self, start as int, delete as int, ...items) + return toSpliced(self, Double.toInt(start), Double.toInt(delete), ...items) } /** @@ -2740,7 +2740,7 @@ export function toReversed(self: FixedArray): FixedArray { * @returns a new Array with the element at the given index replaced with the given value */ export function with(self: FixedArray, index: number, value: short): FixedArray { - return with(self, index as int, value) + return with(self, Double.toInt(index), value) } /** @@ -2790,7 +2790,7 @@ export function map(self: FixedArray, callbackfn: (value: short, index: n const len = self.length; let res : FixedArray = new short[len]; for (let i = 0; i < len; i++) { - res[i] = callbackfn(self[i], i as number, self); + res[i] = callbackfn(self[i], Int.toDouble(i), self); } return res; } @@ -2808,7 +2808,7 @@ export function reduceRight(self: FixedArray, callbackfn: (previousValue: } let acc: short = self[self.length - 1]; for (let i = self.length - 2; i >= 0; i--) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -2916,7 +2916,7 @@ class ArrayValuesIterator_short implements IterableIterator { } public __Iterator_getLength(): int { - return this.parent.length as int + return Double.toInt(this.parent.length) } } @@ -2935,7 +2935,7 @@ class ArrayEntriesIterator_short implements IterableIterator<[number, short]> { return new IteratorResult<[number, short]>() } const i = this.idx++; - const vl: [number, short] = [i as number, this.parent[i]] + const vl: [number, short] = [Int.toDouble(i), this.parent[i]] return new IteratorResult<[number, short]>(vl); } @@ -2944,7 +2944,7 @@ class ArrayEntriesIterator_short implements IterableIterator<[number, short]> { } public __Iterator_getLength(): int { - return this.parent.length as int + return Double.toInt(this.parent.length) } } @@ -2968,7 +2968,7 @@ function cloneArray(self: FixedArray): FixedArray { * Returns undefined if `index` < `-length()` or `index` >= `length()`. */ export function at(self: FixedArray, index: number): Int | undefined { - return at(self, index as int) + return at(self, Double.toInt(index)) } /** @@ -2985,7 +2985,7 @@ export function at(self: FixedArray, index: number): Int | undefined { export function concat(self: FixedArray, ...items: FixedArray>): FixedArray { let totalAdd = self.length; for (let i = 0; i < items.length; i++) { - totalAdd += items[i].length as int + totalAdd += Double.toInt(items[i].length) } const buf : FixedArray = new int[totalAdd]; @@ -2997,7 +2997,7 @@ export function concat(self: FixedArray, ...items: FixedArray, index: int): Int | undefined { * @returns this array after transformation */ export function copyWithin(self: FixedArray, target: number, start: number, end?: Number): FixedArray { - copyWithin(self, target as int, start as int, asIntOrDefault(end, self.length)); + copyWithin(self, Double.toInt(target), Double.toInt(start), asIntOrDefault(end, self.length)); return self; } @@ -3167,7 +3167,7 @@ export function find(self: FixedArray, predicate: (value: int, index: numbe if (res == -1) { return undefined } - return self[res as int]; + return self[Double.toInt(res)]; } /** @@ -3182,7 +3182,7 @@ export function find(self: FixedArray, predicate: (value: int, index: numbe */ export function findIndex(self: FixedArray, predicate: (value: int, index: number, array: FixedArray) => boolean): number { for (let i = 0; i < self.length; i++) { - if (predicate(self[i], i as number, self)) { + if (predicate(self[i], Int.toDouble(i), self)) { return i; } } @@ -3200,7 +3200,7 @@ export function findIndex(self: FixedArray, predicate: (value: int, index: export function findLast(self: FixedArray, predicate: (elem: int, index: number, array: FixedArray) => boolean): Int | undefined { for (let i = self.length - 1; i >= 0; i--) { const val = self[i]; - if (predicate(val, i as number, self)) { + if (predicate(val, Int.toDouble(i), self)) { return val; } } @@ -3218,7 +3218,7 @@ export function findLast(self: FixedArray, predicate: (elem: int, index: nu */ export function every(self: FixedArray, predicate: (value: int, index: number, array: FixedArray) => boolean): boolean { for (let i = 0; i < self.length; i++) { - if (!predicate(self[i], i as number, self)) { + if (!predicate(self[i], Int.toDouble(i), self)) { return false } } @@ -3236,7 +3236,7 @@ export function every(self: FixedArray, predicate: (value: int, index: numb */ export function some(self: FixedArray, predicate: (value: int, index: number, array: FixedArray) => boolean): boolean { for (let i = 0; i < self.length; i++) { - if (predicate(self[i], i as number, self)) { + if (predicate(self[i], Int.toDouble(i), self)) { return true } } @@ -3254,7 +3254,7 @@ export function some(self: FixedArray, predicate: (value: int, index: numbe */ export function findLastIndex(self: FixedArray, predicate: (element: int, index: number, array: FixedArray) => boolean): number { for (let i = self.length - 1; i >= 0; i--) { - if (predicate(self[i], i as number, self)) { + if (predicate(self[i], Int.toDouble(i), self)) { return i } } @@ -3274,7 +3274,7 @@ export function reduce(self: FixedArray, callbackfn: (previousValue: int, c } let acc: int = self[0]; for (let i = 1; i < self.length; i++) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -3291,7 +3291,7 @@ export function reduce(self: FixedArray, callbackfn: (previousValue: int, c export function reduce(self: FixedArray, callbackfn: (previousValue: U, currentValue: int, index: number, array: FixedArray) => U, initialValue: U): U { let acc = initialValue for (let i = 0; i < self.length; i++) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -3308,7 +3308,7 @@ export function reduce(self: FixedArray, callbackfn: (previousValu export function reduceRight(self: FixedArray, callbackfn: (previousValue: U, currentValue: int, index: number, array: FixedArray) => U, initialValue: U): U { let acc = initialValue for (let i = self.length - 1; i >= 0; i--) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -3321,7 +3321,7 @@ export function reduceRight(self: FixedArray, callbackfn: (previousValue export function forEach(self: FixedArray, callbackfn: (value: int, index: number, array: FixedArray) => void): void { const len0 = self.length; for (let i = 0; i < len0; i++) { - callbackfn(self[i], i as number, self) + callbackfn(self[i], Int.toDouble(i), self) } } @@ -3376,7 +3376,7 @@ export function slice(self: FixedArray, start: int, end: int): FixedArray, start: int): FixedArray { - return slice(self, start, Int.MAX_VALUE as int); + return slice(self, start, Int.MAX_VALUE); } /** @@ -3530,7 +3530,7 @@ export function toSpliced(self: FixedArray, start?: Number, delete?: Number */ export function toSpliced(self: FixedArray, start: number, delete: number, ...items: FixedArray): FixedArray { const len = self.length; - return toSpliced(self, start as int, delete as int, ...items) + return toSpliced(self, Double.toInt(start), Double.toInt(delete), ...items) } /** @@ -3700,7 +3700,7 @@ export function toReversed(self: FixedArray): FixedArray { * @returns a new Array with the element at the given index replaced with the given value */ export function with(self: FixedArray, index: number, value: int): FixedArray { - return with(self, index as int, value) + return with(self, Double.toInt(index), value) } /** @@ -3750,7 +3750,7 @@ export function map(self: FixedArray, callbackfn: (value: int, index: numbe const len = self.length; let res : FixedArray = new int[len]; for (let i = 0; i < len; i++) { - res[i] = callbackfn(self[i], i as number, self); + res[i] = callbackfn(self[i], Int.toDouble(i), self); } return res; } @@ -3768,7 +3768,7 @@ export function reduceRight(self: FixedArray, callbackfn: (previousValue: i } let acc: int = self[self.length - 1]; for (let i = self.length - 2; i >= 0; i--) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -3876,7 +3876,7 @@ class ArrayValuesIterator_int implements IterableIterator { } public __Iterator_getLength(): int { - return this.parent.length as int + return Double.toInt(this.parent.length) } } @@ -3895,7 +3895,7 @@ class ArrayEntriesIterator_int implements IterableIterator<[number, int]> { return new IteratorResult<[number, int]>() } const i = this.idx++; - const vl: [number, int] = [i as number, this.parent[i]] + const vl: [number, int] = [Int.toDouble(i), this.parent[i]] return new IteratorResult<[number, int]>(vl); } @@ -3904,7 +3904,7 @@ class ArrayEntriesIterator_int implements IterableIterator<[number, int]> { } public __Iterator_getLength(): int { - return this.parent.length as int + return Double.toInt(this.parent.length) } } @@ -3928,7 +3928,7 @@ function cloneArray(self: FixedArray): FixedArray { * Returns undefined if `index` < `-length()` or `index` >= `length()`. */ export function at(self: FixedArray, index: number): Long | undefined { - return at(self, index as int) + return at(self, Double.toInt(index)) } /** @@ -3945,7 +3945,7 @@ export function at(self: FixedArray, index: number): Long | undefined { export function concat(self: FixedArray, ...items: FixedArray>): FixedArray { let totalAdd = self.length; for (let i = 0; i < items.length; i++) { - totalAdd += items[i].length as int + totalAdd += Double.toInt(items[i].length) } const buf : FixedArray = new long[totalAdd]; @@ -3957,7 +3957,7 @@ export function concat(self: FixedArray, ...items: FixedArray, index: int): Long | undefined { * @returns this array after transformation */ export function copyWithin(self: FixedArray, target: number, start: number, end?: Number): FixedArray { - copyWithin(self, target as int, start as int, asIntOrDefault(end, self.length)); + copyWithin(self, Double.toInt(target), Double.toInt(start), asIntOrDefault(end, self.length)); return self; } @@ -4127,7 +4127,7 @@ export function find(self: FixedArray, predicate: (value: long, index: num if (res == -1) { return undefined } - return self[res as int]; + return self[Double.toInt(res)]; } /** @@ -4142,7 +4142,7 @@ export function find(self: FixedArray, predicate: (value: long, index: num */ export function findIndex(self: FixedArray, predicate: (value: long, index: number, array: FixedArray) => boolean): number { for (let i = 0; i < self.length; i++) { - if (predicate(self[i], i as number, self)) { + if (predicate(self[i], Int.toDouble(i), self)) { return i; } } @@ -4160,7 +4160,7 @@ export function findIndex(self: FixedArray, predicate: (value: long, index export function findLast(self: FixedArray, predicate: (elem: long, index: number, array: FixedArray) => boolean): Long | undefined { for (let i = self.length - 1; i >= 0; i--) { const val = self[i]; - if (predicate(val, i as number, self)) { + if (predicate(val, Int.toDouble(i), self)) { return val; } } @@ -4178,7 +4178,7 @@ export function findLast(self: FixedArray, predicate: (elem: long, index: */ export function every(self: FixedArray, predicate: (value: long, index: number, array: FixedArray) => boolean): boolean { for (let i = 0; i < self.length; i++) { - if (!predicate(self[i], i as number, self)) { + if (!predicate(self[i], Int.toDouble(i), self)) { return false } } @@ -4196,7 +4196,7 @@ export function every(self: FixedArray, predicate: (value: long, index: nu */ export function some(self: FixedArray, predicate: (value: long, index: number, array: FixedArray) => boolean): boolean { for (let i = 0; i < self.length; i++) { - if (predicate(self[i], i as number, self)) { + if (predicate(self[i], Int.toDouble(i), self)) { return true } } @@ -4214,7 +4214,7 @@ export function some(self: FixedArray, predicate: (value: long, index: num */ export function findLastIndex(self: FixedArray, predicate: (element: long, index: number, array: FixedArray) => boolean): number { for (let i = self.length - 1; i >= 0; i--) { - if (predicate(self[i], i as number, self)) { + if (predicate(self[i], Int.toDouble(i), self)) { return i } } @@ -4234,7 +4234,7 @@ export function reduce(self: FixedArray, callbackfn: (previousValue: long, } let acc: long = self[0]; for (let i = 1; i < self.length; i++) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -4251,7 +4251,7 @@ export function reduce(self: FixedArray, callbackfn: (previousValue: long, export function reduce(self: FixedArray, callbackfn: (previousValue: U, currentValue: long, index: number, array: FixedArray) => U, initialValue: U): U { let acc = initialValue for (let i = 0; i < self.length; i++) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -4268,7 +4268,7 @@ export function reduce(self: FixedArray, callbackfn: (previousVa export function reduceRight(self: FixedArray, callbackfn: (previousValue: U, currentValue: long, index: number, array: FixedArray) => U, initialValue: U): U { let acc = initialValue for (let i = self.length - 1; i >= 0; i--) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -4281,7 +4281,7 @@ export function reduceRight(self: FixedArray, callbackfn: (previousValu export function forEach(self: FixedArray, callbackfn: (value: long, index: number, array: FixedArray) => void): void { const len0 = self.length; for (let i = 0; i < len0; i++) { - callbackfn(self[i], i as number, self) + callbackfn(self[i], Int.toDouble(i), self) } } @@ -4336,7 +4336,7 @@ export function slice(self: FixedArray, start: int, end: int): FixedArray< * @returns `Array` instance, constructed from extracted elements of `this` instance. */ export function slice(self: FixedArray, start: int): FixedArray { - return slice(self, start, Int.MAX_VALUE as int); + return slice(self, start, Int.MAX_VALUE); } /** @@ -4490,7 +4490,7 @@ export function toSpliced(self: FixedArray, start?: Number, delete?: Numbe */ export function toSpliced(self: FixedArray, start: number, delete: number, ...items: FixedArray): FixedArray { const len = self.length; - return toSpliced(self, start as int, delete as int, ...items) + return toSpliced(self, Double.toInt(start), Double.toInt(delete), ...items) } /** @@ -4660,7 +4660,7 @@ export function toReversed(self: FixedArray): FixedArray { * @returns a new Array with the element at the given index replaced with the given value */ export function with(self: FixedArray, index: number, value: long): FixedArray { - return with(self, index as int, value) + return with(self, Double.toInt(index), value) } /** @@ -4710,7 +4710,7 @@ export function map(self: FixedArray, callbackfn: (value: long, index: num const len = self.length; let res : FixedArray = new long[len]; for (let i = 0; i < len; i++) { - res[i] = callbackfn(self[i], i as number, self); + res[i] = callbackfn(self[i], Int.toDouble(i), self); } return res; } @@ -4728,7 +4728,7 @@ export function reduceRight(self: FixedArray, callbackfn: (previousValue: } let acc: long = self[self.length - 1]; for (let i = self.length - 2; i >= 0; i--) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -4836,7 +4836,7 @@ class ArrayValuesIterator_long implements IterableIterator { } public __Iterator_getLength(): int { - return this.parent.length as int + return Double.toInt(this.parent.length) } } @@ -4855,7 +4855,7 @@ class ArrayEntriesIterator_long implements IterableIterator<[number, long]> { return new IteratorResult<[number, long]>() } const i = this.idx++; - const vl: [number, long] = [i as number, this.parent[i]] + const vl: [number, long] = [Int.toDouble(i), this.parent[i]] return new IteratorResult<[number, long]>(vl); } @@ -4864,7 +4864,7 @@ class ArrayEntriesIterator_long implements IterableIterator<[number, long]> { } public __Iterator_getLength(): int { - return this.parent.length as int + return Double.toInt(this.parent.length) } } @@ -4888,7 +4888,7 @@ function cloneArray(self: FixedArray): FixedArray { * Returns undefined if `index` < `-length()` or `index` >= `length()`. */ export function at(self: FixedArray, index: number): Float | undefined { - return at(self, index as int) + return at(self, Double.toInt(index)) } /** @@ -4905,7 +4905,7 @@ export function at(self: FixedArray, index: number): Float | undefined { export function concat(self: FixedArray, ...items: FixedArray>): FixedArray { let totalAdd = self.length; for (let i = 0; i < items.length; i++) { - totalAdd += items[i].length as int + totalAdd += Double.toInt(items[i].length) } const buf : FixedArray = new float[totalAdd]; @@ -4917,7 +4917,7 @@ export function concat(self: FixedArray, ...items: FixedArray, index: int): Float | undefined { * @returns this array after transformation */ export function copyWithin(self: FixedArray, target: number, start: number, end?: Number): FixedArray { - copyWithin(self, target as int, start as int, asIntOrDefault(end, self.length)); + copyWithin(self, Double.toInt(target), Double.toInt(start), asIntOrDefault(end, self.length)); return self; } @@ -5087,7 +5087,7 @@ export function find(self: FixedArray, predicate: (value: float, index: n if (res == -1) { return undefined } - return self[res as int]; + return self[Double.toInt(res)]; } /** @@ -5102,7 +5102,7 @@ export function find(self: FixedArray, predicate: (value: float, index: n */ export function findIndex(self: FixedArray, predicate: (value: float, index: number, array: FixedArray) => boolean): number { for (let i = 0; i < self.length; i++) { - if (predicate(self[i], i as number, self)) { + if (predicate(self[i], Int.toDouble(i), self)) { return i; } } @@ -5120,7 +5120,7 @@ export function findIndex(self: FixedArray, predicate: (value: float, ind export function findLast(self: FixedArray, predicate: (elem: float, index: number, array: FixedArray) => boolean): Float | undefined { for (let i = self.length - 1; i >= 0; i--) { const val = self[i]; - if (predicate(val, i as number, self)) { + if (predicate(val, Int.toDouble(i), self)) { return val; } } @@ -5138,7 +5138,7 @@ export function findLast(self: FixedArray, predicate: (elem: float, index */ export function every(self: FixedArray, predicate: (value: float, index: number, array: FixedArray) => boolean): boolean { for (let i = 0; i < self.length; i++) { - if (!predicate(self[i], i as number, self)) { + if (!predicate(self[i], Int.toDouble(i), self)) { return false } } @@ -5156,7 +5156,7 @@ export function every(self: FixedArray, predicate: (value: float, index: */ export function some(self: FixedArray, predicate: (value: float, index: number, array: FixedArray) => boolean): boolean { for (let i = 0; i < self.length; i++) { - if (predicate(self[i], i as number, self)) { + if (predicate(self[i], Int.toDouble(i), self)) { return true } } @@ -5174,7 +5174,7 @@ export function some(self: FixedArray, predicate: (value: float, index: n */ export function findLastIndex(self: FixedArray, predicate: (element: float, index: number, array: FixedArray) => boolean): number { for (let i = self.length - 1; i >= 0; i--) { - if (predicate(self[i], i as number, self)) { + if (predicate(self[i], Int.toDouble(i), self)) { return i } } @@ -5194,7 +5194,7 @@ export function reduce(self: FixedArray, callbackfn: (previousValue: floa } let acc: float = self[0]; for (let i = 1; i < self.length; i++) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -5211,7 +5211,7 @@ export function reduce(self: FixedArray, callbackfn: (previousValue: floa export function reduce(self: FixedArray, callbackfn: (previousValue: U, currentValue: float, index: number, array: FixedArray) => U, initialValue: U): U { let acc = initialValue for (let i = 0; i < self.length; i++) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -5228,7 +5228,7 @@ export function reduce(self: FixedArray, callbackfn: (previous export function reduceRight(self: FixedArray, callbackfn: (previousValue: U, currentValue: float, index: number, array: FixedArray) => U, initialValue: U): U { let acc = initialValue for (let i = self.length - 1; i >= 0; i--) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -5241,7 +5241,7 @@ export function reduceRight(self: FixedArray, callbackfn: (previousVal export function forEach(self: FixedArray, callbackfn: (value: float, index: number, array: FixedArray) => void): void { const len0 = self.length; for (let i = 0; i < len0; i++) { - callbackfn(self[i], i as number, self) + callbackfn(self[i], Int.toDouble(i), self) } } @@ -5296,7 +5296,7 @@ export function slice(self: FixedArray, start: int, end: int): FixedArray * @returns `Array` instance, constructed from extracted elements of `this` instance. */ export function slice(self: FixedArray, start: int): FixedArray { - return slice(self, start, Int.MAX_VALUE as int); + return slice(self, start, Int.MAX_VALUE); } /** @@ -5450,7 +5450,7 @@ export function toSpliced(self: FixedArray, start?: Number, delete?: Numb */ export function toSpliced(self: FixedArray, start: number, delete: number, ...items: FixedArray): FixedArray { const len = self.length; - return toSpliced(self, start as int, delete as int, ...items) + return toSpliced(self, Double.toInt(start), Double.toInt(delete), ...items) } /** @@ -5628,7 +5628,7 @@ export function toReversed(self: FixedArray): FixedArray { * @returns a new Array with the element at the given index replaced with the given value */ export function with(self: FixedArray, index: number, value: float): FixedArray { - return with(self, index as int, value) + return with(self, Double.toInt(index), value) } /** @@ -5678,7 +5678,7 @@ export function map(self: FixedArray, callbackfn: (value: float, index: n const len = self.length; let res : FixedArray = new float[len]; for (let i = 0; i < len; i++) { - res[i] = callbackfn(self[i], i as number, self); + res[i] = callbackfn(self[i], Int.toDouble(i), self); } return res; } @@ -5696,7 +5696,7 @@ export function reduceRight(self: FixedArray, callbackfn: (previousValue: } let acc: float = self[self.length - 1]; for (let i = self.length - 2; i >= 0; i--) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -5804,7 +5804,7 @@ class ArrayValuesIterator_float implements IterableIterator { } public __Iterator_getLength(): int { - return this.parent.length as int + return Double.toInt(this.parent.length) } } @@ -5823,7 +5823,7 @@ class ArrayEntriesIterator_float implements IterableIterator<[number, float]> { return new IteratorResult<[number, float]>() } const i = this.idx++; - const vl: [number, float] = [i as number, this.parent[i]] + const vl: [number, float] = [Int.toDouble(i), this.parent[i]] return new IteratorResult<[number, float]>(vl); } @@ -5832,7 +5832,7 @@ class ArrayEntriesIterator_float implements IterableIterator<[number, float]> { } public __Iterator_getLength(): int { - return this.parent.length as int + return Double.toInt(this.parent.length) } } @@ -5856,7 +5856,7 @@ function cloneArray(self: FixedArray): FixedArray { * Returns undefined if `index` < `-length()` or `index` >= `length()`. */ export function at(self: FixedArray, index: number): Double | undefined { - return at(self, index as int) + return at(self, Double.toInt(index)) } /** @@ -5873,7 +5873,7 @@ export function at(self: FixedArray, index: number): Double | undefined export function concat(self: FixedArray, ...items: FixedArray>): FixedArray { let totalAdd = self.length; for (let i = 0; i < items.length; i++) { - totalAdd += items[i].length as int + totalAdd += Double.toInt(items[i].length) } const buf : FixedArray = new double[totalAdd]; @@ -5885,7 +5885,7 @@ export function concat(self: FixedArray, ...items: FixedArray, index: int): Double | undefined { * @returns this array after transformation */ export function copyWithin(self: FixedArray, target: number, start: number, end?: Number): FixedArray { - copyWithin(self, target as int, start as int, asIntOrDefault(end, self.length)); + copyWithin(self, Double.toInt(target), Double.toInt(start), asIntOrDefault(end, self.length)); return self; } @@ -6055,7 +6055,7 @@ export function find(self: FixedArray, predicate: (value: double, index: if (res == -1) { return undefined } - return self[res as int]; + return self[Double.toInt(res)]; } /** @@ -6070,7 +6070,7 @@ export function find(self: FixedArray, predicate: (value: double, index: */ export function findIndex(self: FixedArray, predicate: (value: double, index: number, array: FixedArray) => boolean): number { for (let i = 0; i < self.length; i++) { - if (predicate(self[i], i as number, self)) { + if (predicate(self[i], Int.toDouble(i), self)) { return i; } } @@ -6088,7 +6088,7 @@ export function findIndex(self: FixedArray, predicate: (value: double, i export function findLast(self: FixedArray, predicate: (elem: double, index: number, array: FixedArray) => boolean): Double | undefined { for (let i = self.length - 1; i >= 0; i--) { const val = self[i]; - if (predicate(val, i as number, self)) { + if (predicate(val, Int.toDouble(i), self)) { return val; } } @@ -6106,7 +6106,7 @@ export function findLast(self: FixedArray, predicate: (elem: double, ind */ export function every(self: FixedArray, predicate: (value: double, index: number, array: FixedArray) => boolean): boolean { for (let i = 0; i < self.length; i++) { - if (!predicate(self[i], i as number, self)) { + if (!predicate(self[i], Int.toDouble(i), self)) { return false } } @@ -6124,7 +6124,7 @@ export function every(self: FixedArray, predicate: (value: double, index */ export function some(self: FixedArray, predicate: (value: double, index: number, array: FixedArray) => boolean): boolean { for (let i = 0; i < self.length; i++) { - if (predicate(self[i], i as number, self)) { + if (predicate(self[i], Int.toDouble(i), self)) { return true } } @@ -6142,7 +6142,7 @@ export function some(self: FixedArray, predicate: (value: double, index: */ export function findLastIndex(self: FixedArray, predicate: (element: double, index: number, array: FixedArray) => boolean): number { for (let i = self.length - 1; i >= 0; i--) { - if (predicate(self[i], i as number, self)) { + if (predicate(self[i], Int.toDouble(i), self)) { return i } } @@ -6162,7 +6162,7 @@ export function reduce(self: FixedArray, callbackfn: (previousValue: dou } let acc: double = self[0]; for (let i = 1; i < self.length; i++) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -6179,7 +6179,7 @@ export function reduce(self: FixedArray, callbackfn: (previousValue: dou export function reduce(self: FixedArray, callbackfn: (previousValue: U, currentValue: double, index: number, array: FixedArray) => U, initialValue: U): U { let acc = initialValue for (let i = 0; i < self.length; i++) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -6196,7 +6196,7 @@ export function reduce(self: FixedArray, callbackfn: (previo export function reduceRight(self: FixedArray, callbackfn: (previousValue: U, currentValue: double, index: number, array: FixedArray) => U, initialValue: U): U { let acc = initialValue for (let i = self.length - 1; i >= 0; i--) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -6209,7 +6209,7 @@ export function reduceRight(self: FixedArray, callbackfn: (previousVa export function forEach(self: FixedArray, callbackfn: (value: double, index: number, array: FixedArray) => void): void { const len0 = self.length; for (let i = 0; i < len0; i++) { - callbackfn(self[i], i as number, self) + callbackfn(self[i], Int.toDouble(i), self) } } @@ -6264,7 +6264,7 @@ export function slice(self: FixedArray, start: int, end: int): FixedArra * @returns `Array` instance, constructed from extracted elements of `this` instance. */ export function slice(self: FixedArray, start: int): FixedArray { - return slice(self, start, Int.MAX_VALUE as int); + return slice(self, start, Int.MAX_VALUE); } /** @@ -6418,7 +6418,7 @@ export function toSpliced(self: FixedArray, start?: Number, delete?: Num */ export function toSpliced(self: FixedArray, start: number, delete: number, ...items: FixedArray): FixedArray { const len = self.length; - return toSpliced(self, start as int, delete as int, ...items) + return toSpliced(self, Double.toInt(start), Double.toInt(delete), ...items) } /** @@ -6596,7 +6596,7 @@ export function toReversed(self: FixedArray): FixedArray { * @returns a new Array with the element at the given index replaced with the given value */ export function with(self: FixedArray, index: number, value: double): FixedArray { - return with(self, index as int, value) + return with(self, Double.toInt(index), value) } /** @@ -6646,7 +6646,7 @@ export function map(self: FixedArray, callbackfn: (value: double, index: const len = self.length; let res : FixedArray = new double[len]; for (let i = 0; i < len; i++) { - res[i] = callbackfn(self[i], i as number, self); + res[i] = callbackfn(self[i], Int.toDouble(i), self); } return res; } @@ -6664,7 +6664,7 @@ export function reduceRight(self: FixedArray, callbackfn: (previousValue } let acc: double = self[self.length - 1]; for (let i = self.length - 2; i >= 0; i--) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -6772,7 +6772,7 @@ class ArrayValuesIterator_double implements IterableIterator { } public __Iterator_getLength(): int { - return this.parent.length as int + return Double.toInt(this.parent.length) } } @@ -6791,7 +6791,7 @@ class ArrayEntriesIterator_double implements IterableIterator<[number, double]> return new IteratorResult<[number, double]>() } const i = this.idx++; - const vl: [number, double] = [i as number, this.parent[i]] + const vl: [number, double] = [Int.toDouble(i), this.parent[i]] return new IteratorResult<[number, double]>(vl); } @@ -6800,7 +6800,7 @@ class ArrayEntriesIterator_double implements IterableIterator<[number, double]> } public __Iterator_getLength(): int { - return this.parent.length as int + return Double.toInt(this.parent.length) } } @@ -6824,7 +6824,7 @@ function cloneArray(self: FixedArray): FixedArray { * Returns undefined if `index` < `-length()` or `index` >= `length()`. */ export function at(self: FixedArray, index: number): Char | undefined { - return at(self, index as int) + return at(self, Double.toInt(index)) } /** @@ -6841,7 +6841,7 @@ export function at(self: FixedArray, index: number): Char | undefined { export function concat(self: FixedArray, ...items: FixedArray>): FixedArray { let totalAdd = self.length; for (let i = 0; i < items.length; i++) { - totalAdd += items[i].length as int + totalAdd += Double.toInt(items[i].length) } const buf : FixedArray = new char[totalAdd]; @@ -6853,7 +6853,7 @@ export function concat(self: FixedArray, ...items: FixedArray, index: int): Char | undefined { * @returns this array after transformation */ export function copyWithin(self: FixedArray, target: number, start: number, end?: Number): FixedArray { - copyWithin(self, target as int, start as int, asIntOrDefault(end, self.length)); + copyWithin(self, Double.toInt(target), Double.toInt(start), asIntOrDefault(end, self.length)); return self; } @@ -7023,7 +7023,7 @@ export function find(self: FixedArray, predicate: (value: char, index: num if (res == -1) { return undefined } - return self[res as int]; + return self[Double.toInt(res)]; } /** @@ -7038,7 +7038,7 @@ export function find(self: FixedArray, predicate: (value: char, index: num */ export function findIndex(self: FixedArray, predicate: (value: char, index: number, array: FixedArray) => boolean): number { for (let i = 0; i < self.length; i++) { - if (predicate(self[i], i as number, self)) { + if (predicate(self[i], Int.toDouble(i), self)) { return i; } } @@ -7056,7 +7056,7 @@ export function findIndex(self: FixedArray, predicate: (value: char, index export function findLast(self: FixedArray, predicate: (elem: char, index: number, array: FixedArray) => boolean): Char | undefined { for (let i = self.length - 1; i >= 0; i--) { const val = self[i]; - if (predicate(val, i as number, self)) { + if (predicate(val, Int.toDouble(i), self)) { return val; } } @@ -7074,7 +7074,7 @@ export function findLast(self: FixedArray, predicate: (elem: char, index: */ export function every(self: FixedArray, predicate: (value: char, index: number, array: FixedArray) => boolean): boolean { for (let i = 0; i < self.length; i++) { - if (!predicate(self[i], i as number, self)) { + if (!predicate(self[i], Int.toDouble(i), self)) { return false } } @@ -7092,7 +7092,7 @@ export function every(self: FixedArray, predicate: (value: char, index: nu */ export function some(self: FixedArray, predicate: (value: char, index: number, array: FixedArray) => boolean): boolean { for (let i = 0; i < self.length; i++) { - if (predicate(self[i], i as number, self)) { + if (predicate(self[i], Int.toDouble(i), self)) { return true } } @@ -7110,7 +7110,7 @@ export function some(self: FixedArray, predicate: (value: char, index: num */ export function findLastIndex(self: FixedArray, predicate: (element: char, index: number, array: FixedArray) => boolean): number { for (let i = self.length - 1; i >= 0; i--) { - if (predicate(self[i], i as number, self)) { + if (predicate(self[i], Int.toDouble(i), self)) { return i } } @@ -7130,7 +7130,7 @@ export function reduce(self: FixedArray, callbackfn: (previousValue: char, } let acc: char = self[0]; for (let i = 1; i < self.length; i++) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -7147,7 +7147,7 @@ export function reduce(self: FixedArray, callbackfn: (previousValue: char, export function reduce(self: FixedArray, callbackfn: (previousValue: U, currentValue: char, index: number, array: FixedArray) => U, initialValue: U): U { let acc = initialValue for (let i = 0; i < self.length; i++) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -7164,7 +7164,7 @@ export function reduce(self: FixedArray, callbackfn: (previousVa export function reduceRight(self: FixedArray, callbackfn: (previousValue: U, currentValue: char, index: number, array: FixedArray) => U, initialValue: U): U { let acc = initialValue for (let i = self.length - 1; i >= 0; i--) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -7177,7 +7177,7 @@ export function reduceRight(self: FixedArray, callbackfn: (previousValu export function forEach(self: FixedArray, callbackfn: (value: char, index: number, array: FixedArray) => void): void { const len0 = self.length; for (let i = 0; i < len0; i++) { - callbackfn(self[i], i as number, self) + callbackfn(self[i], Int.toDouble(i), self) } } @@ -7232,7 +7232,7 @@ export function slice(self: FixedArray, start: int, end: int): FixedArray< * @returns `Array` instance, constructed from extracted elements of `this` instance. */ export function slice(self: FixedArray, start: int): FixedArray { - return slice(self, start, Int.MAX_VALUE as int); + return slice(self, start, Int.MAX_VALUE); } /** @@ -7298,7 +7298,7 @@ export function join(self: FixedArray, sep?: String): string { return "" } const sepReal = sep === undefined ? "," : sep! - let sb = new StringBuilder(new String(self[0])) + let sb = new StringBuilder(new String(self[0].toString())) for (let i: int = 1; i < self.length; i++) { const tmp = self[i] sb.append(sepReal); @@ -7386,7 +7386,7 @@ export function toSpliced(self: FixedArray, start?: Number, delete?: Numbe */ export function toSpliced(self: FixedArray, start: number, delete: number, ...items: FixedArray): FixedArray { const len = self.length; - return toSpliced(self, start as int, delete as int, ...items) + return toSpliced(self, Double.toInt(start), Double.toInt(delete), ...items) } /** @@ -7556,7 +7556,7 @@ export function toReversed(self: FixedArray): FixedArray { * @returns a new Array with the element at the given index replaced with the given value */ export function with(self: FixedArray, index: number, value: char): FixedArray { - return with(self, index as int, value) + return with(self, Double.toInt(index), value) } /** @@ -7606,7 +7606,7 @@ export function map(self: FixedArray, callbackfn: (value: char, index: num const len = self.length; let res : FixedArray = new char[len]; for (let i = 0; i < len; i++) { - res[i] = callbackfn(self[i], i as number, self); + res[i] = callbackfn(self[i], Int.toDouble(i), self); } return res; } @@ -7624,7 +7624,7 @@ export function reduceRight(self: FixedArray, callbackfn: (previousValue: } let acc: char = self[self.length - 1]; for (let i = self.length - 2; i >= 0; i--) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } @@ -7732,7 +7732,7 @@ class ArrayValuesIterator_char implements IterableIterator { } public __Iterator_getLength(): int { - return this.parent.length as int + return Double.toInt(this.parent.length) } } @@ -7751,7 +7751,7 @@ class ArrayEntriesIterator_char implements IterableIterator<[number, char]> { return new IteratorResult<[number, char]>() } const i = this.idx++; - const vl: [number, char] = [i as number, this.parent[i]] + const vl: [number, char] = [Int.toDouble(i), this.parent[i]] return new IteratorResult<[number, char]>(vl); } @@ -7760,21 +7760,21 @@ class ArrayEntriesIterator_char implements IterableIterator<[number, char]> { } public __Iterator_getLength(): int { - return this.parent.length as int + return Double.toInt(this.parent.length) } } function builtin_insertion_sort(arr: FixedArray, startIndex: int, endIndex: int, comp: (lhs: T, rhs: T) => number): void { for (let i = startIndex + 1; i < endIndex; i++) { const tmp = arr[i]; - if (comp(tmp, arr[startIndex]) as int < 0) { + if (Double.toInt(comp(tmp, arr[startIndex])) < 0) { for (let j = i; j > startIndex; j--) { arr[j] = arr[j - 1] } arr[startIndex] = tmp } else { let j = i - 1; - while (comp(tmp, arr[j]) as int < 0) { + while (Double.toInt(comp(tmp, arr[j])) < 0) { arr[j + 1] = arr[j]; j--; } @@ -7798,7 +7798,7 @@ function perform_merge(arr: FixedArray, startIndex: int, midIndex: int, en let j = 0; let k = startIndex; while (i < len1 && j < len2) { - if (comp(left[i]!, right[j]!) as int <= 0) { + if (Double.toInt(comp(left[i]!, right[j]!)) <= 0) { arr[k] = left[i]!; i++; } else { @@ -7959,7 +7959,7 @@ export function sort_default(arr: FixedArray, arrStr: FixedArray, export function reduce(self: Array, callbackfn: (previousValue: T, currentValue: U, index: number, array: Array) => T, initialValue: T): T { let acc = initialValue for (let i = 0; i < self.length; i++) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } diff --git a/static_core/plugins/ets/stdlib/std/core/BuiltinArraySort.ets b/static_core/plugins/ets/stdlib/std/core/BuiltinArraySort.ets index 9a53b52cb5958057e89059a905b826713256e685..c41e3f80c1708f8c69890a764c9c2ae9bacafc84 100644 --- a/static_core/plugins/ets/stdlib/std/core/BuiltinArraySort.ets +++ b/static_core/plugins/ets/stdlib/std/core/BuiltinArraySort.ets @@ -930,7 +930,7 @@ function countSort(arr: FixedArray, startIndex: int, endIndex: int): void let idx = 0 for (let i = 0; i < 256; i++) { for (let j = 0; j < cnts[i]; j++) { - arr[startIndex + idx++] = (i - 128) as byte + arr[startIndex + idx++] = Int.toByte(i - 128) } } } @@ -5567,7 +5567,7 @@ export function test_sortAllOn(arr: FixedArray) { } // ======== end of tests section ======== -function bubbleSort(arr: FixedArray, startIndex: int, endIndex: int, mustPrecede: (lhs: NullishType, rhs: NullishType) => boolean): void { +function bubbleSort(arr: FixedArray, startIndex: int, endIndex: int, mustPrecede: (lhs: T, rhs: T) => boolean): void { let was = true while (was) { was = false @@ -5582,7 +5582,7 @@ function bubbleSort(arr: FixedArray, startIndex: int, endIndex: int } } -function insertionSort(arr: FixedArray, startIndex: int, endIndex: int, mustPrecede: (lhs: NullishType, rhs: NullishType) => boolean, initIndex: int = startIndex): void { +function insertionSort(arr: FixedArray, startIndex: int, endIndex: int, mustPrecede: (lhs: T, rhs: T) => boolean, initIndex: int = startIndex): void { if (startIndex != initIndex) { // arr[startIndex - 1] exists and is less than or equal to all elements in range for (let i = startIndex + 1; i < endIndex; i++) { @@ -5613,7 +5613,7 @@ function insertionSort(arr: FixedArray, startIndex: int, endIndex: } } } -function heapSortUp(arr: FixedArray, idxFromStart: int, startIndex: int, heapRoot: int, mustPrecede: (lhs: NullishType, rhs: NullishType) => boolean): void { +function heapSortUp(arr: FixedArray, idxFromStart: int, startIndex: int, heapRoot: int, mustPrecede: (lhs: T, rhs: T) => boolean): void { const tmp = arr[startIndex + idxFromStart] while (startIndex + idxFromStart > heapRoot) { const p = (idxFromStart - 1) / 2 @@ -5627,7 +5627,7 @@ function heapSortUp(arr: FixedArray, idxFromStart: int, startIndex: } // Build max heap with root in startIndex given its children are roots of valid heaps -function heapSortDown(arr: FixedArray, idxFromStart: int, startIndex: int, endIndex: int, mustPrecede: (lhs: NullishType, rhs: NullishType) => boolean): void { +function heapSortDown(arr: FixedArray, idxFromStart: int, startIndex: int, endIndex: int, mustPrecede: (lhs: T, rhs: T) => boolean): void { let heapRoot = startIndex + idxFromStart let arrIndex = heapRoot let childIndex = startIndex + idxFromStart * 2 + 1 @@ -5650,7 +5650,7 @@ function heapSortDown(arr: FixedArray, idxFromStart: int, startInde heapSortUp(arr, arrIndex - startIndex, startIndex, heapRoot, mustPrecede) } -export function heapSort(arr: FixedArray, startIndex: int, endIndex: int, mustPrecede: (lhs: NullishType, rhs: NullishType) => boolean): void { +export function heapSort(arr: FixedArray, startIndex: int, endIndex: int, mustPrecede: (lhs: T, rhs: T) => boolean): void { let len = endIndex - startIndex for (let i = len / 2 - 1; i >= 0; i--) { heapSortDown(arr, i, startIndex, endIndex, mustPrecede) @@ -5666,7 +5666,7 @@ export function heapSort(arr: FixedArray, startIndex: int, endIndex } // Put median of three array elements to arr[index1] -function median3(arr: FixedArray, index1: int, index2: int, index3: int, mustPrecede: (lhs: NullishType, rhs: NullishType) => boolean): void { +function median3(arr: FixedArray, index1: int, index2: int, index3: int, mustPrecede: (lhs: T, rhs: T) => boolean): void { let swap_idx = index2 if (mustPrecede(arr[index1], arr[index2])) { if (mustPrecede(arr[index3], arr[index1])) { @@ -5690,7 +5690,7 @@ function median3(arr: FixedArray, index1: int, index2: int, index3: // Split range [startIndex, endIndex) by pivot arr[startIndex] and return pivot position // Elements equal to pivot go to the right -function quickSortSplit(arr: FixedArray, startIndex: int, endIndex: int, mustPrecede: (lhs: NullishType, rhs: NullishType) => boolean): int { +function quickSortSplit(arr: FixedArray, startIndex: int, endIndex: int, mustPrecede: (lhs: T, rhs: T) => boolean): int { const pivot = arr[startIndex] let i = startIndex + 1 let j = endIndex - 1 @@ -5724,7 +5724,7 @@ function quickSortSplit(arr: FixedArray, startIndex: int, endIndex: // Split range [startIndex, endIndex) by pivot arr[startIndex] and return pivot position // Elements equal to pivot go to the left -function quickSortSplitLeft(arr: FixedArray, startIndex: int, endIndex: int, mustPrecede: (lhs: NullishType, rhs: NullishType) => boolean): int { +function quickSortSplitLeft(arr: FixedArray, startIndex: int, endIndex: int, mustPrecede: (lhs: T, rhs: T) => boolean): int { const pivot = arr[startIndex] let i = startIndex + 1 let j = endIndex - 1 @@ -5755,7 +5755,7 @@ function quickSortSplitLeft(arr: FixedArray, startIndex: int, endIn return j } -function quickSortImpl3(arr: FixedArray, startIndex: int, endIndex: int, maxDepth: int, mustPrecede: (lhs: NullishType, rhs: NullishType) => boolean): void { +function quickSortImpl3(arr: FixedArray, startIndex: int, endIndex: int, maxDepth: int, mustPrecede: (lhs: T, rhs: T) => boolean): void { while (endIndex - startIndex > 3) { if (--maxDepth == 0) { heapSort(arr, startIndex, endIndex, mustPrecede) @@ -5775,7 +5775,7 @@ function quickSortImpl3(arr: FixedArray, startIndex: int, endIndex: } insertionSort(arr, startIndex, endIndex, mustPrecede) } -function quickSortImpl40(arr: FixedArray, startIndex: int, endIndex: int, maxDepth: int, mustPrecede: (lhs: NullishType, rhs: NullishType) => boolean): void { +function quickSortImpl40(arr: FixedArray, startIndex: int, endIndex: int, maxDepth: int, mustPrecede: (lhs: T, rhs: T) => boolean): void { while (endIndex - startIndex > 40) { if (--maxDepth == 0) { heapSort(arr, startIndex, endIndex, mustPrecede) @@ -5796,7 +5796,7 @@ function quickSortImpl40(arr: FixedArray, startIndex: int, endIndex insertionSort(arr, startIndex, endIndex, mustPrecede) } -function quickSort(arr: FixedArray, startIndex: int, endIndex: int, mustPrecede: (lhs: NullishType, rhs: NullishType) => boolean): void { +function quickSort(arr: FixedArray, startIndex: int, endIndex: int, mustPrecede: (lhs: T, rhs: T) => boolean): void { let size = endIndex - startIndex if (size <= 1) { return @@ -5826,7 +5826,7 @@ function quickSort(arr: FixedArray, startIndex: int, endIndex: int, * sort(arr, 0, arr.length) * ``` */ -export function sort_subarray(arr: FixedArray, startIndex: int, endIndex: int, mustPrecede: (lhs: NullishType, rhs: NullishType) => boolean): void { +export function sort_subarray(arr: FixedArray, startIndex: int, endIndex: int, mustPrecede: (lhs: T, rhs: T) => boolean): void { if (!checkRange(arr.length, startIndex, endIndex)) { throw new ArrayIndexOutOfBoundsError("sort: bounds verification failed") } @@ -5839,11 +5839,11 @@ export function sort_subarray(arr: FixedArray, startIndex: int, end * * @param arr an array to sort */ -export function sort_subarray(arr: FixedArray, mustPrecede: (lhs: NullishType, rhs: NullishType) => boolean): void { +export function sort_subarray(arr: FixedArray, mustPrecede: (lhs: T, rhs: T) => boolean): void { sort_subarray(arr, 0, arr.length, mustPrecede); } -export function sort_subarray(arr: FixedArray, startIndex: int, mustPrecede: (lhs: NullishType, rhs: NullishType) => boolean): void { +export function sort_subarray(arr: FixedArray, startIndex: int, mustPrecede: (lhs: T, rhs: T) => boolean): void { sort_subarray(arr, startIndex, arr.length, mustPrecede) } diff --git a/static_core/plugins/ets/stdlib/std/core/Byte.ets b/static_core/plugins/ets/stdlib/std/core/Byte.ets index d3f6d952c8117167d1bf165e52efb84bcdd6bcff..b6eec4c0d662dc2a6b7ea2f0c019c6a93e1473b7 100644 --- a/static_core/plugins/ets/stdlib/std/core/Byte.ets +++ b/static_core/plugins/ets/stdlib/std/core/Byte.ets @@ -195,6 +195,17 @@ export final class Byte extends Integral implements Comparable, JSONable, JSONable, JSONable, JSONable, JSONable, JSONable, JSONable, JSONable, JSONable, JSONable, JSONable, JSONable, JSONable, JSONable= 0 && codePoint <= Char.MAX_CODE_POINT && - !(codePoint >= (Char.HIGH_SURROGATE_MIN as int) && codePoint <= (Char.LOW_SURROGATE_MAX as int))); + !(codePoint >= (Char.HIGH_SURROGATE_MIN.toInt()) && codePoint <= (Char.LOW_SURROGATE_MAX.toInt()))); } /** @@ -267,7 +393,7 @@ export final class Char extends Object implements Comparable, JSONable>> 10) + Char.HIGH_SURROGATE_MIN) as char + return Int.toChar(((value - 0x10000) >>> 10) + Char.HIGH_SURROGATE_MIN) } /** @@ -279,7 +405,7 @@ export final class Char extends Object implements Comparable, JSONable(); for (let column of columns) { this.tableModel.set(column, new Array()); - this.columnWidths.set(column, column.length as int); + this.columnWidths.set(column, Double.toInt(column.length)); } this.rowsCount = 0; } @@ -652,7 +652,7 @@ class DataFrame { const value = row.get(key) ?? "-"; this.tableModel.get(key)!.push(value); const currentWidth = this.columnWidths.get(key)!; - const valueLength = value.length as int; + const valueLength = Double.toInt(value.length); this.columnWidths.set(key, currentWidth < valueLength ? valueLength @@ -678,8 +678,8 @@ class DataFrame { ): string { const connLength: int = this._indexColumnWidth - - (connectorLeft.length as int) - - (connectorRight.length as int); + Double.toInt(connectorLeft.length) - + Double.toInt(connectorRight.length); const conn: string = ch.repeat(connLength); let border: string = `${connectorLeft}${conn}`; for (const col of this.tableModel.keys()) { diff --git a/static_core/plugins/ets/stdlib/std/core/ConsoleHelper.ets b/static_core/plugins/ets/stdlib/std/core/ConsoleHelper.ets index 0a8c6f30e4c40c7a0dee6fb227c213df0ab9fe8f..ca23797f1977e655c826e3c5566ccc0dd5a318ce 100644 --- a/static_core/plugins/ets/stdlib/std/core/ConsoleHelper.ets +++ b/static_core/plugins/ets/stdlib/std/core/ConsoleHelper.ets @@ -293,11 +293,10 @@ export class Formatter { return s.replaceAll("%%", "%") } - while((i = (ss = s.substring(preI, s.length)).search("%") as int) != -1 && (preI + i < s.length - 1) && (argCounter < args.length)) { + while((i = Double.toInt((ss = s.substring(preI, s.length)).search("%"))) != -1 && (preI + i < s.length - 1) && (argCounter < args.length)) { res.append(s.substring(preI, preI + i)) let flagIndex = preI + i + 1 - //NOTE(ivan-tyulyandin): has to be string due to internal issue 21459 - let flag: string = s[flagIndex] + let flag: string = s[flagIndex].toString() if (flags.includes(flag)) { let d = args[argCounter] if (d != undefined && d != null) { diff --git a/static_core/plugins/ets/stdlib/std/core/Double.ets b/static_core/plugins/ets/stdlib/std/core/Double.ets index c2e6e564e83bb7970ab286f3730e8e5be540bf43..f5ece03096fe5628a8f2f8624c19161e721fabcd 100644 --- a/static_core/plugins/ets/stdlib/std/core/Double.ets +++ b/static_core/plugins/ets/stdlib/std/core/Double.ets @@ -238,6 +238,47 @@ export final class Double extends Floating implements Comparable, JSONab return Double.toFloat(this.value); } + /** + * Returns value of this instance + * + * @returns value as double + * @tag arkts + */ + public override toDouble(): double { + return this.value; + } + + /** + * Returns value of this instance + * + * @returns value as char + * @tag arkts + */ + public toChar(): char { + return Double.toChar(this.value); + } + + /** + * Returns the primitive as double value + * + * @param value value to cast + * + * @returns casted value + */ + public static toDouble(value: double): double { + return value; + } + + /** + * Returns the primitive as char value + * + * @param value value to cast + * + * @returns casted value + */ + public static native toChar(value: double): char; + + /** * Returns the primitive as byte value * @@ -283,16 +324,6 @@ export final class Double extends Floating implements Comparable, JSONab */ public static native toFloat(value: double): float; - /** - * Returns value of this instance - * - * @returns value as double - * @tag arkts - */ - public override toDouble(): double { - return this.value; - } - /** * Compares this instance to other Double object * The result is less than 0 if this instance lesser than provided object @@ -305,7 +336,7 @@ export final class Double extends Floating implements Comparable, JSONab * @tag arkts */ public override compareTo(other: Double): int { - return (this.value - other.unboxed()) as int; + return Double.toInt(this.value - other); } /** @@ -329,7 +360,7 @@ export final class Double extends Floating implements Comparable, JSONab } public toString(d: Number): String { - return Double.toString(this.value, d as int); + return Double.toString(this.value, Double.toInt(d)); } /** @@ -343,29 +374,18 @@ export final class Double extends Floating implements Comparable, JSONab } /** - * Converts a number to a string by using the current locale - * - * @param locales + * Without an argument method returns just toString value * - * @param options + * @returns result of the conversion * - * @returns string representation */ public toLocaleString(): String { - return this.toLocaleString(undefined) + return new Intl.NumberFormat().format(this.value) } - /** - * Converts a number to a string by using the current or specified locale. - * - * @param locales - * - * @param options - * - * @returns string representation - */ - public toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string { - return new Intl.NumberFormat(intlLocalesToLanguageTags(locales), options).format(this.value) + public toLocaleString(locales: string | Intl.Locale | (string | Intl.Locale)[], options?: Intl.NumberFormatOptions): string { + const formatter = new Intl.NumberFormat(intlLocalesToLanguageTags(locales), options) + return formatter.format(this.value) } /** @@ -674,7 +694,7 @@ export final class Double extends Floating implements Comparable, JSONab if ((r < 2.0 || r > 36.0) && r != 0.0) { return NaN; } else { - return Double.parseIntCore(s.trim(), r as int); + return Double.parseIntCore(s.trim(), Double.toInt(r)); } } diff --git a/static_core/plugins/ets/stdlib/std/core/FinalizationRegistry.ets b/static_core/plugins/ets/stdlib/std/core/FinalizationRegistry.ets index bc7cbc2c6452faa35feb067c2ff73303bdf2659b..d8a4ff3c21047137a54d4286b8b5f9bd0b443f2f 100644 --- a/static_core/plugins/ets/stdlib/std/core/FinalizationRegistry.ets +++ b/static_core/plugins/ets/stdlib/std/core/FinalizationRegistry.ets @@ -21,7 +21,7 @@ package std.core; * FinalizationRegistry is coroutine-safe class. * - It is safe to pass an instance to another coroutines. * - It is safe to call methods from several coroutines. - * + * * Notes: * - Runtime doesn't provide any guarantees that the registered object will be * garbage collected (even if its dead). @@ -117,10 +117,10 @@ export final class FinalizationRegistry { * @returns size of the FinalizationRegistry */ public getSize(): int { - let count: int; + let count: int = 0; this.mutex.lockGuard(() => { for (let i = this.idxarr[0]; i != -1; i = this.idxarr[i]) { - count++; + ++count; } }); return count; @@ -220,7 +220,7 @@ export final class FinalizationRegistry { private allocTrimplet(): int { if (this.freeidx == -1) { - // The value selected relative to the internal issue + // The value selected relative to the internal issue const mult: int = this.idxarr.length < 1024 ? 32 : 2; this.enlarge_arrays(this.idxarr.length * mult); } diff --git a/static_core/plugins/ets/stdlib/std/core/Float.ets b/static_core/plugins/ets/stdlib/std/core/Float.ets index 4e3dfa4b48e77d984f31baffe99cb865e57e676a..ec9227ea2bc987d502ee2eb3fd6a49975edca948 100644 --- a/static_core/plugins/ets/stdlib/std/core/Float.ets +++ b/static_core/plugins/ets/stdlib/std/core/Float.ets @@ -25,7 +25,7 @@ export final class Float extends Floating implements Comparable, JSONable * Constructs a new Float instance with initial value zero */ public constructor() { - this.value = 0.0; + this.value = 0.0f; } /** @@ -43,7 +43,7 @@ export final class Float extends Floating implements Comparable, JSONable * @param value the initial value */ public constructor(value: double) { - this.value = value as float; + this.value = Double.toFloat(value); } /** @@ -70,12 +70,12 @@ export final class Float extends Floating implements Comparable, JSONable /** * Minimal value that this type can have as a float */ - public static readonly MIN_VALUE: float = 1.4e-45 as float; + public static readonly MIN_VALUE: float = Double.toFloat(1.4e-45); /** * Maximal value that this type can have as a float */ - public static readonly MAX_VALUE: float = 3.4028235e+38 as float; + public static readonly MAX_VALUE: float = Double.toFloat(3.4028235e+38); /** * Maximal integer value that can be used as a float without loss of precision @@ -96,17 +96,17 @@ export final class Float extends Floating implements Comparable, JSONable /** * Represents the NaN value according to IEEE-754 specification */ - public static readonly NaN: float = 0.0 / 0.0; + public static readonly NaN: float = Double.toFloat(0.0 / 0.0); /** * Represents the +Infinity value according to IEEE-754 specification */ - public static readonly POSITIVE_INFINITY: float = 1.0 / 0.0; + public static readonly POSITIVE_INFINITY: float = Double.toFloat(1.0 / 0.0); /** * Represents the -Infinity value according to IEEE-754 specification */ - public static readonly NEGATIVE_INFINITY: float = -1.0 / 0.0; + public static readonly NEGATIVE_INFINITY: float = Double.toFloat(-1.0 / 0.0); /** * Number of significant precision bits in this floating type @@ -178,6 +178,15 @@ export final class Float extends Floating implements Comparable, JSONable return Float.toDouble(this.value); } + /** + * Returns value of this instance + * + * @returns value as char + */ + public toChar(): char { + return Float.toChar(this.value); + } + /** * Returns the primitive as byte value * @@ -214,6 +223,17 @@ export final class Float extends Floating implements Comparable, JSONable */ public static native toLong(value: float): long; + /** + * Returns the primitive as double value + * + * @param value value to cast + * + * @returns casted value + */ + public static toFloat(value: float): float { + return value; + } + /** * Returns the primitive as double value * @@ -223,6 +243,15 @@ export final class Float extends Floating implements Comparable, JSONable */ public static native toDouble(value: float): double; + /** + * Returns the primitive as char value + * + * @param value value to cast + * + * @returns casted value + */ + public static native toChar(value: float): char; + /** * Compares this instance to other Float object * The result is less than 0 if this instance lesser than provided object @@ -234,7 +263,7 @@ export final class Float extends Floating implements Comparable, JSONable * @returns result of the comparison */ public override compareTo(other: Float): int { - return (this.value - other.unboxed()) as int; + return Float.toInt(this.value - other.unboxed()); } /** @@ -359,7 +388,7 @@ export final class Float extends Floating implements Comparable, JSONable */ public static isInteger(v: float): boolean { // In the language % works as C fmod that differs with IEEE-754 % definition - return Float.compare(v % (1.0 as float), 0.0 as float); + return Float.compare(v % 1.0f, 0.0f); } /** @@ -508,7 +537,7 @@ export final class Float extends Floating implements Comparable, JSONable if (json instanceof JSONNumber) { let val = (json as JSONNumber).value if (-Float.MAX_VALUE <= val && val <= Float.MAX_VALUE) { - return Float.valueOf((json as JSONNumber).value as float) + return Float.valueOf(Double.toFloat((json as JSONNumber).value)) } } throw new JSONTypeError("Cannot create Double from JSON", new ErrorOptions(json as Object)) diff --git a/static_core/plugins/ets/stdlib/std/core/Int.ets b/static_core/plugins/ets/stdlib/std/core/Int.ets index 229d84aaa96a5ebd4a53dea1fbdc0e45771aba7f..fac4f57f4470cfa5e2433680d59a194152c8bf34 100644 --- a/static_core/plugins/ets/stdlib/std/core/Int.ets +++ b/static_core/plugins/ets/stdlib/std/core/Int.ets @@ -195,6 +195,17 @@ export final class Int extends Integral implements Comparable, JSONable, JSONable, JSONable, JSONable, JSONable 36) { + if (Double.toInt(radix) < 2 || Double.toInt(radix) > 36) { throw new RangeError('Radix must be between 2 and 36'); } if (this.value == 0) { @@ -233,19 +244,19 @@ export final class Long extends Integral implements Comparable, JSONable = new char[digitsNum]; let curPlace = digitsNum - 1; while (val != 0) { - let remainder = val % (radix as int); + let remainder = val % Double.toInt(radix); if (negative) { remainder = -remainder; } - data[curPlace] = chars.charAt(remainder as int); - val /= (radix as int); + data[curPlace] = chars.charAt(Long.toInt(remainder)); + val /= Double.toInt(radix); curPlace -= 1; } if (negative) { @@ -384,7 +395,7 @@ export final class Long extends Integral implements Comparable, JSONable = new (AbcFile | undefined)[rawAbcFiles.length as int]; + const abcFiles : FixedArray = new (AbcFile | undefined)[Double.toInt(rawAbcFiles.length)]; for (let i = 0; i < rawAbcFiles.length; i++) { abcFiles[i] = AbcFile.loadFromMemory(this, rawAbcFiles[i]); } diff --git a/static_core/plugins/ets/stdlib/std/core/Object.ets b/static_core/plugins/ets/stdlib/std/core/Object.ets index 49695a916392b8a21c7686ae07781c864f29782e..d5263c8ce9062a2ba8c28d4ec8a3f3a04b96ac10 100644 --- a/static_core/plugins/ets/stdlib/std/core/Object.ets +++ b/static_core/plugins/ets/stdlib/std/core/Object.ets @@ -81,7 +81,7 @@ export class Object { * @returns an array of strings representing the given record's property names */ public static keys(rec: Record): string[] { - const keys: string[] = new string[rec.size as int] + const keys: string[] = new string[Double.toInt(rec.size)] let i = 0 for (const key of rec.keys()) { @@ -154,7 +154,7 @@ export class Object { if (len == 0) { return new string[0] } - let res: string[] = new string[len as int] + let res: string[] = new string[Long.toInt(len)] for (let i = 0; i < len; i++) { // NOTE(shumilov-petr): need to apply more effective way for int to String conversion res[i] = new Int(i).toString() @@ -177,7 +177,7 @@ export class Object { } public static values(rec: Record): NullishType[] { - const vals: NullishType[] = new NullishType[rec.size as int] + const vals: NullishType[] = new NullishType[Double.toInt(rec.size)] let i = 0 for (let val of rec.values()) { @@ -238,7 +238,7 @@ export class Object { if (len == 0) { return new NullishType[0] } - let res: NullishType[] = new NullishType[len as int] + let res: NullishType[] = new NullishType[Long.toInt(len)] for (let i = 0; i < len; i++) { res[i] = av.getElement(i).getData() } @@ -267,7 +267,7 @@ export class Object { * @returns array representation of key/value */ public static entries(rec: Record): NullishEntryType[] { - const entries: NullishEntryType[] = new NullishEntryType[rec.size as int] + const entries: NullishEntryType[] = new NullishEntryType[Double.toInt(rec.size)] let i = 0 for (const entry of rec.entries()) { @@ -327,7 +327,7 @@ export class Object { if (len == 0) { return new NullishEntryType[0] } - let res: NullishEntryType[] = new NullishEntryType[len as int] + let res: NullishEntryType[] = new NullishEntryType[Long.toInt(len)] for (let i = 0; i < len; i++) { res[i] = [new Int(i).toString(), av.getElement(i).getData()] as EntryType } @@ -428,14 +428,14 @@ export class Object { if ((this) instanceof String) { const sv = this as String const len = sv.getLength() - const idx = index as long + const idx = Double.toLong(index) return (0 <= idx && idx < len) } const t = Type.of(this) if (t instanceof ArrayType) { const av = Value.of(this) as ArrayValue const len = av.getLength() - const idx = index as long + const idx = Double.toLong(index) return (0 <= idx && idx < len) } else if (t instanceof EnumType) { // NOTE(shumilov-petr): Not implemented @@ -492,7 +492,7 @@ export class Object { while (!entriesIterResult.done) { const entry: [PropertyKey, T] | undefined = entriesIterResult.value if (entry != undefined) { - result[entry[0]] = entry[1] + result[entry[0] as PropertyKey] = entry[1] as T } entriesIterResult = entriesIter.next() @@ -514,7 +514,7 @@ export class Object { for (const s of source) { const entries = Object.entries(s) for (const e of entries) { - target.set(e![0], e![1]) + target.set(e![0] as PropertyKey, e![1] as NullishType) } } return target diff --git a/static_core/plugins/ets/stdlib/std/core/Segmenter.sts b/static_core/plugins/ets/stdlib/std/core/Segmenter.sts index 26a515af69beeb313b569594c61340eff30e1747..010c5a455f5e8b431aac8f61b94675413c99264b 100644 --- a/static_core/plugins/ets/stdlib/std/core/Segmenter.sts +++ b/static_core/plugins/ets/stdlib/std/core/Segmenter.sts @@ -26,7 +26,7 @@ type SegmenterGranularity = 'grapheme' | 'word' | 'sentence'; class Cluster { /** The text content of the cluster */ cluster: string; - + /** Indicates whether the cluster is word-like */ isWordLike: boolean; @@ -49,13 +49,13 @@ class Cluster { export interface SegmentData { /** The index of the segment in the original text */ index: number; - + /** The original input text */ input: string; - + /** Indicates if the segment is word-like (optional) */ isWordLike: boolean | undefined; - + /** The text content of the segment */ segment: string; } @@ -111,15 +111,15 @@ function TryToSegmentData( clusterData: Cluster, granularity: SegmenterGranularity, input: string -): SegmentDataImpl +): SegmentDataImpl { return new SegmentDataImpl( clusterData.index, input, clusterData.cluster, - granularity == "word" + granularity == "word" ? clusterData.isWordLike - : undefined + : undefined ) } @@ -165,14 +165,14 @@ export class Segments implements IterableIterator { this.parent = parent } - public override $_iterator(): IterableIterator + public override $_iterator(): IterableIterator { return this } - override next(): IteratorResult + override next(): IteratorResult { - if (this.idx < 0 || this.idx >= this.parent.length as int) { + if (this.idx < 0 || this.idx >= Double.toInt(this.parent.length)) { return new IteratorResult() } return new IteratorResult(false, this.parent[this.idx++]) @@ -184,8 +184,8 @@ export class Segments implements IterableIterator { * A specialized class for text segmentation across different linguistic granularities */ export class Segmenter { - /** - * Native static methods for cluster generation across different segmentation types + /** + * Native static methods for cluster generation across different segmentation types */ private native static graphemeClusters(str: string, locale: string): Cluster[] @@ -197,20 +197,20 @@ export class Segmenter { /** * Creates a new Segmenter instance with specified locales and options - * + * * @param locales Optional locale or array of locales for segmentation * @param options Optional segmentation configuration - * + * * @remarks * - Supports single or multiple locales * - Automatically resolves the best-fit locale * - Defaults to grapheme granularity if not specified */ public constructor( - locales?: BCP47LanguageTag | BCP47LanguageTag[], + locales?: BCP47LanguageTag | BCP47LanguageTag[], options?: SegmenterOptions ) { - const picked = {localeMatcher: options?.localeMatcher} + const picked = {localeMatcher: options?.localeMatcher} as PickLocaleMatchSegmenterOptions; const supported = Segmenter.supportedLocalesOf(locales ?? "", picked); this._locale = supported[0] ?? LocaleMatch.bestFitLocale(""); @@ -219,7 +219,7 @@ export class Segmenter { /** * Segments a document into clusters based on the configured granularity - * + * * @param doc The input text to segment * @returns A Segments iterator containing segmented data */ @@ -227,24 +227,24 @@ export class Segmenter { console.log("Segmentize", doc); console.log("Granularity", this._granularity); console.log("Locale", this._locale); - + let result = this.segmentWith(doc, this._granularity) let segments = new SegmentDataImpl[result.length]; for (let i = 0; i < result.length; ++i) { segments[i] = TryToSegmentData(result[i], this._granularity, doc); } - + return new Segments(segments); } /** * Internal method to perform segmentation based on granularity - * + * * @param doc The input text to segment * @param granularity The type of segmentation to perform * @returns An array of Cluster representing the segments - * + * * @privateRemarks * Defaults to grapheme segmentation if an unknown granularity is provided */ @@ -262,7 +262,7 @@ export class Segmenter { /** * Retrieves the resolved options for the current Segmenter instance - * + * * @returns The fully resolved segmentation options */ public resolvedOptions(): ResolvedSegmenterOptions { @@ -274,26 +274,26 @@ export class Segmenter { /** * Returns an array of supported locales for text segmentation - * + * * @param locales An array of BCP 47 language tags to check * @param options Optional configuration for locale matching * @returns An array of supported locales from the input - * + * * @remarks * - Validates which of the provided locales are supported by the Segmenter * - Uses the specified locale matching strategy * - Helps developers determine locale compatibility before creating a Segmenter instance */ public static supportedLocalesOf( - locales: BCP47LanguageTag | BCP47LanguageTag[], + locales: BCP47LanguageTag | BCP47LanguageTag[], options?: PickLocaleMatchSegmenterOptions, - ): BCP47LanguageTag[] + ): BCP47LanguageTag[] { const matchingStrategy = options?.localeMatcher ?? 'best fit'; try { return [ matchingStrategy == 'lookup' - ? intlLookUpLocale(locales) + ? intlLookUpLocale(locales) : intlBestFitLocale(locales) ] } diff --git a/static_core/plugins/ets/stdlib/std/core/Short.ets b/static_core/plugins/ets/stdlib/std/core/Short.ets index ce69e9d8864629a6f2e1ed51edda568fd2f8d87e..adfaa120b0b5f322c617d60f1b2f3ec22b76fb98 100644 --- a/static_core/plugins/ets/stdlib/std/core/Short.ets +++ b/static_core/plugins/ets/stdlib/std/core/Short.ets @@ -195,6 +195,17 @@ export final class Short extends Integral implements Comparable, JSONable */ public static native toChar(value: short): char; + /** + * Returns the primitive as short value + * + * @param value value to cast + * + * @returns casted value + */ + public static toShort(value: short): short { + return value; + } + /** * Compares this instance to other Short object * The result is less than 0 if this instance lesser than provided object @@ -264,7 +275,7 @@ export final class Short extends Integral implements Comparable, JSONable * @returns Result of the addition */ public add(other: Short): Short { - return Short.valueOf((this.value + other.toShort()) as short) + return Short.valueOf(Int.toShort(this.value + other.toShort())) } /** @@ -275,7 +286,7 @@ export final class Short extends Integral implements Comparable, JSONable * @returns Result of the subtraction */ public sub(other: Short): Short { - return Short.valueOf((this.value - other.toShort()) as short) + return Short.valueOf(Int.toShort(this.value - other.toShort())) } /** @@ -286,7 +297,7 @@ export final class Short extends Integral implements Comparable, JSONable * @returns Result of the multiplication */ public mul(other: Short): Short { - return Short.valueOf((this.value * other.toShort()) as short) + return Short.valueOf(Int.toShort(this.value * other.toShort())) } /** @@ -297,7 +308,7 @@ export final class Short extends Integral implements Comparable, JSONable * @returns Result of the division */ public div(other: Short): Short { - return Short.valueOf((this.value / other.toShort()) as short) + return Short.valueOf(Int.toShort(this.value / other.toShort())) } /** @@ -357,7 +368,7 @@ export final class Short extends Integral implements Comparable, JSONable if (json instanceof JSONNumber) { let num = (json as JSONNumber).value if (Double.isInteger(num) && Short.MIN_VALUE <= num && num <= Short.MAX_VALUE) { - return Short.valueOf(num as short) + return Short.valueOf(Double.toShort(num)) } } throw new JSONTypeError("Cannot create Short from JSON", new ErrorOptions(json as Object)) diff --git a/static_core/plugins/ets/stdlib/std/core/String.ets b/static_core/plugins/ets/stdlib/std/core/String.ets index a8cce2850fe5d9c7366963a352c6ecb5ed522b45..f2c6a0762c10b971948a06a08cc14706c585606c 100644 --- a/static_core/plugins/ets/stdlib/std/core/String.ets +++ b/static_core/plugins/ets/stdlib/std/core/String.ets @@ -94,7 +94,7 @@ export final class String extends Object implements Comparable, JSONable * @returns a primitive at index */ public $_get(index: number): char { - return this.$_get(index as int); + return this.$_get(Double.toInt(index)); } /** @@ -136,7 +136,18 @@ export final class String extends Object implements Comparable, JSONable * @returns length of this string */ public get length(): number { - return this.getLength() as number + return Int.toDouble(this.getLength()) + } + + /** + * Returns the value + * + * @param value value to cast + * + * @returns casted value + */ + public static toString(value: String): String { + return value; } /** @@ -156,7 +167,7 @@ export final class String extends Object implements Comparable, JSONable return ""; } let c : FixedArray = new char[1]; - c[0] = this.charAt(index as int) + c[0] = this.charAt(Double.toInt(index)) return new String(c) } @@ -198,7 +209,7 @@ export final class String extends Object implements Comparable, JSONable if (index < 0 || index >= this.getLength() || this.getLength() == 0) { return undefined } - return this.codePointAtInt(index as int) as number; + return Int.toDouble(this.codePointAtInt(Double.toInt(index))); } /** @@ -216,7 +227,7 @@ export final class String extends Object implements Comparable, JSONable if (index < 0 || index >= this.getLength() || this.getLength() == 0) { return undefined } - return this.codePointAtInt(index) as number; + return Int.toDouble(this.codePointAtInt(index)); } /** @@ -233,11 +244,11 @@ export final class String extends Object implements Comparable, JSONable private codePointAtInt(index: int): int { let highValue: char = this.charAt(index); if (!Char.isHighSurrogate(highValue) || ++index == this.getLength()) { - return highValue as int; + return Char.toInt(highValue); } let lowValue: char = this.charAt(index); if (!Char.isLowSurrogate(lowValue)) { - return highValue as int; + return Char.toInt(highValue); } return Char.charsToCodePoint(highValue, lowValue); } @@ -257,7 +268,7 @@ export final class String extends Object implements Comparable, JSONable * @returns the amount of completed codepoints */ public codePointCount(begin: number, end: number): number { - return this.codePointCount(begin as int, end as int) + return this.codePointCount(Double.toInt(begin), Double.toInt(end)) } /** @@ -320,11 +331,11 @@ export final class String extends Object implements Comparable, JSONable public getChars(begin: int, end: int): char[] { // #24515: Need to remove the following function call after primitive type refactoring let ret : FixedArray = this.getCharsImpl(begin, end); - let tmpForceBox : FixedArray = new Char[ret.length]; + let tmpForceBox : Array = new Array(ret.length); for (let i = 0; i < tmpForceBox.length; i++) { tmpForceBox[i] = ret[i] } - return Array.from(tmpForceBox); + return tmpForceBox; } private native getCharsImpl(begin: int, end: int): FixedArray; @@ -346,11 +357,11 @@ export final class String extends Object implements Comparable, JSONable public getBytes(begin: int, end: int): byte[] { // #24515: Need to remove the following function call after primitive type refactoring let ret : FixedArray = this.getBytesImpl(begin, end); - let tmpForceBox : FixedArray = new Byte[ret.length]; + let tmpForceBox: Array = new Array(ret.length); for (let i = 0; i < tmpForceBox.length; i++) { tmpForceBox[i] = ret[i] } - return Array.from(tmpForceBox); + return tmpForceBox; } private native getBytesImpl(begin: int, end: int): FixedArray; @@ -572,7 +583,7 @@ export final class String extends Object implements Comparable, JSONable * @returns new String which is a substring of this String */ public substring(begin: number, end?: Number): String { - return this.substring(begin as int, asIntOrDefault(end, this.getLength())) + return this.substring(Double.toInt(begin), asIntOrDefault(end, this.getLength())) } /** @@ -684,7 +695,7 @@ export final class String extends Object implements Comparable, JSONable * @returns true if this String contains str and false otherwise */ public contains(str: String, fromIndex: number): boolean { - return this.contains(str, fromIndex as int); + return this.contains(str, Double.toInt(fromIndex)); } /** @@ -757,7 +768,7 @@ export final class String extends Object implements Comparable, JSONable } else if (limit == 0) { return new String[0] } else { - lim = limit.unboxed() as long + lim = Double.toLong(limit) } let s = this.getLength() if (s == 0) { @@ -1019,7 +1030,7 @@ export final class String extends Object implements Comparable, JSONable * @returns this string that is repeated count times */ public repeat(count: number): String { - return this.repeat(count as int) + return this.repeat(Double.toInt(count)) } /** @@ -1073,7 +1084,7 @@ export final class String extends Object implements Comparable, JSONable if (index < 0 || index >= n) { return undefined; } - return new String(this.charAt(index as int)); + return new String(this.charAt(Double.toInt(index)).toString()); } private CreateHTMLString(tag: String, param: String): String{ @@ -1196,14 +1207,14 @@ export final class String extends Object implements Comparable, JSONable if (index < 0 || index >= this.getLength() || this.getLength() == 0) { return NaN; } - return this.charAt(index as int); + return this.charAt(Double.toInt(index)); } /* * The charCodeAt() method returns an integer between 0 and 65535 representing the UTF-16 code unit at the given index. */ public charCodeAt(index: int): int { - return this.charAt(index) as int; + return Char.toInt(this.charAt(index)); } /** @@ -1264,7 +1275,7 @@ export final class String extends Object implements Comparable, JSONable */ public padEnd(maxLength: number, fillString?: String): String { const str = (fillString == undefined) ? "\u0020" : fillString - return this.padEnd(maxLength as int, str) + return this.padEnd(Double.toInt(maxLength), str) } /* @@ -1322,7 +1333,7 @@ export final class String extends Object implements Comparable, JSONable */ public padStart(maxLength: number, fillString?: String): String { const str = (fillString == undefined) ? "\u0020" : fillString - return this.padStart(maxLength as int, str) + return this.padStart(Double.toInt(maxLength), str) } /* @@ -1379,11 +1390,7 @@ export final class String extends Object implements Comparable, JSONable * @returns new string containing the specified part of the given string */ public substr(begin: number, length?: Number): String { - return this.substr(begin as int, asIntOrDefault(length, this.getLength())); - } - - public substr(begin: number, length: number): String { - return this.substr(begin as int, length as int); + return this.substr(Double.toInt(begin), asIntOrDefault(length, this.getLength())); } /* @@ -1438,10 +1445,6 @@ export final class String extends Object implements Comparable, JSONable return this.substring(normalizeIndex(begin, this.getLength())) } - //public slice(begin: number, end: number): String { - // return this.slice(begin as int, end as int) - //} - public slice(begin: int, end: int): String { begin = normalizeIndex(begin, this.getLength()) end = normalizeIndex(end, this.getLength()) @@ -1574,7 +1577,7 @@ export final class String extends Object implements Comparable, JSONable } let preceding = this.substring(0, position) let following = this.substring(position + searchLength) - let replacement = String.getSubstitution(searchValue, this, position as int, new String[0], undefined, replaceValue) + let replacement = String.getSubstitution(searchValue, this, Double.toInt(position), new String[0], undefined, replaceValue) return preceding + replacement + following } @@ -1643,7 +1646,7 @@ export final class String extends Object implements Comparable, JSONable let matchPositions = new ArrayAsListInt(); let position = this.indexOf(searchValue, 0) while (position != -1) { - matchPositions.pushBack(position) + matchPositions.pushBack(Double.toInt(position)) if (position == this.getLength()) { break; } @@ -1698,7 +1701,7 @@ export final class String extends Object implements Comparable, JSONable let matchPositions = new ArrayAsListInt(); let position = this.indexOf(searchValue, 0) while (position != -1) { - matchPositions.pushBack(position) + matchPositions.pushBack(Double.toInt(position)) position = this.indexOf(searchValue, position + advanceBy) } let endOfLastMatch = 0 @@ -1885,7 +1888,7 @@ export final class String extends Object implements Comparable, JSONable res.append(REPLACEMENT_CHARACTER); // Regular Characters } else if (Char.isValidCodePoint(codeUnit)) { - res.append(this.charAt(i) as char); + res.append(this.charAt(i).toChar()); } else { res.append(REPLACEMENT_CHARACTER); } @@ -1910,11 +1913,11 @@ export final class String extends Object implements Comparable, JSONable if (cp < 0 || cp > MAX_CODE_POINT || isNaN(cp) || !Number.isInteger(cp)) { throw new RangeError("Invalid code point: " + new Number(cp).toString()) } - let chrs = String.codePointToChar(cp as int); - res.append((chrs & 0xffff) as char) + let chrs = String.codePointToChar(Double.toInt(cp)); + res.append(Int.toChar(chrs & 0xffff)) chrs = (chrs >> 16) & 0xffff if (chrs > 0) { - res.append(chrs as char); + res.append(Int.toChar(chrs)); } } return res.toString() @@ -1970,13 +1973,13 @@ class StringIterator implements IterableIterator { let highValue: char = this.s.charAt(this.idx); this.idx += 1 if (!Char.isHighSurrogate(highValue) || this.idx == this.s.getLength()) { - return new IteratorResult(String.fromCharCode(highValue as number)); + return new IteratorResult(String.fromCharCode(Char.toDouble(highValue))); } let lowValue: char = this.s.charAt(this.idx); if (!Char.isLowSurrogate(lowValue)) { - return new IteratorResult(String.fromCharCode(highValue as number)); + return new IteratorResult(String.fromCharCode(Char.toDouble(highValue))); } this.idx += 1 - return new IteratorResult(String.fromCharCode(highValue as number, lowValue as number)); + return new IteratorResult(String.fromCharCode(Char.toDouble(highValue), Char.toDouble(lowValue))); } } diff --git a/static_core/plugins/ets/stdlib/std/core/Type.ets b/static_core/plugins/ets/stdlib/std/core/Type.ets index bfe76e0f33d4d5197e7d6cdacd4da8c22c39ae9b..d825254c06764e3e0267359cb29215fc4154c969 100644 --- a/static_core/plugins/ets/stdlib/std/core/Type.ets +++ b/static_core/plugins/ets/stdlib/std/core/Type.ets @@ -144,7 +144,7 @@ export class TypeKind { } // 5 lower bits stores kind's id -const TypeKindMask: byte = (1 << 6) - 1 +const TypeKindMask: byte; // NOTE(shumilov-petr): replace to enum, enum not available now class ValueTypeDesc { @@ -221,7 +221,7 @@ export abstract class Type extends Object { * @returns instance of appropriate type or undefined if resolving is failed */ internal static resolve(td: RuntimeTypeDescriptor, contextLinker: RuntimeLinker): Type | undefined { - let kind = (TypeAPI.getTypeKind(td, contextLinker) & TypeKindMask) as byte + let kind = Int.toByte(TypeAPI.getTypeKind(td, contextLinker) & TypeKindMask) switch (kind) { case TypeKind.NONE: return undefined @@ -375,89 +375,6 @@ export abstract class Type extends Object { // ----- - public static of(v: Boolean): Type { - return BooleanType.REF - } - - /** - * Returns Type of value - * - * @param v value - * - * @returns Type instance of this value - */ - public static of(v: Char): Type { - return CharType.REF - } - - /** - * Returns Type of value - * - * @param v value - * - * @returns Type instance of this value - */ - public static of(v: Byte): Type { - return ByteType.REF - } - - /** - * Returns Type of value - * - * @param v value - * - * @returns Type instance of this value - */ - public static of(v: Short): Type { - return ShortType.REF - } - - /** - * Returns Type of value - * - * @param v value - * - * @returns Type instance of this value - */ - public static of(v: Int): Type { - return IntType.REF - } - - /** - * Returns Type of value - * - * @param v value - * - * @returns Type instance of this value - */ - public static of(v: Long): Type { - return LongType.REF - } - - /** - * Returns Type of value - * - * @param v value - * - * @returns Type instance of this value - */ - public static of(v: Float): Type { - return FloatType.REF - } - - /** - * Returns Type of value - * - * @param v value - * - * @returns Type instance of this value - */ - public static of(v: Double): Type { - return DoubleType.REF - } - - // ----- - /** * Returns Type of value * @@ -830,7 +747,7 @@ export final class UndefinedType extends Type { * Represents void type */ export final class VoidType extends Type { - public static readonly VAL: VoidType = new VoidType(ValueTypeDesc.VOID, true) + public static readonly VAL: VoidType = new VoidType(ValueTypeDesc.VOID, true) public static readonly REF: VoidType = new VoidType(TypeAPI.getTypeDescriptor(Void.void_instance), false) private readonly value: boolean @@ -2279,7 +2196,7 @@ export final class ArrayType extends Type { internal static getInstance(arrayClass: Class, elemTD?: RuntimeTypeDescriptor): ArrayType { elemTD = elemTD ?? TypeAPI.getArrayElementType(arrayClass) const contextLinker = arrayClass.getLinker() - let ek = (TypeAPI.getTypeKind(elemTD, contextLinker) & TypeKindMask) as byte + let ek = Int.toByte(TypeAPI.getTypeKind(elemTD, contextLinker) & TypeKindMask) switch (ek) { case TypeKind.BOOLEAN: return TypeAPI.isValueType(elemTD, contextLinker) ? ArrayType.BOOLEAN_VAL : ArrayType.BOOLEAN_REF diff --git a/static_core/plugins/ets/stdlib/std/core/TypeCreator.ets b/static_core/plugins/ets/stdlib/std/core/TypeCreator.ets index 07583a3707e13867b768fb18a5d97b138e69cd89..b4d9d4d4fc29b111c54e3607ecd066950b32b25b 100644 --- a/static_core/plugins/ets/stdlib/std/core/TypeCreator.ets +++ b/static_core/plugins/ets/stdlib/std/core/TypeCreator.ets @@ -314,7 +314,7 @@ final class TypeCreatorCtx { this.checkError() - const objsArray : FixedArray = new Object[this.objects.length as int] + const objsArray : FixedArray = new Object[Double.toInt(this.objects.length)] for (let i = 0; i < this.objects.length; i++) { objsArray[i] = this.objects.$_get(i) as Object } @@ -335,7 +335,7 @@ final class TypeCreatorCtx { internal registerObject(o: Object): int { const r = this.objects.length this.objects.push(o) - return r as int + return Double.toInt(r) } /** diff --git a/static_core/plugins/ets/stdlib/std/core/Value.ets b/static_core/plugins/ets/stdlib/std/core/Value.ets index 3fd0a696e024b15243435a1bede7040f3457b710..06f995a256c63f87d8f7f241b1e6df1db179a24f 100644 --- a/static_core/plugins/ets/stdlib/std/core/Value.ets +++ b/static_core/plugins/ets/stdlib/std/core/Value.ets @@ -170,40 +170,6 @@ export abstract class Value extends Object { // ----- - public static of(v: Boolean): Value { - return new BooleanValue(BooleanType.REF, v) - } - - public static of(v: Char): Value { - return new CharValue(CharType.REF, v) - } - - public static of(v: Byte): Value { - return new ByteValue(ByteType.REF, v) - } - - public static of(v: Short): Value { - return new ShortValue(ShortType.REF, v) - } - - public static of(v: Int): Value { - return new IntValue(IntType.REF, v) - } - - public static of(v: Long): Value { - return new LongValue(LongType.REF, v) - } - - public static of(v: Float): Value { - return new FloatValue(FloatType.REF, v) - } - - public static of(v: Double): Value { - return new DoubleValue(DoubleType.REF, v) - } - - // ----- - /** * Returns value of this object * @@ -778,10 +744,6 @@ export final class BooleanValue extends Value { this.data = data } - internal constructor(typ: BooleanType, data: Boolean) { - this(typ, data.unboxed()) - } - public override toPrint(depth: int): string { return new StringBuilder().append(this.data).toString() } @@ -819,10 +781,6 @@ export final class ByteValue extends Value { this.data = data } - internal constructor(typ: ByteType, data: Byte) { - this(typ, data.unboxed()) - } - public override toPrint(depth: int): string { return new StringBuilder().append(this.data).toString() } @@ -860,10 +818,6 @@ export final class ShortValue extends Value { this.data = data } - internal constructor(typ: ShortType, data: Short) { - this(typ, data.unboxed()) - } - public override toPrint(depth: int): string { return new StringBuilder().append(this.data).toString() } @@ -901,10 +855,6 @@ export final class CharValue extends Value { this.data = data } - internal constructor(typ: CharType, data: Char) { - this(typ, data.unboxed()) - } - public override toPrint(depth: int): string { return new StringBuilder("\"").append(this.data).append("\"").toString() } @@ -942,10 +892,6 @@ export final class IntValue extends Value { this.data = data } - internal constructor(typ: IntType, data: Int) { - this(typ, data.unboxed()) - } - public override toPrint(depth: int): string { return new StringBuilder().append(this.data).toString() } @@ -983,10 +929,6 @@ export final class FloatValue extends Value { this.data = data } - internal constructor(typ: FloatType, data: Float) { - this(typ, data.unboxed()) - } - public override toPrint(depth: int): string { return new StringBuilder().append(this.data).toString() } @@ -1024,10 +966,6 @@ export final class DoubleValue extends Value { this.data = data } - internal constructor(typ: DoubleType, data: Double) { - this(typ, data.unboxed()) - } - public override toPrint(depth: int): string { return new StringBuilder().append(this.data).toString() } @@ -1065,10 +1003,6 @@ export final class LongValue extends Value { this.data = data } - internal constructor(typ: LongType, data: Long) { - this(typ, data.unboxed()) - } - public override toPrint(depth: int): string { return new StringBuilder().append(this.data).toString() } diff --git a/static_core/plugins/ets/stdlib/std/core/_initializerBlock_.ets b/static_core/plugins/ets/stdlib/std/core/_initializerBlock_.ets index ba0a85e3a7ccf57b48cdcfe440c3e054f588a74f..2a46f54938dbd7a1101ff8e2acab87f114033a3c 100644 --- a/static_core/plugins/ets/stdlib/std/core/_initializerBlock_.ets +++ b/static_core/plugins/ets/stdlib/std/core/_initializerBlock_.ets @@ -16,6 +16,9 @@ package std.core; // Note: This file initialize all the `const` property that non-immediately initialized(spec-issue 217). static { + // 5 lower bits stores kind's id + TypeKindMask = ((1 << 6) - 1).toByte(); + ObjectType = Type.of(new Object()) as ClassType; console = new Console(); coroutine = new Coroutine(); diff --git a/static_core/plugins/ets/stdlib/std/interop/ESValue.ets b/static_core/plugins/ets/stdlib/std/interop/ESValue.ets index 9ec7fe7c5976741d3de2dedb392fedfd10a815b3..a8ae02b671e53f3e510473f8dd3c0e681c97d7fd 100644 --- a/static_core/plugins/ets/stdlib/std/interop/ESValue.ets +++ b/static_core/plugins/ets/stdlib/std/interop/ESValue.ets @@ -247,7 +247,7 @@ export final class ESValue { public getProperty(index: number): ESValue { if (Number.isInteger(index) && index >= 0) { - return new ESValue(JSRuntime.getElementJSValue(this.ev, index as int)); + return new ESValue(JSRuntime.getElementJSValue(this.ev, index.toInt())); } let numObj = ESValue.wrapNumber(index); return this.getProperty(numObj); @@ -265,7 +265,7 @@ export final class ESValue { } public getPropertySafe(index: number): ESValue { - if (JSRuntime.hasElement(this.ev, index as int)) { + if (JSRuntime.hasElement(this.ev, index.toInt())) { return this.getProperty(index); } return ESValue.Undefined; @@ -288,10 +288,10 @@ export final class ESValue { public setProperty(index: number, value: StaticOrESValue): void { if (value instanceof ESValue) { - JSRuntime.setElementJSValue(this.ev, index as int, (value as ESValue).ev); + JSRuntime.setElementJSValue(this.ev, index.toInt(), (value as ESValue).ev); return; } - JSRuntime.setElementJSValue(this.ev, index as int, ESValue.wrap(value).ev); + JSRuntime.setElementJSValue(this.ev, index.toInt(), ESValue.wrap(value).ev); } public setProperty(property: ESValue, value: StaticOrESValue): void { diff --git a/static_core/plugins/ets/stdlib/std/interop/js/JSRuntime.ets b/static_core/plugins/ets/stdlib/std/interop/js/JSRuntime.ets index 47cfa30ec61aa1d9cd05df35bbf5b49d5ddb76b0..7a73098d0f1f334228128d4a2c90710a814aaf87 100644 --- a/static_core/plugins/ets/stdlib/std/interop/js/JSRuntime.ets +++ b/static_core/plugins/ets/stdlib/std/interop/js/JSRuntime.ets @@ -72,11 +72,11 @@ export final class JSRuntime { } public static newJSValueInt(value: int): JSValue { - return JSRuntime.newJSValueDouble(value as double); + return JSRuntime.newJSValueDouble(Int.toDouble(value)); } public static newJSValueLong(value: long): JSValue { - return JSRuntime.newJSValueDouble(value as double); + return JSRuntime.newJSValueDouble(Long.toDouble(value)); } public static newJSValueFloat(value: float): JSValue { @@ -131,27 +131,27 @@ export final class JSRuntime { } public static getPropertyByte(object: JSValue, name: String): byte { - return JSRuntime.getPropertyInt(object, name) as byte; + return Int.toByte(JSRuntime.getPropertyInt(object, name)); } public static getPropertyChar(object: JSValue, name: String): char { - return JSRuntime.getPropertyInt(object, name) as char; + return Int.toChar(JSRuntime.getPropertyInt(object, name)); } public static getPropertyShort(object: JSValue, name: String): short { - return JSRuntime.getPropertyInt(object, name) as short; + return Int.toShort(JSRuntime.getPropertyInt(object, name)); } public static getPropertyInt(object: JSValue, name: String): int { - return JSRuntime.getPropertyDouble(object, name) as int; + return Double.toInt(JSRuntime.getPropertyDouble(object, name)); } public static getPropertyLong(object: JSValue, name: String): long { - return JSRuntime.getPropertyDouble(object, name) as long; + return Double.toLong(JSRuntime.getPropertyDouble(object, name)); } public static getPropertyFloat(object: JSValue, name: String): float { - return JSRuntime.getPropertyDouble(object, name) as float; + return Double.toFloat(JSRuntime.getPropertyDouble(object, name)); } public static getPropertyDouble(object: JSValue, name: String): double { @@ -190,11 +190,11 @@ export final class JSRuntime { } public static setPropertyInt(object: JSValue, name: String, value: int): void { - JSRuntime.setPropertyDouble(object, name, value as double); + JSRuntime.setPropertyDouble(object, name, Int.toDouble(value)); } public static setPropertyLong(object: JSValue, name: String, value: long): void { - JSRuntime.setPropertyDouble(object, name, value as double); + JSRuntime.setPropertyDouble(object, name, Long.toDouble(value)); } public static setPropertyFloat(object: JSValue, name: String, value: float): void { @@ -290,27 +290,27 @@ export final class JSRuntime { } public static getElementByte(object: JSValue, index: int): byte { - return JSRuntime.getElementInt(object, index) as byte; + return Int.toByte(JSRuntime.getElementInt(object, index)); } public static getElementChar(object: JSValue, index: int): char { - return JSRuntime.getElementInt(object, index) as char; + return Int.toChar(JSRuntime.getElementInt(object, index)); } public static getElementShort(object: JSValue, index: int): short { - return JSRuntime.getElementInt(object, index) as short; + return Int.toShort(JSRuntime.getElementInt(object, index)); } public static getElementInt(object: JSValue, index: int): int { - return JSRuntime.getElementDouble(object, index) as int; + return Double.toInt(JSRuntime.getElementDouble(object, index)); } public static getElementLong(object: JSValue, index: int): long { - return JSRuntime.getElementDouble(object, index) as long; + return Double.toLong(JSRuntime.getElementDouble(object, index)); } public static getElementFloat(object: JSValue, index: int): float { - return JSRuntime.getElementDouble(object, index) as float; + return Double.toFloat(JSRuntime.getElementDouble(object, index)); } public static getElementDouble(object: JSValue, index: int): double { @@ -345,11 +345,11 @@ export final class JSRuntime { } public static setElementInt(object: JSValue, index: int, value: int): void { - JSRuntime.setElementDouble(object, index, value as double); + JSRuntime.setElementDouble(object, index, Int.toDouble(value)); } public static setElementLong(object: JSValue, index: int, value: long): void { - JSRuntime.setElementDouble(object, index, value as double); + JSRuntime.setElementDouble(object, index, Long.toDouble(value)); } public static setElementFloat(object: JSValue, index: int, value: float): void { diff --git a/static_core/plugins/ets/stdlib/std/math/math.ets b/static_core/plugins/ets/stdlib/std/math/math.ets index f12b4eadec75f03c4860e7d88829b6615dd16d0e..0bd578c66ed9fe1f20c44ada711e6f931632be21 100644 --- a/static_core/plugins/ets/stdlib/std/math/math.ets +++ b/static_core/plugins/ets/stdlib/std/math/math.ets @@ -187,25 +187,25 @@ export native function ceil(v: double): double; export native function clz64(v: long): int; export function clz64(v: int) { - let extendedNum: long = (v as long); + let extendedNum: long = Int.toLong(v); let mask: long = (1 as long << 32) - 1; return clz64(extendedNum & mask); } export function clz64(v: short) { - let extendedNum: long = (v as long); + let extendedNum: long = Short.toLong(v); let mask: long = (1 as long << 16) - 1; return clz64(extendedNum & mask); } export function clz64(v: byte) { - let extendedNum: long = (v as long); + let extendedNum: long = Byte.toLong(v); let mask: long = (1 as long << 8) - 1; return clz64(extendedNum & mask); } export function clz64(v: char) { - let extendedNum: long = (v as long); + let extendedNum: long = Char.toLong(v); let mask: long = (1 as long << 16) - 1; return clz64(extendedNum & mask); } diff --git a/static_core/plugins/ets/templates/stdlib/Array_builtin.erb b/static_core/plugins/ets/templates/stdlib/Array_builtin.erb index 0f53ac9dd3e49920e1d1748401ff028b0cfde444..1b6d52422e74eb937b59a25bd5a4a0438fe29ceb 100644 --- a/static_core/plugins/ets/templates/stdlib/Array_builtin.erb +++ b/static_core/plugins/ets/templates/stdlib/Array_builtin.erb @@ -43,7 +43,7 @@ class BuiltinArrayKeysIterator implements IterableIterator { this.isDone = true return new IteratorResult() } - return new IteratorResult(this.idx++ as number) + return new IteratorResult(Int.toDouble(this.idx++)) } override $_iterator(): IterableIterator { @@ -215,14 +215,14 @@ export function keys<%= ctx.this_generic %>(self: <%= ctx.this_type %>): Iterabl function builtin_insertion_sort(arr: FixedArray, startIndex: int, endIndex: int, comp: (lhs: T, rhs: T) => number): void { for (let i = startIndex + 1; i < endIndex; i++) { const tmp = arr[i]; - if (comp(tmp, arr[startIndex]) as int < 0) { + if (Double.toInt(comp(tmp, arr[startIndex])) < 0) { for (let j = i; j > startIndex; j--) { arr[j] = arr[j - 1] } arr[startIndex] = tmp } else { let j = i - 1; - while (comp(tmp, arr[j]) as int < 0) { + while (Double.toInt(comp(tmp, arr[j])) < 0) { arr[j + 1] = arr[j]; j--; } @@ -246,7 +246,7 @@ function perform_merge(arr: FixedArray, startIndex: int, midIndex: int, en let j = 0; let k = startIndex; while (i < len1 && j < len2) { - if (comp(left[i]!, right[j]!) as int <= 0) { + if (Double.toInt(comp(left[i]!, right[j]!)) <= 0) { arr[k] = left[i]!; i++; } else { @@ -407,7 +407,7 @@ export function sort_default(arr: FixedArray, arrStr: FixedArray, export function reduce(self: Array, callbackfn: (previousValue: T, currentValue: U, index: number, array: Array) => T, initialValue: T): T { let acc = initialValue for (let i = 0; i < self.length; i++) { - acc = callbackfn(acc, self[i], i as number, self) + acc = callbackfn(acc, self[i], Int.toDouble(i), self) } return acc } diff --git a/static_core/plugins/ets/templates/stdlib/Array_builtin_sort.ets.j2 b/static_core/plugins/ets/templates/stdlib/Array_builtin_sort.ets.j2 index 5f756e98c7efbcb2bb81e3fde86b2239ab542aeb..b7c73f3a1e7e26fa5072358e645ca62f15d4f703 100644 --- a/static_core/plugins/ets/templates/stdlib/Array_builtin_sort.ets.j2 +++ b/static_core/plugins/ets/templates/stdlib/Array_builtin_sort.ets.j2 @@ -17,15 +17,17 @@ package std.core; // NOTE: autogenerated file -{% for T in ['boolean', 'byte', 'short', 'int', 'long', 'float', 'double', 'char', 'NullishType'] %} +{% for T in ['boolean', 'byte', 'short', 'int', 'long', 'float', 'double', 'char', 'T'] %} + +{%- set Tdef = '' if T == 'T' else '' %} {%- for arg, fwdArg, prec, sortNameSuff, initIndex in [('', '', '(%s < %s)', '', ', initIndex: int = startIndex'), (', mustPrecede: (lhs: ' + T + ', rhs: ' + T + ') => boolean', ', mustPrecede', 'mustPrecede(%s, %s)', '_subarray', '')] %} -{%- if T == 'NullishType' and arg == '' %} +{%- if T == 'T' and arg == '' %} {%- continue %} {%- elif T == 'boolean' and arg == '' %} {%- set prec = '((%s) ? 1 : 0) < ((%s) ? 1 : 0)' %} {%- endif %} -function bubbleSort(arr: FixedArray<{{T}}>, startIndex: int, endIndex: int{{arg}}): void { +function bubbleSort{{Tdef}}(arr: FixedArray<{{T}}>, startIndex: int, endIndex: int{{arg}}): void { let was = true while (was) { was = false @@ -40,7 +42,7 @@ function bubbleSort(arr: FixedArray<{{T}}>, startIndex: int, endIndex: int{{arg} } } -function insertionSort(arr: FixedArray<{{T}}>, startIndex: int, endIndex: int{{arg}}, initIndex: int = startIndex): void { +function insertionSort{{Tdef}}(arr: FixedArray<{{T}}>, startIndex: int, endIndex: int{{arg}}, initIndex: int = startIndex): void { if (startIndex != initIndex) { // arr[startIndex - 1] exists and is less than or equal to all elements in range for (let i = startIndex + 1; i < endIndex; i++) { @@ -73,7 +75,7 @@ function insertionSort(arr: FixedArray<{{T}}>, startIndex: int, endIndex: int{{a } {%- if T != "boolean" %} -function heapSortUp(arr: FixedArray<{{T}}>, idxFromStart: int, startIndex: int, heapRoot: int{{arg}}): void { +function heapSortUp{{Tdef}}(arr: FixedArray<{{T}}>, idxFromStart: int, startIndex: int, heapRoot: int{{arg}}): void { const tmp = arr[startIndex + idxFromStart] while (startIndex + idxFromStart > heapRoot) { const p = (idxFromStart - 1) / 2 @@ -87,7 +89,7 @@ function heapSortUp(arr: FixedArray<{{T}}>, idxFromStart: int, startIndex: int, } // Build max heap with root in startIndex given its children are roots of valid heaps -function heapSortDown(arr: FixedArray<{{T}}>, idxFromStart: int, startIndex: int, endIndex: int{{arg}}): void { +function heapSortDown{{Tdef}}(arr: FixedArray<{{T}}>, idxFromStart: int, startIndex: int, endIndex: int{{arg}}): void { let heapRoot = startIndex + idxFromStart let arrIndex = heapRoot let childIndex = startIndex + idxFromStart * 2 + 1 @@ -110,7 +112,7 @@ function heapSortDown(arr: FixedArray<{{T}}>, idxFromStart: int, startIndex: int heapSortUp(arr, arrIndex - startIndex, startIndex, heapRoot{{fwdArg}}) } -export function heapSort(arr: FixedArray<{{T}}>, startIndex: int, endIndex: int{{arg}}): void { +export function heapSort{{Tdef}}(arr: FixedArray<{{T}}>, startIndex: int, endIndex: int{{arg}}): void { let len = endIndex - startIndex for (let i = len / 2 - 1; i >= 0; i--) { heapSortDown(arr, i, startIndex, endIndex{{fwdArg}}) @@ -126,7 +128,7 @@ export function heapSort(arr: FixedArray<{{T}}>, startIndex: int, endIndex: int{ } // Put median of three array elements to arr[index1] -function median3(arr: FixedArray<{{T}}>, index1: int, index2: int, index3: int{{arg}}): void { +function median3{{Tdef}}(arr: FixedArray<{{T}}>, index1: int, index2: int, index3: int{{arg}}): void { let swap_idx = index2 if ({{prec % ('arr[index1]', 'arr[index2]')}}) { if ({{prec % ('arr[index3]', 'arr[index1]')}}) { @@ -150,7 +152,7 @@ function median3(arr: FixedArray<{{T}}>, index1: int, index2: int, index3: int{{ // Split range [startIndex, endIndex) by pivot arr[startIndex] and return pivot position // Elements equal to pivot go to the right -function quickSortSplit(arr: FixedArray<{{T}}>, startIndex: int, endIndex: int{{arg}}): int { +function quickSortSplit{{Tdef}}(arr: FixedArray<{{T}}>, startIndex: int, endIndex: int{{arg}}): int { const pivot = arr[startIndex] let i = startIndex + 1 let j = endIndex - 1 @@ -184,7 +186,7 @@ function quickSortSplit(arr: FixedArray<{{T}}>, startIndex: int, endIndex: int{{ // Split range [startIndex, endIndex) by pivot arr[startIndex] and return pivot position // Elements equal to pivot go to the left -function quickSortSplitLeft(arr: FixedArray<{{T}}>, startIndex: int, endIndex: int{{arg}}): int { +function quickSortSplitLeft{{Tdef}}(arr: FixedArray<{{T}}>, startIndex: int, endIndex: int{{arg}}): int { const pivot = arr[startIndex] let i = startIndex + 1 let j = endIndex - 1 @@ -216,7 +218,7 @@ function quickSortSplitLeft(arr: FixedArray<{{T}}>, startIndex: int, endIndex: i } {% for quickUpTo in [3, 40] %} -function quickSortImpl{{quickUpTo}}(arr: FixedArray<{{T}}>, startIndex: int, endIndex: int, maxDepth: int{{arg}}{{initIndex}}): void { +function quickSortImpl{{quickUpTo}}{{Tdef}}(arr: FixedArray<{{T}}>, startIndex: int, endIndex: int, maxDepth: int{{arg}}{{initIndex}}): void { {%- set fwdInitIndex = initIndex.split(':')[0] %} while (endIndex - startIndex > {{quickUpTo}}) { if (--maxDepth == 0) { @@ -251,7 +253,7 @@ function quickSortImpl{{quickUpTo}}(arr: FixedArray<{{T}}>, startIndex: int, end } {%- endfor %} -function quickSort(arr: FixedArray<{{T}}>, startIndex: int, endIndex: int{{arg}}): void { +function quickSort{{Tdef}}(arr: FixedArray<{{T}}>, startIndex: int, endIndex: int{{arg}}): void { let size = endIndex - startIndex if (size <= 1) { return @@ -282,7 +284,7 @@ function quickSort(arr: FixedArray<{{T}}>, startIndex: int, endIndex: int{{arg}} * sort(arr, 0, arr.length) * ``` */ -export function sort{{sortNameSuff}}(arr: FixedArray<{{T}}>, startIndex: int, endIndex: int{{arg}}): void { +export function sort{{sortNameSuff}}{{Tdef}}(arr: FixedArray<{{T}}>, startIndex: int, endIndex: int{{arg}}): void { if (!checkRange(arr.length, startIndex, endIndex)) { throw new ArrayIndexOutOfBoundsError("sort: bounds verification failed") } @@ -314,15 +316,15 @@ export function sort{{sortNameSuff}}(arr: FixedArray<{{T}}>, startIndex: int, en * * @param arr an array to sort */ -export function sort_subarray(arr: FixedArray<{{T}}>, mustPrecede: (lhs: {{T}}, rhs: {{T}}) => boolean): void { +export function sort_subarray{{Tdef}}(arr: FixedArray<{{T}}>, mustPrecede: (lhs: {{T}}, rhs: {{T}}) => boolean): void { sort_subarray(arr, 0, arr.length, mustPrecede); } -export function sort_subarray(arr: FixedArray<{{T}}>, startIndex: int, mustPrecede: (lhs: {{T}}, rhs: {{T}}) => boolean): void { +export function sort_subarray{{Tdef}}(arr: FixedArray<{{T}}>, startIndex: int, mustPrecede: (lhs: {{T}}, rhs: {{T}}) => boolean): void { sort_subarray(arr, startIndex, arr.length, mustPrecede) } -{% if T != "NullishType" -%} +{% if T != "T" -%} {%- if T == 'byte' %} function countSort(arr: FixedArray, startIndex: int, endIndex: int): void { @@ -333,7 +335,7 @@ function countSort(arr: FixedArray, startIndex: int, endIndex: int): void let idx = 0 for (let i = 0; i < 256; i++) { for (let j = 0; j < cnts[i]; j++) { - arr[startIndex + idx++] = (i - 128) as byte + arr[startIndex + idx++] = Int.toByte(i - 128) } } } diff --git a/static_core/plugins/ets/templates/stdlib/Array_code.rb b/static_core/plugins/ets/templates/stdlib/Array_code.rb index a70d06168e44ffa2f7db8d6a914b586e1f40523a..b34cb6b3c24c443d9ec5114e694928113e41d9d8 100644 --- a/static_core/plugins/ets/templates/stdlib/Array_code.rb +++ b/static_core/plugins/ets/templates/stdlib/Array_code.rb @@ -16,7 +16,7 @@ module TemplateData def self.get_lambda_data() [ - [2, ", i as number, #{$ctx.this}", ", index: number, array: #{$ctx.this_type}", ", index, #{$ctx.this}"], + [2, ", Int.toDouble(i), #{$ctx.this}", ", index: number, array: #{$ctx.this_type}", ", index, #{$ctx.this}"], ] end end diff --git a/static_core/plugins/ets/templates/stdlib/Array_common.erb b/static_core/plugins/ets/templates/stdlib/Array_common.erb index b764a28e79cbda332f4cb8d8ad2b513f5e98606d..111d308b7220d34f45eb9f1a3b8266f9e94b8148 100644 --- a/static_core/plugins/ets/templates/stdlib/Array_common.erb +++ b/static_core/plugins/ets/templates/stdlib/Array_common.erb @@ -25,7 +25,7 @@ * Returns undefined if `index` < `-length()` or `index` >= `length()`. */ <%= access_public %> <%= override %> at<%= this_generic %>(<%= this_arg %>index: number): <%= el_type_boxed %> | undefined { - return <%= this_call.('at') %>index as int) + return <%= this_call.('at') %>Double.toInt(index)) } /** @@ -42,7 +42,7 @@ <%= access_public %> concat<%= this_generic %>(<%= this_arg %>...items: FixedArray>>): <%= this_type %> { let totalAdd = <%= this_len_int %>; for (let i = 0; i < items.length; i++) { - totalAdd += items[i].length as int + totalAdd += Double.toInt(items[i].length) } const buf : <%= make_fixed_array %> = <%= make_buffer.('totalAdd') %>; @@ -54,7 +54,7 @@ let insertTo = <%= this_len_int %>; for (let i = 0; i < items.length; i++) { const arr = items[i] - const len = arr.length as int + const len = Double.toInt(arr.length) for (let j = 0; j < len; j++) { buf[insertTo++] = arr.$_get(j) } @@ -102,7 +102,7 @@ * @returns this array after transformation */ <%= access_public %> copyWithin<%= this_generic %>(<%= this_arg %>target: number, start: number, end?: Number): <%= this_return_type %> { - <%= this_call.('copyWithin') %>target as int, start as int, asIntOrDefault(end, <%= this_len_int %>)); + <%= this_call.('copyWithin') %>Double.toInt(target), Double.toInt(start), asIntOrDefault(end, <%= this_len_int %>)); return <%= this %>; } @@ -226,7 +226,7 @@ if (res == -1) { return undefined } - return <%= get_unsafe.(this, 'res as int') %>; + return <%= get_unsafe.(this, 'Double.toInt(res)') %>; } /** @@ -439,7 +439,7 @@ * @returns `Array` instance, constructed from extracted elements of `this` instance. */ <%= access_public %> slice<%= this_generic %>(<%= this_arg %>start: int): <%= this_type %> { - return <%= this_call.('slice') %>start, Int.MAX_VALUE as int); + return <%= this_call.('slice') %>start, Int.MAX_VALUE); } <% if access_public == "export function" %><% #generate code for BuiltinArray.ets %> @@ -566,7 +566,7 @@ if (first_el !== undefined && first_el !== null) { first_str = new String(first_el) } - let sb = new StringBuilder(first_str)<% else %>let sb = new StringBuilder(new String(<%= get_unsafe.(this, '0') %>))<% end %> + let sb = new StringBuilder(first_str)<% else %>let sb = new StringBuilder(new String(<%= get_unsafe.(this, '0') %><% if el_type == "char" %>.toString()<%end%>))<% end %> for (let i: int = 1; i < <%= this_len_int %>; i++) { const tmp = <%= get_unsafe.(this, 'i') %> sb.append(sepReal); @@ -659,7 +659,7 @@ */ <%= access_public %> toSpliced<%= this_generic %>(<%= this_arg %>start: number, delete: number, ...items: FixedArray<<%= el_type %>>): <%= this_type %> { const len = <%= this_len_int %>; - return <%= this_call.('toSpliced') %>start as int, delete as int, ...items) + return <%= this_call.('toSpliced') %>Double.toInt(start), Double.toInt(delete), ...items) } /** @@ -874,7 +874,7 @@ * @returns a new Array with the element at the given index replaced with the given value */ <%= access_public %> with<%= this_generic %>(<%= this_arg %>index: number, value: <%= el_type %>): <%= this_type %> { - return <%= this_call.('with') %>index as int, value) + return <%= this_call.('with') %>Double.toInt(index), value) } /** diff --git a/static_core/plugins/ets/templates/stdlib/Array_common_top_scope.erb b/static_core/plugins/ets/templates/stdlib/Array_common_top_scope.erb index fc4ce9bfdacbf3a8abc87c16b41082d759c68ebf..e0333b9aa679d7b8254a31a3c341ab5ec9278246 100644 --- a/static_core/plugins/ets/templates/stdlib/Array_common_top_scope.erb +++ b/static_core/plugins/ets/templates/stdlib/Array_common_top_scope.erb @@ -35,7 +35,7 @@ class ArrayValuesIterator_<%= ctx.el_type %><%= ctx.this_iterator_generic || ctx } public __Iterator_getLength(): int { - return this.parent.length as int + return Double.toInt(this.parent.length) } } @@ -54,7 +54,7 @@ class ArrayEntriesIterator_<%= ctx.el_type %><%= ctx.this_iterator_generic || ct return new IteratorResult<[number, <%= ctx.el_type %>]>() } const i = this.idx++; - const vl: [number, <%= ctx.el_type %>] = [i as number, <%= ctx.get_unsafe.('this.parent', 'i') %>] + const vl: [number, <%= ctx.el_type %>] = [Int.toDouble(i), <%= ctx.get_unsafe.('this.parent', 'i') %>] return new IteratorResult<[number, <%= ctx.el_type %>]>(vl); } @@ -63,6 +63,6 @@ class ArrayEntriesIterator_<%= ctx.el_type %><%= ctx.this_iterator_generic || ct } public __Iterator_getLength(): int { - return this.parent.length as int + return Double.toInt(this.parent.length) } } diff --git a/static_core/plugins/ets/templates/stdlib/Array_escompat.erb b/static_core/plugins/ets/templates/stdlib/Array_escompat.erb index 23fa252b3e5048fba0d7879898e21bb8bc6d96bf..0ffba4ed2389484897c1455ac921e1f0a921bbf3 100644 --- a/static_core/plugins/ets/templates/stdlib/Array_escompat.erb +++ b/static_core/plugins/ets/templates/stdlib/Array_escompat.erb @@ -34,7 +34,7 @@ class ArrayKeysIterator implements IterableIterator { this.isDone = true return new IteratorResult() } - return new IteratorResult(this.idx++ as number) + return new IteratorResult(Int.toDouble(this.idx++)) } override $_iterator(): IterableIterator { @@ -54,11 +54,11 @@ export class Array implements ReadonlyArray, Iterable { internal actualLength: int override get length(): number { - return this.actualLength as number + return Int.toDouble(this.actualLength) } set length(newLen: number) { - const len = newLen as int + const len = Double.toInt(newLen) if (len < 0 || len > this.actualLength) { throw new RangeError("can't change length to bigger or negative") } @@ -66,11 +66,11 @@ export class Array implements ReadonlyArray, Iterable { } public override $_get(index: number): T { - return this.$_get(index as int) + return this.$_get(Double.toInt(index)) } public $_set(i: number, val: T): void { - this.$_set(i as int, val) + this.$_set(Double.toInt(i), val) } public native $_get(idx: int): T; @@ -94,7 +94,7 @@ export class Array implements ReadonlyArray, Iterable { } public constructor(arrayLen: number) { - this(arrayLen as int) + this(Double.toInt(arrayLen)) } internal constructor(_tag: FromBuffer, buf: FixedArray) { @@ -114,7 +114,7 @@ export class Array implements ReadonlyArray, Iterable { */ public constructor(first: T, ...d: T[]) { this.buffer = new NullishType[d.length + 1] - this.actualLength = d.length as int + 1 + this.actualLength = Double.toInt(d.length) + 1 this.buffer[0] = first @@ -132,7 +132,7 @@ export class Array implements ReadonlyArray, Iterable { * */ public static create(arrayLength: number, initialValue: T): Array { - let other = new Array(arrayLength as int) + let other = new Array(Double.toInt(arrayLength)) other.fill(initialValue) return other } @@ -149,7 +149,7 @@ export class Array implements ReadonlyArray, Iterable { if (arrayLength > Int.MAX_VALUE) { throw new RangeError("arrayLength must be <= int32 max") } - const len = arrayLength as int + const len = Double.toInt(arrayLength) const delta: int = len - this.actualLength if (delta <= 0) { return @@ -171,7 +171,7 @@ export class Array implements ReadonlyArray, Iterable { if (arrayLength >= this.actualLength) { return } - let newLen: int = arrayLength as int + let newLen: int = Double.toInt(arrayLength) if (newLen < 0) { // Convert from signed to unsigned newLen = newLen & Int.MAX_VALUE @@ -244,7 +244,7 @@ export class Array implements ReadonlyArray, Iterable { * @returns `Array` intance constructed from `Object[]` ArrayLike. */ public static from(arr: ArrayLike): Array { - const ret = new Array(arr.length as int) + const ret = new Array(arr.length.toInt()) let i = 0 iteratorForEach(arr.$_iterator(), (x: T): void => { ret[i] = x @@ -270,7 +270,7 @@ export class Array implements ReadonlyArray, Iterable { const idx : FixedArray = new int[1] idx[0] = 0 iteratorForEach(iterable.$_iterator(), (x: T): void => { - ret.push(mapfn(x, idx[0] as number)) + ret.push(mapfn(x, Int.toDouble(idx[0]))) idx[0] += 1 }) return ret @@ -293,7 +293,7 @@ export class Array implements ReadonlyArray, Iterable { */ public static from(arr: FixedArray): Array { const len = arr.length - const ret : FixedArray = new NullishType[len as int] + const ret : FixedArray = new NullishType[Double.toInt(len)] for (let i: int = 0; i < len; i++) { ret[i] = arr[i] as NullishType } @@ -331,7 +331,7 @@ export class Array implements ReadonlyArray, Iterable { } private lastIndexOfNumber(val: Number, fi: int): int { - const unboxedVal: number = val.valueOf() + const unboxedVal: number = val if (isNaN(val)) { return -1 } @@ -347,7 +347,7 @@ export class Array implements ReadonlyArray, Iterable { } private lastIndexOfFloat(val: Float, fi: int): int { - const unboxedVal: float = val.unboxed() + const unboxedVal: float = val if (isNaN(val)) { return -1 } @@ -619,13 +619,13 @@ export class Array implements ReadonlyArray, Iterable { */ private static defaultComparator(a: NullishType, b: NullishType): number { if (a instanceof Number && b instanceof Number) { - const x = (a as Number).valueOf() - const y = (b as Number).valueOf() + const x = a + const y = b if (Number.isInteger(x) && Number.isInteger(y) && x <= Int.MAX_VALUE / 128 && x >= Int.MIN_VALUE / 128 && y <= Int.MAX_VALUE / 128 && y >= Int.MIN_VALUE / 128) { - let z = x as int - let w = y as int + let z = Double.toInt(x) + let w = Double.toInt(y) return Array.defaultComparatorInts(z, w) } } else if (a instanceof String && b instanceof String) { @@ -823,11 +823,11 @@ export class Array implements ReadonlyArray, Iterable { * @returns new length */ public push(...val: T[]): number { - this.ensureUnusedCapacity(val.length as int) + this.ensureUnusedCapacity(Double.toInt(val.length)) for (let i = 0; i < val.length; i++) { this.buffer[this.actualLength + i] = val[i] } - this.actualLength += val.length + this.actualLength += Double.toInt(val.length) return this.actualLength } @@ -837,11 +837,11 @@ export class Array implements ReadonlyArray, Iterable { * @returns new length */ public pushECMA(...val: T[]): number { - this.ensureUnusedCapacity(val.length as int) + this.ensureUnusedCapacity(Double.toInt(val.length)) for (let i = 0; i < val.length; i++) { this.buffer[this.actualLength + i] = val[i] } - this.actualLength += val.length + this.actualLength += Double.toInt(val.length) return this.actualLength } @@ -866,7 +866,7 @@ export class Array implements ReadonlyArray, Iterable { * @returns an Array with deleted elements */ public splice(start: number, delete: Number | undefined, ...items: T[]): Array { - return this.splice(start as int, asIntOrDefault(delete, 0), ...items) + return this.splice(Double.toInt(start), asIntOrDefault(delete, 0), ...items) } /** @@ -889,9 +889,9 @@ export class Array implements ReadonlyArray, Iterable { } // this: [left middle right], we must replace middle with `items` - this.ensureUnusedCapacity(items.length as int - delete) + this.ensureUnusedCapacity(Double.toInt(items.length) - delete) const oldLen = this.actualLength - this.actualLength = this.actualLength - delete + items.length as int + this.actualLength = this.actualLength - delete + Double.toInt(items.length) let ret = new Array(delete) let lastSet = start @@ -908,7 +908,7 @@ export class Array implements ReadonlyArray, Iterable { } } else { for (let i = 0; i < rightLen; i++) { - this.buffer[start + items.length as int + i] = this.buffer[start + delete + i] + this.buffer[start + Double.toInt(items.length) + i] = this.buffer[start + delete + i] } } // insert middle part @@ -927,7 +927,7 @@ export class Array implements ReadonlyArray, Iterable { * @returns an Array with deleted elements from start to the last element of the current instance */ public splice(start: number): Array { - return this.splice(start as int) + return this.splice(Double.toInt(start)) } /** @@ -966,7 +966,7 @@ export class Array implements ReadonlyArray, Iterable { */ public static of(...values: T[]): Array { const ret = new Array() - ret.ensureUnusedCapacity(values.length as int) + ret.ensureUnusedCapacity(Double.toInt(values.length)) for (let i = 0; i < values.length; i++) { ret.push(values[i]) } @@ -987,13 +987,13 @@ export class Array implements ReadonlyArray, Iterable { buffer = new NullishType[this.buffer.length * 2 + values.length] } for (let i = 0; i < this.actualLength; i++) { - buffer[this.actualLength + values.length as int - i - 1] = this.buffer[this.actualLength - 1 - i] + buffer[this.actualLength + Double.toInt(values.length) - i - 1] = this.buffer[this.actualLength - 1 - i] } for (let i = 0; i < values.length; i++) { buffer[i] = values[i] } this.buffer = buffer - this.actualLength += values.length + this.actualLength += Double.toInt(values.length) return this.actualLength } @@ -1023,7 +1023,7 @@ export class Array implements ReadonlyArray, Iterable { const res = new Array() for (let i: int = 0; i < this.actualLength; i++) { const val = this.$_get_unsafe(i) - if (predicate(val, i as number, this)) { + if (predicate(val, Int.toDouble(i), this)) { res.push(val) } } @@ -1039,7 +1039,7 @@ export class Array implements ReadonlyArray, Iterable { * @returns a flattened Array with respect to depth */ public flat(depth: number): Array { - return this.flat(depth as int) + return this.flat(Double.toInt(depth)) } /** diff --git a/static_core/plugins/ets/templates/stdlib/Array_header.erb b/static_core/plugins/ets/templates/stdlib/Array_header.erb index fcd5808d01a09c229300b1cee6f3499d8953b699..faa76d85f0da241ec527b3dbdb1c6e6b83e61d04 100644 --- a/static_core/plugins/ets/templates/stdlib/Array_header.erb +++ b/static_core/plugins/ets/templates/stdlib/Array_header.erb @@ -15,7 +15,7 @@ function asIntOrDefault(n: Number | undefined, def: int): int { if (n === undefined) { return def } - return (n! as Object as Number) as number as int; + return Double.toInt(n!); } function normalizeIndex(idx: int, len: int): int { diff --git a/static_core/plugins/ets/templates/stdlib/DataView.ets.j2 b/static_core/plugins/ets/templates/stdlib/DataView.ets.j2 index ff5ea0bba4672cb5f97941d772e86f3a60d033df..737f16ff42acfc14ff0e65ac563ae598ba1348bf 100644 --- a/static_core/plugins/ets/templates/stdlib/DataView.ets.j2 +++ b/static_core/plugins/ets/templates/stdlib/DataView.ets.j2 @@ -83,10 +83,10 @@ export final class DataView implements ArrayBufferView { {%- set impls = ['Little', 'Big'] if bit != 8 else ['Big'] %} {%- set type2nameBits = {8: "byte", 16: "short", 32: "int", 64: "long"} %} - {%- set type2nameCompat = {8: "number", 16: "number", 32: "number", 64: "bigint"} %} + {%- set type2nameCompat = {8: "double", 16: "double", 32: "double", 64: "bigint"} %} {%- if mode == "Float" %} - {%- set type2name = {32: "float", 64: "number"} %} - {%- set type2nameCompat = {32: "number", 64: "number"} %} + {%- set type2name = {32: "float", 64: "double"} %} + {%- set type2nameCompat = {32: "double", 64: "double"} %} {%- elif mode == "Int" %} {%- set type2name = {8: "int", 16: "int", 32: "int", 64: "long"} %} {%- elif mode == "Uint" %} @@ -196,9 +196,9 @@ export final class DataView implements ArrayBufferView { let res: {{resType}} = 0; const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < {{bit // 8}}; i++) { - let byteVal = this.actualBuffer.at(startByte {{getIdx}} i) as {{resType}}; + let byteVal = Byte.to{{resType|capitalize}}(this.actualBuffer.at(startByte {{getIdx}} i)); byteVal &= 0xff - res = (res | byteVal << (8 * i)) as {{resType}}; + res = Long.to{{resType|capitalize}}(res | byteVal << (8 * i)); } {%- if bit == 32 and mode == "Float" %} return Float.bitCastFromInt(res) @@ -209,13 +209,13 @@ export final class DataView implements ArrayBufferView { {%- elif bit == 64 and mode == "Uint" %} return DataView.bigintFromULong(res) {%- elif mode == 'Int' %} - return (res as {{type2nameBits[bit]}}) as {{resType}} + return {{resType|capitalize}}.to{{type2nameBits[bit]|capitalize}}(res) {%- else %} return res {%- endif %} } private get{{methodName}}{{suffix}}(byteOffset: number): {{type2nameCompat[bit]}} { - let res = this.get{{methodName}}{{suffix}}(byteOffset as int) + let res = this.get{{methodName}}{{suffix}}(Double.toInt(byteOffset)) return res } @@ -237,7 +237,7 @@ export final class DataView implements ArrayBufferView { {%- endif %} const startByte = this.byteOffset_ + byteOffset for (let i = 0; i < {{bit // 8}}; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + let byteVal = {{type2name[bit]|capitalize}}.toByte((bits >>> (i * 8)) & 0xff) this.actualBuffer.set(startByte {{getIdx}} i, byteVal) } } @@ -247,15 +247,15 @@ export final class DataView implements ArrayBufferView { {%- elif bit == 64 and mode == "Uint" %} const val: {{type2name[bit]}} = value.getLong(); {%- elif type2name[bit] == "int" %} - let temp: long = value as long; + let temp: long = {{type2nameCompat[bit]|capitalize}}.toLong(value); if (temp == Long.MAX_VALUE || temp == Long.MIN_VALUE) { temp = 0; } - const val: {{type2name[bit]}} = temp as {{type2name[bit]}}; + const val: {{type2name[bit]}} = Long.to{{type2name[bit]|capitalize}}(temp); {%- else %} - const val: {{type2name[bit]}} = value as {{type2name[bit]}}; + const val: {{type2name[bit]}} = Double.to{{type2name[bit]|capitalize}}(value); {%- endif %} - this.set{{methodName}}{{suffix}}(byteOffset as int, val) + this.set{{methodName}}{{suffix}}(Double.toInt(byteOffset), val) } {%- endfor %} diff --git a/static_core/plugins/ets/templates/stdlib/typedArray.ets.j2 b/static_core/plugins/ets/templates/stdlib/typedArray.ets.j2 index e97878afa175315c0809d75888b267927e0f2763..21f0a692b24998e163bdd1f7eb9adbc7c605132d 100644 --- a/static_core/plugins/ets/templates/stdlib/typedArray.ets.j2 +++ b/static_core/plugins/ets/templates/stdlib/typedArray.ets.j2 @@ -17,28 +17,28 @@ package escompat -{%- for N, T, S in [ - ('Int8', 'byte', 1), - ('Int16', 'short', 2), - ('Int32', 'int', 4), - ('BigInt64', 'long', 8), - ('Float32', 'float', 4), - ('Float64', 'double', 8)] +{%- for N, T, BT, S in [ + ('Int8', 'byte', 'Byte', 1), + ('Int16', 'short', 'Short', 2), + ('Int32', 'int', 'Int', 4), + ('BigInt64', 'long', 'Long', 8), + ('Float32', 'float', 'Float', 4), + ('Float64', 'double', 'Double', 8)] %} {%- set elementCompat = 'number' if T != 'long' else 'BigInt' %} - {%- set asElementCompat = '%s as number' if elementCompat == 'number' else 'new BigInt(%s)' %} - {%- set fromElementCompat = (' as ' + T) if elementCompat == 'number' else '.getLong()' %} + {%- set asElementCompat = '(%s).toDouble()' if elementCompat == 'number' else 'new BigInt(%s)' %} + {%- set fromElementCompat = ('.to' + BT + '()') if elementCompat == 'number' else '.getLong()' %} {%- set subsetTypeValues = 'Number' if elementCompat == 'number' else 'BigInt' %} - {%- set numberBigIntToPrimitive = ('.' + T + 'Value()') if elementCompat == 'number' else '.getLong()' %} - {%- set numberBigIntUndefToPrimitive = (numberBigIntToPrimitive) %} + {%- set numberBigIntToPrimitive = ('.to' + BT + '()') if elementCompat == 'number' else '.getLong()' %} + {%- set numberBigIntUndefToPrimitive = ('!' + numberBigIntToPrimitive) %} class {{N}}ArrayIteratorKeys implements IterableIterator { private length: int private idx: int = 0 constructor(parent: {{N}}Array) { - this.length = parent.length as int + this.length = Double.toInt(parent.length) } public override $_iterator(): IterableIterator { @@ -49,7 +49,7 @@ class {{N}}ArrayIteratorKeys implements IterableIterator { if (this.idx < 0 || this.idx >= this.length) { return new IteratorResult() } - return new IteratorResult(false, this.idx++ as number) + return new IteratorResult(false, Int.toDouble(this.idx++)) } } @@ -66,7 +66,7 @@ class {{N}}ArrayIterator implements IterableIterator<{{subsetTypeValues}}> { } override next(): IteratorResult<{{subsetTypeValues}}> { - if (this.idx < 0 || this.idx >= this.parent.length as int) { + if (this.idx < 0 || this.idx >= Double.toInt(this.parent.length)) { return new IteratorResult<{{subsetTypeValues}}>() } return new IteratorResult<{{subsetTypeValues}}>(false, new {{subsetTypeValues}}(this.parent[this.idx++])) @@ -88,7 +88,7 @@ class {{N}}ArrayIteratorEntries implements IterableIterator<{{subsetTypeValuesEn } override next(): IteratorResult<{{subsetTypeValuesEntries}}> { - if (this.idx < 0 || this.idx >= this.parent.length as int) { + if (this.idx < 0 || this.idx >= Double.toInt(this.parent.length)) { return new IteratorResult<{{subsetTypeValuesEntries}}>() } return new IteratorResult<{{subsetTypeValuesEntries}}>( @@ -102,15 +102,15 @@ class {{N}}ArrayIteratorEntries implements IterableIterator<{{subsetTypeValuesEn * JS {{N}}Array API-compatible class */ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLike<{{subsetTypeValues}}> { - public static readonly BYTES_PER_ELEMENT: number = {{S}} - public readonly BYTES_PER_ELEMENT: number = {{N}}Array.BYTES_PER_ELEMENT + public static readonly BYTES_PER_ELEMENT: int = {{S}} + public readonly BYTES_PER_ELEMENT: int = {{N}}Array.BYTES_PER_ELEMENT internal readonly lengthInt: int /** * Creates an empty {{N}}Array. */ public constructor() { - this(0 as int) + this(0) } /** @@ -120,9 +120,9 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi const items: Object = elements as Object if (items instanceof ArrayLike) { const arr = Types.identity_cast<{{subsetTypeValues}}>(items as ArrayLike<{{subsetTypeValues}}>) - this.byteLength = arr.length as int * {{N}}Array.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int - this.buffer = new ArrayBuffer(this.byteLength as int) + this.byteLength = Double.toInt(arr.length) * {{N}}Array.BYTES_PER_ELEMENT + this.lengthInt = Double.toInt(arr.length) + this.buffer = new ArrayBuffer(Double.toInt(this.byteLength)) this.byteOffset = 0 for (let i: int = 0; i < this.lengthInt; ++i) { {%- if N == 'BigInt64' %} @@ -162,27 +162,27 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi throw new RangeError("Range Error: byteLength " + intByteLength + " is outside the bounds of the buffer with byteOffset " + intByteOffset) } {% if S != 1 %} - if (intByteLength % {{N}}Array.BYTES_PER_ELEMENT as int != 0) { + if (intByteLength % {{N}}Array.BYTES_PER_ELEMENT.toInt() != 0) { throw new RangeError("ArrayBuffer.byteLength should be multiple of {{S}} as {{N}}Array.BYTES_PER_ELEMENT") } - if (intByteOffset % {{N}}Array.BYTES_PER_ELEMENT as int != 0) { + if (intByteOffset % {{N}}Array.BYTES_PER_ELEMENT != 0) { throw new RangeError("byteOffset should be multiple of {{S}} as {{N}}Array.BYTES_PER_ELEMENT") } {% endif %} let intLength: int if (length != undefined) { intLength = length.toInt() - if (intLength > intByteLength / {{N}}Array.BYTES_PER_ELEMENT as int) { + if (intLength > Double.toInt(intByteLength / {{N}}Array.BYTES_PER_ELEMENT)) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer with byteOffset " + intByteOffset) } } else { - intLength = intByteLength / {{N}}Array.BYTES_PER_ELEMENT as int + intLength = Double.toInt(intByteLength / {{N}}Array.BYTES_PER_ELEMENT) } if (intLength < 0) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer") } - if (intLength < intByteLength / {{N}}Array.BYTES_PER_ELEMENT as int) { - intByteLength = intLength * {{N}}Array.BYTES_PER_ELEMENT as int + if (intLength < Double.toInt(intByteLength / {{N}}Array.BYTES_PER_ELEMENT)) { + intByteLength = intLength * {{N}}Array.BYTES_PER_ELEMENT } this.byteLength = intByteLength this.byteOffset = intByteOffset @@ -190,32 +190,6 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi this.buffer = buf } - /** - * Creates an {{N}}Array with respect to data, byteOffset and length. - * - * @param buf data initializer - * - * @param byteOffset byte offset from begin of the buf - * - * @param length size of elements of type {{T}} in newly created {{N}}Array - */ - public constructor(buf: ArrayBuffer, byteOffset: Number | undefined) { - this(buf, byteOffset, undefined) - } - - /** - * Creates an {{N}}Array with respect to data, byteOffset and length. - * - * @param buf data initializer - * - * @param byteOffset byte offset from begin of the buf - * - * @param length size of elements of type {{T}} in newly created {{N}}Array - */ - public constructor(buf: ArrayBuffer, byteOffset: number, length: number) { - this(buf, new Number(byteOffset), new Number(length)) - } - /** * Creates an {{N}}Array with respect to data, byteOffset and length. * @@ -261,19 +235,19 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi public constructor(buf: ArrayLike | ArrayBuffer) { if (buf instanceof ArrayBuffer) { this.byteLength = (buf as ArrayBuffer).getByteLength() - if (this.byteLength % {{N}}Array.BYTES_PER_ELEMENT as int != 0) { + if (this.byteLength % {{N}}Array.BYTES_PER_ELEMENT.toInt() != 0) { throw new RangeError("ArrayBuffer.byteLength should be multiple of {{S}} as {{N}}Array.BYTES_PER_ELEMENT") } - this.lengthInt = this.byteLength / {{N}}Array.BYTES_PER_ELEMENT as int + this.lengthInt = Double.toInt(this.byteLength / {{N}}Array.BYTES_PER_ELEMENT) this.buffer = buf as ArrayBuffer this.byteOffset = 0 } else if (buf instanceof ArrayLike) { // NOTE (ikorobkov): dealing with this overload is tricky // with banned `instanceof` generic, so it is delegated to array here. Initial idea from Set.ets let arr = Array.from((buf as ArrayLike)) - this.byteLength = arr.length as int * {{N}}Array.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int - this.buffer = new ArrayBuffer(this.byteLength as int) + this.byteLength = arr.length.toInt() * {{N}}Array.BYTES_PER_ELEMENT.toInt() + this.lengthInt = arr.length.toInt() + this.buffer = new ArrayBuffer(this.byteLength.toInt()) this.byteOffset = 0 for (let i: int = 0; i < this.lengthInt; ++i) { this.setUnsafe(i, arr.$_get(i).to{{T.capitalize()}}()) @@ -289,7 +263,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @param length data initializer */ public constructor(length: int) { - this(length as number) + this(Int.toDouble(length)) } /** @@ -298,13 +272,13 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @param length data initializer */ public constructor(length: number) { - if (length < 0 || length > (Int.MAX_VALUE / {{N}}Array.BYTES_PER_ELEMENT)) { + if (length < 0 || length > Double.toInt(Int.MAX_VALUE / {{N}}Array.BYTES_PER_ELEMENT)) { throw new TypeError("Type Error: length " + length + " is outside the bounds of the buffer") } - this.lengthInt = length as int - this.byteLength = this.lengthInt * {{N}}Array.BYTES_PER_ELEMENT as int + this.lengthInt = Double.toInt(length) + this.byteLength = this.lengthInt * {{N}}Array.BYTES_PER_ELEMENT this.byteOffset = 0 - this.buffer = new ArrayBuffer(this.byteLength as int) + this.buffer = new ArrayBuffer(this.byteLength.toInt()) } /** @@ -313,9 +287,9 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @param other data initializer */ public constructor(other: {{N}}Array) { - this.buffer = other.buffer.slice(other.byteOffset as int, (other.byteOffset + other.byteLength) as int) as ArrayBuffer + this.buffer = other.buffer.slice(other.byteOffset.toInt(), (other.byteOffset + other.byteLength).toInt()) as ArrayBuffer this.byteLength = other.byteLength - this.lengthInt = other.length as int + this.lengthInt = Double.toInt(other.length) this.byteOffset = 0 } @@ -326,10 +300,10 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi this(numbers.length) for (let i: int = 0; i < this.lengthInt; ++i) { {%- if N == 'BigInt64' %} - this.setUnsafe(i, numbers[i] as long) + this.setUnsafe(i, Double.toLong(numbers[i])) {%- elif N not in ['Float32', 'Float64'] %} - this.setUnsafe(i, {{ ('this.zeroIfInfinity(numbers[i])' + ' as ' + T) - if elementCompat != 'BigInt' else 'this.zeroIfInfinity(numbers[i] as long)' }}) + this.setUnsafe(i, {{ ('this.zeroIfInfinity(numbers[i]).to' + BT + '()') + if elementCompat != 'BigInt' else 'this.zeroIfInfinity(Double.toLong(numbers[i]))' }}) {%- else %} this.setUnsafe(i, numbers[i]{{fromElementCompat}}) {%- endif %} @@ -343,10 +317,10 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi this(numbers.length) for (let i: int = 0; i < this.lengthInt; ++i) { {%- if N == 'BigInt64' %} - this.setUnsafe(i, numbers[i] as long) + this.setUnsafe(i, Int.toLong(numbers[i])) {%- elif N not in ['Float32', 'Float64'] %} - this.setUnsafe(i, {{ ('this.zeroIfInfinity(numbers[i])' + ' as ' + T) - if elementCompat != 'BigInt' else 'this.zeroIfInfinity(numbers[i] as long)' }}) + this.setUnsafe(i, {{ ('this.zeroIfInfinity(numbers[i]).to' + BT + '()') + if elementCompat != 'BigInt' else 'this.zeroIfInfinity(Int.toLong(numbers[i]))' }}) {%- else %} this.setUnsafe(i, numbers[i]{{fromElementCompat}}) {%- endif %} @@ -374,14 +348,14 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi {%- else %} if ((val{{fromElementCompat}} == Infinity) || (val{{fromElementCompat}} == -Infinity)) { {%- endif %} - return {{asElementCompat % '0'}} + return {{ '0' if elementCompat != 'BigInt' else 'new BigInt(0)' }} } return {{asElementCompat % 'val'}} } internal zeroIfInfinity(val: {{T}}): {{T}} { if ((val == Infinity) || (val == -Infinity)) { - return 0 as {{T}} + return {{ '0' if S >= 4 else 'Int.to' + BT + '(0)' }} } return val } @@ -397,7 +371,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @param index index to change */ public $_set(index: number, val: {{elementCompat}}): void { - this.$_set(index as int, val) + this.$_set(Double.toInt(index), val) } /** @@ -426,7 +400,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @param index index to change */ public $_set(index: number, val: int): void { - this.$_set(index as int, val) + this.$_set(Double.toInt(index), val) } /** @@ -447,7 +421,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @param index index to change */ public $_set(index: number, val: {{T}}): void { - this.$_set(index as int, val) + this.$_set(Double.toInt(index), val) } /** @@ -472,7 +446,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @returns a primitive at index */ public override $_get(index: number): {{subsetTypeValues}} { - return this.$_get(index as int) as {{subsetTypeValues}} + return {{ 'this.$_get(Double.toInt(index))' if elementCompat != 'BigInt' else 'new BigInt(this.$_get(Double.toInt(index)))' }} } /** @@ -502,7 +476,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @returns a primitive at index */ public at(index: number): Number | undefined { - return this.at(index as int) + return this.at(Double.toInt(index)) } /** @@ -534,7 +508,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @returns a primitive at index */ public at(index: number): {{elementCompat}} | undefined { - return this.at(index as int) + return this.at(Double.toInt(index)) } /** @@ -570,7 +544,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: number, start: number, end?: number): {{N}}Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(Double.toInt(target), Double.toInt(start), asIntOrDefault(end, this.lengthInt)) } /** @@ -585,7 +559,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: int, start: number, end?: number): {{N}}Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target, Double.toInt(start), asIntOrDefault(end, this.lengthInt)) } /** @@ -600,7 +574,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: number, start: int, end?: number): {{N}}Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(Double.toInt(target), start, asIntOrDefault(end, this.lengthInt)) } /** @@ -615,7 +589,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: int, start: int, end?: number): {{N}}Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target, start, asIntOrDefault(end, this.lengthInt)) } /** @@ -640,7 +614,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} */ public copyWithin(target: number): {{N}}Array { - return this.copyWithin(target as int) + return this.copyWithin(Double.toInt(target)) } /** @@ -677,7 +651,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi {%- if not N in ['Float32', 'Float64', 'BigInt64'] %} value = this.zeroIfInfinity(value) {%- endif %} - this.fill(value{{fromElementCompat}}, asIntOrDefault(start, 0 as int), asIntOrDefault(end, this.lengthInt)) + this.fill(value{{fromElementCompat}}, asIntOrDefault(start, 0), asIntOrDefault(end, this.lengthInt)) return this } @@ -692,22 +666,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi {%- if not N in ['Float32', 'Float64', 'BigInt64'] %} value = this.zeroIfInfinity(value) {%- endif %} - this.fill(value{{fromElementCompat}}, start as int, asIntOrDefault(end, this.lengthInt)) - return this - } - - /** - * Fills the {{N}}Array with specified value - * - * @param value new valuy - * - * @returns modified {{N}}Array - */ - public fill(value: {{elementCompat}}, start: int, end: number): this { - {%- if not N in ['Float32', 'Float64', 'BigInt64'] %} - value = this.zeroIfInfinity(value) - {%- endif %} - this.fill(value{{fromElementCompat}}, start as int, end as int) + this.fill(value{{fromElementCompat}}, start, asIntOrDefault(end, this.lengthInt)) return this } @@ -722,7 +681,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi {%- if not N in ['Float32', 'Float64', 'BigInt64'] %} value = this.zeroIfInfinity(value) {%- endif %} - this.fill(value{{fromElementCompat}}, start as int, end as int) + this.fill(value{{fromElementCompat}}, Double.toInt(start), end) return this } @@ -739,7 +698,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi {%- if N not in ['Float32', 'BigInt64'] %} value = this.zeroIfInfinity(value) {%- endif %} - this.fill(value{{fromElementCompat}}, start as int, end as int) + this.fill(value{{fromElementCompat}}, start, end) return this } @@ -751,7 +710,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @returns modified {{N}}Array */ public fill(value: {{T}}, start?: number, end?: number): this { - this.fill(value, asIntOrDefault(start, 0 as int), asIntOrDefault(end, this.lengthInt)) + this.fill(value, asIntOrDefault(start, 0), asIntOrDefault(end, this.lengthInt)) return this } @@ -763,19 +722,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @returns modified {{N}}Array */ public fill(value: {{T}}, start: int, end?: number): this { - this.fill(value, start as int, asIntOrDefault(end, this.lengthInt)) - return this - } - - /** - * Fills the {{N}}Array with specified value - * - * @param value new valuy - * - * @returns modified {{N}}Array - */ - public fill(value: {{T}}, start: int, end: number): this { - this.fill(value, start as int, end as int) + this.fill(value, start, asIntOrDefault(end, this.lengthInt)) return this } @@ -787,7 +734,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @returns modified {{N}}Array */ public fill(value: {{T}}, start: number, end: int): this { - this.fill(value, start as int, end as int) + this.fill(value, Double.toInt(start), end) return this } @@ -843,11 +790,11 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ public set(arr: FixedArray<{{elementCompat}}>, insertPos: number): void { - const offset = insertPos as int + const offset = Double.toInt(insertPos) if (offset < 0 || offset + arr.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } - for (let i = 0; i < arr.length as int; ++i) { + for (let i = 0; i < Double.toInt(arr.length); ++i) { {%- if (N == 'BigInt64') %} let truncatedVal: BigInt = BigInt.asIntN(64, arr[i]) this.$_set(offset + i, truncatedVal{{fromElementCompat}}) @@ -870,11 +817,11 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ public set(arr: FixedArray<{{T}}>, insertPos: int): void { - const offset = insertPos as int + const offset = insertPos if (offset < 0 || offset + arr.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } - for (let i = 0; i < arr.length as int; ++i) { + for (let i = 0; i < Double.toInt(arr.length); ++i) { {%- if not N in ['Float32', 'Float64', 'BigInt64'] %} let v = this.zeroIfInfinity(arr[i]) this.$_set(offset + i, v) @@ -891,7 +838,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @param arr array to copy data from */ public set(arr: FixedArray<{{elementCompat}}>): void { - this.set(arr, 0 as number) + this.set(arr, 0) } {%- endif %} @@ -901,7 +848,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @param arr array to copy data from */ public set(arr: FixedArray<{{T}}>): void { - this.set(arr, 0 as int) + this.set(arr, 0) } public native set(array: {{N}}Array): void @@ -916,11 +863,11 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @param offset Optional. The offset into the target array at which to begin writing values from the source array */ public set(array: ArrayLike<{% if N == 'BigInt64'%}BigInt{% else %}number{% endif %}>, offset: number = 0): void { - const insertPos = offset as int + const insertPos = Double.toInt(offset) if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } - for (let i = array.length - 1 as int; i >= 0; --i) { + for (let i = Double.toInt(array.length) - 1; i >= 0; --i) { {%- if (N == 'BigInt64') %} let truncatedVal: BigInt = BigInt.asIntN(64, array[i]) this.$_set(offset + i, truncatedVal{{fromElementCompat}}) @@ -945,21 +892,21 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @returns new {{N}}Array */ public static of(...items: FixedArray<{{argType}}>): {{N}}Array { - let res = new {{N}}Array(items.length as int) + let res = new {{N}}Array(Double.toInt(items.length)) for (let i: int = 0; i < items.length; i++) { {%- if argType == 'number' %} {%- if N == 'BigInt64' %} - res.setUnsafe(i, items[i] as long) + res.setUnsafe(i, items[i].toLong()) {%- elif (N != 'Float32') and (N != 'Float64') %} res.setUnsafe(i, res.zeroIfInfinity(items[i]){{fromElementCompat}}) {%- else %} - res.setUnsafe(i, items[i]{{ ' as ' + T if argType != T and T != 'double' else ''}}) + res.setUnsafe(i, items[i]{{ '.to' + BT + '()' if argType != T and T != 'double' else ''}}) {%- endif %} {%- else %} {%- if N == 'BigInt64' and argType == 'bigint' %} res.setUnsafe(i, items[i].getLong()) {%- else %} - res.setUnsafe(i, items[i]{{ ' as ' + T if argType != T else ''}}) + res.setUnsafe(i, items[i]{{ '.to' + BT + '()' if argType != T else ''}}) {%- endif %} {%- endif %} } @@ -976,7 +923,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @returns new {{N}}Array */ public static of(): {{N}}Array { - return new {{N}}Array(0 as int) + return new {{N}}Array(0) } /** @@ -1072,9 +1019,9 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi idx[0] = 0 iteratorForEach(arrayLike.$_iterator(), (x: T): void => { {%- if N not in ['Float32', 'Float64', 'BigInt64'] %} - res.setUnsafe(idx[0] as int, res.zeroIfInfinity(mapfn(x as T, idx[0] as number)){{fromElementCompat}}) + res.setUnsafe(idx[0], res.zeroIfInfinity(mapfn(x as T, Int.toDouble(idx[0])){{fromElementCompat}})) {%- else %} - res.setUnsafe(idx[0] as int, mapfn(x as T, idx[0] as number){{fromElementCompat}}) + res.setUnsafe(idx[0], mapfn(x as T, idx[0]){{fromElementCompat}}) {%- endif %} idx[0] += 1 }) @@ -1122,7 +1069,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @returns true if e is in {{N}}Array, false otherwise */ public includes(searchElement: {{T}}, fromIndex: int): boolean { - return this.indexOf(searchElement as int, fromIndex) != -1 + return this.indexOf(searchElement.toInt(), fromIndex) != -1 } /** @@ -1186,7 +1133,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @returns index of element if it presents, -1 otherwise */ public indexOf(searchElement: int, fromIndex: int): number { - return this.indexOfImpl(searchElement as long, fromIndex) + return this.indexOfImpl(Int.toLong(searchElement), fromIndex) } /** @@ -1321,7 +1268,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ public lastIndexOf(searchElement: int, fromIndex: int): number { - return this.lastIndexOfImpl(searchElement as long, fromIndex) + return this.lastIndexOfImpl(Int.toLong(searchElement), fromIndex) } /** @@ -1392,22 +1339,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin?: number, end?: number): {{N}}Array { - return this.slice(asIntOrDefault(begin, 0 as int), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Creates a slice of current {{N}}Array using range [begin, end) - * - * @param begin start index to be taken into slice - * - * @param end last index to be taken into slice - * - * @returns a new {{N}}Array with elements of current {{N}}Array[begin;end) where end index is excluded - * - * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice - */ - public slice(begin: number, end: number): {{N}}Array { - return this.slice(begin as int, end as int) + return this.slice(asIntOrDefault(begin, 0), asIntOrDefault(end, this.lengthInt)) } /** @@ -1422,7 +1354,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin: number, end: int): {{N}}Array { - return this.slice(begin as int, end as int) + return this.slice(Double.toInt(begin), end) } /** @@ -1437,7 +1369,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin: int, end: number): {{N}}Array { - return this.slice(begin as int, end as int) + return this.slice(begin, Double.toInt(end)) } /** @@ -1459,21 +1391,10 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi if (count < 0) { count = 0 } - let buf = this.buffer.slice(relStart * {{N}}Array.BYTES_PER_ELEMENT as int, relEnd * {{N}}Array.BYTES_PER_ELEMENT as int) as ArrayBuffer + let buf = this.buffer.slice(relStart * {{N}}Array.BYTES_PER_ELEMENT.toInt(), relEnd * {{N}}Array.BYTES_PER_ELEMENT.toInt()) as ArrayBuffer return new {{N}}Array(buf) } - /** - * Creates a slice of current {{N}}Array using range [begin, this.length). - * - * @param begin start index to be taken into slice - * - * @returns a new {{N}}Array with elements of current {{N}}Array[begin, this.length) - */ - public slice(begin: number): {{N}}Array { - return this.slice(begin as int) - } - /** * Creates a slice of current {{N}}Array using range [begin, this.length). * @@ -1498,19 +1419,6 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi return this.subarray(asIntOrDefault(begin, 0 as int), asIntOrDefault(end, this.lengthInt)) } - /** - * Creates a {{N}}Array with the same underlying ArrayBuffer - * - * @param begin start index, inclusive - * - * @param end last index, exclusive - * - * @returns new {{N}}Array with the same underlying ArrayBuffer - */ - public subarray(begin: number, end: number): {{N}}Array { - return this.subarray(begin as int, end as int) - } - /** * Creates a {{N}}Array with the same underlying ArrayBuffer * @@ -1521,7 +1429,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @returns new {{N}}Array with the same underlying ArrayBuffer */ public subarray(begin: number, end: int): {{N}}Array { - return this.subarray(begin as int, end as int) + return this.subarray(Double.toInt(begin), end) } /** @@ -1534,7 +1442,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @returns new {{N}}Array with the same underlying ArrayBuffer */ public subarray(begin: int, end: number): {{N}}Array { - return this.subarray(begin as int, end as int) + return this.subarray(begin, Double.toInt(end)) } /** @@ -1554,7 +1462,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi if (count < 0) { count = 0 } - return new {{N}}Array(this.buffer, relStart * {{N}}Array.BYTES_PER_ELEMENT as int, count) + return new {{N}}Array(this.buffer, relStart * {{N}}Array.BYTES_PER_ELEMENT.toInt(), count) } /** @@ -1565,7 +1473,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @returns new {{N}}Array with the same ArrayBuffer */ public subarray(begin: number): {{N}}Array { - return this.subarray(begin as int, this.lengthInt) + return this.subarray(begin.toInt(), this.lengthInt) } /** @@ -1576,7 +1484,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @returns new {{N}}Array with the same ArrayBuffer */ public subarray(begin: int): {{N}}Array { - return this.subarray(begin as int, this.lengthInt) + return this.subarray(begin, this.lengthInt) } /** @@ -1612,7 +1520,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi let res: StringBuilder = new StringBuilder("") for (let i = 0; i < this.lengthInt - 1; ++i) { {%- if N != 'BigInt64' %} - res.append((this.getUnsafe(i) as {{subsetTypeValues}}).toLocaleString()) + res.append(new {{subsetTypeValues}}(this.getUnsafe(i)).toLocaleString()) {%- else %} res.append(new BigInt(this.getUnsafe(i)).toLocaleString()) {%- endif %} @@ -1620,7 +1528,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi } if (this.lengthInt > 0) { {%- if N != 'BigInt64' %} - res.append((this.getUnsafe(this.lengthInt - 1) as {{subsetTypeValues}}).toLocaleString()) + res.append(new {{subsetTypeValues}}(this.getUnsafe(this.lengthInt - 1))).toLocaleString() {%- else %} res.append(new BigInt(this.getUnsafe(this.lengthInt - 1)).toLocaleString()) {%- endif %} @@ -1683,7 +1591,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @returns an {{N}}Array with replaced value on index */ public with(index: number, value: {{elementCompat}}): {{N}}Array { - return this.with(index as int, value{{fromElementCompat}}) + return this.with(Double.toInt(index), value{{fromElementCompat}}) } /** @@ -1703,7 +1611,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi /// === with element lambda functions === {#- NOTE: to add overloads with idxType == 'int' we need to enhance generics supports #} - {%- for idxType, castToIdx in [('number', ' as number')] %} + {%- for idxType, castToIdx in [('number', '.toDouble()')] %} {%- set skip = False %} {%- set elType, castToEl, castFromEl = elementCompat, asElementCompat, fromElementCompat %} {%- set retType = 'number | undefined' if elementCompat == 'number' else 'BigInt | undefined' %} @@ -1753,16 +1661,21 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi arr[i] = this.getUnsafe(i) } let cmp = (l: {{T}}, r: {{T}}): number => { - const result = compareFn!({{asElementCompat % 'l'}}, {{asElementCompat % 'r'}}) - {%- if N == 'BigInt64' %} - if (result instanceof BigInt) { - return (result as BigInt).getLong() - } else { - return result as number + return (l - r).toDouble() + } + if (compareFn != undefined) { + cmp = (l: {{T}}, r: {{T}}): number => { + const result = compareFn!({{asElementCompat % 'l'}}, {{asElementCompat % 'r'}}) + {%- if N == 'BigInt64' %} + if (result instanceof BigInt) { + return result.getLong() + } else { + return result as number + } + {%- else %} + return result + {%- endif %} } - {%- else %} - return result - {%- endif %} } sort(arr, cmp) for (let i = 0; i < this.lengthInt; ++i) { @@ -1895,8 +1808,8 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @returns a new {{N}}Array where for each element from current {{N}}Array fn was applied */ public map(fn: (val: {{elType}}, index: {{idxType}}, array: {{N}}Array) => {{elType}}): {{N}}Array { - let resBuf = new ArrayBuffer(this.lengthInt * {{N}}Array.BYTES_PER_ELEMENT as int) - let res = new {{N}}Array(resBuf, 0, resBuf.getByteLength() / {{N}}Array.BYTES_PER_ELEMENT as int) + let resBuf = new ArrayBuffer(this.lengthInt * {{N}}Array.BYTES_PER_ELEMENT) + let res = new {{N}}Array(resBuf, 0, Double.toInt(resBuf.getByteLength() / {{N}}Array.BYTES_PER_ELEMENT)) for (let i = 0; i < this.lengthInt; ++i) { res.set(i, fn({{castToEl % 'this.getUnsafe(i)'}}, i{{castToIdx}}, this){{castFromEl}}) } @@ -1938,7 +1851,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi ++resLen } } - let resBuf = new ArrayBuffer(resLen * {{N}}Array.BYTES_PER_ELEMENT as int) + let resBuf = new ArrayBuffer(resLen * {{N}}Array.BYTES_PER_ELEMENT) let res = new {{N}}Array(resBuf, 0) for (let i = 0, j = 0; i < this.lengthInt; ++i) { if (markers[i]) { @@ -1985,7 +1898,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi return i{{castToIdx}} } } - return -1{{castToIdx}} + return (-1){{castToIdx}} } /** @@ -2019,7 +1932,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi return i } } - return -1{{castToIdx}} + return (-1){{castToIdx}} } /** @@ -2048,7 +1961,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi } internal getUnsafe(index: int): {{T}} { - let byteIndex = index * {{N}}Array.BYTES_PER_ELEMENT as int + this.byteOffset as int + let byteIndex = index * {{N}}Array.BYTES_PER_ELEMENT + Double.toInt(this.byteOffset) {%- if T == "float" %} {%- set ET = "int" %} {%- elif T == "double" %} @@ -2059,12 +1972,12 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi let res : {{ET}} = 0 let byteVal : {{ET}} if (IS_LITTLE_ENDIAN) { - for (let i: int = 0; i < {{N}}Array.BYTES_PER_ELEMENT as int; ++i) { - byteVal = (this.buffer as ArrayBuffer).at(byteIndex as int + i) + for (let i: int = 0; i < {{N}}Array.BYTES_PER_ELEMENT.toInt(); ++i) { + byteVal = (this.buffer as ArrayBuffer).at(byteIndex.toInt() + i) {%- if ET != "byte" %} byteVal &= 0xff {%- endif %} - res = (res | byteVal << (8 * i)) as {{ET}} + res = (res | byteVal << (8 * i)).to{{ET.capitalize()}}() } {%- if T == "float" %} return Float.bitCastFromInt(res) @@ -2074,12 +1987,12 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi return res {%- endif %} } else { - for (let i: int = 0; i < {{N}}Array.BYTES_PER_ELEMENT as int; ++i) { - byteVal = this.buffer.at(byteIndex as int + {{S - 1}} - i) + for (let i: int = 0; i < {{N}}Array.BYTES_PER_ELEMENT.toInt(); ++i) { + byteVal = this.buffer.at(byteIndex.toInt() + {{S - 1}} - i) {%- if ET != "byte" %} byteVal &= 0xff {%- endif %} - res = (res | byteVal << (8 * i)) as {{ET}} + res = (res | byteVal << (8 * i)).to{{ET.capitalize()}}() } {%- if T == "float" %} return Float.bitCastFromInt(res) @@ -2092,7 +2005,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi } internal setUnsafe(insertPos: int, val: {{T}}): void { - let startByte = insertPos * {{N}}Array.BYTES_PER_ELEMENT as int + this.byteOffset as int + let startByte = insertPos * {{N}}Array.BYTES_PER_ELEMENT + Double.toInt(this.byteOffset) {%- if T == "float" %} let bits = Float.bitCastToInt(val) {%- elif T == "double" %} @@ -2101,13 +2014,13 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi let bits = val {%- endif %} if (IS_LITTLE_ENDIAN) { - for (let i = 0; i < {{N}}Array.BYTES_PER_ELEMENT as int; ++i) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + for (let i = 0; i < {{N}}Array.BYTES_PER_ELEMENT.toInt(); ++i) { + let byteVal = ((bits >>> (i * 8)) & 0xff).toByte() this.buffer.set(startByte + i, byteVal) } } else { - for (let i = 0; i < {{N}}Array.BYTES_PER_ELEMENT as int; i++) { - let byteVal = ((bits >>> (i * 8)) & 0xff) as byte + for (let i = 0; i < {{N}}Array.BYTES_PER_ELEMENT.toInt(); i++) { + let byteVal = ((bits >>> (i * 8)) & 0xff).toByte() this.buffer.set(startByte + {{S - 1}} - i, byteVal) } } diff --git a/static_core/plugins/ets/templates/stdlib/typedUArray.ets.j2 b/static_core/plugins/ets/templates/stdlib/typedUArray.ets.j2 index d1d0e1087ddee839f95109a41c2fe6d56184d764..fc77aaaf3b592b34839e8628f48f5c6b02553b02 100644 --- a/static_core/plugins/ets/templates/stdlib/typedUArray.ets.j2 +++ b/static_core/plugins/ets/templates/stdlib/typedUArray.ets.j2 @@ -25,20 +25,20 @@ const IS_LITTLE_ENDIAN: boolean; {'name': 'Uint32', 'subsetType': 'number', 'subsetTypeValues': 'Number', 'primitiveType': 'long', 'bytes': 4, 'primitiveTypeWide': 'long'}, {'name': 'BigUint64', 'subsetType': 'BigInt', 'subsetTypeValues': 'BigInt', 'primitiveType': 'long', 'bytes': 8, 'primitiveTypeWide': 'long'}] %} {%- set _ = element.update({'subsetTypeBoxed': element['subsetType'][0].upper() + element['subsetType'][1:], 'primitiveTypeBoxed': element['primitiveType'][0].upper() + element['primitiveType'][1:]}) %} - {%- set asElementCompat = ('%s as ' + element['subsetType']) if element['subsetType'] != 'BigInt' else 'new BigInt(%s)' %} - {%- set fromElementCompat = ('%s as ' + element['primitiveType']) if element['subsetType'] != 'BigInt' else '%s.getULong()' %} - {%- set numberBigIntToPrimitive = ('.' + element['primitiveType'] + 'Value()') if element['subsetType'] != 'BigInt' else '.getULong()' %} + {%- set asElementCompat = ('%s.toDouble()') if element['subsetType'] != 'BigInt' else 'new BigInt(%s)' %} + {%- set fromElementCompat = ('%s.to' + element['primitiveType'].capitalize() + '()') if element['subsetType'] != 'BigInt' else '%s.getULong()' %} + {%- set numberBigIntToPrimitive = ('.to' + element['primitiveType'].capitalize() + '()') if element['subsetType'] != 'BigInt' else '.getULong()' %} {%- set numberBigIntUndefToPrimitive = (numberBigIntToPrimitive) %} {%- set isNonCompat = '/* public */ internal' if element['subsetType'] != 'BigInt' else 'private' %} {%- set valueOrBigIntGetULong = '%s' if element['subsetType'] != 'BigInt' else 'new BigInt(%s).getULong()' %} - {%- set asElementCompatOrBigInt = ('%s as ' + element['primitiveType']) if element['subsetType'] != 'BigInt' else '%s' %} + {%- set asElementCompatOrBigInt = ('%s.to' + element['primitiveType'].capitalize() + '()') if element['subsetType'] != 'BigInt' else '%s' %} class {{element['name']}}ArrayIteratorKeys implements IterableIterator { private length: int = 0 private idx: int = 0 constructor(parent: {{element['name']}}Array) { - this.length = parent.length as int + this.length = parent.length.toInt() } public override $_iterator(): IterableIterator { @@ -49,7 +49,7 @@ class {{element['name']}}ArrayIteratorKeys implements IterableIterator { if (this.idx < 0 || this.idx >= this.length) { return new IteratorResult() } - return new IteratorResult(false, this.idx++ as number) + return new IteratorResult(false, Int.toDouble(this.idx++)) } } @@ -102,8 +102,8 @@ class {{element['name']}}ArrayIteratorEntries implements IterableIterator<{{subs * JS {{element['name']}}Array API-compatible class */ export final class {{element['name']}}Array implements Iterable<{{element['subsetTypeValues']}}>, ArrayLike<{{element['subsetTypeValues']}}> { - public static readonly BYTES_PER_ELEMENT: number = {{element['bytes']}} - public readonly BYTES_PER_ELEMENT: number = {{element['name']}}Array.BYTES_PER_ELEMENT + public static readonly BYTES_PER_ELEMENT: int = {{element['bytes']}} + public readonly BYTES_PER_ELEMENT: int = {{element['name']}}Array.BYTES_PER_ELEMENT /** Underlying Buffer */ public readonly buffer: ArrayBuffer @@ -116,7 +116,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * Creates an empty {{element['name']}}Array. */ public constructor() { - this(0 as int) + this(0) } /** @@ -126,17 +126,17 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse const items: Object = elements as Object if (items instanceof ArrayLike) { const arr = Types.identity_cast<{{element['subsetTypeValues']}}>(items as ArrayLike<{{element['subsetTypeValues']}}>) - this.byteLengthInt = arr.length as int * {{element['name']}}Array.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int + this.byteLengthInt = arr.length.toInt() * {{element['name']}}Array.BYTES_PER_ELEMENT + this.lengthInt = arr.length.toInt() this.buffer = new ArrayBuffer(this.byteLengthInt) this.byteOffsetInt = 0 for (let i: int = 0; i < this.lengthInt; ++i) { {%- if element.get('name') == 'BigUint64' %} this.setUnsafeClamp(i, arr.$_get(i){{numberBigIntToPrimitive}}) {%- elif element.get('name') != 'Uint8Clamped' %} - this.setUnsafeClamp(i, this.zeroIfInfinity(arr.$_get(i)) as {{element['primitiveType']}}) + this.setUnsafeClamp(i, this.zeroIfInfinity(arr.$_get(i)).to{{element['primitiveType'].capitalize()}}()) {%- else %} - this.setUnsafeClamp(i, arr.$_get(i) as {{element['primitiveType']}}) + this.setUnsafeClamp(i, arr.$_get(i).to{{element['primitiveType'].capitalize()}}()) {%- endif %} } } else { @@ -170,27 +170,27 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse throw new RangeError("Range Error: byteLength " + intByteLength + " is outside the bounds of the buffer with byteOffset " + intByteOffset) } {% if element.get('bytes') != 1 %} - if (intByteLength % {{element['name']}}Array.BYTES_PER_ELEMENT as int != 0) { + if (intByteLength % {{element['name']}}Array.BYTES_PER_ELEMENT.toInt() != 0) { throw new RangeError("ArrayBuffer.byteLength should be multiple of {{element['bytes']}} as {{element['name']}}Array.BYTES_PER_ELEMENT") } - if (intByteOffset % {{element['name']}}Array.BYTES_PER_ELEMENT as int != 0) { + if (intByteOffset % {{element['name']}}Array.BYTES_PER_ELEMENT != 0) { throw new RangeError("byteOffset should be multiple of {{element['bytes']}} as {{element['name']}}Array.BYTES_PER_ELEMENT") } {% endif %} let intLength: int if (length != undefined) { intLength = length.toInt() - if (intLength > intByteLength / {{element['name']}}Array.BYTES_PER_ELEMENT as int) { + if (intLength > intByteLength / {{element['name']}}Array.BYTES_PER_ELEMENT) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer with byteOffset " + intByteOffset) } } else { - intLength = intByteLength / {{element['name']}}Array.BYTES_PER_ELEMENT as int + intLength = intByteLength / {{element['name']}}Array.BYTES_PER_ELEMENT } if (intLength < 0) { throw new RangeError("Range Error: length " + intLength + " is outside the bounds of the buffer") } - if (intLength < intByteLength / {{element['name']}}Array.BYTES_PER_ELEMENT as int) { - intByteLength = intLength * {{element['name']}}Array.BYTES_PER_ELEMENT as int + if (intLength < intByteLength / {{element['name']}}Array.BYTES_PER_ELEMENT) { + intByteLength = intLength * {{element['name']}}Array.BYTES_PER_ELEMENT } this.byteLengthInt = intByteLength this.byteOffsetInt = intByteOffset @@ -198,30 +198,6 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse this.buffer = buf } - /** - * Creates an {{element['name']}}Array with respect to data, byteOffset and length. - * - * @param buf data initializer - * - * @param byteOffset byte offset from begin of the buf - */ - public constructor(buf: ArrayBuffer, byteOffset: Number | undefined) { - this(buf, byteOffset, undefined) - } - - /** - * Creates an {{element['name']}}Array with respect to data, byteOffset and length. - * - * @param buf data initializer - * - * @param byteOffset byte offset from begin of the buf - * - * @param length size of elements of type {{element['primitiveType']}} in newly created {{element['name']}}Array - */ - public constructor(buf: ArrayBuffer, byteOffset: number, length: number) { - this(buf, new Number(byteOffset), new Number(length)) - } - /** * Creates an {{element['name']}}Array with respect to buf and byteOffset. * @@ -242,7 +218,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * * @param length size of elements of type {{element['primitiveType']}} in newly created {{element['name']}}Array */ - public constructor(buf: ArrayBuffer, byteOffset: int, length: int) { + public constructor(buf: ArrayBufferLike, byteOffset: int, length: int) { this(buf, new Number(byteOffset), new Number(length)) } @@ -265,18 +241,18 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse public constructor(buf: ArrayLike | ArrayBuffer) { if (buf instanceof ArrayBuffer) { this.byteLengthInt = (buf as ArrayBuffer).getByteLength() - if (this.byteLengthInt % {{element['name']}}Array.BYTES_PER_ELEMENT as int != 0) { + if (this.byteLengthInt % {{element['name']}}Array.BYTES_PER_ELEMENT.toInt() != 0) { throw new RangeError("ArrayBuffer.byteLength should be multiple of {{element['primitiveType']}} as {{element['name']}}Array.BYTES_PER_ELEMENT") } - this.lengthInt = this.byteLengthInt / {{element['name']}}Array.BYTES_PER_ELEMENT as int + this.lengthInt = this.byteLengthInt / {{element['name']}}Array.BYTES_PER_ELEMENT this.buffer = buf as ArrayBuffer this.byteOffsetInt = 0 } else if (buf instanceof ArrayLike) { // NOTE (ikorobkov): dealing with this overload is tricky // with banned `instanceof` generic, so it is delegated to array here. Initial idea from Set.ets let arr = Array.from((buf as ArrayLike)) - this.byteLengthInt = arr.length as int * {{element['name']}}Array.BYTES_PER_ELEMENT as int - this.lengthInt = arr.length as int + this.byteLengthInt = arr.length.toInt() * {{element['name']}}Array.BYTES_PER_ELEMENT + this.lengthInt = arr.length.toInt() this.buffer = new ArrayBuffer(this.byteLengthInt) this.byteOffsetInt = 0 for (let i: int = 0; i < this.lengthInt; ++i) { @@ -297,7 +273,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @param length data initializer */ public constructor(length: int) { - this(length as number) + this(length.toDouble()) } /** @@ -309,8 +285,8 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse if (length < 0 || length > (Int.MAX_VALUE / {{element['name']}}Array.BYTES_PER_ELEMENT)) { throw new TypeError("Type Error: length " + length + " is outside the bounds of the buffer") } - this.lengthInt = length as int - this.byteLengthInt = this.lengthInt * {{element['name']}}Array.BYTES_PER_ELEMENT as int + this.lengthInt = length.toInt() + this.byteLengthInt = this.lengthInt * {{element['name']}}Array.BYTES_PER_ELEMENT this.byteOffsetInt = 0 this.buffer = new ArrayBuffer(this.byteLengthInt) } @@ -321,9 +297,9 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @param other data initializer */ public constructor(other: {{element['name']}}Array) { - this.buffer = other.buffer.slice(other.byteOffset as int, (other.byteOffset + other.byteLength) as int) as ArrayBuffer - this.byteLengthInt = other.byteLength as int - this.lengthInt = other.length as int + this.buffer = other.buffer.slice(other.byteOffset.toInt(), (other.byteOffset + other.byteLength).toInt()) as ArrayBuffer + this.byteLengthInt = other.byteLength.toInt() + this.lengthInt = other.length.toInt() this.byteOffsetInt = 0 } @@ -338,7 +314,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse {%- elif element.get('name') != 'Uint8Clamped' %} this.setUnsafeClamp(i, {{ asElementCompatOrBigInt % ( 'this.zeroIfInfinity(' + (valueOrBigIntGetULong % 'numbers[i]') + ')' ) }}) {%- else %} - this.setUnsafeClamp(i, numbers[i] as {{element['primitiveType']}}) + this.setUnsafeClamp(i, numbers[i].to{{element['primitiveType'].capitalize()}}()) {%- endif %} } } @@ -354,7 +330,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse {%- elif element.get('name') != 'Uint8Clamped' %} this.setUnsafeClamp(i, {{ asElementCompatOrBigInt % ( 'this.zeroIfInfinity(' + (valueOrBigIntGetULong % 'numbers[i]') + ')' ) }}) {%- else %} - this.setUnsafeClamp(i, numbers[i] as {{element['primitiveType']}}) + this.setUnsafeClamp(i, numbers[i].to{{element['primitiveType'].capitalize()}}()) {%- endif %} } } @@ -380,14 +356,14 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse {%- else %} if (({{fromElementCompat % 'val'}} == Infinity) || ({{fromElementCompat % 'val'}} == -Infinity)) { {%- endif %} - return {{asElementCompat % '0'}} + return {{ '0' if element['subsetType'] != 'BigInt' else 'new BigInt(0)' }} } - return {{asElementCompat % 'val'}} + return {{ 'val' if element['subsetType'] != 'BigInt' else 'new BigInt(val)' }} } internal zeroIfInfinity(val: {{element['primitiveType']}}): {{element['primitiveType']}} { if ((val == Infinity) || (val == -Infinity)) { - return 0 as {{element['primitiveType']}} + return 0 } return val } @@ -410,7 +386,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @returns a primitive at index */ public at(index: number): {{element['subsetTypeBoxed']}} | undefined { - return this.at(index as int) + return this.at(index.toInt()) } /** @@ -445,7 +421,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @returns a primitive at index */ public override $_get(index: number): {{element['subsetTypeValues']}} { - return this.$_get(index as int) as {{element['subsetTypeValues']}} + return {{ asElementCompat % 'this.$_get(index.toInt())' }} } /** @@ -472,7 +448,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @param index index to change */ public $_set(index: number, val: {{element['subsetType']}}): void { - this.$_set(index as int, val) + this.$_set(index.toInt(), val) } /** @@ -499,7 +475,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @param index index to change */ public $_set(index: number, val: {{element['primitiveType']}}): void { - this.$_set(index as int, val) + this.$_set(index.toInt(), val) } /** @@ -520,7 +496,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @param index index to change */ public $_set(index: number, val: int): void { - this.$_set(index as int, val as int) + this.$_set(index.toInt(), val.toInt()) } /** @@ -545,7 +521,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: number, start: number, end?: number): {{element['name']}}Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -560,7 +536,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: int, start: number, end?: number): {{element['name']}}Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -575,7 +551,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: number, start: int, end?: number): {{element['name']}}Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -590,7 +566,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ public copyWithin(target: int, start: int, end?: number): {{element['name']}}Array { - return this.copyWithin(target as int, start as int, asIntOrDefault(end, this.lengthInt)) + return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -615,7 +591,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} */ public copyWithin(target: number): {{element['name']}}Array { - return this.copyWithin(target as int) + return this.copyWithin(target.toInt()) } /** @@ -650,7 +626,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse {%- if not element.get('name') in ['Uint8Clamped', 'BigUint64'] %} value = this.zeroIfInfinity(value) {%- endif %} - this.fill({{fromElementCompat % 'value'}}, asIntOrDefault(start, 0 as int), asIntOrDefault(end, this.lengthInt)) + this.fill({{fromElementCompat % 'value'}}, asIntOrDefault(start, 0), asIntOrDefault(end, this.lengthInt)) return this } @@ -665,22 +641,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse {%- if not element.get('name') in ['Uint8Clamped', 'BigUint64'] %} value = this.zeroIfInfinity(value) {%- endif %} - this.fill({{fromElementCompat % 'value'}}, start as int, asIntOrDefault(end, this.lengthInt)) - return this - } - - /** - * Fills the {{element['name']}}Array with specified value - * - * @param value new value - * - * @returns modified {{element['name']}}Array - */ - public fill(value: {{element['subsetType']}}, start: int, end: number): {{element['name']}}Array { - {%- if not element.get('name') in ['Uint8Clamped', 'BigUint64'] %} - value = this.zeroIfInfinity(value) - {%- endif %} - this.fill({{fromElementCompat % 'value'}}, start as int, end as int) + this.fill({{fromElementCompat % 'value'}}, start.toInt(), asIntOrDefault(end, this.lengthInt)) return this } @@ -695,7 +656,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse {%- if not element.get('name') in ['Uint8Clamped', 'BigUint64'] %} value = this.zeroIfInfinity(value) {%- endif %} - this.fill({{fromElementCompat % 'value'}}, start as int, end as int) + this.fill({{fromElementCompat % 'value'}}, start.toInt(), end.toInt()) return this } @@ -710,7 +671,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse {%- if not element.get('name') in ['Uint8Clamped', 'BigUint64'] %} value = this.zeroIfInfinity(value) {%- endif %} - this.fill({{fromElementCompat % 'value'}}, start as int, end as int) + this.fill({{fromElementCompat % 'value'}}, start.toInt(), end.toInt()) return this } @@ -722,7 +683,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @returns modified {{element['name']}}Array */ public fill(value: {{element['primitiveType']}}, start?: number, end?: number): {{element['name']}}Array { - this.fill(value, asIntOrDefault(start, 0 as int), asIntOrDefault(end, this.lengthInt)) + this.fill(value, asIntOrDefault(start, 0), asIntOrDefault(end, this.lengthInt)) return this } @@ -734,19 +695,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @returns modified {{element['name']}}Array */ public fill(value: {{element['primitiveType']}}, start: int, end?: number): {{element['name']}}Array { - this.fill(value, start as int, asIntOrDefault(end, this.lengthInt)) - return this - } - - /** - * Fills the {{element['name']}}Array with specified value - * - * @param value new value - * - * @returns modified {{element['name']}}Array - */ - public fill(value: {{element['primitiveType']}}, start: int, end: number): {{element['name']}}Array { - this.fill(value, start as int, end as int) + this.fill(value, start.toInt(), asIntOrDefault(end, this.lengthInt)) return this } @@ -758,7 +707,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @returns modified {{element['name']}}Array */ public fill(value: {{element['primitiveType']}}, start: number, end: int): {{element['name']}}Array { - this.fill(value, start as int, end as int) + this.fill(value, start.toInt(), end.toInt()) return this } @@ -789,7 +738,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @param index index to change */ public set(insertPos: number, val: {{element['subsetType']}}): void { - this.$_set(insertPos as int, val) + this.$_set(insertPos.toInt(), val) } /** @@ -800,7 +749,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @param index index to change */ public set(insertPos: int, val: {{element['subsetType']}}): void { - this.$_set(insertPos as int, val) + this.$_set(insertPos.toInt(), val) } /** @@ -811,7 +760,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @param index index to change */ public set(insertPos: number, val: {{element['primitiveType']}}): void { - this.$_set(insertPos as int, val) + this.$_set(insertPos.toInt(), val) } /** @@ -822,7 +771,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @param index index to change */ public set(insertPos: int, val: {{element['primitiveType']}}): void { - this.$_set(insertPos as int, val) + this.$_set(insertPos.toInt(), val) } /** @@ -835,16 +784,16 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ public set(arr: FixedArray<{{element['subsetType']}}>, insertPos1: number): void { - const insertPos = insertPos1 as int + const insertPos = insertPos1.toInt() if (insertPos < 0 || insertPos + arr.length > this.lengthInt) { throw new RangeError("set(insertPos: int, arr: FixedArray<{{element['primitiveType']}}>): size of arr is greater than {{element['name']}}Array.length") } for (let i = 0; i < arr.length; i++) { {%- if not element.get('name') in ['Uint8Clamped', 'BigUint64']%} let v = this.zeroIfInfinity(arr[i]) - this.setUnsafeClamp(insertPos as int + i as int, {{fromElementCompat % 'v'}}) + this.setUnsafeClamp(insertPos.toInt() + i.toInt(), {{fromElementCompat % 'v'}}) {%- else %} - this.setUnsafeClamp(insertPos as int + i as int, {{fromElementCompat % 'arr[i]'}}) + this.setUnsafeClamp(insertPos.toInt() + i.toInt(), {{fromElementCompat % 'arr[i]'}}) {%- endif %} } } @@ -902,16 +851,16 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @param offset Optional. The offset into the target array at which to begin writing values from the source array */ public set(array: ArrayLike<{% if element['name'] == 'BigUint64' %}BigInt{% else %}number{% endif %}>, offset: number = 0): void { - const insertPos = offset as int + const insertPos = offset.toInt() if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } for (let i = array.length - 1; i >= 0; --i) { {%- if not element.get('name') in ['Uint8Clamped', 'BigUint64'] %} let v = this.zeroIfInfinity(array[i]) - this.setUnsafeClamp(insertPos as int + i as int, {{fromElementCompat % 'v'}}) + this.setUnsafeClamp(insertPos.toInt() + i.toInt(), {{fromElementCompat % 'v'}}) {%- else %} - this.setUnsafeClamp(insertPos as int + i as int, {{fromElementCompat % 'array[i]'}}) + this.setUnsafeClamp(insertPos.toInt() + i.toInt(), {{fromElementCompat % 'array[i]'}}) {%- endif %} } } @@ -927,7 +876,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @returns new {{element['name']}}Array */ public static of(...items: FixedArray<{{argType}}>): {{element['name']}}Array { - let res = new {{element['name']}}Array(items.length as int) + let res = new {{element['name']}}Array(items.length.toInt()) for (let i: int = 0; i < items.length; i++) { {%- if element.get('name') != 'Uint8Clamped' %} {%- if argType == 'bigint' %} @@ -936,13 +885,13 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse {%- if element.get('name') == 'BigUint64' %} res.setUnsafeClamp(i, ({{asElementCompat % 'items[i]'}}){{numberBigIntToPrimitive}}) {%- else %} - res.setUnsafeClamp(i, res.zeroIfInfinity(items[i]) as {{element['primitiveType']}}) + res.setUnsafeClamp(i, res.zeroIfInfinity(items[i]).to{{element['primitiveType'].capitalize()}}()) {%- endif %} {%- else %} - res.setUnsafeClamp(i, items[i]{{ ' as ' + element['primitiveType'] if argType != element['primitiveType'] else ''}}) + res.setUnsafeClamp(i, items[i]{{ '.to' + element['primitiveType'].capitalize() + '()' if argType != element['primitiveType'] else ''}}) {%- endif %} {%- else %} - res.setUnsafeClamp(i, items[i]{{ ' as ' + element['primitiveType'] if argType != element['primitiveType'] else ''}}) + res.setUnsafeClamp(i, items[i]{{ '.to' + element['primitiveType'].capitalize() + '()' if argType != element['primitiveType'] else ''}}) {%- endif %} } return res @@ -957,7 +906,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @returns new {{element['name']}}Array */ public static of(): {{element['name']}}Array { - return new {{element['name']}}Array(0 as int) + return new {{element['name']}}Array(0) } /** @@ -1005,9 +954,9 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse {%- if element.get('name') == 'BigUint64' %} result.setUnsafeClamp(i, ((mapfn)!(x.value!, i)){{numberBigIntToPrimitive}}) {%- elif element.get('name') != 'Uint8Clamped' %} - result.setUnsafeClamp(i, result.zeroIfInfinity((mapfn)!(x.value!, i)) as {{element['primitiveType']}}) + result.setUnsafeClamp(i, result.zeroIfInfinity((mapfn)!(x.value!, i)).to{{element['primitiveType'].capitalize()}}()) {%- else %} - result.setUnsafeClamp(i, (mapfn)!(x.value!, i) as {{element['primitiveType']}}) + result.setUnsafeClamp(i, (mapfn)!(x.value!, i).to{{element['primitiveType'].capitalize()}}()) {%- endif %} } return result @@ -1031,9 +980,9 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse {%- if element.get('name') == 'BigUint64' %} temp.setUnsafeClamp(index[0], ((mapfn)!(x, index[0])){{numberBigIntToPrimitive}}) {%- elif element.get('name') != 'Uint8Clamped' %} - temp.setUnsafeClamp(index[0], temp.zeroIfInfinity((mapfn)!(x, index[0])) as {{element['primitiveType']}}) + temp.setUnsafeClamp(index[0], temp.zeroIfInfinity((mapfn)!(x, index[0])).to{{element['primitiveType'].capitalize()}}()) {%- else %} - temp.setUnsafeClamp(index[0], (mapfn)!(x, index[0]) as {{element['primitiveType']}}) + temp.setUnsafeClamp(index[0], (mapfn)!(x, index[0]).to{{element['primitiveType'].capitalize()}}()) {%- endif %} index[0]++ }) @@ -1057,11 +1006,11 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse idx[0] = 0 iteratorForEach(arrayLike.$_iterator(), (x: T): void => { {%- if element.get('name') == 'BigUint64' %} - res.setUnsafeClamp(idx[0], (mapfn(x as T, idx[0] as number)){{numberBigIntToPrimitive}}) + res.setUnsafeClamp(idx[0], (mapfn(x as T, idx[0].toDouble())){{numberBigIntToPrimitive}}) {%- elif element.get('name') != 'Uint8Clamped' %} - res.setUnsafeClamp(idx[0], res.zeroIfInfinity(mapfn(x as T, idx[0] as number)) as {{element['primitiveType']}}) + res.setUnsafeClamp(idx[0], res.zeroIfInfinity(mapfn(x as T, idx[0].toDouble())).to{{element['primitiveType'].capitalize()}}()) {%- else %} - res.setUnsafeClamp(idx[0], mapfn(x as T, idx[0] as number) as {{element['primitiveType']}}) + res.setUnsafeClamp(idx[0], mapfn(x as T, idx[0].toDouble()).to{{element['primitiveType'].capitalize()}}()) {%- endif %} idx[0] += 1 }) @@ -1091,7 +1040,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @returns true if searchElement is in {{element['name']}}Array, false otherwise */ public includes(searchElement: {{element['primitiveType']}}, fromIndex: int): boolean { - return this.indexOf(searchElement as int, fromIndex) != -1 + return this.indexOf(searchElement.toInt(), fromIndex) != -1 } /** @@ -1104,7 +1053,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @returns true if searchElement is in {{element['name']}}Array, false otherwise */ public includes(searchElement: {{element['primitiveType']}}): boolean { - return this.indexOf(searchElement as int, 0) != -1 + return this.indexOf(searchElement.toInt(), 0) != -1 } /** @@ -1154,7 +1103,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @returns index of element if it presents, -1 otherwise */ public indexOf(searchElement: int, fromIndex: int): number { - return this.indexOfImpl(searchElement as long, fromIndex) + return this.indexOfImpl(Int.toLong(searchElement), fromIndex) } /** @@ -1290,7 +1239,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ public lastIndexOf(searchElement: int, fromIndex: int): number { - return this.lastIndexOfImpl(searchElement as long, fromIndex) + return this.lastIndexOfImpl(Int.toLong(searchElement), fromIndex) } /** @@ -1361,22 +1310,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin?: number, end?: number): {{element['name']}}Array { - return this.slice(asIntOrDefault(begin, 0 as int), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Creates a slice of current {{element['name']}}Array using range [begin, end) - * - * @param begin start index to be taken into slice - * - * @param end last index to be taken into slice - * - * @returns a new {{element['name']}}Array with elements of current {{element['name']}}Array[begin;end) where end index is excluded - * - * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice - */ - public slice(begin: number, end: number): {{element['name']}}Array { - return this.slice(begin as int, end as int) + return this.slice(asIntOrDefault(begin, 0), asIntOrDefault(end, this.lengthInt)) } /** @@ -1391,7 +1325,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin: number, end: int): {{element['name']}}Array { - return this.slice(begin as int, end as int) + return this.slice(begin.toInt(), end.toInt()) } /** @@ -1406,7 +1340,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice */ public slice(begin: int, end: number): {{element['name']}}Array { - return this.slice(begin as int, end as int) + return this.slice(begin.toInt(), end.toInt()) } /** @@ -1428,21 +1362,10 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse if (count < 0) { count = 0 } - let buf = this.buffer.slice(relStart * {{element['name']}}Array.BYTES_PER_ELEMENT as int, relEnd * {{element['name']}}Array.BYTES_PER_ELEMENT as int) as ArrayBuffer + let buf = this.buffer.slice(relStart * {{element['name']}}Array.BYTES_PER_ELEMENT.toInt(), relEnd * {{element['name']}}Array.BYTES_PER_ELEMENT.toInt()) as ArrayBuffer return new {{element['name']}}Array(buf) } - /** - * Creates a slice of current {{element['name']}}Array using range [begin, this.lengthInt). - * - * @param begin start index to be taken into slice - * - * @returns a new {{element['name']}}Array with elements of current {{element['name']}}Array[begin, this.lengthInt) - */ - public slice(begin: number): {{element['name']}}Array { - return this.slice(begin as int) - } - /** * Creates a slice of current {{element['name']}}Array using range [begin, this.lengthInt). * @@ -1485,16 +1408,21 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse arr[i] = this.getUnsafe(i) } let cmp = (l: {{element['primitiveType']}}, r: {{element['primitiveType']}}): number => { - const result = compareFn!({{asElementCompat % 'l'}}, {{asElementCompat % 'r'}}) - {%- if element['name'] == 'BigUint64' %} - if (result instanceof BigInt) { - return (result as BigInt).getLong() - } else { - return result as number + return (l - r).toDouble() + } + if (compareFn != undefined) { + cmp = (l: {{element['primitiveType']}}, r: {{element['primitiveType']}}): number => { + const result = compareFn!({{asElementCompat % 'l'}}, {{asElementCompat % 'r'}}) + {%- if element['name'] == 'BigUint64' %} + if (result instanceof BigInt) { + return (result as BigInt).getLong() + } else { + return result.toDouble() + } + {%- else %} + return result + {%- endif %} } - {%- else %} - return result - {%- endif %} } sort(arr, cmp) for (let i = 0; i < this.lengthInt; ++i) { @@ -1513,20 +1441,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @returns new {{element['name']}}Array with the same underlying Buffer */ public subarray(begin?: number, end?: number): {{element['name']}}Array { - return this.subarray(asIntOrDefault(begin, 0 as int), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Creates a {{element['name']}}Array with the same underlying Buffer - * - * @param begin start index, inclusive - * - * @param end last index, exclusive - * - * @returns new {{element['name']}}Array with the same underlying Buffer - */ - public subarray(begin: number, end: number): {{element['name']}}Array { - return this.subarray(begin as int, end as int) + return this.subarray(asIntOrDefault(begin, 0), asIntOrDefault(end, this.lengthInt)) } /** @@ -1539,7 +1454,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @returns new {{element['name']}}Array with the same underlying Buffer */ public subarray(begin: number, end: int): {{element['name']}}Array { - return this.subarray(begin as int, end as int) + return this.subarray(begin.toInt(), end.toInt()) } /** @@ -1552,7 +1467,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @returns new {{element['name']}}Array with the same underlying Buffer */ public subarray(begin: int, end: number): {{element['name']}}Array { - return this.subarray(begin as int, end as int) + return this.subarray(begin.toInt(), end.toInt()) } /** @@ -1572,18 +1487,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse if (count < 0) { count = 0 } - return new {{element['name']}}Array(this.buffer, relStart * {{element['name']}}Array.BYTES_PER_ELEMENT as int, count) - } - - /** - * Creates a {{element['name']}}Array with the same Buffer - * - * @param begin start index, inclusive - * - * @returns new {{element['name']}}Array with the same Buffer - */ - public subarray(begin: number): {{element['name']}}Array { - return this.subarray(begin as int, this.lengthInt) + return new {{element['name']}}Array(this.buffer, relStart * {{element['name']}}Array.BYTES_PER_ELEMENT, count) } /** @@ -1630,7 +1534,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse let res: StringBuilder = new StringBuilder("") for (let i = 0; i < this.lengthInt - 1; ++i) { {%- if element['name'] != 'BigUint64' %} - res.append((this.getUnsafe(i) as {{element['subsetTypeValues']}}).toLocaleString()) + res.append((this.getUnsafe(i).toDouble()).toLocaleString()) {%- else %} res.append(new BigInt(this.getUnsafe(i)).toLocaleString()) {%- endif %} @@ -1638,7 +1542,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse } if (this.lengthInt > 0) { {%- if element['name'] != 'BigUint64' %} - res.append((this.getUnsafe(this.lengthInt - 1) as {{element['subsetTypeValues']}}).toLocaleString()) + res.append((this.getUnsafe(this.lengthInt - 1).toDouble()).toLocaleString()) {%- else %} res.append(new BigInt(this.getUnsafe(this.lengthInt - 1)).toLocaleString()) {%- endif %} @@ -1692,7 +1596,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @returns an {{element['name']}}Array with replaced value on index */ public with(index: number, value: {{element['subsetType']}}): {{element['name']}}Array { - return this.with(index as int, {{fromElementCompat % 'value'}}) + return this.with(index.toInt(), {{fromElementCompat % 'value'}}) } /** @@ -1717,7 +1621,8 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse {%- set idxType, castToIdx = 'int', '' %} {%- set elType, castToEl, castFromEl = element['primitiveType'], '%s', '%s' %} {%- else %} - {%- set idxType, castToIdx = 'number', ' as number' %} + {#- NOTE: castToIdx as toDouble() is not neccessary, widening should be applied implicitly #} + {%- set idxType, castToIdx = 'number', '' %} {%- set elType, castToEl, castFromEl = element['subsetType'], asElementCompat, fromElementCompat %} {%- endif %} @@ -1842,7 +1747,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @returns a new {{element['name']}}Array where for each element from current {{element['name']}}Array fn was applied */ public map(fn: (val: {{elType}}, index: {{idxType}}, array: {{element['name']}}Array) => {{elType}}): {{element['name']}}Array { - let resBuf = new ArrayBuffer(this.lengthInt * {{element['name']}}Array.BYTES_PER_ELEMENT as int) + let resBuf = new ArrayBuffer(this.lengthInt * {{element['name']}}Array.BYTES_PER_ELEMENT) let res = new {{element['name']}}Array(resBuf) for (let i = 0; i < this.lengthInt; i++) { const fnRes = fn({{castToEl % 'this.getUnsafe(i)'}}, i{{castToIdx}}, this) @@ -1978,7 +1883,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse */ public forEach(callbackfn: (value: {{elType}}, index: number, array: {{element['name']}}Array) => void): void { for (let i = 0; i < this.lengthInt; i++) { - callbackfn({{castToEl % 'this.getUnsafe(i)'}}, i as number, this) + callbackfn({{castToEl % 'this.getUnsafe(i)'}}, i.toDouble(), this) } } @@ -2030,17 +1935,17 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse } internal getUnsafe(index: int): {{element['primitiveType']}} { - index = index * {{element['name']}}Array.BYTES_PER_ELEMENT as int + this.byteOffsetInt + index = index * {{element['name']}}Array.BYTES_PER_ELEMENT + this.byteOffsetInt let res: {{element['primitiveType']}} = 0 if (IS_LITTLE_ENDIAN) { - for (let i = 0; i < {{element['name']}}Array.BYTES_PER_ELEMENT as int; i++) { - let el = this.buffer.at(index + i) as {{element['primitiveType']}} + for (let i = 0; i < {{element['name']}}Array.BYTES_PER_ELEMENT.toInt(); i++) { + let el = this.buffer.at(index + i).to{{element['primitiveType'].capitalize()}}() el &= 0xff res |= el << (8 * i) } } else { - for (let i = 0; i < {{element['name']}}Array.BYTES_PER_ELEMENT as int; i++) { - let el = this.buffer.at(index + {{element['bytes'] - 1}} - i) as {{element['primitiveType']}} + for (let i = 0; i < {{element['name']}}Array.BYTES_PER_ELEMENT.toInt(); i++) { + let el = this.buffer.at(index + {{element['bytes'] - 1}} - i).to{{element['primitiveType'].capitalize()}}() el &= 0xff res |= el << (8 * i) } @@ -2049,16 +1954,16 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse } internal setUnsafe(index: int, val: {{element['primitiveType']}}): void { - index = index * {{element['name']}}Array.BYTES_PER_ELEMENT as int + this.byteOffsetInt + index = index * {{element['name']}}Array.BYTES_PER_ELEMENT + this.byteOffsetInt let res: {{element['primitiveType']}} = 0 if (IS_LITTLE_ENDIAN) { - for (let i = 0; i < {{element['name']}}Array.BYTES_PER_ELEMENT as int; i++) { - this.buffer.set(index + i, (val & 0xff) as byte) + for (let i = 0; i < {{element['name']}}Array.BYTES_PER_ELEMENT.toInt(); i++) { + this.buffer.set(index + i, (val & 0xff).toByte()) val = val >> 8 } } else { - for (let i = 0; i < {{element['name']}}Array.BYTES_PER_ELEMENT as int; i++) { - this.buffer.set(index + {{element['bytes'] - 1}} - i, (val & 0xff) as byte) + for (let i = 0; i < {{element['name']}}Array.BYTES_PER_ELEMENT.toInt(); i++) { + this.buffer.set(index + {{element['bytes'] - 1}} - i, (val & 0xff).toByte()) val = val >> 8 } } diff --git a/static_core/plugins/ets/tests/ani/tests/array_ops/array_region_char_test.ets b/static_core/plugins/ets/tests/ani/tests/array_ops/array_region_char_test.ets index 895cdfd3c9d382b3ca14d71f09b45f2008cca668..0f4f23a780f242f06688e783c47d95f4c5965ac8 100644 --- a/static_core/plugins/ets/tests/ani/tests/array_ops/array_region_char_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/array_ops/array_region_char_test.ets @@ -14,21 +14,21 @@ */ function getArray(): char[] { - let a : char[] = ['a', 'b', 'c', 'd', 'e'] + let a : char[] = [c'a', c'b', c'c', c'd', c'e'] return a } function checkArray(a: char[]): boolean { - let b : char[] = ['a', 'b', 'x', 'y', 'z'] + let b : char[] = [c'a', c'b', c'x', c'y', c'z'] return compareCharArrays(a, b) == 0 } function changeArray(arr: FixedArray): FixedArray { - arr[0] = 'a'; - arr[1] = 'b'; - arr[2] = 'x'; - arr[3] = 'y'; - arr[4] = 'z'; + arr[0] = c'a'; + arr[1] = c'b'; + arr[2] = c'x'; + arr[3] = c'y'; + arr[4] = c'z'; return arr; } @@ -42,6 +42,6 @@ function compareCharArrays(a: char[], b: char[]): int { } function GetSpecialArray(): char[] { - let aChar : char[] = ['\0', '\0', '\n', '\r', '\t', '\b', '\a', '\v', '\f', '\0'] + let aChar : char[] = [c'\0', c'\0', c'\n', c'\r', c'\t', c'\b', c'\a', c'\v', c'\f', c'\0'] return aChar } diff --git a/static_core/plugins/ets/tests/ani/tests/array_ops/array_region_double_test.ets b/static_core/plugins/ets/tests/ani/tests/array_ops/array_region_double_test.ets index de8cafcfeff2fc72935249542f3d7877f36a0566..f9faf36bfd4ce8081eed59a21f8a7fe94cc700cf 100644 --- a/static_core/plugins/ets/tests/ani/tests/array_ops/array_region_double_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/array_ops/array_region_double_test.ets @@ -23,11 +23,11 @@ class ArrayClass { public static CheckStaticArray(): boolean { return ( - ArrayClass.array[0] as int == 1.0 && - ArrayClass.array[1] as int == 2.0 && - ArrayClass.array[2] as int == 22.0 && - ArrayClass.array[3] as int == 33.0 && - ArrayClass.array[4] as int == 44.0 + ArrayClass.array[0].toInt() == 1.0 && + ArrayClass.array[1].toInt() == 2.0 && + ArrayClass.array[2].toInt() == 22.0 && + ArrayClass.array[3].toInt() == 33.0 && + ArrayClass.array[4].toInt() == 44.0 ) } } @@ -48,7 +48,7 @@ function GetEscompatArray(): Array { } function CheckArray(a: double[]): boolean { - return a[0] as int == 1 && a[1] as int == 2 && a[2] as int == 30 && a[3] as int == 40 && a[4] as int == 50 + return a[0].toInt() == 1 && a[1].toInt() == 2 && a[2].toInt() == 30 && a[3].toInt() == 40 && a[4].toInt() == 50 } function GetSpecialArray(): double[] { @@ -60,9 +60,9 @@ function GetSpecialArray(): double[] { } function CheckEscompatArray(a: Array): boolean { - return a[0] as int == 1 && - a[1] as int == 2 && - a[2] as int == 30 && - a[3] as int == 40 && - a[4] as int == 50 + return a[0].toInt() == 1 && + a[1].toInt() == 2 && + a[2].toInt() == 30 && + a[3].toInt() == 40 && + a[4].toInt() == 50 } diff --git a/static_core/plugins/ets/tests/ani/tests/array_ops/array_region_float_test.ets b/static_core/plugins/ets/tests/ani/tests/array_ops/array_region_float_test.ets index 727b02d93d19334f781616f7342a3d1ca8e98415..909cbe46798ede45bf76f5f16a1ee2826ab1a9b7 100644 --- a/static_core/plugins/ets/tests/ani/tests/array_ops/array_region_float_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/array_ops/array_region_float_test.ets @@ -14,7 +14,7 @@ */ class ArrayClass { - public static array: float[] = [1.0, 2.0, 3.0, 4.0, 5.0]; + public static array: float[] = [1.0f, 2.0f, 3.0f, 4.0f, 5.0f]; public static ChangeStaticArray() { ArrayClass.array[2] = 22.0 as float; @@ -23,18 +23,18 @@ class ArrayClass { public static CheckStaticArray(): boolean { return ( - ArrayClass.array[0] as int == 1.0 && - ArrayClass.array[1] as int == 2.0 && - ArrayClass.array[2] as int == 22.0 && - ArrayClass.array[3] as int == 33.0 && - ArrayClass.array[4] as int == 44.0 + ArrayClass.array[0].toInt() == 1.0 && + ArrayClass.array[1].toInt() == 2.0 && + ArrayClass.array[2].toInt() == 22.0 && + ArrayClass.array[3].toInt() == 33.0 && + ArrayClass.array[4].toInt() == 44.0 ) } } function GetArray(): float[] { - let a : float[] = [1.0, 2.0, 3.0, 4.0, 5.0] + let a : float[] = [1.0f, 2.0f, 3.0f, 4.0f, 5.0f] return a } @@ -49,21 +49,21 @@ function GetEscompatArray(): Array { } function CheckArray(a: float[]): boolean { - return a[0] as int == 1 && a[1] as int == 2 && a[2] as int == 30 && a[3] as int == 40 && a[4] as int == 50 + return a[0].toInt() == 1 && a[1].toInt() == 2 && a[2].toInt() == 30 && a[3].toInt() == 40 && a[4].toInt() == 50 } function GetSpecialArray(): float[] { let min: float = new Float(1.40129846432481707e-45) let max: float = new Float(3.40282346638528860e+38) let minus: float = new Float(-3.40282346638528860e+38) - let a : float[] = [min, max, minus, 0.0, 0.0, 0.0] + let a : float[] = [min, max, minus, 0.0f, 0.0f, 0.0f] return a } function CheckEscompatArray(a: Array): boolean { - return a[0] as int == 1 && - a[1] as int == 2 && - a[2] as int == 30 && - a[3] as int == 40 && - a[4] as int == 50 + return a[0].toInt() == 1 && + a[1].toInt() == 2 && + a[2].toInt() == 30 && + a[3].toInt() == 40 && + a[4].toInt() == 50 } diff --git a/static_core/plugins/ets/tests/ani/tests/array_ops/array_set_ref_test.cpp b/static_core/plugins/ets/tests/ani/tests/array_ops/array_set_ref_test.cpp index 55bafd84834102eae3ceda4d04d00365d6278544..bfe46487e8de211a23992a4530b52bbde8f2bc0a 100644 --- a/static_core/plugins/ets/tests/ani/tests/array_ops/array_set_ref_test.cpp +++ b/static_core/plugins/ets/tests/ani/tests/array_ops/array_set_ref_test.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ +#include "ani.h" #include "ani_gtest_array_ops.h" #include @@ -34,7 +35,7 @@ TEST_F(ArraySetRefTest, SetRefErrorTests) const ani_size invalidIndex = 5; ASSERT_EQ(env_->Array_Set_Ref(nullptr, index, ref), ANI_INVALID_ARGS); ASSERT_EQ(env_->Array_Set_Ref(array, invalidIndex, ref), ANI_OUT_OF_RANGE); - auto num = static_cast(CallEtsFunction("array_set_ref_test", "GetNumber")); + auto num = static_cast(CallEtsFunction("array_set_ref_test", "GetObj")); // Can set any object as a type ASSERT_EQ(env_->Array_Set_Ref(array, 0, num), ANI_OK); } @@ -51,7 +52,7 @@ TEST_F(ArraySetRefTest, FixedSetRefErrorTests) const ani_size invalidIndex = 5; ASSERT_EQ(env_->Array_Set_Ref(nullptr, index, ref), ANI_INVALID_ARGS); ASSERT_EQ(env_->Array_Set_Ref(array, invalidIndex, ref), ANI_OUT_OF_RANGE); - auto num = static_cast(CallEtsFunction("array_set_ref_test", "GetNumber")); + auto num = static_cast(CallEtsFunction("array_set_ref_test", "GetObj")); ASSERT_EQ(env_->Array_Set_Ref(array, 0, num), ANI_INVALID_TYPE); } diff --git a/static_core/plugins/ets/tests/ani/tests/array_ops/array_set_ref_test.ets b/static_core/plugins/ets/tests/ani/tests/array_ops/array_set_ref_test.ets index b0843a1856b055966eb021f2185280034861dc45..d756743f86462f83aa57c9dc8cfe8163f3a1fa49 100644 --- a/static_core/plugins/ets/tests/ani/tests/array_ops/array_set_ref_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/array_ops/array_set_ref_test.ets @@ -42,6 +42,6 @@ function CheckEscompatArray(array: Array): boolean { return array[0] == "New String 1!" && array[1] == null && array[2] == "New String 2!"; } -function GetNumber(): Number { - return new Number(42); +function GetObj(): Object { + return new Object(); } diff --git a/static_core/plugins/ets/tests/ani/tests/arraybuffer_ops/accessors_test.ets b/static_core/plugins/ets/tests/ani/tests/arraybuffer_ops/accessors_test.ets index fb49552caba6201fecaf8e984e15a7ee803546e8..cdeefbdf36dd245737d921b88035b11bf76f1644 100644 --- a/static_core/plugins/ets/tests/ani/tests/arraybuffer_ops/accessors_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/arraybuffer_ops/accessors_test.ets @@ -22,5 +22,5 @@ export function createSlicedArrayBuffer(buff: ArrayBuffer, begin: int, end: int) } export function getLength(buff: ArrayBuffer): int { - return buff.byteLength as int; + return buff.byteLength.toInt(); } diff --git a/static_core/plugins/ets/tests/ani/tests/class_ops/call_static_method_byte_test.ets b/static_core/plugins/ets/tests/ani/tests/class_ops/call_static_method_byte_test.ets index 7eb30c1a758f18f312b2a7425dc9b1410ba14e39..9bd5da16a259abe1aa24f9adc1109e21b8944916 100644 --- a/static_core/plugins/ets/tests/ani/tests/class_ops/call_static_method_byte_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/class_ops/call_static_method_byte_test.ets @@ -15,13 +15,13 @@ class Operations { static sum(a0: byte, a1: byte): byte { - return a0 + a1 as byte; + return (a0 + a1).toByte(); } } class A { static funcA(a0: byte, a1: byte): byte { - return a0 + a1 as byte; + return (a0 + a1).toByte(); } static funcA(a0: int, a1: int): int { @@ -35,7 +35,7 @@ class A { class B extends A{ static funcB(a0: byte, a1: byte): byte { - return a1 - a0 as byte; + return (a1 - a0).toByte(); } } @@ -44,7 +44,7 @@ class C extends A{ class D extends A{ static funcA(a0: byte, a1: byte): byte { - return a1 - a0 as byte; + return (a1 - a0).toByte(); } } @@ -69,11 +69,11 @@ class F { class G { public static publicMethod(a0: byte, a1: byte): byte { - return a0 + a1 as byte; + return (a0 + a1).toByte(); } private static privateMethod(a0: byte, a1: byte): byte { - return a1 - a0 as byte; + return (a1 - a0).toByte(); } static callPrivateMethod(a0: byte, a1: byte): byte { diff --git a/static_core/plugins/ets/tests/ani/tests/class_ops/call_static_method_char_test.ets b/static_core/plugins/ets/tests/ani/tests/class_ops/call_static_method_char_test.ets index 139695f5911253686dfc111e2ac0e13a9ffb9e0b..4075ded7b698ed5d87bf3b08b3fee29e32de26cf 100644 --- a/static_core/plugins/ets/tests/ani/tests/class_ops/call_static_method_char_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/class_ops/call_static_method_char_test.ets @@ -15,11 +15,11 @@ class Operations { static sub(c0: char, c1: char): char { - let c: Char = new Char('0'); + let c: Char = new Char(c'0'); if (c0 > c1) { - c = c0 - c1 as Char; + c = (c0 - c1).toChar(); } else { - c = c1 - c0 as Char; + c = (c1 - c0).toChar(); } return c as char; } @@ -27,11 +27,11 @@ class Operations { class A { static funcA(a0: char, a1: char): char { - let c: Char = new Char('0'); + let c: Char = new Char(c'0'); if (a0 > a1) { - c = a0 - a1 as Char; + c = (a0 - a1).toChar(); } else { - c = a1 - a0 as Char; + c = (a1 - a0).toChar(); } return c as char; } @@ -47,8 +47,8 @@ class A { class B extends A{ static funcB(a0: char, a1: char): char { - let c: Char = new Char('0'); - c = a0 + a1 as Char; + let c: Char = new Char(c'0'); + c = (a0 + a1).toChar(); return c as char; } } @@ -58,8 +58,8 @@ class C extends A{ class D extends A{ static funcA(a0: char, a1: char): char { - let c: Char = new Char('0'); - c = a0 + a1 as char; + let c: Char = new Char(c'0'); + c = (a0 + a1).toChar(); return c as char; } } @@ -72,30 +72,30 @@ class E extends A{ class F { static increment(a0: char, a1: char): void { - F.count = F.count + a0 as char; - F.count = F.count + a1 as char; + F.count = (F.count + a0).toChar(); + F.count = (F.count + a1).toChar(); } static getCount(): char { return F.count; } - static count: char = '\0'; + static count: char = c'\0'; } class G { public static publicMethod(a0: char, a1: char): char { - let c: Char = new Char('0'); - c = a0 + a1 as char; + let c: Char = new Char(c'0'); + c = (a0 + a1).toChar(); return c as char; } private static privateMethod(a0: char, a1: char): char { - let c: Char = new Char('0'); + let c: Char = new Char(c'0'); if (a0 > a1) { - c = a0 - a1 as char; + c = (a0 - a1).toChar(); } else { - c = a1 - a0 as char; + c = (a1 - a0).toChar(); } return c as char; } @@ -103,4 +103,4 @@ class G { static callPrivateMethod(a0: char, a1: char): char { return G.privateMethod(a0, a1); } -} \ No newline at end of file +} diff --git a/static_core/plugins/ets/tests/ani/tests/class_ops/call_static_method_short_test.ets b/static_core/plugins/ets/tests/ani/tests/class_ops/call_static_method_short_test.ets index b8aa5a38fe8fa787bbe056586f9abe744567a9d0..bd6e7467d9dc760da2a7e2bad99dce7c2b80dd9e 100644 --- a/static_core/plugins/ets/tests/ani/tests/class_ops/call_static_method_short_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/class_ops/call_static_method_short_test.ets @@ -16,13 +16,13 @@ class Operations { static sum(a0: short, a1: short): short { - return a0 + a1 as short; + return (a0 + a1).toShort(); } } class A { static funcA(a0: short, a1: short): short { - return a0 + a1 as short; + return (a0 + a1).toShort(); } static funcA(a0: int, a1: int): int { @@ -36,7 +36,7 @@ class A { class B extends A{ static funcB(a0: short, a1: short): short { - return a1 - a0 as short; + return (a1 - a0).toShort(); } } @@ -45,7 +45,7 @@ class C extends A{ class D extends A{ static funcA(a0: short, a1: short): short { - return a1 - a0 as short; + return (a1 - a0).toShort(); } } @@ -70,11 +70,11 @@ class F { class G { public static publicMethod(a0: short, a1: short): short { - return a0 + a1 as short; + return (a0 + a1).toShort(); } private static privateMethod(a0: short, a1: short): short { - return a1 - a0 as short; + return (a1 - a0).toShort(); } static callPrivateMethod(a0: short, a1: short): short { diff --git a/static_core/plugins/ets/tests/ani/tests/class_ops/class_call_static_method_by_name_byte_test.ets b/static_core/plugins/ets/tests/ani/tests/class_ops/class_call_static_method_by_name_byte_test.ets index 4e02bf93f828301d118418a25761aaef8c87598f..40705ca2d6b1f50b061dce856c01a05f25678839 100644 --- a/static_core/plugins/ets/tests/ani/tests/class_ops/class_call_static_method_by_name_byte_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/class_ops/class_call_static_method_by_name_byte_test.ets @@ -15,14 +15,14 @@ class Operations { static sum(a0: byte, a1: byte): byte { - return a0 + a1 as byte; + return (a0 + a1).toByte(); } } namespace na { class A { static funcA(a0: byte, a1: byte): byte { - return a0 + a1 as byte; + return (a0 + a1).toByte(); } static funcA(a0: int, a1: int): int { return a1 - a0 as int; @@ -34,7 +34,7 @@ namespace nb { namespace nc { class A { static funcA(a0: byte, a1: byte): byte { - return a0 + a1 as byte; + return (a0 + a1).toByte(); } } } @@ -43,20 +43,20 @@ class A { namespace nd { class A { static funcA(a0: byte, a1: byte): byte { - return a0 + a1 as byte; + return (a0 + a1).toByte(); } } class B extends A{ static funcA(a0: byte, a1: byte): byte { - return a1 - a0 as byte; + return (a1 - a0).toByte(); } } } class A { static funcA(a0: byte, a1: byte): byte { - return a0 + a1 as byte; + return (a0 + a1).toByte(); } static funcA(a0: int, a1: int): int { @@ -70,7 +70,7 @@ class A { class B extends A{ static funcB(a0: byte, a1: byte): byte { - return a1 - a0 as byte; + return (a1 - a0).toByte(); } } @@ -79,7 +79,7 @@ class C extends A{ class D extends A{ static funcA(a0: byte, a1: byte): byte { - return a1 - a0 as byte; + return (a1 - a0).toByte(); } } @@ -104,11 +104,11 @@ class F { class G { public static publicMethod(a0: byte, a1: byte): byte { - return a0 + a1 as byte; + return (a0 + a1).toByte(); } private static privateMethod(a0: byte, a1: byte): byte { - return a1 - a0 as byte; + return (a1 - a0).toByte(); } static callPrivateMethod(a0: byte, a1: byte): byte { diff --git a/static_core/plugins/ets/tests/ani/tests/class_ops/class_call_static_method_by_name_char_test.ets b/static_core/plugins/ets/tests/ani/tests/class_ops/class_call_static_method_by_name_char_test.ets index df8247cafe0b1eac80a1221256e3356d13227f6b..cc24be27d21386c1190425730a5335957dfff99e 100644 --- a/static_core/plugins/ets/tests/ani/tests/class_ops/class_call_static_method_by_name_char_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/class_ops/class_call_static_method_by_name_char_test.ets @@ -15,11 +15,11 @@ class Operations { static sub(c0: char, c1: char): char { - let c: Char = new Char('0'); + let c: Char = new Char(c'0'); if (c0 > c1) { - c = c0 - c1 as Char; + c = (c0 - c1).toChar(); } else { - c = c1 - c0 as Char; + c = (c1 - c0).toChar(); } return c as char; } @@ -28,11 +28,11 @@ class Operations { namespace na { class A { static funcA(c0: char, c1: char): char { - let c: Char = new Char('0'); + let c: Char = new Char(c'0'); if (c0 > c1) { - c = c0 - c1 as Char; + c = (c0 - c1).toChar(); } else { - c = c1 - c0 as Char; + c = (c1 - c0).toChar(); } return c as char; } @@ -46,11 +46,11 @@ namespace nb { namespace nc { class A { static funcA(c0: char, c1: char): char { - let c: Char = new Char('0'); + let c: Char = new Char(c'0'); if (c0 > c1) { - c = c0 - c1 as Char; + c = (c0 - c1).toChar(); } else { - c = c1 - c0 as Char; + c = (c1 - c0).toChar(); } return c as char; } @@ -61,11 +61,11 @@ class A { namespace nd { class A { static funcA(c0: char, c1: char): char { - let c: Char = new Char('0'); + let c: Char = new Char(c'0'); if (c0 > c1) { - c = c0 - c1 as Char; + c = (c0 - c1).toChar(); } else { - c = c1 - c0 as Char; + c = (c1 - c0).toChar(); } return c as char; } @@ -73,8 +73,8 @@ class A { class B extends A { static funcA(c0: char, c1: char): char { - let c: Char = new Char('0'); - c = c0 + c1 as Char; + let c: Char = new Char(c'0'); + c = (c0 + c1).toChar(); return c as char; } } @@ -82,11 +82,11 @@ class B extends A { class A { static funcA(c0: char, c1: char): char { - let c: Char = new Char('0'); + let c: Char = new Char(c'0'); if (c0 > c1) { - c = c0 - c1 as char; + c = (c0 - c1).toChar(); } else { - c = c1 - c0 as char; + c = (c1 - c0).toChar(); } return c as char; } @@ -102,8 +102,8 @@ class A { class B extends A { static funcB(c0: char, c1: char): char { - let c: Char = new Char('0'); - c = c0 + c1 as char; + let c: Char = new Char(c'0'); + c = (c0 + c1).toChar(); return c as char; } } @@ -113,8 +113,8 @@ class C extends A { class D extends A { static funcA(c0: char, c1: char): char { - let c: Char = new Char('0'); - c = c0 + c1 as char; + let c: Char = new Char(c'0'); + c = (c0 + c1).toChar(); return c as char; } } @@ -127,30 +127,30 @@ class E extends A { class F { static increment(c0: char, c1: char): void { - F.count = F.count + c0 as char; - F.count = F.count + c1 as char; + F.count = (F.count + c0).toChar(); + F.count = (F.count + c1).toChar(); } static getCount(): char { return F.count; } - static count: char = '\0'; + static count: char = c'\0'; } class G { public static publicMethod(c0: char, c1: char): char { - let c: Char = new Char('0'); - c = c0 + c1 as char; + let c: Char = new Char(c'0'); + c = (c0 + c1).toChar(); return c as char; } private static privateMethod(c0: char, c1: char): char { - let c: Char = new Char('0'); + let c: Char = new Char(c'0'); if (c0 > c1) { - c = c0 - c1 as char; + c = (c0 - c1).toChar(); } else { - c = c1 - c0 as char; + c = (c1 - c0).toChar(); } return c as char; } @@ -158,4 +158,5 @@ class G { static callPrivateMethod(c0: char, c1: char): char { return G.privateMethod(c0, c1); } -} \ No newline at end of file +} + diff --git a/static_core/plugins/ets/tests/ani/tests/class_ops/class_call_static_method_by_name_short_test.ets b/static_core/plugins/ets/tests/ani/tests/class_ops/class_call_static_method_by_name_short_test.ets index 07ae84b46d022b5f6848d63e5ae5b9cd1e512062..7f7fc8c2db271dc45526314f7ebce42dc8a18837 100644 --- a/static_core/plugins/ets/tests/ani/tests/class_ops/class_call_static_method_by_name_short_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/class_ops/class_call_static_method_by_name_short_test.ets @@ -15,14 +15,14 @@ class Operations { static sum(a0: short, a1: short): short { - return a0 + a1 as short; + return (a0 + a1).toShort(); } }; namespace na { class A { static funcA(a0: short, a1: short): short { - return a0 + a1 as short; + return (a0 + a1).toShort(); } static funcA(a0: int, a1: int): int { return a1 - a0 as int; @@ -34,7 +34,7 @@ namespace nb { namespace nc { class A { static funcA(a0: short, a1: short): short { - return a0 + a1 as short; + return (a0 + a1).toShort(); } }; } @@ -43,19 +43,19 @@ class A { namespace nd { class A { static funcA(a0: short, a1: short): short { - return a0 + a1 as short; + return (a0 + a1).toShort(); } }; class B extends A{ static funcA(a0: short, a1: short): short { - return a1 - a0 as short; + return (a1 - a0).toShort(); } }; } class A { static funcA(a0: short, a1: short): short { - return a0 + a1 as short; + return (a0 + a1).toShort(); } static funcA(a0: int, a1: int): int { @@ -68,14 +68,14 @@ class A { }; class B extends A{ static funcB(a0: short, a1: short): short { - return a1 - a0 as short; + return (a1 - a0).toShort(); } }; class C extends A{ }; class D extends A{ static funcA(a0: short, a1: short): short { - return a1 - a0 as short; + return (a1 - a0).toShort(); } }; class E extends A{ @@ -97,11 +97,11 @@ class F { } class G { public static publicMethod(a0: short, a1: short): short { - return a0 + a1 as short; + return (a0 + a1).toShort(); } private static privateMethod(a0: short, a1: short): short { - return a1 - a0 as short; + return (a1 - a0).toShort(); } static callPrivateMethod(a0: short, a1: short): short { diff --git a/static_core/plugins/ets/tests/ani/tests/class_ops/class_call_static_method_by_name_void_test.ets b/static_core/plugins/ets/tests/ani/tests/class_ops/class_call_static_method_by_name_void_test.ets index 1dd4ccf078dfaffac38c22e8535b248b19b336af..5411aa1ec0064ff7e0fe9cfaf6d815b0c556f9bf 100644 --- a/static_core/plugins/ets/tests/ani/tests/class_ops/class_call_static_method_by_name_void_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/class_ops/class_call_static_method_by_name_void_test.ets @@ -38,7 +38,7 @@ class A { } static funcA(a0: short, a1: short): short { - return a1 - a0 as short; + return (a1 - a0).toShort(); } static count: int = 0; @@ -101,7 +101,7 @@ class A { } static funcA(a0: short, a1: short): short { - return a1 - a0 as short; + return (a1 - a0).toShort(); } static funcB(a0: int, a1: int): void { diff --git a/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_method_test.ets b/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_method_test.ets index 669aa75f4eaf452edf27283c370e0f61432cf461..c4c25817e196050772ab98ca6b6883be67468700 100644 --- a/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_method_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_method_test.ets @@ -100,12 +100,12 @@ class C implements I { public imethod(x: string): int { - return x.length as int + return x.length.toInt() } public override imethod_tuple(tuple: [int, long]): int { - return tuple[0] + tuple[1] as int + return (tuple[0] + tuple[1]).toInt() } public imethod_optional(z?: string): int @@ -128,7 +128,7 @@ class C implements I { public method_union(x: int | string): int { if (x instanceof string) { - return x.length as int + return x.length.toInt() } return x } @@ -217,7 +217,7 @@ class SpecialTypes { } public string_literal_method(a: "aaa"): int { - return a.length as int + return a.length.toInt() } public null_method(a: null): int { diff --git a/static_core/plugins/ets/tests/ani/tests/class_ops/class_get_static_field_by_name_char_test.ets b/static_core/plugins/ets/tests/ani/tests/class_ops/class_get_static_field_by_name_char_test.ets index a2863db53122d4d1d111d5927c33d4298ddcd5bd..de242cb78c93b63526aaf1565c00750ed587310b 100644 --- a/static_core/plugins/ets/tests/ani/tests/class_ops/class_get_static_field_by_name_char_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/class_ops/class_get_static_field_by_name_char_test.ets @@ -14,27 +14,27 @@ */ class GetCharStatic { - static name: char = 'b'; + static name: char = c'b'; static age: int = 20; static specia2: string = ""; static specia3: null = null; static specia4: undefined = undefined ; - static specia5: char = "\n"; - static specia6: char = "\r"; - static specia7: char = "\t"; - static specia8: char = "\b"; - static specia9: char = "\a"; - static specia10: char = "\f"; - static specia11: char = "\v"; - static specia12: char = "\0"; + static specia5: char = c'\n'; + static specia6: char = c'\r'; + static specia7: char = c'\t'; + static specia8: char = c'\b'; + static specia9: char = c'\a'; + static specia10: char = c'\f'; + static specia11: char = c'\v'; + static specia12: char = c'\0'; static charMin: char = 0; static charMax: char = 65535; } class CharStaticA extends GetCharStatic { - static char_value: char = 'a'; + static char_value: char = c'a'; } final class CharStaticFinal extends GetCharStatic { - static char_value: char = 'a'; + static char_value: char = c'a'; } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ani/tests/class_ops/class_get_static_field_by_name_float_test.ets b/static_core/plugins/ets/tests/ani/tests/class_ops/class_get_static_field_by_name_float_test.ets index 85aeeb0fd9cb5ddbd9c14785ba78f2468d4b8558..d426e3d504418c9c45878d98661f53f04636f825 100644 --- a/static_core/plugins/ets/tests/ani/tests/class_ops/class_get_static_field_by_name_float_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/class_ops/class_get_static_field_by_name_float_test.ets @@ -20,9 +20,9 @@ class GetFloatStatic { static specia3: string = ""; static specia4: null = null; static specia5: undefined = undefined ; - static floatMin: float = -3.40282346638528860e+38; - static minpositive: float = 1.17549435e-38; - static floatMax: float = 3.40282346638528860e+38; + static floatMin: float = -3.40282346638528860e+38f; + static minpositive: float = 1.17549435e-38f; + static floatMax: float = 3.40282346638528860e+38f; } class FloatStaticA extends GetFloatStatic { @@ -31,4 +31,4 @@ class FloatStaticA extends GetFloatStatic { final class FloatStaticFinal extends GetFloatStatic { static float_value: float = 0.0f; -} \ No newline at end of file +} diff --git a/static_core/plugins/ets/tests/ani/tests/class_ops/class_get_static_field_char_test.ets b/static_core/plugins/ets/tests/ani/tests/class_ops/class_get_static_field_char_test.ets index 855164c640151baf3e7cf82dedab52553a63f8bc..334060c6cd37a8663895cd268b7d818beb616915 100644 --- a/static_core/plugins/ets/tests/ani/tests/class_ops/class_get_static_field_char_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/class_ops/class_get_static_field_char_test.ets @@ -13,24 +13,24 @@ * limitations under the License. */ class TestChar { - static char_value: char = 'c'; + static char_value: char = c'c'; static string_value: String = "c"; static special1: string = ""; static special2: null = null; static special3: undefined = undefined ; - static special4: char = "\n"; - static special5: char = "\r"; - static special6: char = "\t"; - static special7: char = "\b"; - static special8: char = "\0"; + static special4: char = c'\n'; + static special5: char = c'\r'; + static special6: char = c'\t'; + static special7: char = c'\b'; + static special8: char = c'\0'; static charMin: char = 0; static charMax: char = 65535; } class TestCharA extends TestChar { - static char_value: char = 'c'; + static char_value: char = c'c'; } final class TestCharFinal extends TestChar { - static char_value: char = 'c'; + static char_value: char = c'c'; } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ani/tests/class_ops/class_get_static_field_float_test.ets b/static_core/plugins/ets/tests/ani/tests/class_ops/class_get_static_field_float_test.ets index 38bd534e445b231b4be943a2f240638f0783e426..e7e833cdd5531ef3a8171154d1703fa90df87024 100644 --- a/static_core/plugins/ets/tests/ani/tests/class_ops/class_get_static_field_float_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/class_ops/class_get_static_field_float_test.ets @@ -13,21 +13,21 @@ * limitations under the License. */ class TestFloat { - static float_value: float = 18.0; + static float_value: float = 18.0f; static string_value: String = "18.0"; static specia1: int = 0; static specia3: string = ""; static specia4: null = null; static specia5: undefined = undefined ; - static floatMin: float = -3.40282346638528860e+38; - static minpositive: float = 1.17549435e-38; - static floatMax: float = 3.40282346638528860e+38; + static floatMin: float = -3.40282346638528860e+38f; + static minpositive: float = 1.17549435e-38f; + static floatMax: float = 3.40282346638528860e+38f; } class TestFloatA extends TestFloat { - static float_value: float = 18.0; + static float_value: float = 18.0f; } final class TestFloatFinal extends TestFloat { - static float_value: float = 18.0; -} \ No newline at end of file + static float_value: float = 18.0f; +} diff --git a/static_core/plugins/ets/tests/ani/tests/class_ops/class_set_static_field_by_name_char_test.ets b/static_core/plugins/ets/tests/ani/tests/class_ops/class_set_static_field_by_name_char_test.ets index 8d999c0ac2031798583fea6bf3de679a4841658f..7333dd19f28485e125790b86376fad2b56667fb9 100644 --- a/static_core/plugins/ets/tests/ani/tests/class_ops/class_set_static_field_by_name_char_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/class_ops/class_set_static_field_by_name_char_test.ets @@ -14,14 +14,14 @@ */ class CharStatic { - static char_value: char = 'a'; + static char_value: char = c'a'; static string_value: String = ""; } class CharStaticA extends CharStatic { - static char_value: char = 'a'; + static char_value: char = c'a'; } final class CharStaticFinal extends CharStatic { - static char_value: char = 'a'; + static char_value: char = c'a'; } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ani/tests/class_ops/class_set_static_field_char_test.ets b/static_core/plugins/ets/tests/ani/tests/class_ops/class_set_static_field_char_test.ets index 4f1c4cdf480af1843da4f947452e7937d098fd8f..0dc31a1806da5d7320dc017ddad1316e0c806d3f 100644 --- a/static_core/plugins/ets/tests/ani/tests/class_ops/class_set_static_field_char_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/class_ops/class_set_static_field_char_test.ets @@ -13,14 +13,14 @@ * limitations under the License. */ class TestSetChar { - static char_value: char = 'a'; + static char_value: char = c'a'; static string_value: string = ""; } class TestSetCharA extends TestSetChar { - static char_value: char = 'a'; + static char_value: char = c'a'; } final class TestSetCharFinal extends TestSetChar { - static char_value: char = 'a'; + static char_value: char = c'a'; } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ani/tests/class_ops/class_set_static_field_float_test.ets b/static_core/plugins/ets/tests/ani/tests/class_ops/class_set_static_field_float_test.ets index f7cec953ee5f0ce8866ed6d20738c572b2584947..012c89c52699097f0cd42f513f11efc87e9c7de0 100644 --- a/static_core/plugins/ets/tests/ani/tests/class_ops/class_set_static_field_float_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/class_ops/class_set_static_field_float_test.ets @@ -13,14 +13,14 @@ * limitations under the License. */ class TestSetFloat { - static float_value: float = 18.0; + static float_value: float = 18.0f; static string_value: string = ""; } class TestSetFloatA extends TestSetFloat { - static float_value: float = 18.0; + static float_value: float = 18.0f; } final class TestSetFloatFinal extends TestSetFloat { - static float_value: float = 18.0; -} \ No newline at end of file + static float_value: float = 18.0f; +} diff --git a/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_boolean_test.ets b/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_boolean_test.ets index f94edb7fdcf0d83cc5e94fce1c4edf1c8f9742f7..c12ac89261e6198938d5948a2a961ee7db8e1e9a 100644 --- a/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_boolean_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_boolean_test.ets @@ -75,7 +75,7 @@ namespace A { } function calculateBoolean(value1: int, value2: int, value3: char, value4: double): boolean { - let aChar: char = 'A'; + let aChar: char = c'A'; if (value3 == aChar) { return true; } diff --git a/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_byte_test.ets b/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_byte_test.ets index 0cd37ccb10020ecf8ac5eed473209e2cf0118a69..c877944644372ae5a79e61d55dcf00303462f4c8 100644 --- a/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_byte_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_byte_test.ets @@ -15,31 +15,31 @@ namespace ops { function sum(a0: byte, a1: byte): byte { - return a0 + a1 as byte; + return (a0 + a1).toByte(); } } function moduleFunction(value1: byte, value2: byte): byte { - return value1 + value2 as byte; + return (value1 + value2).toByte(); } function moduleFunction(value1: byte, value2: byte, value3: byte): byte { - return value1 + value2 + value3 as byte; + return (value1 + value2 + value3).toByte(); } namespace A { function byteFunctionA(value1: byte, value2: byte): byte { - return value1 + value2 as byte; + return (value1 + value2).toByte(); } function byteFunctionA(value1: byte, value2: byte, value3: byte): byte { - return value1 + value2 + value3 as byte; + return (value1 + value2 + value3).toByte(); } function nestedFunction(value1: byte, value2: byte): byte { let lambdaFunction: (p1: byte, p2: byte) => byte = (param1: byte, param2: byte): byte => { - return param1 + param2 as byte; + return (param1 + param2).toByte(); }; return lambdaFunction(value1, value2); } @@ -48,24 +48,24 @@ namespace A { if (value <= 1) { return 1; } else { - return value + recursiveFunction(value - 1) as byte; + return (value + recursiveFunction(value - 1)).toByte(); } } function calculateSum(value1: byte, value2: byte, value3: char, value4: int): byte { - let aChar: char = 'A'; + let aChar: char = c'A'; if (value3 == aChar) { - return value2 - value1 as byte; + return (value2 - value1).toByte(); } if (value4 == 1) { return value1; } - return value2 + value1 as byte; + return (value2 + value1).toByte(); } namespace B { function byteFunctionB(value1: byte, value2: byte): byte { - return value1 + value2 as byte; + return (value1 + value2).toByte(); } } } diff --git a/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_char_test.ets b/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_char_test.ets index 7dd4b453d97f54328b8621be9949f0be4df43a9f..e9c70203c7e6e3be64e4ac6a1d44eebf145298a0 100644 --- a/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_char_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_char_test.ets @@ -15,11 +15,11 @@ namespace ops { function sub(c0: char, c1: char): char { - let c: Char = new Char('0'); + let c: Char = new Char(c'0'); if (c0 > c1) { - c = c0 - c1 as char; + c = (c0 - c1).toChar(); } else { - c = c1 - c0 as char; + c = (c1 - c0).toChar(); } return c as char; } @@ -52,10 +52,10 @@ namespace A { export function recursiveFunction(value: int): char { if (value <= 0) { - return 'A'; + return c'A'; } if (value === 1) { - return 'Z'; + return c'Z'; } return recursiveFunction(value - 1); } diff --git a/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_double_test.ets b/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_double_test.ets index 4e3db9ed24f976e59539786beb8ab0b3e0803164..b3f162ba26057dff2ecb821f0f0a35b367f024f5 100644 --- a/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_double_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_double_test.ets @@ -53,7 +53,7 @@ namespace A { } function calculateSum(value1: double, value2: double, value3: char, value4: int): double { - let aChar: char = 'A'; + let aChar: char = c'A'; if (value3 == aChar) { return value2 - value1 as double; } diff --git a/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_float_test.ets b/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_float_test.ets index 6df078d1977fc85b2910d9a36b7c04b4354675fd..a49b4b3c659fba75af373a9a08fdc9823d362985 100644 --- a/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_float_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_float_test.ets @@ -53,7 +53,7 @@ namespace A { } function calculateSum(value1: float, value2: float, value3: char, value4: int): float { - let aChar: char = 'A'; + let aChar: char = c'A'; if (value3 == aChar) { return value2 - value1 as float; } diff --git a/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_int_test.ets b/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_int_test.ets index 1bd48fc77d0d3cdd4322693746ec3d6257684d47..3d12c1baf7e9a44e7c2c6f5b1c303f54dcbde26d 100644 --- a/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_int_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_int_test.ets @@ -53,7 +53,7 @@ namespace A { } function calculateSum(value1: int, value2: int, value3: char, value4: double): int { - let aChar: char = 'A'; + let aChar: char = c'A'; if (value3 == aChar) { return value2 - value1 as int; } diff --git a/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_long_test.ets b/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_long_test.ets index 4e6c2ad5c4aa7577670689d71dabc2b225808747..6a417a8290df2aa1739a149e2d7446ea4c41d0ce 100644 --- a/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_long_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_long_test.ets @@ -53,7 +53,7 @@ namespace A { } function calculateSum(value1: long, value2: long, value3: char, value4: double): long { - let aChar: char = 'A'; + let aChar: char = c'A'; if (value3 == aChar) { return value2 - value1 as long; } diff --git a/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_short_test.ets b/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_short_test.ets index 29f02bce07dd6264756aa564605c7f7627a58d47..2212fe884852fe10dd5f6a0e1b99a05b04ab9fe8 100644 --- a/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_short_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_short_test.ets @@ -15,31 +15,31 @@ namespace ops { function sum(a0: short, a1: short): short { - return a0 + a1 as short; + return (a0 + a1).toShort(); } } function moduleFunction(value1: short, value2: short): short { - return value1 + value2 as short; + return (value1 + value2).toShort(); } function moduleFunction(value1: short, value2: short, value3: short): short { - return value1 + value2 + value3 as short; + return (value1 + value2 + value3).toShort(); } namespace A { function shortFunctionA(value1: short, value2: short): short { - return value1 + value2 as short; + return (value1 + value2).toShort(); } function shortFunctionA(value1: short, value2: short, value3: short): short { - return value1 + value2 + value3 as short; + return (value1 + value2 + value3).toShort(); } function nestedFunction(value1: short, value2: short): short { let lambdaFunction: (p1: short, p2: short) => short = (param1: short, param2: short): short => { - return param1 + param2 as short; + return (param1 + param2).toShort(); }; return lambdaFunction(value1, value2); } @@ -48,24 +48,24 @@ namespace A { if (value <= 1) { return 1; } else { - return value + recursiveFunction(value - 1) as short; + return (value + recursiveFunction(value - 1)).toShort(); } } function calculateSum(value1: short, value2: short, value3: char, value4: double): short { - let aChar: char = 'A'; + let aChar: char = c'A'; if (value3 == aChar) { - return value2 - value1 as short; + return (value2 - value1).toShort(); } if (value4 == 1.0) { return value1; } - return value2 + value1 as short; + return (value2 + value1).toShort(); } namespace B { function shortFunctionB(value1: short, value2: short): short { - return value1 + value2 as short; + return (value1 + value2).toShort(); } } } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_void_test.ets b/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_void_test.ets index 240d156a7509322c963c42c3133b925a17dab7ae..aae30c59fac1b2743df9f7621e422a12d7dc2c27 100644 --- a/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_void_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/function_ops/function_call_void_test.ets @@ -24,7 +24,7 @@ function getCount(): int { } export let intExport: int = 3; -export let charExport: char = "a"; +export let charExport: char = c'a'; function moduleFunction(value1: int, value2: int): void { intExport = value1 + value2; } diff --git a/static_core/plugins/ets/tests/ani/tests/module_ops/module_find_class_test.ets b/static_core/plugins/ets/tests/ani/tests/module_ops/module_find_class_test.ets index 429220eb3f89681371eb0f0f49e6bf265cb166f7..b1ce12f1d55cd38371f9779b31965fe68e464930 100644 --- a/static_core/plugins/ets/tests/ani/tests/module_ops/module_find_class_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/module_ops/module_find_class_test.ets @@ -86,4 +86,4 @@ class ContainerTest implements Container{ this.items[this.index++] = item; } } - + diff --git a/static_core/plugins/ets/tests/ani/tests/module_ops/module_find_variable_test.ets b/static_core/plugins/ets/tests/ani/tests/module_ops/module_find_variable_test.ets index 1219c21dd878f1d08859aa868740eb74b2346d45..462ee10b3d7a05314e36356a24481883bb41fa9d 100644 --- a/static_core/plugins/ets/tests/ani/tests/module_ops/module_find_variable_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/module_ops/module_find_variable_test.ets @@ -28,11 +28,11 @@ export let moduleI: int = 3; export let moduleJ: int = 3; export let moduleK: boolean = false; -export let moduleL: char = 'G'; +export let moduleL: char = c'G'; export let moduleM: byte = 2; export let moduleN: short = 10; export let moduleO: long = 100; -export let moduleP: float = 3.14; +export let moduleP: float = 3.14f; export let moduleQ: double = 6.28; namespace ops { diff --git a/static_core/plugins/ets/tests/ani/tests/object_ops/call_object_method_byte_test.ets b/static_core/plugins/ets/tests/ani/tests/object_ops/call_object_method_byte_test.ets index 64711059a2cb9caff2fdbc8cb1f5d274ab548c25..b6edd029679ca9c5b29f072464592ecf46e5c63a 100644 --- a/static_core/plugins/ets/tests/ani/tests/object_ops/call_object_method_byte_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/object_ops/call_object_method_byte_test.ets @@ -36,14 +36,14 @@ class A { } else if (a2 > a3) { return a0; } else { - return (a4 + a0) as byte; + return (a4 + a0).toByte(); } } public nestedMethod(data1: byte, data2: byte): byte { let method = (value1: byte, value2: byte): byte => { - return (value1 + value2) as byte; + return (value1 + value2).toByte(); } return method(data1, data2); @@ -54,7 +54,7 @@ class A { if (a0 > 100) { return a0 as byte; } else { - return this.recursionMethod((a0 + 10) as byte); + return this.recursionMethod((a0 + 10).toByte()); } } } @@ -73,12 +73,12 @@ abstract class C { class D extends C { public override func(a: byte, b: byte): byte { - return (a + b) as byte; + return (a + b).toByte(); } } class E extends D { public override func(a: byte, b: byte): byte { - return (a - b) as byte; + return (a - b).toByte(); } } diff --git a/static_core/plugins/ets/tests/ani/tests/object_ops/call_object_method_char_test.ets b/static_core/plugins/ets/tests/ani/tests/object_ops/call_object_method_char_test.ets index 73c57ce79c1f5138386ff4a114abbd78bd3589df..36ebe13cc2aefd2d72b91b0659d3a987b5f1c7dc 100755 --- a/static_core/plugins/ets/tests/ani/tests/object_ops/call_object_method_char_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/object_ops/call_object_method_char_test.ets @@ -26,24 +26,24 @@ class A { public charMethodVoidParam(): char { - return 'A'; + return c'A'; } public charMethodMultipleParam(a0: byte, a1: boolean, a2: float, a3: float, a4: byte): char { if (a1) { - return 'A'; + return c'A'; } else if (a2 > a3) { - return 'B'; + return c'B'; } else { - return 'C'; + return c'C'; } } public nestedMethod(data1: char, data2: int): char { let method = (value1: char, value2: int): char => { - return (value1 + value2) as char; + return (value1 + value2).toChar(); } return method(data1, data2); @@ -54,7 +54,7 @@ class A { if (a0 > 100) { return a0 as char; } else { - return this.recursionMethod((a0 + 5) as char); + return this.recursionMethod((a0 + 5).toChar()); } } } @@ -63,7 +63,7 @@ final class B extends A { public subCharMethodVoidParam(): char { - return 'W'; + return c'W'; } } @@ -73,12 +73,12 @@ abstract class C { class D extends C { public override func(a: char, b: byte): char { - return (a + b) as char; + return (a + b).toChar(); } } class E extends D { public override func(a: char, b: byte): char { - return (a - b) as char; + return (a - b).toChar(); } } diff --git a/static_core/plugins/ets/tests/ani/tests/object_ops/call_object_method_float_test.ets b/static_core/plugins/ets/tests/ani/tests/object_ops/call_object_method_float_test.ets index b29138245d314a2eb68d630bedbfd1bf60abfa80..c91e4f95c85b3491a9b027e05a06edfbe8bc0ad6 100644 --- a/static_core/plugins/ets/tests/ani/tests/object_ops/call_object_method_float_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/object_ops/call_object_method_float_test.ets @@ -54,7 +54,7 @@ class A { if (a0 > 100) { return a0; } else { - return this.recursionMethod((a0 + 10.0) as float); + return this.recursionMethod((a0 + 10.0).toFloat()); } } } diff --git a/static_core/plugins/ets/tests/ani/tests/object_ops/call_object_method_short_test.ets b/static_core/plugins/ets/tests/ani/tests/object_ops/call_object_method_short_test.ets index 8ee76dfa10ecde03f8050f5020a296fc6ae98ce3..9298a7d0e853cb84ffffca416d2f41a7de49a89a 100644 --- a/static_core/plugins/ets/tests/ani/tests/object_ops/call_object_method_short_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/object_ops/call_object_method_short_test.ets @@ -32,18 +32,18 @@ class A { public shortMethodMultipleParam(a0: int, a1: boolean, a2: float, a3: short, a4: short): short { if (a1) { - return (a3 + a4) as short; + return (a3 + a4).toShort(); } else if (a0 > a3) { return a3; } else { - return (a3 - a4) as short; + return (a3 - a4).toShort(); } } public nestedMethod(data1: short, data2: short): short { let method = (value1: short, value2: short): short => { - return (value1 + value2) as short; + return (value1 + value2).toShort(); } return method(data1, data2); @@ -54,7 +54,7 @@ class A { if (a0 > 100) { return a0; } else { - return this.recursionMethod((a0 + 10) as short); + return this.recursionMethod((a0 + 10).toShort()); } } } @@ -69,11 +69,11 @@ final class B extends A { public subMethodMultipleParam(a0: short, a1: boolean, a2:float, a3:short, a4:short): short { if (a1) { - return (a3 + a4) as short; + return (a3 + a4).toShort(); } else if (a0 > a3) { return a3; } else { - return (a3 - a4) as short; + return (a3 - a4).toShort(); } } } @@ -84,12 +84,12 @@ abstract class C { class D extends C { public override func(a: short, b: short): short { - return (a + b) as short; + return (a + b).toShort(); } } class E extends D { public override func(a: short, b: short): short { - return (a - b) as short; + return (a - b).toShort(); } } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_boolean_test.ets b/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_boolean_test.ets index f7fc788e805d10208b4621974ae70fbf3f50dd79..d94d5f2356230e8a802b942bc07d30b961cef94c 100644 --- a/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_boolean_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_boolean_test.ets @@ -93,7 +93,7 @@ class B implements ji { } calculateSum(value1: int, value2: char, value3: double): boolean { - let aChar: char = 'A'; + let aChar: char = c'A'; if (value2 == aChar) { return true; } diff --git a/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_byte_test.ets b/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_byte_test.ets index 7119a4d7ac15cbd259e8f63cd05ce87aba3390e9..562118f370a9c5ca6e3f1cfc595804f45e648213 100644 --- a/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_byte_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_byte_test.ets @@ -19,7 +19,7 @@ class A { } byteByNameMethod(a0: byte, a1: byte): byte { - return a0 + a1 as byte; + return (a0 + a1).toByte(); } } @@ -38,7 +38,7 @@ class B implements ji { if (this.data > value1 + value2) { return this.data; } else { - return value1 + value2 as byte; + return (value1 + value2).toByte(); } } @@ -51,17 +51,17 @@ class B implements ji { } protected protectedMethod(value: byte): byte { - return this.data + value as byte; + return (this.data + value).toByte(); } private privateMethod(value: byte): byte { - return this.data - value as byte; + return (this.data - value).toByte(); } public nestedMethod(value: byte): byte { let lambdaMethod: (p1: byte, p2: byte) => byte = (param1: byte, param2: byte): byte => { - return param1 + param2 as byte; + return (param1 + param2).toByte(); }; return lambdaMethod(this.data, value); } @@ -70,23 +70,23 @@ class B implements ji { if (value <= 0) { return 1; } else { - return value * this.recursiveMethod(value - 1) as byte; + return (value * this.recursiveMethod(value - 1)).toByte(); } } calculateSum(value1: byte, value2: char, value3: int): byte { - let aChar: char = 'A'; + let aChar: char = c'A'; if (value2 == aChar) { - return this.data - value1 as byte; + return (this.data - value1).toByte(); } if (value3 == 1) { return value1; } - return this.data + value1 as byte; + return (this.data + value1).toByte(); } public jf(value: byte): byte { - return this.data - value as byte; + return (this.data - value).toByte(); } } @@ -99,11 +99,11 @@ final class C extends B { data1: byte; public byteAddMethod(value1: byte, value2: byte): byte { - return this.data1 + value1 + value2 as byte; + return (this.data1 + value1 + value2).toByte(); } public override byteMethod(value1: byte, value2: byte): byte { - return this.data1 - value1 - value2 as byte; + return (this.data1 - value1 - value2).toByte(); } public callProtected(value: byte): byte { @@ -111,6 +111,6 @@ final class C extends B { } public jf(value: byte): byte { - return this.data1 + value as byte; + return (this.data1 + value).toByte(); } } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_char_test.ets b/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_char_test.ets index 6ad555445b301f6a1e1cb6020fc02700499b38a1..6696a26e323337f92d67dcf21cb35105435da0c3 100644 --- a/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_char_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_char_test.ets @@ -68,10 +68,10 @@ class B implements ji { public recursiveMethod(value: int): char { if (value <= 0) { - return 'A'; + return c'A'; } if (value === 1) { - return 'Z'; + return c'Z'; } return this.recursiveMethod(value - 1); } diff --git a/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_double_test.ets b/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_double_test.ets index 94cf34f220810fbc81f0b8cf871f0ca060b3cb1e..6491535791c7eb05363a71e696d3d77e1a1cf330 100644 --- a/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_double_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_double_test.ets @@ -76,7 +76,7 @@ class B implements ji { } calculateSum(value1: double, value2: char, value3: int): double { - let aChar: char = 'A'; + let aChar: char = c'A'; if (value2 == aChar) { return this.data - value1 as double; } diff --git a/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_float_test.ets b/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_float_test.ets index 3935c6161482a725676b156d5476959ef50b263a..90cf560e1089ed1666f68c7197bada5e3e1de033 100644 --- a/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_float_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_float_test.ets @@ -76,7 +76,7 @@ class B implements ji { } calculateSum(value1: float, value2: char, value3: int): float { - let aChar: char = 'A'; + let aChar: char = c'A'; if (value2 == aChar) { return this.data - value1 as float; } diff --git a/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_int_test.ets b/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_int_test.ets index bcbf927aa37b212700d29d0ec5c79927ab89cfc2..bfa27cb3153c259f8cbed88fc5b574478e65ae80 100644 --- a/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_int_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_int_test.ets @@ -75,7 +75,7 @@ class B implements ji { } calculateSum(value1: int, value2: char, value3: double): int { - let aChar: char = 'A'; + let aChar: char = c'A'; if (value2 == aChar) { return this.data - value1 as int; } diff --git a/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_long_test.ets b/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_long_test.ets index ca5174388050e33ed12394705d25313b51473067..6e209d4849e324e061c8411e10fa1db06e4ed715 100644 --- a/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_long_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_long_test.ets @@ -76,7 +76,7 @@ class B implements ji { } calculateSum(value1: long, value2: char, value3: int): long { - let aChar: char = 'A'; + let aChar: char = c'A'; if (value2 == aChar) { return this.data - value1 as long; } diff --git a/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_ref_test.ets b/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_ref_test.ets index 62e56dbd6c9c8a85964b475b3ba55ebb685db032..0f4ad5f66036930fe6f83b48b3a40b569c46b832 100644 --- a/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_ref_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_ref_test.ets @@ -94,7 +94,7 @@ class B implements ji { } calculateSum(value1: int, value2: char, value3: double): string { - let aChar: char = 'A'; + let aChar: char = c'A'; if (value2 == aChar) { return "CharEquality"; } diff --git a/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_short_test.ets b/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_short_test.ets index b0d0492a7c293f46229a55729ec9b6f626049ce8..8769d44e74b1c9649ab199978e2c6cc006106bfb 100644 --- a/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_short_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_by_name_short_test.ets @@ -19,7 +19,7 @@ class A { } shortByNameMethod(a0: short, a1: short): short { - return a0 + a1 as short; + return (a0 + a1).toShort(); } } @@ -38,7 +38,7 @@ class B implements ji { if (this.data > value1 + value2) { return this.data; } else { - return value1 + value2 as short; + return (value1 + value2).toShort(); } } @@ -51,17 +51,17 @@ class B implements ji { } protected protectedMethod(value: short): short { - return this.data + value as short; + return (this.data + value).toShort(); } private privateMethod(value: short): short { - return this.data - value as short; + return (this.data - value).toShort(); } public nestedMethod(value: short): short { let lambdaMethod: (p1: short, p2: short) => short = (param1: short, param2: short): short => { - return param1 + param2 as short; + return (param1 + param2).toShort(); }; return lambdaMethod(this.data, value); } @@ -70,23 +70,23 @@ class B implements ji { if (value <= 0) { return 1; } else { - return value * this.recursiveMethod(value - 1) as short; + return (value * this.recursiveMethod(value - 1)).toShort(); } } calculateSum(value1: short, value2: char, value3: double): short { - let aChar: char = 'A'; + let aChar: char = c'A'; if (value2 == aChar) { - return this.data - value1 as short; + return (this.data - value1).toShort(); } if (value3 == 1.0) { return value1; } - return this.data + value1 as short; + return (this.data + value1).toShort(); } public jf(value: short): short { - return this.data - value as short; + return (this.data - value).toShort(); } } @@ -99,11 +99,11 @@ final class C extends B { data1: short; public shortAddMethod(value1: short, value2: short): short { - return this.data1 + value1 + value2 as short; + return (this.data1 + value1 + value2).toShort(); } public override shortMethod(value1: short, value2: short): short { - return this.data1 - value1 - value2 as short; + return (this.data1 - value1 - value2).toShort(); } public callProtected(value: short): short { @@ -111,6 +111,6 @@ final class C extends B { } public jf(value: short): short { - return this.data1 + value as short; + return (this.data1 + value).toShort(); } } diff --git a/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_ref_test.ets b/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_ref_test.ets index 03ddde4facc9b19b1703153cfad3bb5753edb092..2edbb0f4686e000085b597b87f0bcf9c14d62df0 100644 --- a/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_ref_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/object_ops/object_call_method_ref_test.ets @@ -64,7 +64,7 @@ class A { if (a0 > 100) { return "hello"; } else { - return this.recursionMethod((a0 + 10) as short); + return this.recursionMethod((a0 + 10).toShort()); } } } diff --git a/static_core/plugins/ets/tests/ani/tests/object_ops/object_get_field_by_name_char_test.ets b/static_core/plugins/ets/tests/ani/tests/object_ops/object_get_field_by_name_char_test.ets index 919e8840813517dc8b36158b86d057aaf9dcd4f7..6441ffb2016c5bc27c42dfc3e562406f14046c0d 100644 --- a/static_core/plugins/ets/tests/ani/tests/object_ops/object_get_field_by_name_char_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/object_ops/object_get_field_by_name_char_test.ets @@ -23,5 +23,5 @@ class Animal { } function newAnimalObject() { - return new Animal("Cat", 'a'); + return new Animal("Cat", c'a'); } diff --git a/static_core/plugins/ets/tests/ani/tests/object_ops/object_get_field_char_test.ets b/static_core/plugins/ets/tests/ani/tests/object_ops/object_get_field_char_test.ets index 3144db63bcef105cfb1c30b780bf592a56028e6f..68e99d48580087e7ce2b740dd1a618ea5bc03632 100644 --- a/static_core/plugins/ets/tests/ani/tests/object_ops/object_get_field_char_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/object_ops/object_get_field_char_test.ets @@ -23,5 +23,5 @@ class Woman { } function newSarahObject() { - return new Woman("Sarah", 'a'); + return new Woman("Sarah", c'a'); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ani/tests/object_ops/object_get_field_float_test.ets b/static_core/plugins/ets/tests/ani/tests/object_ops/object_get_field_float_test.ets index 13d80fb63c532eea86369ee8b7c73a9a12b03c56..a4fdc1335731208ebe753cc142a9a2e7a6234477 100644 --- a/static_core/plugins/ets/tests/ani/tests/object_ops/object_get_field_float_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/object_ops/object_get_field_float_test.ets @@ -23,6 +23,6 @@ class Woman { } function newSarahObject() { - const age_: float = 24.0; + const age_: float = 24.0f; return new Woman("Sarah", age_); } diff --git a/static_core/plugins/ets/tests/ani/tests/object_ops/object_get_property_by_name_char_test.ets b/static_core/plugins/ets/tests/ani/tests/object_ops/object_get_property_by_name_char_test.ets index 91d1c8338e03efde7bdd67e5d8c96c7be7926f93..fa6e091a637501d947e0fa44fb3985cdb9a6b899 100644 --- a/static_core/plugins/ets/tests/ani/tests/object_ops/object_get_property_by_name_char_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/object_ops/object_get_property_by_name_char_test.ets @@ -33,5 +33,5 @@ class Car { } function newCarObject() { - return new Car("Porsche", "Porsche 911", 'z', 'a'); + return new Car("Porsche", "Porsche 911", c'z', c'a'); } diff --git a/static_core/plugins/ets/tests/ani/tests/object_ops/object_instance_of_test.cpp b/static_core/plugins/ets/tests/ani/tests/object_ops/object_instance_of_test.cpp index 05b1645e18ae22a111f5d931eb7d2be4ae1d3d03..2e4c5d1175098a2637901ae8b98ae22a3d09959c 100644 --- a/static_core/plugins/ets/tests/ani/tests/object_ops/object_instance_of_test.cpp +++ b/static_core/plugins/ets/tests/ani/tests/object_ops/object_instance_of_test.cpp @@ -232,7 +232,7 @@ TEST_F(ObjectInstanceOfTest, object_boxed_primitive_instance_of) { ani_object objectInt; ani_class classF; - GetMethodData(&objectInt, &classF, "Lobject_instance_of_test/F;", "new_Boxed_Primitive", ":Lstd/core/Int;"); + GetMethodData(&objectInt, &classF, "Lobject_instance_of_test/F;", "new_Boxed_Primitive", ":Lstd/core/Object;"); ani_boolean res; ani_class classInt; diff --git a/static_core/plugins/ets/tests/ani/tests/object_ops/object_instance_of_test.ets b/static_core/plugins/ets/tests/ani/tests/object_ops/object_instance_of_test.ets index c0de599929b320a40a0b27f070486b396c2ef72f..d6ed4d5938afd192b4fa56ca7318dd4f37f787a4 100644 --- a/static_core/plugins/ets/tests/ani/tests/object_ops/object_instance_of_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/object_ops/object_instance_of_test.ets @@ -96,7 +96,8 @@ class F implements I { return new Object(); } - public static new_Boxed_Primitive(): Int { + /// @brief Returns boxed primitive, union is required for boxing of int + public static new_Boxed_Primitive(): Int | String { return 5; } } diff --git a/static_core/plugins/ets/tests/ani/tests/object_ops/object_new_test.ets b/static_core/plugins/ets/tests/ani/tests/object_ops/object_new_test.ets index 32129e0768dc7665a32c0a5993fbc1b600d856ce..a6cc0616f6a338f784df7913ec02ea2e68befb4a 100644 --- a/static_core/plugins/ets/tests/ani/tests/object_ops/object_new_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/object_ops/object_new_test.ets @@ -128,7 +128,7 @@ class Mixture { private arr: int[] = [1, 2, 3]; private byteArr: byte[] = [10, 11, 12]; private i: int = 0; - private f: float = 1.0; + private f: float = 1.0f; private d: double = 20.0; private b: boolean = false; private longVal: long = 100; diff --git a/static_core/plugins/ets/tests/ani/tests/object_ops/object_set_field_by_name_char_test.ets b/static_core/plugins/ets/tests/ani/tests/object_ops/object_set_field_by_name_char_test.ets index 380654895f20e220841ba0837a5d123f75f8f895..ef179c3528a6e715a8b1793ff9801a5cbe0ad1b3 100644 --- a/static_core/plugins/ets/tests/ani/tests/object_ops/object_set_field_by_name_char_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/object_ops/object_set_field_by_name_char_test.ets @@ -23,7 +23,7 @@ class Animal { } function newAnimalObject() { - return new Animal("Cat", 'a'); + return new Animal("Cat", c'a'); } function checkObjectField(animal: Animal, value: char): boolean { diff --git a/static_core/plugins/ets/tests/ani/tests/object_ops/object_set_field_char_test.ets b/static_core/plugins/ets/tests/ani/tests/object_ops/object_set_field_char_test.ets index e5789ac2328a39158cddf21cda92fc89b31a6db6..a80c9e8841c461b210750fbced1874e09bd2aa3f 100644 --- a/static_core/plugins/ets/tests/ani/tests/object_ops/object_set_field_char_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/object_ops/object_set_field_char_test.ets @@ -16,7 +16,7 @@ class Pack { boolean_value: boolean = true; string_value: string = ""; - char_value: char = 'a'; + char_value: char = c'a'; } function newPackObject(): Pack { diff --git a/static_core/plugins/ets/tests/ani/tests/object_ops/object_set_field_float_test.ets b/static_core/plugins/ets/tests/ani/tests/object_ops/object_set_field_float_test.ets index c40744869afc6d8ea397bb82d835538c8fa7c6f9..4f16ba42b00f9065a4a7ea7941e831415025689b 100644 --- a/static_core/plugins/ets/tests/ani/tests/object_ops/object_set_field_float_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/object_ops/object_set_field_float_test.ets @@ -12,11 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + class Pack { boolean_value: boolean = true; string_value: string = ""; - float_value: float = 0.0; + float_value: float = 0.0f; } function newPackObject(): Pack { diff --git a/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_getitem_char_test.ets b/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_getitem_char_test.ets index 1551b1fc326e2454e11f7f19171d5deb372a4beb..579c9e46295ef01388e62ec7f0b1b740a007f2ea 100644 --- a/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_getitem_char_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_getitem_char_test.ets @@ -14,7 +14,7 @@ */ function getCharTuple(): [char, char, char, char, char] { - return ['H', 'e', 'l', 'l', 'o']; + return [c'H', c'e', c'l', c'l', c'o']; } function getReferenceTuple(): [String, double[], String] { @@ -22,5 +22,5 @@ function getReferenceTuple(): [String, double[], String] { } function getTestPrimitiveTuple(): [boolean, char, byte, short, int, long, float, double] { - return [true, 'x', 127, 300, 500, 600, 100.0, 400.0]; + return [true, c'x', 127, 300, 500, 600, 100.0f, 400.0]; } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_getitem_float_test.ets b/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_getitem_float_test.ets index eea2e1ac75eecf7da849b8304f81cc6d5c56e8d2..1b24ba4dba44006c1fcd8556a88a6cfb9053cb19 100644 --- a/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_getitem_float_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_getitem_float_test.ets @@ -14,5 +14,5 @@ */ function getFloatTuple(): [float, float, float, float, float] { - return [3.14, 2.71, 1.61, 0.59, 10.0]; + return [3.14f, 2.71f, 1.61f, 0.59f, 10.0f]; } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_getnumberofitem_test.ets b/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_getnumberofitem_test.ets index eec29e9b7925d861b1b9a733eb49284a76bd6e4c..f7d1bba68cfe0b2bcca130e7b4fe98328fd6c8a9 100644 --- a/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_getnumberofitem_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_getnumberofitem_test.ets @@ -18,11 +18,11 @@ function getEmptyTuple(): [] { } function getTestPrimitiveTuple(): [boolean, char, byte, short, int, long, float, double] { - return [true, 'x', 127, 300, 500, 600, 100.0, 400.0]; + return [true, c'x', 127, 300, 500, 600, 100.0f, 400.0]; } function getCharTuple(): [char, char, char, char, char] { - return ['H', 'e', 'l', 'l', 'o'] + return [c'H', c'e', c'l', c'l', c'o'] } function getBooleanTuple(): [boolean, boolean, boolean, boolean, boolean] { @@ -46,7 +46,7 @@ function getLongTuple(): [long, long, long, long, long] { } function getFloatTuple(): [float, float, float, float, float] { - return [3.14, 2.71, 1.61, 0.59, 10.0]; + return [3.14f, 2.71f, 1.61f, 0.59f, 10.0f]; } function getDoubleTuple(): [double, double, double, double, double] { diff --git a/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_boolean_test.ets b/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_boolean_test.ets index 27c530ca29c59e83e9fba4a88a573da6d208a9bd..fe90183cc130e29e90ef29fc20861d4b35dcc9f8 100644 --- a/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_boolean_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_boolean_test.ets @@ -18,5 +18,5 @@ function getBooleanTuple(): [boolean, boolean, boolean, boolean, boolean] { } function getCharTuple(): [char, char, char, char, char] { - return ['H', 'e', 'l', 'l', 'o'] + return [c'H', c'e', c'l', c'l', c'o'] } diff --git a/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_byte_test.ets b/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_byte_test.ets index d06714647cacc56ba5b775d9962c139bcc2f429f..ce9d7798154a4a74f5665d10511b0ceae85f8b98 100644 --- a/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_byte_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_byte_test.ets @@ -18,5 +18,5 @@ function getByteTuple(): [byte, byte, byte, byte, byte] { } function getCharTuple(): [char, char, char, char, char] { - return ['H', 'e', 'l', 'l', 'o'] + return [c'H', c'e', c'l', c'l', c'o'] } diff --git a/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_char_test.ets b/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_char_test.ets index b5c736a56a92c8a82554a567b207d4cb2704fd8e..2702854d8997ce3bc4e84eec81721c15b91e7774 100644 --- a/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_char_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_char_test.ets @@ -14,7 +14,7 @@ */ function getCharTuple(): [char, char, char, char, char] { - return ['H', 'e', 'l', 'l', 'o']; + return [c'H', c'e', c'l', c'l', c'o']; } function getIntTuple(): [int, int, int, int, int] { diff --git a/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_double_test.ets b/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_double_test.ets index da84d1cddfd6a6aaca36afdb4184af73da44e734..bab0902737f3da8e2d59f1446f06e181e80fda3b 100644 --- a/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_double_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_double_test.ets @@ -18,5 +18,5 @@ function getDoubleTuple(): [double, double, double, double, double] { } function getCharTuple(): [char, char, char, char, char] { - return ['H', 'e', 'l', 'l', 'o'] + return [c'H', c'e', c'l', c'l', c'o'] } diff --git a/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_float_test.ets b/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_float_test.ets index 9ac4377c256f9644b7c463079bdd4466000f4738..6a8ef5e1652d37d1f4289f629f2629542ac81c56 100644 --- a/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_float_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_float_test.ets @@ -14,9 +14,9 @@ */ function getFloatTuple(): [float, float, float, float, float] { - return [3.14, 2.71, 1.61, 0.59, 10.0]; + return [3.14f, 2.71f, 1.61f, 0.59f, 10.0f]; } function getCharTuple(): [char, char, char, char, char] { - return ['H', 'e', 'l', 'l', 'o'] + return [c'H', c'e', c'l', c'l', c'o'] } diff --git a/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_int_test.ets b/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_int_test.ets index b7bad8cd81dc015d09e34312a0c517e61d3dbe34..5a283bc5e54768fc6a4aed78ee9574aafc192345 100644 --- a/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_int_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_int_test.ets @@ -18,5 +18,5 @@ function getIntTuple(): [int, int, int, int, int] { } function getCharTuple(): [char, char, char, char, char] { - return ['H', 'e', 'l', 'l', 'o'] + return [c'H', c'e', c'l', c'l', c'o'] } diff --git a/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_long_test.ets b/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_long_test.ets index 6dba9ccdaf23ee62ef28f7a0404d8330a3c37437..80763868e2898c9d6b1ebdee84490b46b114017d 100644 --- a/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_long_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_long_test.ets @@ -18,5 +18,5 @@ function getLongTuple(): [long, long, long, long, long] { } function getCharTuple(): [char, char, char, char, char] { - return ['H', 'e', 'l', 'l', 'o'] + return [c'H', c'e', c'l', c'l', c'o'] } diff --git a/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_ref_test.ets b/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_ref_test.ets index 79ad3e9b511067e7ce123e88ca468785b8977d43..eee52d7521db1c62763a51d8b6b8e3f68a24bbad 100644 --- a/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_ref_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_ref_test.ets @@ -18,5 +18,5 @@ function getReferenceTuple(): [String, double[], String] { } function getCharTuple(): [char, char, char, char, char] { - return ['H', 'e', 'l', 'l', 'o']; + return [c'H', c'e', c'l', c'l', c'o']; } diff --git a/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_short_test.ets b/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_short_test.ets index 01362aaffeb028e9175c65fc8ae69966ba97c124..b7163752b65115767ffcb2543495143ee4022500 100644 --- a/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_short_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/tuple_ops/tuplevalue_setitem_short_test.ets @@ -18,5 +18,5 @@ function getShortTuple(): [short, short, short, short, short] { } function getCharTuple(): [char, char, char, char, char] { - return ['H', 'e', 'l', 'l', 'o']; + return [c'H', c'e', c'l', c'l', c'o']; } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ani/tests/var_ops/variable_get_value_char_test.ets b/static_core/plugins/ets/tests/ani/tests/var_ops/variable_get_value_char_test.ets index cda67875a6c7da86b644e291cc5eca83f68122ab..9d0364e36d50a36636bf752d57fd2fafb863b3bb 100644 --- a/static_core/plugins/ets/tests/ani/tests/var_ops/variable_get_value_char_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/var_ops/variable_get_value_char_test.ets @@ -14,7 +14,7 @@ */ namespace anyns { - let x: char = 'a'; + let x: char = c'a'; let s: String = "abc"; let z: boolean = false; } diff --git a/static_core/plugins/ets/tests/ani/tests/var_ops/variable_set_value_byte_test.ets b/static_core/plugins/ets/tests/ani/tests/var_ops/variable_set_value_byte_test.ets index b616ac84085245b89138eb7cab027e8448fe3fd8..27116cb005210d3427fc48b7cc1ab7c28196d017 100644 --- a/static_core/plugins/ets/tests/ani/tests/var_ops/variable_set_value_byte_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/var_ops/variable_set_value_byte_test.ets @@ -21,7 +21,7 @@ namespace anyns { static val1: byte = 5; static val2: byte = 1; public static add(): byte { - sum = (A.val1 + A.val2) as byte; + sum = (A.val1 + A.val2).toByte(); return sum; } } diff --git a/static_core/plugins/ets/tests/ani/tests/var_ops/variable_set_value_char_test.ets b/static_core/plugins/ets/tests/ani/tests/var_ops/variable_set_value_char_test.ets index c4b227ee6272adc143da19d95cac6ca8731ffa5a..79bc504a5271909b631cc12ae2e681c0952bd24a 100644 --- a/static_core/plugins/ets/tests/ani/tests/var_ops/variable_set_value_char_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/var_ops/variable_set_value_char_test.ets @@ -14,23 +14,23 @@ */ namespace anyns { - export let aChar: char = 'A'; + export let aChar: char = c'A'; export let aDouble: double = 3.0; export let sum: char; class A { - static val1: char = 'C'; + static val1: char = c'C'; static val2: char = 2; public static add(): char { - sum = A.val1 + A.val2 as char; + sum = (A.val1 + A.val2).toChar(); return sum; } } namespace second { - export let aValue: char = 'W'; + export let aValue: char = c'W'; } } namespace anyns { - export let testValue: char = 'M'; -} \ No newline at end of file + export let testValue: char = c'M'; +} diff --git a/static_core/plugins/ets/tests/ani/tests/var_ops/variable_set_value_float_test.ets b/static_core/plugins/ets/tests/ani/tests/var_ops/variable_set_value_float_test.ets index a2da229290969536a50f7de33b4afb2986b6bee0..1711cd6db89b4fb26ae5c436797abbde6c56fdca 100644 --- a/static_core/plugins/ets/tests/ani/tests/var_ops/variable_set_value_float_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/var_ops/variable_set_value_float_test.ets @@ -15,11 +15,11 @@ namespace anyns { export let intValue: int = 3; - export let floatValue: float = 3.14; + export let floatValue: float = 3.14f; export let sum: float; class A { - static val1: float = 1.5; - static val2: float = 2.5; + static val1: float = 1.5f; + static val2: float = 2.5f; public static add(): float { sum = A.val1 + A.val2; return sum; @@ -27,10 +27,10 @@ namespace anyns { } namespace second { - export let aValue: float = 5.0; + export let aValue: float = 5.0f; } } namespace anyns { - export let testValue: float = 3.14; -} \ No newline at end of file + export let testValue: float = 3.14f; +} diff --git a/static_core/plugins/ets/tests/ani/tests/var_ops/variable_set_value_int_test.ets b/static_core/plugins/ets/tests/ani/tests/var_ops/variable_set_value_int_test.ets index 64f88f506730073e9f8fb67d9ac19d874bee701a..6c9bcc29af54036473d96881f1dfff3adb91ef52 100644 --- a/static_core/plugins/ets/tests/ani/tests/var_ops/variable_set_value_int_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/var_ops/variable_set_value_int_test.ets @@ -15,7 +15,7 @@ namespace anyns { export let intValue: int = 5; - export let floatValue: float = 3.14; + export let floatValue: float = 3.14f; export let sum: int; class A { static val1: int = 1; diff --git a/static_core/plugins/ets/tests/ani/tests/var_ops/variable_set_value_long_test.ets b/static_core/plugins/ets/tests/ani/tests/var_ops/variable_set_value_long_test.ets index 15691019c10a187ccc0763d1f4b233be72787688..2c3c6f9a2f88c242666155b4c95d83b3c557b24d 100644 --- a/static_core/plugins/ets/tests/ani/tests/var_ops/variable_set_value_long_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/var_ops/variable_set_value_long_test.ets @@ -15,7 +15,7 @@ namespace anyns { export let longValue: long = 3; - export let floatValue: float = 3.14; + export let floatValue: float = 3.14f; export let sum: long; class A { static val1: long = 1; diff --git a/static_core/plugins/ets/tests/ani/tests/var_ops/variable_set_value_short_test.ets b/static_core/plugins/ets/tests/ani/tests/var_ops/variable_set_value_short_test.ets index 27a90db92187db9b75fdc7732681dc6c863e6b25..e0d82fca9b7160f6701a4bc7ab6df482b01bbcca 100644 --- a/static_core/plugins/ets/tests/ani/tests/var_ops/variable_set_value_short_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/var_ops/variable_set_value_short_test.ets @@ -15,13 +15,13 @@ namespace anyns { export let shortValue: short = 3; - export let floatValue: float = 3.14; + export let floatValue: float = 3.14f; export let sum: short; class A { static val1: short = 1; static val2: short = 2; public static add(): short { - sum = (A.val1 + A.val2) as short; + sum = (A.val1 + A.val2).toShort(); return sum; } } diff --git a/static_core/plugins/ets/tests/checked/CMakeLists.txt b/static_core/plugins/ets/tests/checked/CMakeLists.txt index 1693157501d5fba2ad2013917745125265112299..64335bd4ef57d1337e197e3872846caa6f41f75a 100644 --- a/static_core/plugins/ets/tests/checked/CMakeLists.txt +++ b/static_core/plugins/ets/tests/checked/CMakeLists.txt @@ -193,7 +193,8 @@ if (PANDA_TARGET_AMD64 OR NOT PANDA_ARM64_TESTS_WITH_SANITIZER) # Causes regalloc verification failure on ARM32 panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ets_escompat_typed_arrays.ets BOOT) panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ets_escompat_typed_arrays_reverse.ets BOOT) - panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ets_escompat_typed_arrays_fill.ets BOOT) + # Issue 26080 (work only with disabled jit) + # panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ets_escompat_typed_arrays_fill.ets BOOT) endif() if (PANDA_TARGET_ARM64) panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/memory_coalescing.ets) @@ -312,7 +313,8 @@ if (PANDA_TARGET_AMD64 OR NOT PANDA_ARM64_TESTS_WITH_SANITIZER) # panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ets_typeof_compare3.ets) # panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ets_typeof_compare4.ets) # panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ets_typeof_compare6.ets) - panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ets_promise_launch.ets) + #24004 jit assert + # panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ets_promise_launch.ets) panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/inlining_test/inlining_nested_lambdas.ets) panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/isinstance_elim_load_static.ets) panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/lse_parameter_aliasing.ets) @@ -325,7 +327,7 @@ panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/optimize_negation.et panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/llvm_infer_flags.ets) panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ani/direct_native.ets NATIVE SUPPORT_RELEASE) panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ani/quick_native.ets NATIVE SUPPORT_RELEASE) -panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/optimize_load_object_boxed.ets) +#panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/optimize_load_object_boxed.ets) panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/load_static_const_folding.ets) panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/lower_boxed_boolean.ets) panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/optimize_doubled_xor.ets OPT_LEVEL 0) diff --git a/static_core/plugins/ets/tests/checked/ani/unsafe_memory.ets b/static_core/plugins/ets/tests/checked/ani/unsafe_memory.ets index 813bac4e837ba22545ef687d9e79773a340fa2fd..cebe32a6cef4e13d8e1ba8cd8b112a103009a656 100644 --- a/static_core/plugins/ets/tests/checked/ani/unsafe_memory.ets +++ b/static_core/plugins/ets/tests/checked/ani/unsafe_memory.ets @@ -33,7 +33,7 @@ native function freeMem(addr: long) : void; function testBoolean() : int { let vals: boolean[] = [true, false, false, false, true, true, false, true]; - let size: int = vals.length as int * Byte.BYTE_SIZE; + let size: int = vals.length.toInt() * Byte.BYTE_SIZE; let addr: long = allocMem(size); let ptr: long = addr for (let i: int = 0; i < vals.length; ++i) { @@ -56,7 +56,7 @@ function testBoolean() : int { function testInt8() : int { let vals: byte[] = [1, -1, 0, 2, -2, 127, -128]; - let size: int = vals.length as int * Byte.BYTE_SIZE; + let size: int = vals.length.toInt() * Byte.BYTE_SIZE; let addr: long = allocMem(size); let ptr: long = addr for (let i: int = 0; i < vals.length; ++i) { @@ -78,8 +78,8 @@ function testInt8() : int { } function testInt16() : int { - let vals: short[] = [1, -1, 0, 2, -2, 0x7fff as short, 0x8000 as short ]; - let size: int = vals.length as int * Short.BYTE_SIZE; + let vals: short[] = [1, -1, 0, 2, -2, 0x7fff.toShort(), 0x8000.toShort() ]; + let size: int = vals.length.toInt() * Short.BYTE_SIZE; let addend = Short.BYTE_SIZE - 1 let addr: long = allocMem(size + addend); for (let l: int = 0; l <= addend; ++l) { @@ -105,7 +105,7 @@ function testInt16() : int { function testInt32() : int { let vals: int[] = [1, -1, 0, 2, -2, 0x7fffffff, 0x80000000]; - let size: int = vals.length as int * Int.BYTE_SIZE; + let size: int = vals.length.toInt() * Int.BYTE_SIZE; let addend = Int.BYTE_SIZE - 1 let addr: long = allocMem(size + addend); for (let l: int = 0; l <= addend; ++l) { @@ -131,7 +131,7 @@ function testInt32() : int { function testInt64() : int { let vals: long[] = [1, -1, 0, 2, -2, 0x7fffffffffffffff as long, 0x8000000000000000 as long]; - let size: int = vals.length as int * Long.BYTE_SIZE; + let size: int = vals.length.toInt() * Long.BYTE_SIZE; let addend = Long.BYTE_SIZE - 1 let addr: long = allocMem(size + addend); for (let l: int = 0; l <= addend; ++l) { @@ -156,8 +156,8 @@ function testInt64() : int { } function testFloat32() : int { - let vals: float[] = [1.123456, -1.234567, 1.2E-50, -1.2E+50 as float, 1.23456E+50 as float, -1.23456E-50]; - let size: int = vals.length as int * Float.BYTE_SIZE; + let vals: float[] = [1.123456f, -1.234567f, 1.2E-50f, -1.2E+50f, 1.23456E+50f, -1.23456E-50f]; + let size: int = vals.length.toInt() * Float.BYTE_SIZE; let addend = Float.BYTE_SIZE - 1 let addr: long = allocMem(size + addend); for (let l: int = 0; l <= addend; ++l) { @@ -184,7 +184,7 @@ function testFloat32() : int { function testFloat64() : int { let vals: double[] = [1.23456789, -1.23456789, 1.2E-300, 1.2E+300, 1.23456789E+300, -1.23456789E-300]; - let size: int = vals.length as int * Double.BYTE_SIZE; + let size: int = vals.length.toInt() * Double.BYTE_SIZE; let addend = Double.BYTE_SIZE - 1 let addr: long = allocMem(size + addend); for (let l: int = 0; l <= addend; ++l) { diff --git a/static_core/plugins/ets/tests/checked/checks_elimination_actual_length.ets b/static_core/plugins/ets/tests/checked/checks_elimination_actual_length.ets index a91c2c23b2b81686a923239290afa2febc13f138..1e18c87c70d5637c8cf378bf5e986493b20f91e7 100644 --- a/static_core/plugins/ets/tests/checked/checks_elimination_actual_length.ets +++ b/static_core/plugins/ets/tests/checked/checks_elimination_actual_length.ets @@ -102,7 +102,7 @@ class Derived extends Array { public func1() : int { let sum : int = 0 - let length = this.length as int + let length = this.length.toInt() for (let i : int = 0; i < length; i++) { sum += this.$_get_unsafe(i) } @@ -111,7 +111,7 @@ class Derived extends Array { public func2() : int { let sum : int = 0 - let length = this.length as int + let length = this.length.toInt() for (let i : int = length - 1; i >= 0; i--) { sum += this.$_get_unsafe(i) } @@ -120,7 +120,7 @@ class Derived extends Array { public func3() : int { let sum : int = 0 - let length = this.length as int + let length = this.length.toInt() for (let i : int = 0; i < length / 2; i++) { sum += this.$_get_unsafe(i) } @@ -129,7 +129,7 @@ class Derived extends Array { public func4() : int { let sum : int = 0 - let length = this.length as int + let length = this.length.toInt() for (let i : int = 0; i < length; i++) { sum += this.$_get_unsafe(length - i - 1) } @@ -141,7 +141,7 @@ class Derived extends Array { public func5() : int { let has_error : boolean = false let sum : int = 0 - let length = this.length as int + let length = this.length.toInt() for (let i : int = 0; i < length + 1; i++) { try { sum += this.$_get_unsafe(i) @@ -156,7 +156,7 @@ class Derived extends Array { public func6() : int { let has_error : boolean = false let sum : int = 0 - let length = this.length as int + let length = this.length.toInt() for (let i : int = 0; i < length; i--) { try { sum += this.$_get_unsafe(i) @@ -172,7 +172,7 @@ class Derived extends Array { public func7() : int { let has_error : boolean = false let sum : int = 0 - let length = this.length as int + let length = this.length.toInt() for (let i : int = length; i >= 0; i--) { try { sum += this.$_get_unsafe(i) @@ -187,7 +187,7 @@ class Derived extends Array { public func8() : int { let has_error : boolean = false let sum : int = 0 - let length = this.length as int + let length = this.length.toInt() for (let i : int = -1; i < length; i++) { try { sum += this.$_get_unsafe(i) @@ -201,7 +201,7 @@ class Derived extends Array { public func9() : int { let sum : int = 0 - for (let i : int = 0; i < (this.length as int); i++) { + for (let i : int = 0; i < (this.length.toInt()); i++) { this.length = this.length - 1 sum += this[i] } @@ -210,7 +210,7 @@ class Derived extends Array { public func10() : int { let sum : int = 0 - for (let i : int = 0; i < (this.length as int); i++) { + for (let i : int = 0; i < (this.length.toInt()); i++) { this.__noinline__setlen(3) sum += this[i] } diff --git a/static_core/plugins/ets/tests/checked/checks_elimination_no_hoist.ets b/static_core/plugins/ets/tests/checked/checks_elimination_no_hoist.ets index d4e6da43c070c280726698a7ae2267cdf5c408d7..7a904fb8328155c7a54db7f8ef62b3da7165fda3 100644 --- a/static_core/plugins/ets/tests/checked/checks_elimination_no_hoist.ets +++ b/static_core/plugins/ets/tests/checked/checks_elimination_no_hoist.ets @@ -33,7 +33,7 @@ function HoistableInput(): int { let c:int = 0; // [prehead 1] for (let i:int = 0; i < I; i++) { - c = c1 / 3; + c = c1 / 3; if (c > 0) { // 'c' != 0 here, 'v / c' can be hosisted to [prehead 2] but still // shouldn't be hoisted into [prehead 1]. Since 'c1 / 2' will be hoisted, @@ -45,7 +45,7 @@ function HoistableInput(): int { } } } - + return u; } @@ -77,7 +77,7 @@ function DomCheckOutside(): int { } } } - + return u; } @@ -100,11 +100,11 @@ function InvalidBoundsOutside(): int { // 'NO_HOIST' in 'v / c'. // [prehead 2] for (let j:int = 0; j < I; j++) { - u = v / c; + u = v / c; } } } - + return u; } @@ -130,7 +130,7 @@ function ValidBoundsOutside(): int { } } } - + return u; } @@ -150,7 +150,7 @@ let RES = -3; function NullCheck(): int { let nulref = __noinline__getnull(); - let x : char = '\0'; + let x : char = c'\0'; for (let i = 0; i < 3; i++) { if (nulref != null) { RES += nulref.indexOf(x); @@ -177,7 +177,7 @@ function BoundsCheck(): int { if (str1char.length <= 100000) { RES += 1; } else { - RES += str1char.charAt(10000) as int; + RES += Char.toInt(str1char.charAt(10000)); } } return RES; diff --git a/static_core/plugins/ets/tests/checked/escape_analysis_casted.ets b/static_core/plugins/ets/tests/checked/escape_analysis_casted.ets index bc173e2ef49af3d96e7b29b352b29154c6ccc219..7801dcd510840e0bbda40e350f12a8bc5f80bed3 100644 --- a/static_core/plugins/ets/tests/checked/escape_analysis_casted.ets +++ b/static_core/plugins/ets/tests/checked/escape_analysis_casted.ets @@ -18,16 +18,17 @@ //! EVENT /Compilation,escape_analysis_casted.ETSGLOBAL::main_char,.*,COMPILED/ //! METHOD "escape_analysis_casted.ETSGLOBAL::main_char" //! PASS_BEFORE "EscapeAnalysis" -//! INST_COUNT "Cast", 0 +//! INST_COUNT "Cast", 6 //! PASS_AFTER "EscapeAnalysis" -//! INST_COUNT "Cast", 1 -//! INST_COUNT ".u16 Cast i8", 1 +//! INST_COUNT "Cast", 6 +//! INST_COUNT ".u16 Cast i8", 0 class A { fld: Char constructor(p: byte) { - this.fld = new Char(p as char); + this.fld = new Char(p.toChar()); + console.log("a side-effect to break LSE") } } @@ -48,16 +49,17 @@ function main_char(): int { //! EVENT /Compilation,escape_analysis_casted.ETSGLOBAL::main_long,.*,COMPILED/ //! METHOD "escape_analysis_casted.ETSGLOBAL::main_long" //! PASS_BEFORE "EscapeAnalysis" -//! INST_COUNT "Cast", 1 +//! INST_COUNT "Cast", 7 //! INST_COUNT ".u16 Cast i8", 0 //! PASS_AFTER "EscapeAnalysis" -//! INST_COUNT "Cast", 2 -//! INST_COUNT ".u16 Cast i8", 1 +//! INST_COUNT "Cast", 7 +//! INST_COUNT ".u16 Cast i8", 0 class B { fld: Char constructor(p: int) { - this.fld = new Char(p as byte); + this.fld = new Char(p.toByte()); + console.log("a side-effect to break LSE") } } // |will cut| |will cut| diff --git a/static_core/plugins/ets/tests/checked/ets_escompat_typed_arrays.ets b/static_core/plugins/ets/tests/checked/ets_escompat_typed_arrays.ets index c34ef6e5a5df2fe21cbea8bf02277220026d60da..c300455ce58c7bac6e4734ec50cc00754cc7f398 100644 --- a/static_core/plugins/ets/tests/checked/ets_escompat_typed_arrays.ets +++ b/static_core/plugins/ets/tests/checked/ets_escompat_typed_arrays.ets @@ -965,9 +965,9 @@ function check_array(arr: BigUint64Array, expected: BigUint64Array) { function test_int8array_set_byte_cpp(): void { let ar = new Int8Array(10) ar[2] = -128 as byte - ar[3] = -129 as byte + ar[3] = Int.toByte(-129) ar[4] = 127 as byte - ar[5] = 128 as byte + ar[5] = Int.toByte(128) assertEquals(-128, ar[2]) assertEquals(127, ar[3]) assertEquals(127, ar[4]) @@ -987,9 +987,9 @@ function test_int8array_set_byte_cpp(): void { function test_int8array_set_byte_ir(): void { let ar = new Int8Array(10) ar[2] = -128 as byte - ar[3] = -129 as byte + ar[3] = Int.toByte(-129) ar[4] = 127 as byte - ar[5] = 128 as byte + ar[5] = Int.toByte(128) assertEquals(-128, ar[2]) assertEquals(127, ar[3]) assertEquals(127, ar[4]) @@ -1083,9 +1083,9 @@ function test_int8array_set_number_cpp(): void { function test_int16array_set_short_cpp(): void { let ar = new Int16Array(10) ar[2] = -32768 as short - ar[3] = -32769 as short + ar[3] = Int.toShort(-32769) ar[4] = 32767 as short - ar[5] = 32768 as short + ar[5] = Int.toShort(32768) assertEquals(-32768, ar[2]) assertEquals(32767, ar[3]) assertEquals(32767, ar[4]) @@ -1105,9 +1105,9 @@ function test_int16array_set_short_cpp(): void { function test_int16array_set_short_ir(): void { let ar = new Int16Array(10) ar[2] = -32768 as short - ar[3] = -32769 as short + ar[3] = Int.toShort(-32769) ar[4] = 32767 as short - ar[5] = 32768 as short + ar[5] = Int.toShort(32768) assertEquals(-32768, ar[2]) assertEquals(32767, ar[3]) assertEquals(32767, ar[4]) @@ -1256,10 +1256,6 @@ function test_int32array_set_number_cpp(): void { //! CHECKER BigInt64Array $_set int/$_get cpp intrinsic //! RUN force_jit: true, options: "--compiler-encode-intrinsics=false --compiler-loop-idioms=false --compiler-regex=.*BigInt64Array::.*", entry: "ets_escompat_typed_arrays.ETSGLOBAL::test_bigint64array_set_int_cpp" -//! METHOD "escompat_BigInt64Array::__set" -//! PASS_AFTER "IrBuilder" -//! INST "Intrinsic.BigInt64ArraySetLong " -//! INST_NOT /Call.*Array::\$_set/ //! METHOD "escompat_BigInt64Array::__get" //! PASS_AFTER "IrBuilder" //! INST "Intrinsic.BigInt64ArrayGet " @@ -2201,11 +2197,11 @@ function test_uint8clampedarray_index_of() { //! METHOD "ets_escompat_typed_arrays.ETSGLOBAL::test_int8array_last_index_of" function test_int8array_last_index_of() { let array = new Int8Array([1, 2, 3, 3, 3, 4, 5]) - assertEQ(array.lastIndexOf(3 , 0), -1.); - assertEQ(array.lastIndexOf(3 , 6), 4.); - assertEQ(array.lastIndexOf(3 , 8), 4.); - assertEQ(array.lastIndexOf(3., -1), 4.); - assertEQ(array.lastIndexOf(3., -7), -1.); + assertEQ(array.lastIndexOf(3 as int, 0 as int), -1.); + assertEQ(array.lastIndexOf(3 as int, 6 as int), 4.); + assertEQ(array.lastIndexOf(3 as int, 8 as int), 4.); + assertEQ(array.lastIndexOf(3. as double, -1 as int), 4.); + assertEQ(array.lastIndexOf(3. as double, -7 as int), -1.); } //! CHECKER Int16Array lastIndexOf @@ -2216,8 +2212,8 @@ function test_int16array_last_index_of() { assertEQ(array.lastIndexOf(3., 0), -1.); assertEQ(array.lastIndexOf(3., 6), 4.); assertEQ(array.lastIndexOf(3., 8), 4.); - assertEQ(array.lastIndexOf(3 , -1), 4.); - assertEQ(array.lastIndexOf(3 , -7), -1.); + assertEQ(array.lastIndexOf(3 as int, -1 as int), 4.); + assertEQ(array.lastIndexOf(3 as int, -7 as int), -1.); } //! CHECKER Int32Array lastIndexOf @@ -2226,9 +2222,9 @@ function test_int16array_last_index_of() { function test_int32array_last_index_of() { let array = new Int32Array([1, 2, 3, 3, 3, 4, 5]) assertEQ(array.lastIndexOf(3., 0), -1.); - assertEQ(array.lastIndexOf(3 , 6), 4.); - assertEQ(array.lastIndexOf(3 , 8), 4.); - assertEQ(array.lastIndexOf(3 , -1), 4.); + assertEQ(array.lastIndexOf(3 as int, 6 as int), 4.); + assertEQ(array.lastIndexOf(3 as int, 8 as int), 4.); + assertEQ(array.lastIndexOf(3 as int, -1 as int), 4.); assertEQ(array.lastIndexOf(3., -7), -1.); } @@ -2252,8 +2248,8 @@ function test_float32array_last_index_of() { assertEQ(array.lastIndexOf(3., 0), -1.); assertEQ(array.lastIndexOf(3., 6), 4.); assertEQ(array.lastIndexOf(3., 8), 4.); - assertEQ(array.lastIndexOf(3 , -1), 4.); - assertEQ(array.lastIndexOf(3 , -7), -1.); + assertEQ(array.lastIndexOf(3 as int, -1 as int), 4.); + assertEQ(array.lastIndexOf(3 as int, -7 as int), -1.); } //! CHECKER Float64Array lastIndexOf @@ -2261,9 +2257,9 @@ function test_float32array_last_index_of() { //! METHOD "ets_escompat_typed_arrays.ETSGLOBAL::test_float64array_last_index_of" function test_float64array_last_index_of() { let array = new Float64Array([1, 2, 3, 3, 3, 4, 5]) - assertEQ(array.lastIndexOf(3 , 0), -1.); - assertEQ(array.lastIndexOf(3 , 6), 4.); - assertEQ(array.lastIndexOf(3 , 8), 4.); + assertEQ(array.lastIndexOf(3 as int, 0 as int), -1.); + assertEQ(array.lastIndexOf(3 as int, 6 as int), 4.); + assertEQ(array.lastIndexOf(3 as int, 8 as int), 4.); assertEQ(array.lastIndexOf(3., -1), 4.); assertEQ(array.lastIndexOf(3., -7), -1.); } @@ -2273,9 +2269,9 @@ function test_float64array_last_index_of() { //! METHOD "ets_escompat_typed_arrays.ETSGLOBAL::test_uint8array_last_index_of" function test_uint8array_last_index_of() { let array = new Uint8Array([1, 2, 3, 3, 3, 4, 5]) - assertEQ(array.lastIndexOf(3 , 0), -1.); - assertEQ(array.lastIndexOf(3 , 6), 4.); - assertEQ(array.lastIndexOf(3 , 8), 4.); + assertEQ(array.lastIndexOf(3 as int, 0 as int), -1.); + assertEQ(array.lastIndexOf(3 as int, 6 as int), 4.); + assertEQ(array.lastIndexOf(3 as int, 8 as int), 4.); assertEQ(array.lastIndexOf(3., -1), 4.); assertEQ(array.lastIndexOf(3., -7), -1.); } @@ -2285,9 +2281,9 @@ function test_uint8array_last_index_of() { //! METHOD "ets_escompat_typed_arrays.ETSGLOBAL::test_uint16array_last_index_of" function test_uint16array_last_index_of() { let array = new Uint16Array([1, 2, 3, 3, 3, 4, 5]) - assertEQ(array.lastIndexOf(3 , 0), -1.); - assertEQ(array.lastIndexOf(3 , 6), 4.); - assertEQ(array.lastIndexOf(3 , 8), 4.); + assertEQ(array.lastIndexOf(3 as int, 0 as int), -1.); + assertEQ(array.lastIndexOf(3 as int, 6 as int), 4.); + assertEQ(array.lastIndexOf(3 as int, 8 as int), 4.); assertEQ(array.lastIndexOf(3., -1), 4.); assertEQ(array.lastIndexOf(3., -7), -1.); } @@ -2297,9 +2293,9 @@ function test_uint16array_last_index_of() { //! METHOD "ets_escompat_typed_arrays.ETSGLOBAL::test_uint32array_last_index_of" function test_uint32array_last_index_of() { let array = new Uint32Array([1, 2, 3, 3, 3, 4, 5]) - assertEQ(array.lastIndexOf(3 , 0), -1.); - assertEQ(array.lastIndexOf(3 , 6), 4.); - assertEQ(array.lastIndexOf(3 , 8), 4.); + assertEQ(array.lastIndexOf(3 as int, 0 as int), -1.); + assertEQ(array.lastIndexOf(3 as int, 6 as int), 4.); + assertEQ(array.lastIndexOf(3 as int, 8 as int), 4.); assertEQ(array.lastIndexOf(3., -1), 4.); assertEQ(array.lastIndexOf(3., -7), -1.); } @@ -2327,9 +2323,9 @@ function test_biguint64array_last_index_of() { //! METHOD "ets_escompat_typed_arrays.ETSGLOBAL::test_uint8clampedarray_last_index_of" function test_uint8clampedarray_last_index_of() { let array = new Uint8ClampedArray([1, 2, 3, 3, 3, 4, 5]) - assertEQ(array.lastIndexOf(3 , 0), -1.); - assertEQ(array.lastIndexOf(3 , 6), 4.); - assertEQ(array.lastIndexOf(3 , 8), 4.); + assertEQ(array.lastIndexOf(3 as int, 0 as int), -1.); + assertEQ(array.lastIndexOf(3 as int, 6 as int), 4.); + assertEQ(array.lastIndexOf(3 as int, 8 as int), 4.); assertEQ(array.lastIndexOf(3., -1), 4.); assertEQ(array.lastIndexOf(3., -7), -1.); } diff --git a/static_core/plugins/ets/tests/checked/ets_isinteger.ets b/static_core/plugins/ets/tests/checked/ets_isinteger.ets index dea35c286fcef6d63c5393d7aa45e0185e9ad05c..d49f2b8ab63f34299300a9c0f3a3275421a70a55 100644 --- a/static_core/plugins/ets/tests/checked/ets_isinteger.ets +++ b/static_core/plugins/ets/tests/checked/ets_isinteger.ets @@ -95,7 +95,7 @@ //! ASM_NEXT arm32: /mov\s+r[0-9]+,\s+#0/ function main(): int { - let trueInt: float = 1.0; + let trueInt: float = 1.0f; if (Float.isInteger(trueInt) != true) return 1; diff --git a/static_core/plugins/ets/tests/checked/ets_pea_loads_upward_propagation.ets b/static_core/plugins/ets/tests/checked/ets_pea_loads_upward_propagation.ets index 028f4632e088d1c346cb8afbf8d5c46193626a1d..1e928860e6308aace6918028d8b706719f6fa443 100644 --- a/static_core/plugins/ets/tests/checked/ets_pea_loads_upward_propagation.ets +++ b/static_core/plugins/ets/tests/checked/ets_pea_loads_upward_propagation.ets @@ -69,9 +69,9 @@ //! METHOD "ets_pea_loads_upward_propagation.ETSGLOBAL::test9" //! PASS_BEFORE "EscapeAnalysis" //! INST_COUNT /NewObject/, 10 -//! INST_COUNT /StoreObject.*done/, 1 +//! INST_COUNT /StoreObject.*done/, 2 //! PASS_AFTER "EscapeAnalysis" -//! INST_COUNT /NewObject/, 9 +//! INST_COUNT /NewObject/, 8 //! INST_COUNT /StoreObject.*done/, 0 //! //! METHOD "ets_pea_loads_upward_propagation.ETSGLOBAL::ntest1" @@ -119,89 +119,89 @@ //! RUN entry: "ets_pea_loads_upward_propagation.ETSGLOBAL::main" //! METHOD "ets_pea_loads_upward_propagation.ETSGLOBAL::test1" //! PASS_BEFORE "EscapeAnalysis" -//! INST_COUNT /NewObject/, 3 +//! INST_COUNT /NewObject/, 5 //! INST_COUNT /StoreObject.*res/, 4 //! INST_COUNT /LoadObject.*res/, 1 //! PASS_AFTER "EscapeAnalysis" -//! INST_COUNT /NewObject/, 1 +//! INST_COUNT /NewObject/, 3 //! INST_COUNT /StoreObject.*res/, 0 //! INST_COUNT /LoadObject.*res/, 0 //! //! METHOD "ets_pea_loads_upward_propagation.ETSGLOBAL::test2" //! PASS_BEFORE "EscapeAnalysis" -//! INST_COUNT /NewObject/, 3 +//! INST_COUNT /NewObject/, 5 //! INST_COUNT /StoreObject.*res/, 4 //! INST_COUNT /LoadObject.*res/, 2 //! PASS_AFTER "EscapeAnalysis" -//! INST_COUNT /NewObject/, 1 +//! INST_COUNT /NewObject/, 3 //! INST_COUNT /StoreObject.*res/, 0 //! INST_COUNT /LoadObject.*res/, 0 //! //! METHOD "ets_pea_loads_upward_propagation.ETSGLOBAL::test3" //! PASS_BEFORE "EscapeAnalysis" -//! INST_COUNT /NewObject/, 3 +//! INST_COUNT /NewObject/, 5 //! INST_COUNT /StoreObject.*res/, 4 //! INST_COUNT /LoadObject.*res/, 3 //! PASS_AFTER "EscapeAnalysis" -//! INST_COUNT /NewObject/, 1 +//! INST_COUNT /NewObject/, 3 //! INST_COUNT /StoreObject.*res/, 0 //! INST_COUNT /LoadObject.*res/, 0 //! //! METHOD "ets_pea_loads_upward_propagation.ETSGLOBAL::test4" //! PASS_BEFORE "EscapeAnalysis" -//! INST_COUNT /NewObject/, 4 +//! INST_COUNT /NewObject/, 6 //! INST_COUNT /StoreObject.*res/, 6 //! INST_COUNT /LoadObject.*res/, 1 //! PASS_AFTER "EscapeAnalysis" -//! INST_COUNT /NewObject/, 1 +//! INST_COUNT /NewObject/, 3 //! INST_COUNT /StoreObject.*res/, 0 //! INST_COUNT /LoadObject.*res/, 0 //! //! METHOD "ets_pea_loads_upward_propagation.ETSGLOBAL::test5" //! PASS_BEFORE "EscapeAnalysis" -//! INST_COUNT /NewObject/, 13 +//! INST_COUNT /NewObject/, 15 //! INST_COUNT /StoreObject.*res/, 24 //! INST_COUNT /LoadObject.*res/, 1 //! PASS_AFTER "EscapeAnalysis" -//! INST_COUNT /NewObject/, 8 +//! INST_COUNT /NewObject/, 10 //! INST_COUNT /StoreObject.*res/, 14 //! INST_COUNT /LoadObject.*res/, 1 //! //! METHOD "ets_pea_loads_upward_propagation.ETSGLOBAL::ntest1" //! PASS_BEFORE "EscapeAnalysis" -//! INST_COUNT /NewObject/, 3 +//! INST_COUNT /NewObject/, 5 //! INST_COUNT /StoreObject.*res/, 4 //! PASS_AFTER "EscapeAnalysis" -//! INST_COUNT /NewObject/, 3 +//! INST_COUNT /NewObject/, 5 //! INST_COUNT /StoreObject.*res/, 4 //! //! METHOD "ets_pea_loads_upward_propagation.ETSGLOBAL::ntest2" //! PASS_BEFORE "EscapeAnalysis" -//! INST_COUNT /NewObject/, 3 +//! INST_COUNT /NewObject/, 5 //! INST_COUNT /StoreObject.*res/, 4 //! INST_COUNT /LoadObject.*res/, 1 //! PASS_AFTER "EscapeAnalysis" -//! INST_COUNT /NewObject/, 3 +//! INST_COUNT /NewObject/, 5 //! INST_COUNT /StoreObject.*res/, 4 //! INST_COUNT /LoadObject.*res/, 1 //! //! METHOD "ets_pea_loads_upward_propagation.ETSGLOBAL::ntest3" //! PASS_BEFORE "EscapeAnalysis" -//! INST_COUNT /NewObject/, 3 +//! INST_COUNT /NewObject/, 5 //! INST_COUNT /StoreObject.*res/, 4 //! INST_COUNT /LoadObject.*res/, 1 //! PASS_AFTER "EscapeAnalysis" -//! INST_COUNT /NewObject/, 3 +//! INST_COUNT /NewObject/, 5 //! INST_COUNT /StoreObject.*res/, 4 //! INST_COUNT /LoadObject.*res/, 1 //! //! METHOD "ets_pea_loads_upward_propagation.ETSGLOBAL::ntest4" //! PASS_BEFORE "EscapeAnalysis" -//! INST_COUNT /NewObject/, 4 +//! INST_COUNT /NewObject/, 6 //! INST_COUNT /StoreObject.*res/, 6 //! INST_COUNT /LoadObject.*res/, 1 //! PASS_AFTER "EscapeAnalysis" -//! INST_COUNT /NewObject/, 4 +//! INST_COUNT /NewObject/, 6 //! INST_COUNT /StoreObject.*res/, 6 //! INST_COUNT /LoadObject.*res/, 1 @@ -254,7 +254,7 @@ function foo3(a: Array): number function test1(): boolean { let aa: Array = new Array aa.push(3); - return foo1(aa[0]).res as int == 3; + return foo1(aa[0]).res.toInt() == 3; } /* two loads case (two phi users) */ @@ -262,7 +262,7 @@ function test2(): boolean { let aa: Array = new Array aa.push(3) let z: BBB = foo1(aa[0]) - return (z.res + z.res1) as int == 6; + return (z.res + z.res1).toInt() == 6; } /* more complex CFG: different number of loads in different branchs */ @@ -272,17 +272,26 @@ function test3(): boolean { let t: boolean = (aa[0] > 0) let z: BBB = foo1(aa[0]) if (t) { - return z.res as int == 3 + return z.res.toInt() == 3 } else { - return (z.res + z.res1) as int == 6; + return (z.res + z.res1).toInt() == 6; } } +/* test the stdlib iterator */ +function test9(): boolean { + let aa: Array = new Array + aa.push(3); + aa.push(5); + aa.push(1); + return foo3(aa).toInt() == 9; +} + /* many inputs phi */ function test4(): boolean { let aa: Array = new Array aa.push(3) - let t: int = aa[0] as int; + let t: int = aa[0].toInt(); let a: BBB; if (t > 0) { if (t > 2) { @@ -305,7 +314,7 @@ function test5(): boolean { let aa: Array = new Array aa.push(3) let a: BBB = new BBB(); - let t: int = aa[0] as int; + let t: int = aa[0].toInt(); for (let i:int = 0; i < t; ++i) { a = new BBB(i) if (i % 2 == 0) { @@ -318,15 +327,6 @@ function test5(): boolean { return false; } -/* test the stdlib iterator */ -function test9(): boolean { - let aa: Array = new Array - aa.push(3); - aa.push(5); - aa.push(1); - return foo3(aa) as int == 9; -} - // Negative tests /* object consumer, not to be inlined */ @@ -355,7 +355,7 @@ function ntest2(): boolean { let z: BBB = foo1(aa[0]) let res: number = z.res if (getRef(z)) { - return res as int == 3; + return res.toInt() == 3; } return false } @@ -364,14 +364,14 @@ function ntest2(): boolean { function ntest3(): boolean { let aa: Array = new Array aa.push(3); - return foo2(aa[0]).res as int == 3; + return foo2(aa[0]).res.toInt() == 3; } /* negative: many inputs phi, different object types */ function ntest4(): boolean { let aa: Array = new Array aa.push(3) - let t: int = aa[0] as int; + let t: int = aa[0].toInt(); let a: BBB; if (t > 0) { if (t > 2) { diff --git a/static_core/plugins/ets/tests/checked/ets_string_builder_merge.ets b/static_core/plugins/ets/tests/checked/ets_string_builder_merge.ets index 15bd67cff4113796e9b80cf6a1ad0dd83cd4d2bb..fce72a5ab895f6268223dc5bd6c6a5f329952510 100644 --- a/static_core/plugins/ets/tests/checked/ets_string_builder_merge.ets +++ b/static_core/plugins/ets/tests/checked/ets_string_builder_merge.ets @@ -91,7 +91,7 @@ //! INST_COUNT "Intrinsic.StdCoreSbAppendShort",2 //! INST_COUNT "Intrinsic.StdCoreSbAppendInt",2 //! INST_COUNT "Intrinsic.StdCoreSbAppendLong",2 -//! INST_COUNT "std.core.StringBuilder::append",8 +//! INST_COUNT "std.core.StringBuilder::append",2 //! INST_COUNT "Intrinsic.StdCoreSbToString",2 //! PASS_AFTER "SimplifyStringBuilder" //! INST_COUNT "StringBuilder::",1 @@ -279,7 +279,7 @@ //! INST_COUNT "Intrinsic.StdCoreSbAppendShort",2 //! INST_COUNT "Intrinsic.StdCoreSbAppendInt",2 //! INST_COUNT "Intrinsic.StdCoreSbAppendLong",2 -//! INST_COUNT "std.core.StringBuilder::append",8 +//! INST_COUNT "std.core.StringBuilder::append",2 //! INST_COUNT "Intrinsic.StdCoreSbToString",2 //! PASS_AFTER "SimplifyStringBuilder" //! INST_COUNT "StringBuilder::",1 @@ -513,7 +513,7 @@ function supported_chain_concat6(): String { .append(space) .append(new Object()) .append(space) - .append(1.0 as Float) + .append(1.0f as Float) .append(space) .append(1.0 as Double) .append(space) @@ -546,7 +546,7 @@ function supported_chain_concat6(): String { .append(space) .append(new Object()) .append(space) - .append(1.0 as Float) + .append(1.0f as Float) .append(space) .append(1.0 as Double) .append(space) diff --git a/static_core/plugins/ets/tests/checked/ets_string_builder_reserve_uber.ets b/static_core/plugins/ets/tests/checked/ets_string_builder_reserve_uber.ets index addaf64e1d3b6a1a7803a8f921b506e45cff7ef9..ac203a53a285f9a6b418f3210f963f45becebce4 100644 --- a/static_core/plugins/ets/tests/checked/ets_string_builder_reserve_uber.ets +++ b/static_core/plugins/ets/tests/checked/ets_string_builder_reserve_uber.ets @@ -58,18 +58,18 @@ function uber_reserve38(cond: boolean) : string switch (i) { case 0: sb.append(i) - sb.append((i as Number).toString()) - sb.append(i as number) - sb.append(i as long) + sb.append((i.toDouble()).toString()) + sb.append(i.toDouble().toString()) + sb.append(i.toLong().toString()) sb.append("-") break case 1: sb.append(i) if (cond) - sb.append((i as Number).toString()) + sb.append((i.toDouble()).toString()) else - sb.append(i as number) - sb.append(i as long) + sb.append(i.toDouble().toString()) + sb.append(i.toLong().toString()) sb.append("-") break case 2: diff --git a/static_core/plugins/ets/tests/checked/load_static_const_folding.ets b/static_core/plugins/ets/tests/checked/load_static_const_folding.ets index 1ed5bd3cd65efdaca919386077f1372c176f91bc..4d331f55659a168f5ed9931312091f787793904b 100644 --- a/static_core/plugins/ets/tests/checked/load_static_const_folding.ets +++ b/static_core/plugins/ets/tests/checked/load_static_const_folding.ets @@ -16,9 +16,6 @@ //! CHECKER Remove LoadStatic for static readonly fields //! RUN force_jit: true, options: "--compiler-regex='.*test.*'", entry: "load_static_const_folding.ETSGLOBAL::main", return: 0 //! METHOD "load_static_const_folding.ETSGLOBAL::testInt" -//! PASS_BEFORE "Peepholes" -//! INST "LoadStatic" -//! INST_NOT "Constant" //! PASS_AFTER "Peepholes" //! INST /Constant\s+20 ->.+/ //! PASS_AFTER "Cleanup" @@ -27,9 +24,6 @@ //! INST_COUNT "Constant", 1 //! //! METHOD "load_static_const_folding.ETSGLOBAL::testFloat" -//! PASS_BEFORE "Peepholes" -//! INST "LoadStatic" -//! INST_NOT "Constant" //! PASS_AFTER "Peepholes" //! INST /Constant\s+10 ->.+/ //! PASS_AFTER "Cleanup" diff --git a/static_core/plugins/ets/tests/checked/lower_boxed_boolean.ets b/static_core/plugins/ets/tests/checked/lower_boxed_boolean.ets index 7ee4e7bd05aaba458c3e719dfaccfed2fe80d456..34008c7c66e7aaf3c276aab2205f4654044b2167 100644 --- a/static_core/plugins/ets/tests/checked/lower_boxed_boolean.ets +++ b/static_core/plugins/ets/tests/checked/lower_boxed_boolean.ets @@ -17,51 +17,18 @@ //! RUN force_jit: true, options: "--compiler-regex='.*lower_boxed_boolean.*test.*' ", entry: "lower_boxed_boolean.ETSGLOBAL::main" //! //! METHOD "lower_boxed_boolean.ETSGLOBAL::test1" -//! PASS_BEFORE "LowerBoxedBoolean" -//! INST /LoadStatic.*std.core.Boolean.TRUE/ -//! INST /LoadStatic.*std.core.Boolean.FALSE/ -//! INST /.*ref.*Phi.*/ -//! INST_NOT /Constant.*0x1/ -//! INST_NOT /Constant.*0x0/ -//! INST_NOT /.*b.*Phi.*/ -//! PASS_AFTER "LowerBoxedBoolean" -//! INST /Constant.*0x1/ -//! INST /Constant.*0x0/ -//! INST /.*b.*Phi.*/ -//! INST_NEXT /.*ref.*Phi.*/ //! PASS_AFTER "Codegen" //! INST_NOT /LoadStatic.*std.core.Boolean.TRUE/ //! INST_NOT /LoadStatic.*std.core.Boolean.FALSE/ //! INST_NOT /.*ref.*Phi.*/ //! //! METHOD "lower_boxed_boolean.ETSGLOBAL::test2" -//! PASS_BEFORE "LowerBoxedBoolean" -//! INST /CallStatic.*Inlined.*std.core.Lambda/ -//! INST /LoadStatic.*std.core.Boolean.TRUE/ -//! INST /LoadStatic.*std.core.Boolean.FALSE/ -//! INST /.*ref.*Phi.*/ -//! INST_NOT /.*b.*Phi.*/ -//! PASS_AFTER "LowerBoxedBoolean" -//! INST /Constant.*0x1/ -//! INST /Constant.*0x0/ -//! INST /.*b.*Phi.*/ -//! INST_NEXT /.*ref.*Phi.*/ //! PASS_AFTER "Codegen" //! INST_NOT /LoadStatic.*std.core.Boolean.TRUE/ //! INST_NOT /LoadStatic.*std.core.Boolean.FALSE/ //! INST_NOT /.*ref.*Phi.*/ //! //! METHOD "lower_boxed_boolean.ETSGLOBAL::test3" -//! PASS_BEFORE "LowerBoxedBoolean" -//! INST /LoadStatic.*std.core.Boolean.TRUE/ -//! INST /LoadStatic.*std.core.Boolean.FALSE/ -//! INST /.*ref.*Phi.*v.*v.*v.*/ -//! INST_NOT /.*b.*Phi.*v.*v.*v.*/ -//! PASS_AFTER "LowerBoxedBoolean" -//! INST /Constant.*0x1/ -//! INST /Constant.*0x0/ -//! INST /.*b.*Phi.*v.*.v.*v.*/ -//! INST_NEXT /.*ref.*Phi.*v.*v.*v.*/ //! PASS_AFTER "Codegen" //! INST_NOT /LoadStatic.*std.core.Boolean.TRUE/ //! INST_NOT /LoadStatic.*std.core.Boolean.FALSE/ @@ -84,37 +51,19 @@ //! INST_NOT /.*b.*Phi.*/ //! //! METHOD "lower_boxed_boolean.ETSGLOBAL::test5" -//! PASS_BEFORE "LowerBoxedBoolean" -//! INST /LoadStatic.*std.core.Boolean.TRUE/ -//! INST /LoadStatic.*std.core.Boolean.FALSE/ -//! INST /.*ref.*Phi.*/ -//! INST_NOT /.*b.*Phi.*/ -//! PASS_AFTER "LowerBoxedBoolean" -//! INST /LoadStatic.*std.core.Boolean.TRUE/ -//! INST /LoadStatic.*std.core.Boolean.FALSE/ //! INST /.*ref.*Phi.*/ //! INST_NOT /.*b.*Phi.*/ //! //! METHOD "lower_boxed_boolean.ETSGLOBAL::test6" //! PASS_BEFORE "LowerBoxedBoolean" -//! INST /LoadStatic.*std.core.Boolean.TRUE/ -//! INST /LoadStatic.*std.core.Boolean.FALSE/ -//! INST /.*ref.*Phi.*/ //! INST_NOT /.*b.*Phi.*/ //! PASS_AFTER "LowerBoxedBoolean" -//! INST /LoadStatic.*std.core.Boolean.TRUE/ -//! INST /LoadStatic.*std.core.Boolean.FALSE/ -//! INST /.*ref.*Phi.*/ //! INST_NOT /.*b.*Phi.*/ //! //! METHOD "lower_boxed_boolean.ETSGLOBAL::test7" //! PASS_BEFORE "LowerBoxedBoolean" -//! INST /LoadStatic.*std.core.Boolean.TRUE/ -//! INST_NEXT /Compare NE.*-> (.*).*/ //! INST_NOT /.*ref.*Phi.*/ //! PASS_AFTER "LowerBoxedBoolean" -//! INST /LoadStatic.*std.core.Boolean.TRUE/ -//! INST_NOT /Compare NE.*-> (.*).*/ //! PASS_AFTER "Codegen" //! INST_NOT /LoadStatic.*std.core.Boolean.TRUE/ @@ -123,15 +72,6 @@ //! RUN_AOT options: "--compiler-regex='.*lower_boxed_boolean.*test.*' --compiler-simplify-string-builder=false", entry: "lower_boxed_boolean.ETSGLOBAL::main" //! //! METHOD "lower_boxed_boolean.ETSGLOBAL::test8" -//! PASS_BEFORE "CheckElimination" -//! INST /CallStatic.*std.core.Boolean::valueOf/ -//! INST_NEXT /.*ref.*Phi.*/ -//! INST_NEXT /SaveState (?!.*->).*/ -//! PASS_AFTER "CheckElimination" -//! INST /CallStatic.*std.core.Boolean::valueOf/ -//! INST_NEXT /.*ref.*Phi.*/ -//! INST_NOT /.*b.*Phi.*/ -//! INST_NEXT /SaveState (?!.*->).*/ // Check LowerBoxedBoolean optimization on Phi with two inputs. function test1(input: boolean): boolean { diff --git a/static_core/plugins/ets/tests/checked/multiarray.ets b/static_core/plugins/ets/tests/checked/multiarray.ets index f9df8fdb19098da431d2cc035f28db1503633853..030ce431ecb005d160afcaa4cd369c88f2c1755e 100644 --- a/static_core/plugins/ets/tests/checked/multiarray.ets +++ b/static_core/plugins/ets/tests/checked/multiarray.ets @@ -65,5 +65,5 @@ function main2(): int { function main3(): int { let arr: FixedArray> = new String[2][3]; arr[0][0] = new String(); - return arr[0][0].length as int; // Should be "0" + return arr[0][0].length.toInt(); // Should be "0" } diff --git a/static_core/plugins/ets/tests/checked/optimize_load_object_boxed.ets b/static_core/plugins/ets/tests/checked/optimize_load_object_boxed.ets index 1ec5e2a7125ecfb60cff8eeb0ce6ec4e62bf5270..bcbb7d56e6f0ebda8864b446442fd2e77b305391 100644 --- a/static_core/plugins/ets/tests/checked/optimize_load_object_boxed.ets +++ b/static_core/plugins/ets/tests/checked/optimize_load_object_boxed.ets @@ -22,7 +22,7 @@ //! INST_COUNT /LoadObject.*Byte/, 0 //! PASS_AFTER "LICM" //! IN_BLOCK /prehead/ -//! INST_COUNT /LoadObject.*Byte/, 1 +//! INST_COUNT /LoadObject.*Byte/, 0 //! //! METHOD "optimize_load_object_boxed.ETSGLOBAL::testChar" //! PASS_BEFORE "LICM" @@ -30,7 +30,7 @@ //! INST_COUNT /LoadObject.*Char/, 0 //! PASS_AFTER "LICM" //! IN_BLOCK /prehead/ -//! INST_COUNT /LoadObject.*Char/, 1 +//! INST_COUNT /LoadObject.*Char/, 0 //! //! METHOD "optimize_load_object_boxed.ETSGLOBAL::testShort" //! PASS_BEFORE "LICM" @@ -38,7 +38,7 @@ //! INST_COUNT /LoadObject.*Short/, 0 //! PASS_AFTER "LICM" //! IN_BLOCK /prehead/ -//! INST_COUNT /LoadObject.*Short/, 1 +//! INST_COUNT /LoadObject.*Short/, 0 //! //! METHOD "optimize_load_object_boxed.ETSGLOBAL::testInt" //! PASS_BEFORE "LICM" @@ -46,7 +46,7 @@ //! INST_COUNT /LoadObject.*Int/, 0 //! PASS_AFTER "LICM" //! IN_BLOCK /prehead/ -//! INST_COUNT /LoadObject.*Int/, 1 +//! INST_COUNT /LoadObject.*Int/, 0 //! //! METHOD "optimize_load_object_boxed.ETSGLOBAL::testLong" //! PASS_BEFORE "LICM" @@ -54,7 +54,7 @@ //! INST_COUNT /LoadObject.*Long/, 0 //! PASS_AFTER "LICM" //! IN_BLOCK /prehead/ -//! INST_COUNT /LoadObject.*Long/, 1 +//! INST_COUNT /LoadObject.*Long/, 0 //! //! METHOD "optimize_load_object_boxed.ETSGLOBAL::testFloat" //! PASS_BEFORE "LICM" @@ -62,7 +62,7 @@ //! INST_COUNT /LoadObject.*Float/, 0 //! PASS_AFTER "LICM" //! IN_BLOCK /prehead/ -//! INST_COUNT /LoadObject.*Float/, 1 +//! INST_COUNT /LoadObject.*Float/, 0 //! //! METHOD "optimize_load_object_boxed.ETSGLOBAL::testNumber" //! PASS_BEFORE "LICM" @@ -70,52 +70,52 @@ //! INST_COUNT /LoadObject.*Double/, 0 //! PASS_AFTER "LICM" //! IN_BLOCK /prehead/ -//! INST_COUNT /LoadObject.*Double/, 1 +//! INST_COUNT /LoadObject.*Double/, 0 //! //! METHOD "optimize_load_object_boxed.ETSGLOBAL::testByteVN" //! PASS_BEFORE "LSE" -//! INST_COUNT /LoadObject.*Byte/, 8 +//! INST_COUNT /LoadObject.*Byte/, 6 //! PASS_AFTER "LSE" -//! INST_COUNT /LoadObject.*Byte/, 2 +//! INST_COUNT /LoadObject.*Byte/, 0 //! //! METHOD "optimize_load_object_boxed.ETSGLOBAL::testCharVN" //! PASS_BEFORE "LSE" -//! INST_COUNT /LoadObject.*Char/, 8 +//! INST_COUNT /LoadObject.*Char/, 6 //! PASS_AFTER "LSE" -//! INST_COUNT /LoadObject.*Char/, 2 +//! INST_COUNT /LoadObject.*Char/, 0 //! //! METHOD "optimize_load_object_boxed.ETSGLOBAL::testShortVN" //! PASS_BEFORE "LSE" -//! INST_COUNT /LoadObject.*Short/, 8 +//! INST_COUNT /LoadObject.*Short/, 6 //! PASS_AFTER "LSE" -//! INST_COUNT /LoadObject.*Short/, 2 +//! INST_COUNT /LoadObject.*Short/, 0 //! //! METHOD "optimize_load_object_boxed.ETSGLOBAL::testIntVN" //! PASS_BEFORE "LSE" -//! INST_COUNT /LoadObject.*Int/, 8 +//! INST_COUNT /LoadObject.*Int/, 6 //! PASS_AFTER "LSE" -//! INST_COUNT /LoadObject.*Int/, 2 +//! INST_COUNT /LoadObject.*Int/, 0 //! //! METHOD "optimize_load_object_boxed.ETSGLOBAL::testLongVN" //! PASS_BEFORE "LSE" -//! INST_COUNT /LoadObject.*Long/, 8 +//! INST_COUNT /LoadObject.*Long/, 6 //! PASS_AFTER "LSE" -//! INST_COUNT /LoadObject.*Long/, 2 +//! INST_COUNT /LoadObject.*Long/, 0 //! //! METHOD "optimize_load_object_boxed.ETSGLOBAL::testFloatVN" //! PASS_BEFORE "LSE" -//! INST_COUNT /LoadObject.*Float/, 8 +//! INST_COUNT /LoadObject.*Float/, 6 //! PASS_AFTER "LSE" -//! INST_COUNT /LoadObject.*Float/, 2 +//! INST_COUNT /LoadObject.*Float/, 0 //! //! METHOD "optimize_load_object_boxed.ETSGLOBAL::testNumberVN" //! PASS_BEFORE "LSE" -//! INST_COUNT /LoadObject.*Double/, 8 +//! INST_COUNT /LoadObject.*Double/, 6 //! PASS_AFTER "LSE" -//! INST_COUNT /LoadObject.*Double/, 2 +//! INST_COUNT /LoadObject.*Double/, 0 function testByte(input: Byte): byte { - let result: byte = 0 as byte; + let result: byte = (0).toByte(); for (let i = 0; i < 5000; i++) { result += Byte.valueOf(input); @@ -125,7 +125,7 @@ function testByte(input: Byte): byte { } function testChar(input: Char): char { - let result: char = 'A'; + let result: char = c'A'; for (let i = 0; i < 5000; i++) { result += Char.valueOf(input); @@ -192,48 +192,48 @@ function __noinline__dummyReturn(): Int { } function testByteVN(a: Byte, b: Byte): byte { - let x: byte = Byte.valueOf(a) + Byte.valueOf(b) as byte; + let x: byte = (Byte.valueOf(a) + Byte.valueOf(b)).toByte(); __noinline__dummy(x); - let y: byte = Byte.valueOf(a) + Byte.valueOf(b) as byte; + let y: byte = (Byte.valueOf(a) + Byte.valueOf(b)).toByte(); __noinline__dummy(y); - let z: byte = Byte.valueOf(b) + Byte.valueOf(a) as byte; + let z: byte = (Byte.valueOf(b) + Byte.valueOf(a)).toByte(); __noinline__dummy(z); for (let i = 0; i < 5000; i++) { let t: Int = __noinline__dummyReturn() } - return x + y + z as byte; + return (x + y + z).toByte(); } function testCharVN(a: Char, b: Char): char { - let x: char = Char.valueOf(a) + Char.valueOf(b) as char; + let x: char = (Char.valueOf(a) + Char.valueOf(b)).toChar(); __noinline__dummy(x); - let y: char = Char.valueOf(a) + Char.valueOf(b) as char; + let y: char = (Char.valueOf(a) + Char.valueOf(b)).toChar(); __noinline__dummy(y); - let z: char = Char.valueOf(b) + Char.valueOf(a) as char; + let z: char = (Char.valueOf(b) + Char.valueOf(a)).toChar(); __noinline__dummy(z); for (let i = 0; i < 5000; i++) { let t: Int = __noinline__dummyReturn() } - return x + y + z as char; + return (x + y + z).toChar(); } function testShortVN(a: Short, b: Short): short { - let x: short = Short.valueOf(a) + Short.valueOf(b) as short; + let x: short = (Short.valueOf(a) + Short.valueOf(b)).toShort(); __noinline__dummy(x); - let y: short = Short.valueOf(a) + Short.valueOf(b) as short; + let y: short = (Short.valueOf(a) + Short.valueOf(b)).toShort(); __noinline__dummy(y); - let z: short = Short.valueOf(b) + Short.valueOf(a) as short; + let z: short = (Short.valueOf(b) + Short.valueOf(a)).toShort(); __noinline__dummy(z); for (let i = 0; i < 5000; i++) { let t: Int = __noinline__dummyReturn() } - return x + y + z as short; + return (x + y + z).toShort(); } function testIntVN(a: Int, b: Int): int { @@ -300,7 +300,7 @@ function main(): int { let valByte: Byte = new Byte(1 as byte); let resultByte: byte = testByte(valByte); - let valChar: Char = new Char('A'); + let valChar: Char = new Char(c'A'); let resultChar: char = testChar(valChar); let valShort: Short = new Short(42 as short); @@ -322,8 +322,8 @@ function main(): int { let inputByteB: Byte = new Byte(2 as byte); resultByte = testByteVN(inputByteA, inputByteB); - let inputCharA: Char = new Char('A'); - let inputCharB: Char = new Char('B'); + let inputCharA: Char = new Char(c'A'); + let inputCharB: Char = new Char(c'B'); resultChar = testCharVN(inputCharA, inputCharB); let inputShortA: Short = new Short(42 as short); diff --git a/static_core/plugins/ets/tests/common/bouncing_pandas/bouncing_pandas.ets b/static_core/plugins/ets/tests/common/bouncing_pandas/bouncing_pandas.ets index beb5f78b979285cc9ce52f67d6c9555455cd9de5..008d0706c114149308e3e29bcad363f1758b97df 100644 --- a/static_core/plugins/ets/tests/common/bouncing_pandas/bouncing_pandas.ets +++ b/static_core/plugins/ets/tests/common/bouncing_pandas/bouncing_pandas.ets @@ -21,8 +21,10 @@ export class Ball { this.x = x; this.y = y; - this.vx = sqrt(2) as float * speed; - this.vy = sqrt(2) as float * speed; + this.vx = sqrt(2).toFloat() * speed; + this.vy = sqrt(2).toFloat() * speed; + this.vx = Double.toFloat(sqrt(2)) * speed; + this.vy = Double.toFloat(sqrt(2)) * speed; } move(): void { @@ -56,7 +58,7 @@ export function recomputeFrameBall(balls: Ball[], frameWidth: float, frameHeight let nx: float = b2.x - b1.x; let ny: float = b2.y - b1.y; - let dist: float = sqrt(nx * nx + ny * ny) as float; + let dist: float = Double.toFloat(sqrt(nx * nx + ny * ny)); if (dist > (b1.radius + b2.radius)) continue; nx = nx / dist; @@ -66,7 +68,7 @@ export function recomputeFrameBall(balls: Ball[], frameWidth: float, frameHeight b1.vx -= nx * 2 * dot; b1.vy -= ny * 2 * dot; - let d: float = b1.radius + b2.radius - dist - 0.1 as float; + let d: float = Double.toFloat(b1.radius + b2.radius - dist - 0.1); b1.x -= nx * d; b1.y -= ny * d; } @@ -115,7 +117,7 @@ function v2scale(a: float, b: Vec2): Vec2 { } export function v2len(a: Vec2): float { - return sqrt(a.x * a.x + a.y * a.y) as float; + return Double.toFloat(sqrt(a.x * a.x + a.y * a.y)); } export class SBody { @@ -206,10 +208,10 @@ function main(): int { result_hash += resArr[i].r.x + resArr[i].r.y + resArr[i].v.x + resArr[i].v.y + resArr[i].rad + resArr[i].m; } - if (result_hash as int != 392623) + if (Float.toInt(result_hash) != 392623) { console.print("Wrong result hash: "); - console.print(result_hash as int); + console.print(Float.toInt(result_hash)); console.println(); return 1; } diff --git a/static_core/plugins/ets/tests/common/bouncing_peas/bouncing_peas.ets b/static_core/plugins/ets/tests/common/bouncing_peas/bouncing_peas.ets index 528c2bd26947bdb986a6d07c28a9a10be8d06870..8664d88b1824e89c1cb949ed2000b8157699fb4f 100644 --- a/static_core/plugins/ets/tests/common/bouncing_peas/bouncing_peas.ets +++ b/static_core/plugins/ets/tests/common/bouncing_peas/bouncing_peas.ets @@ -82,14 +82,14 @@ function encodeFPS(input: int): FixedArray/*Uint8Array*/ { let result : FixedArray = new byte[resultLength];/*Uint8Array(resultLength);*/ let index: int = HEADER_LEN; for (let digitNumber: int = 0; digitNumber < digitsQuantity; digitNumber++) { - let cp = input / power(10., (digitsQuantity - digitNumber - 1) as double) as int % 10 + 48; - result[index++] = cp as byte; + let cp = input / power(10., (digitsQuantity - digitNumber - 1).toDouble()).toInt() % 10 + 48; + result[index++] = cp.toByte(); } result[index] = 0; - result[0] = ((resultLength - HEADER_LEN) & 0xff) as byte; - result[0 + 1] = (((resultLength - HEADER_LEN) as int >> 8) & 0xff) as byte; - result[0 + 2] = (((resultLength - HEADER_LEN) as int >> 16) & 0xff) as byte; - result[0 + 3] = (((resultLength - HEADER_LEN) as int >> 24) & 0xff) as byte; + result[0] = ((resultLength - HEADER_LEN) & 0xff).toByte(); + result[0 + 1] = (((resultLength - HEADER_LEN) as int >> 8) & 0xff).toByte(); + result[0 + 2] = (((resultLength - HEADER_LEN) as int >> 16) & 0xff).toByte(); + result[0 + 3] = (((resultLength - HEADER_LEN) as int >> 24) & 0xff).toByte(); return result; } @@ -100,8 +100,8 @@ class Ball { this.x = x; this.y = y; - this.vx = sqrt(2) as float * speed; - this.vy = sqrt(2) as float * speed; + this.vx = sqrt(2).toFloat() * speed; + this.vy = sqrt(2).toFloat() * speed; } draw(canvasPtr: long/*KNativePointer*/): void { let shapePaintPtr = _skoala_Paint__1nMake(); @@ -143,14 +143,14 @@ class Drawer { const scale : float = 1; this.redrawerDataPtr = _skoala_initRedrawer(this.frameWidth, this.frameHeight, scale, this.redrawerPeer, this.frameHandle); - this.startTime = Date.now() as long; + this.startTime = Date.now().toLong(); } draw(balls: Ball[]): void { - let canvasPtr = _skoala_PictureRecorder__1nBeginRecording(this.pictureRecorderPtr, 0, 0, this.frameWidth as float, this.frameHeight as float); + let canvasPtr = _skoala_PictureRecorder__1nBeginRecording(this.pictureRecorderPtr, 0, 0, this.frameWidth.toFloat(), this.frameHeight.toFloat()); _skoala_Canvas__1nSave(canvasPtr); - let canvas2Ptr = _skoala_PictureRecorder__1nBeginRecording(this.pictureRecorder2Ptr, 0, 0, this.frameWidth as float, this.frameHeight as float); + let canvas2Ptr = _skoala_PictureRecorder__1nBeginRecording(this.pictureRecorder2Ptr, 0, 0, this.frameWidth.toFloat(), this.frameHeight.toFloat()); for (let i = 0; i < balls.length; i++) { balls[i].draw(canvas2Ptr); @@ -166,7 +166,7 @@ class Drawer { _skoala_Canvas__1nRestore(canvasPtr); - let picturePtr = _skoala_PictureRecorder__1nFinishRecordingAsPictureWithCull(this.pictureRecorderPtr, 0, 0, this.frameWidth as float, this.frameHeight as float); + let picturePtr = _skoala_PictureRecorder__1nFinishRecordingAsPictureWithCull(this.pictureRecorderPtr, 0, 0, this.frameWidth.toFloat(), this.frameHeight.toFloat()); let pictureFinalizer = _skoala_impl_RefCnt__getFinalizer(); _skoala_drawPicture(picturePtr, this.redrawerDataPtr, new Object(), true); @@ -176,11 +176,11 @@ class Drawer { // Update FPS this.drawCounter++; - const currentTime: long = Date.now() as long; + const currentTime: long = Date.now().toLong(); if (currentTime - this.startTime >= 1000) { - this.fps = ((this.drawCounter * 1000) as long / (currentTime - this.startTime) as long) as int; + this.fps = ((this.drawCounter * 1000) as long / (currentTime - this.startTime) as long).toInt(); this.drawCounter = 0; - this.startTime = Date.now() as long; + this.startTime = Date.now().toLong(); } } @@ -251,7 +251,7 @@ class Scene { for (let i = 0; i < ballsQuantity; i++) { offset += ballRadius * 3; let x: float = offset % this.drawer.frameWidth; - let y: float = ((offset / this.drawer.frameWidth) as int + 1) as float * ballRadius * 3; + let y: float = ((offset / this.drawer.frameWidth).toInt() + 1).toFloat() * ballRadius * 3; this.balls[i] = new Ball(x, y, BALL_SPEED, ballRadius); } } @@ -271,7 +271,7 @@ class Scene { let nx: float = b2.x - b1.x; let ny: float = b2.y - b1.y; - let dist: float = sqrt(nx * nx + ny * ny) as float; + let dist: float = sqrt(nx * nx + ny * ny).toFloat(); if (dist > (b1.radius + b2.radius)) continue; nx = nx / dist; @@ -281,7 +281,7 @@ class Scene { b1.vx -= nx * 2 * dot; b1.vy -= ny * 2 * dot; - let d: float = b1.radius + b2.radius - dist - 0.1 as float; + let d: float = b1.radius + b2.radius - dist - 0.1.toFloat(); b1.x -= nx * d; b1.y -= ny * d; } @@ -331,7 +331,7 @@ function startApplication(): void { function main(): int { startApplication(); - if (result_hash as int != 7936) + if (result_hash.toInt() != 7936) { console.print("Wrong result hash"); console.println(); diff --git a/static_core/plugins/ets/tests/common/bouncing_peas/bouncing_peas_unit_native.ets b/static_core/plugins/ets/tests/common/bouncing_peas/bouncing_peas_unit_native.ets index 18696c9ace3579974e7cf804de8ef87be8a9e448..d53a20b027139e37db52a8b5bde73cf4e569eacf 100644 --- a/static_core/plugins/ets/tests/common/bouncing_peas/bouncing_peas_unit_native.ets +++ b/static_core/plugins/ets/tests/common/bouncing_peas/bouncing_peas_unit_native.ets @@ -78,14 +78,14 @@ function encodeFPS(input: int): FixedArray/*Uint8Array*/ { let result : FixedArray = new byte[resultLength];/*Uint8Array(resultLength);*/ let index: int = HEADER_LEN; for (let digitNumber: int = 0; digitNumber < digitsQuantity; digitNumber++) { - let cp = input / power(10., (digitsQuantity - digitNumber - 1) as double) as int % 10 + 48; - result[index++] = cp as byte; + let cp = input / power(10., (digitsQuantity - digitNumber - 1).toDouble()).toInt() % 10 + 48; + result[index++] = cp.toByte(); } result[index] = 0; - result[0] = ((resultLength - HEADER_LEN) & 0xff) as byte; - result[0 + 1] = (((resultLength - HEADER_LEN) as int >> 8) & 0xff) as byte; - result[0 + 2] = (((resultLength - HEADER_LEN) as int >> 16) & 0xff) as byte; - result[0 + 3] = (((resultLength - HEADER_LEN) as int >> 24) & 0xff) as byte; + result[0] = ((resultLength - HEADER_LEN) & 0xff).toByte(); + result[0 + 1] = (((resultLength - HEADER_LEN) as int >> 8) & 0xff).toByte(); + result[0 + 2] = (((resultLength - HEADER_LEN) as int >> 16) & 0xff).toByte(); + result[0 + 3] = (((resultLength - HEADER_LEN) as int >> 24) & 0xff).toByte(); return result; } @@ -96,8 +96,8 @@ class Ball { this.x = x; this.y = y; - this.vx = sqrt(2) as float * speed; - this.vy = sqrt(2) as float * speed; + this.vx = sqrt(2).toFloat() * speed; + this.vy = sqrt(2).toFloat() * speed; } draw(canvasPtr: long/*KNativePointer*/): void { let shapePaintPtr = _skoala_Paint__1nMake(); @@ -139,14 +139,14 @@ class Drawer { const scale : float = 1; this.redrawerDataPtr = _skoala_initRedrawer(this.frameWidth, this.frameHeight, scale, this.redrawerPeer, this.frameHandle); - this.startTime = Date.now() as long; + this.startTime = Date.now().toLong(); } draw(balls: Ball[]): void { - let canvasPtr = _skoala_PictureRecorder__1nBeginRecording(this.pictureRecorderPtr, 0, 0, this.frameWidth as float, this.frameHeight as float); + let canvasPtr = _skoala_PictureRecorder__1nBeginRecording(this.pictureRecorderPtr, 0, 0, this.frameWidth.toFloat(), this.frameHeight.toFloat()); _skoala_Canvas__1nSave(canvasPtr); - let canvas2Ptr = _skoala_PictureRecorder__1nBeginRecording(this.pictureRecorder2Ptr, 0, 0, this.frameWidth as float, this.frameHeight as float); + let canvas2Ptr = _skoala_PictureRecorder__1nBeginRecording(this.pictureRecorder2Ptr, 0, 0, this.frameWidth.toFloat(), this.frameHeight.toFloat()); for (let i = 0; i < balls.length; i++) { balls[i].draw(canvas2Ptr); @@ -162,7 +162,7 @@ class Drawer { _skoala_Canvas__1nRestore(canvasPtr); - let picturePtr = _skoala_PictureRecorder__1nFinishRecordingAsPictureWithCull(this.pictureRecorderPtr, 0, 0, this.frameWidth as float, this.frameHeight as float); + let picturePtr = _skoala_PictureRecorder__1nFinishRecordingAsPictureWithCull(this.pictureRecorderPtr, 0, 0, this.frameWidth.toFloat(), this.frameHeight.toFloat()); let pictureFinalizer = _skoala_impl_RefCnt__getFinalizer(); _skoala_drawPicture(picturePtr, this.redrawerDataPtr, new Object(), true); @@ -172,11 +172,11 @@ class Drawer { // Update FPS this.drawCounter++; - const currentTime: long = Date.now() as long; + const currentTime: long = Date.now().toLong(); if (currentTime - this.startTime >= 1000) { - this.fps = ((this.drawCounter * 1000) as long / (currentTime - this.startTime) as long) as int; + this.fps = ((this.drawCounter * 1000) as long / (currentTime - this.startTime) as long).toInt(); this.drawCounter = 0; - this.startTime = Date.now() as long; + this.startTime = Date.now().toLong(); } } @@ -247,7 +247,7 @@ class Scene { for (let i = 0; i < ballsQuantity; i++) { offset += ballRadius * 3; let x: float = offset % this.drawer.frameWidth; - let y: float = ((offset / this.drawer.frameWidth) as int + 1) as float * ballRadius * 3; + let y: float = ((offset / this.drawer.frameWidth).toInt() + 1).toFloat() * ballRadius * 3; this.balls[i] = new Ball(x, y, BALL_SPEED, ballRadius); } } @@ -267,7 +267,7 @@ class Scene { let nx: float = b2.x - b1.x; let ny: float = b2.y - b1.y; - let dist: float = sqrt(nx * nx + ny * ny) as float; + let dist: float = sqrt(nx * nx + ny * ny).toFloat(); if (dist > (b1.radius + b2.radius)) continue; nx = nx / dist; @@ -277,7 +277,7 @@ class Scene { b1.vx -= nx * 2 * dot; b1.vy -= ny * 2 * dot; - let d: float = b1.radius + b2.radius - dist - 0.1 as float; + let d: float = b1.radius + b2.radius - dist - 0.1.toFloat(); b1.x -= nx * d; b1.y -= ny * d; } @@ -327,7 +327,7 @@ function startApplication(): void { function main(): int { startApplication(); - if (result_hash as int != 7936) + if (result_hash.toInt() != 7936) { console.print("Wrong result hash"); console.println(); diff --git a/static_core/plugins/ets/tests/debugger/src/arkdb/internal_tests/test_arkts_str.py b/static_core/plugins/ets/tests/debugger/src/arkdb/internal_tests/test_arkts_str.py index 49740dc9013d2de36a6e7df2c9b7cd887c8dac7c..1d6831d6e499f8ba9bd1ac6995796bad68bb90a4 100644 --- a/static_core/plugins/ets/tests/debugger/src/arkdb/internal_tests/test_arkts_str.py +++ b/static_core/plugins/ets/tests/debugger/src/arkdb/internal_tests/test_arkts_str.py @@ -158,10 +158,10 @@ async def test_arkts_primitive( ("Float", 1), ("double", 1), ("Double", 1), - ("char", ("'A'", "A")), + ("char", ("c'A'", "A")), ("string", ("'AA'", "AA")), - ("Char", ("c'A'", '"A"')), # Char object will be output as String - ("Char", ("new Char(c'A')", '"A"')), # Char object will be output as String + ("Char", ("c'A'", "A")), # Char object will be output as String + ("Char", ("new Char(c'A')", "A")), # Char object will be output as String ("boolean", ("true", True)), ("Boolean", ("true", True)), ("", ("null", None)), diff --git a/static_core/plugins/ets/tests/debugger/src/tests/test_predefined_types.py b/static_core/plugins/ets/tests/debugger/src/tests/test_predefined_types.py index 1465aacebf4e7531b6e12e56c92492da9e85fcf6..3e2c8b68020a9f6096f7ba47cff456011134cf7a 100644 --- a/static_core/plugins/ets/tests/debugger/src/tests/test_predefined_types.py +++ b/static_core/plugins/ets/tests/debugger/src/tests/test_predefined_types.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2025 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 @@ -77,21 +77,13 @@ async def test_primitive_types( variables = [ ("boolean", "true", val_type("std.core.BooleanType"), b(True)), - ("Boolean", "true", ref_type("std.core.BooleanType"), cls("std.core.Boolean", value=b(True))), ("byte", 1, val_type("std.core.ByteType"), n(1)), - ("Byte", 1, ref_type("std.core.ByteType"), cls("std.core.Byte", value=n(1))), ("short", 1, val_type("std.core.ShortType"), n(1)), - ("Short", 1, ref_type("std.core.ShortType"), cls("std.core.Short", value=n(1))), ("int", 1, val_type("std.core.IntType"), n(1)), - ("Int", 1, ref_type("std.core.IntType"), cls("std.core.Int", value=n(1))), ("long", 1, val_type("std.core.LongType"), n(1)), - ("Long", 1, ref_type("std.core.LongType"), cls("std.core.Long", value=n(1))), ("float", 1, val_type("std.core.FloatType"), n(1)), - ("Float", 1, ref_type("std.core.FloatType"), cls("std.core.Float", value=n(1))), ("double", 1, val_type("std.core.DoubleType"), n(1)), - ("Double", 1, ref_type("std.core.DoubleType"), cls("std.core.Double", value=n(1))), ("number", 1, val_type("std.core.DoubleType"), n(1)), - ("Number", 1, ref_type("std.core.DoubleType"), cls("std.core.Double", value=n(1))), ] code = _code_generator(variables) async with run_and_stop_on_breakpoint(code) as paused: diff --git a/static_core/plugins/ets/tests/debugger/src/tests/test_remote_object.py b/static_core/plugins/ets/tests/debugger/src/tests/test_remote_object.py index ce0b1eb934d06aea810d83ccc1ac7a1bae3a348e..5eb9dc770f0b087c838887d06078251859a88b23 100644 --- a/static_core/plugins/ets/tests/debugger/src/tests/test_remote_object.py +++ b/static_core/plugins/ets/tests/debugger/src/tests/test_remote_object.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2025 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 @@ -23,15 +23,15 @@ from pytest import mark from arkdb.debug import StopOnPausedType from arkdb.logs import RichLogger -from arkdb.mirrors import mirror_object, mirror_primitive +from arkdb.mirrors import mirror_primitive @mark.parametrize( "line,meta", [ - ("Number = 1", mirror_object("std.core.Double", value=1)), + ("Number = 1", mirror_primitive("number", 1)), ("int = 1", 1), - ("float = 1.0", 1), + ("float = 1.0f", 1), ], ) async def test_const_var( @@ -66,7 +66,7 @@ async def test_let_vars( let n: Number = 1.3; let i0: int = 1; let i: int = 30 + i0; - let f: float = 1.2; + let f: float = 1.2f; let b: boolean = true; let s: String = "str"; foo(n, i, f, b, s); @@ -80,7 +80,7 @@ async def test_let_vars( "b": value("boolean", True), "f": value("number", 1.2), "i": value("number", 31), - "n": mirror_object("std.core.Double", value=1.3), + "n": value("number", 1.3), "s": value("string", "str"), } log.info("Variables: %s", rich.pretty.pretty_repr(scope_vars)) diff --git a/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_compare_exchange.ets b/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_compare_exchange.ets index 2435ac071785d24e24c6473274003e95b6eeeedb..6abe20f6380f5e075edf2ee02623df863d9f2763 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_compare_exchange.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_compare_exchange.ets @@ -30,7 +30,7 @@ function main() { arr_2 = new Int32Array(buf_2, 0, 1); for (let i = 0; i < 5; i++) { - launch Int>(worker_i8, i as byte) + launch Int>(worker_i8, i.toByte()) } while (Atomics.load(arr, 0) != 5) { } @@ -45,7 +45,7 @@ function main() { } function worker_i8(i: byte): Int { - while (Atomics.compareExchange(arr, 0, i as byte, (i + 1) as byte) != i) { + while (Atomics.compareExchange(arr, 0, i as byte, (i + 1).toByte()) != i) { } return 1 } diff --git a/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_countdownlatch.ets b/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_countdownlatch.ets index 5895c808e2413af8a3f64085049e8a91355345ee..b03ae8b2fc30376d38c3b30312b4f7811cb4fb39 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_countdownlatch.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_countdownlatch.ets @@ -38,11 +38,11 @@ function main() { for (let i = 0; i < N; i++) { launch Int>(task_1) } - let cur: byte = Atomics.load(bytearr_i8, 0) as byte + let cur: byte = Atomics.load(bytearr_i8, 0).toByte() while (cur != N) { L.log("waiting, finished tasks: " + cur) Atomics.wait(arr_1, 0, new BigInt(cur)) - cur = Atomics.load(bytearr_i8, 0) as byte + cur = Atomics.load(bytearr_i8, 0).toByte() } for (let i = 0; i < N; i++) { diff --git a/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_increment.ets b/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_increment.ets index 3026f50a053b3d209cdba25b1cb58c787e9a7457..2a005484ee0710f194be428697a7118d23a06d3e 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_increment.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_increment.ets @@ -16,7 +16,7 @@ import { launch } from "std/concurrency" let N = 200 -let RESULT = N as byte +let RESULT = N.toByte() let arr: Int8Array = new Int8Array; let arr_u32: Int32Array = new Int32Array; diff --git a/static_core/plugins/ets/tests/ets-common-tests/atomics/nonconcurrent_increment.ets b/static_core/plugins/ets/tests/ets-common-tests/atomics/nonconcurrent_increment.ets index f8a615c0ae5e9a6103f862aa9c8af301a241d172..9c05ecf6c541b00f5c7837f3a0e4c361b5b1afe6 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/atomics/nonconcurrent_increment.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/atomics/nonconcurrent_increment.ets @@ -14,7 +14,7 @@ */ let N = 200 -let RESULT = N as byte +let RESULT = N.toByte() function main() { let buf = new ArrayBuffer(4); diff --git a/static_core/plugins/ets/tests/ets-common-tests/import_name_conflicts/imported_module_2.ets b/static_core/plugins/ets/tests/ets-common-tests/import_name_conflicts/imported_module_2.ets index b0fe346b44bbdc80542ab4f2de51f33afba7568c..245626efd44be019ad0a1e7652aaa9639c86d9db 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/import_name_conflicts/imported_module_2.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/import_name_conflicts/imported_module_2.ets @@ -17,7 +17,7 @@ tags: [not-a-test] ---*/ -export const flt: float = 2.345; +export const flt: float = 2.345f; export let c: int = 3; diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/bigint64array_join.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/bigint64array_join.ets index 9e66613ee41903b21e54003d89a51c17d44b80b3..2790e9140e6e16c83a5dd832bfc75817a70339f7 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/bigint64array_join.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/bigint64array_join.ets @@ -14,7 +14,7 @@ */ const SINGLE = [1]; -const ARRAY = [Long.MIN_VALUE,0,1,2,3,4,5,6,7,8,9,Long.MAX_VALUE]; +const ARRAY: Array = [Long.MIN_VALUE,0,1,2,3,4,5,6,7,8,9,Long.MAX_VALUE]; const EMPTY_JOINED = "-922337203685477580801234567899223372036854775807"; const COMMA_JOINED = "-9223372036854775808,0,1,2,3,4,5,6,7,8,9,9223372036854775807"; const NSIGN_JOINED = "-9223372036854775808###0###1###2###3###4###5###6###7###8###9###9223372036854775807"; diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/bigint64array_sort.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/bigint64array_sort.ets index 268d5e2855d1fd09e92e06522a87094d29f1f98f..879dd96f18454611d26cc088192864b41eadf06f 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/bigint64array_sort.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/bigint64array_sort.ets @@ -14,7 +14,7 @@ */ const ARRAY_SIZE = 15; -const UNSORTED = [5,3,Long.MAX_VALUE,2,4,-1,99,10,7,0,45,1,88,Long.MIN_VALUE,37]; +const UNSORTED: Array = [5,3,Long.MAX_VALUE,2,4,-1,99,10,7,0,45,1,88,Long.MIN_VALUE,37]; const SORTED = [Long.MIN_VALUE,-1,0,1,2,3,4,5,7,10,37,45,88,99,Long.MAX_VALUE]; const SINGLE = [88]; diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/biguint64array_join.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/biguint64array_join.ets index 1a1fbb3b7891185372c791d451279f47ad9fc4c6..11635c9ffb92aded51d92afcfa66f0580396a682 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/biguint64array_join.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/biguint64array_join.ets @@ -14,7 +14,7 @@ */ const SINGLE = [1]; -const ARRAY = [0,1,2,3,4,5,6,7,8,9,0xffffffffffffffff]; +const ARRAY: Array = [0,1,2,3,4,5,6,7,8,9,0xffffffffffffffff]; const EMPTY_JOINED = "012345678918446744073709551615"; const COMMA_JOINED = "0,1,2,3,4,5,6,7,8,9,18446744073709551615"; const NSIGN_JOINED = "0###1###2###3###4###5###6###7###8###9###18446744073709551615"; diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/biguint64array_sort.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/biguint64array_sort.ets index 22dfb500c4702a2d736a366368cf4015239f3ce8..5b58b7f158aa771b7c5fe126014da0dcd7884607 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/biguint64array_sort.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/biguint64array_sort.ets @@ -14,7 +14,7 @@ */ const ARRAY_SIZE = 15; -const UNSORTED = [5,3,127,2,4,255,99,10,7,0,45,1,88,6,0xffffffffffffffff]; +const UNSORTED: Array = [5,3,127,2,4,255,99,10,7,0,45,1,88,6,0xffffffffffffffff]; const SORTED = [0,1,2,3,4,5,6,7,10,45,88,99,127,255,0xffffffffffffffff]; const SINGLE = [88]; diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/float32array_join.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/float32array_join.ets index 72e0a4872b4e71e7155aef89eb11bc133cb89058..2d94a1e319acfc58988f9223d15f5e23a80cc9d2 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/float32array_join.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/float32array_join.ets @@ -14,7 +14,7 @@ */ const SINGLE = [1]; -const ARRAY = [Float.MIN_VALUE,Float.NaN,-1,0,0.2,1,2,3,4,5,6,7,8,9,Float.POSITIVE_INFINITY,Float.NEGATIVE_INFINITY,Float.MAX_VALUE]; +const ARRAY: Array = [Float.MIN_VALUE,Float.NaN,-1,0,0.2,1,2,3,4,5,6,7,8,9,Float.POSITIVE_INFINITY,Float.NEGATIVE_INFINITY,Float.MAX_VALUE]; const EMPTY_JOINED = "1.401298464324817e-45NaN-100.20000000298023224123456789Infinity-Infinity3.4028234663852886e+38"; const COMMA_JOINED = "1.401298464324817e-45,NaN,-1,0,0.20000000298023224,1,2,3,4,5,6,7,8,9,Infinity,-Infinity,3.4028234663852886e+38"; const NSIGN_JOINED = "1.401298464324817e-45###NaN###-1###0###0.20000000298023224###1###2###3###4###5###6###7###8###9###Infinity###-Infinity###3.4028234663852886e+38"; diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/float32array_sort.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/float32array_sort.ets index acf20477d60e56627c3d6f852b3f449887e1b376..06548b1c9d14b13edb205ee10ce78855b2ba173f 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/float32array_sort.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/float32array_sort.ets @@ -15,11 +15,11 @@ const ARRAY_SIZE = 15; const AB_SIZE = ARRAY_SIZE * Float.BYTE_SIZE; -const UNSORTED = [Float.MAX_VALUE,0,100.5,3.375,1.125,-1.125,Float.POSITIVE_INFINITY,10.5,7.375,45.125,1.375,Float.NEGATIVE_INFINITY,Float.MIN_VALUE,36.625,123.375]; +const UNSORTED: Array = [Float.MAX_VALUE.toDouble(),0,100.5,3.375,1.125,-1.125,Float.POSITIVE_INFINITY.toDouble(),10.5,7.375,45.125,1.375,Float.NEGATIVE_INFINITY.toDouble(),Float.MIN_VALUE.toDouble(),36.625,123.375]; const SORTED = [Float.NEGATIVE_INFINITY,-1.125,0,Float.MIN_VALUE,1.125,1.375,3.375,7.375,10.5,36.625,45.125,100.5,123.375,Float.MAX_VALUE,Float.POSITIVE_INFINITY]; const SORTED_UNALIGNED = [Float.NEGATIVE_INFINITY,-1.125,0,Float.MIN_VALUE,1.125,1.375,3.375,7.375,10.5,36.625,45.125,100.5,123.375,Float.POSITIVE_INFINITY]; -const UNSORTED_WITH_NAN = [Float.MAX_VALUE,0.0,100.5,Float.NaN,1.125,-1.125,Float.POSITIVE_INFINITY,10.5,7.375,45.125,1.375,Float.NEGATIVE_INFINITY,Float.MIN_VALUE,36.625,123.375]; -const SORTED_WITH_NAN = [Float.NEGATIVE_INFINITY,-1.125,0.0,100.5,Float.MAX_VALUE,Float.NaN,Float.MIN_VALUE,1.125,1.375,7.375,10.5,36.625,45.125,123.375,Float.POSITIVE_INFINITY]; +const UNSORTED_WITH_NAN: double[] = [Float.MAX_VALUE.toDouble(),0.0,100.5,Float.NaN.toDouble(),1.125,-1.125,Float.POSITIVE_INFINITY.toDouble(),10.5,7.375,45.125,1.375,Float.NEGATIVE_INFINITY.toDouble(),Float.MIN_VALUE.toDouble(),36.625,123.375]; +const SORTED_WITH_NAN: double[] = [Float.NEGATIVE_INFINITY.toDouble(),-1.125,0.0,100.5,Float.MAX_VALUE.toDouble(),Float.NaN.toDouble(),Float.MIN_VALUE.toDouble(),1.125,1.375,7.375,10.5,36.625,45.125,123.375,Float.POSITIVE_INFINITY.toDouble()]; const SINGLE = [88.0]; function fillBuffer(buf: ArrayBuffer): void { @@ -27,17 +27,17 @@ function fillBuffer(buf: ArrayBuffer): void { assertEQ(Float.BYTE_SIZE, 4); for (let i = 0; i < AB_SIZE; ++i) { if ((i % Float.BYTE_SIZE) == 0) { - let v: int = Float.bitCastToInt(UNSORTED[i/Float.BYTE_SIZE] as float); + let v: int = Float.bitCastToInt(UNSORTED[i/Float.BYTE_SIZE].toFloat()); if (Runtime.isLittleEndianPlatform()) { - buf.set(i, v as byte); - buf.set(i + 1, (v >>> 8) as byte); - buf.set(i + 2, (v >>> 16) as byte); - buf.set(i + 3, (v >>> 24) as byte); + buf.set(i, v.toByte()); + buf.set(i + 1, (v >>> 8).toByte()); + buf.set(i + 2, (v >>> 16).toByte()); + buf.set(i + 3, (v >>> 24).toByte()); } else { - buf.set(i, (v >>> 24) as byte); - buf.set(i + 1, (v >>> 16) as byte); - buf.set(i + 2, (v >>> 8) as byte); - buf.set(i + 3, v as byte); + buf.set(i, (v >>> 24).toByte()); + buf.set(i + 1, (v >>> 16).toByte()); + buf.set(i + 2, (v >>> 8).toByte()); + buf.set(i + 3, v.toByte()); } } } @@ -51,12 +51,12 @@ function checkSorted(a: Float32Array): void { function checkSortedWithNaN(a: Float32Array): void { for (let i = 0; i < ARRAY_SIZE; ++i) { - if (a[i] != SORTED_WITH_NAN[i] as float) { - if (Float.isNaN(a[i] as float) && Float.isNaN(SORTED_WITH_NAN[i] as float)) { + if (a[i] != SORTED_WITH_NAN[i].toFloat()) { + if (Float.isNaN(a[i].toFloat()) && Float.isNaN(SORTED_WITH_NAN[i].toFloat())) { continue; } } - assertEQ(a[i], SORTED_WITH_NAN[i] as float); + assertEQ(a[i], SORTED_WITH_NAN[i].toFloat()); } } diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/float64array_join.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/float64array_join.ets index 33c42ceea733016a3590153d2914f871b7ab3fa0..4fed939b54c1388c8bba7a1e623db7d094720caf 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/float64array_join.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/float64array_join.ets @@ -14,7 +14,7 @@ */ const SINGLE = [1]; -const ARRAY = [Double.MIN_VALUE,Double.NaN,-1.1,0,0.2,1,2,3,4,5,6,7,8,9,Double.POSITIVE_INFINITY,Double.NEGATIVE_INFINITY,Double.MAX_VALUE]; +const ARRAY: Array = [Double.MIN_VALUE,Double.NaN,-1.1,0,0.2,1,2,3,4,5,6,7,8,9,Double.POSITIVE_INFINITY,Double.NEGATIVE_INFINITY,Double.MAX_VALUE]; const EMPTY_JOINED = "5e-324NaN-1.100.2123456789Infinity-Infinity1.7976931348623157e+308"; const COMMA_JOINED = "5e-324,NaN,-1.1,0,0.2,1,2,3,4,5,6,7,8,9,Infinity,-Infinity,1.7976931348623157e+308"; const NSIGN_JOINED = "5e-324###NaN###-1.1###0###0.2###1###2###3###4###5###6###7###8###9###Infinity###-Infinity###1.7976931348623157e+308"; diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/float64array_sort.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/float64array_sort.ets index 929c1eea5d9315abd04e8256606609d4e8d3415c..5c2b095d601d8b9b39fbacaacb6737ad1cd56472 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/float64array_sort.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/float64array_sort.ets @@ -14,7 +14,7 @@ */ const ARRAY_SIZE = 15; -const UNSORTED = [Double.MAX_VALUE,0,100.5,3.375,1.125,-1.125,Double.POSITIVE_INFINITY,10.5,7.375,45.125,1.375,Double.NEGATIVE_INFINITY,Double.MIN_VALUE,36.625,123.375]; +const UNSORTED: Array = [Double.MAX_VALUE,0,100.5,3.375,1.125,-1.125,Double.POSITIVE_INFINITY,10.5,7.375,45.125,1.375,Double.NEGATIVE_INFINITY,Double.MIN_VALUE,36.625,123.375]; const SORTED = [Double.NEGATIVE_INFINITY,-1.125,0,Double.MIN_VALUE,1.125,1.375,3.375,7.375,10.5,36.625,45.125,100.5,123.375,Double.MAX_VALUE,Double.POSITIVE_INFINITY]; const SORTED_UNALIGNED = [Double.NEGATIVE_INFINITY,-1.125,0,Double.MIN_VALUE,1.125,1.375,3.375,7.375,10.5,36.625,45.125,100.5,123.375,Double.POSITIVE_INFINITY]; const UNSORTED_WITH_NAN = [Double.MAX_VALUE,0.0,100.5,Double.NaN,1.125,-1.125,Double.POSITIVE_INFINITY,10.5,7.375,45.125,1.375,Double.NEGATIVE_INFINITY,Double.MIN_VALUE,36.625,123.375]; diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/int16array_join.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/int16array_join.ets index 0fba77c023156d778d56864abae4d848077d8888..e167727bb0a7dec4f1d595da1f2f055df31771e6 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/int16array_join.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/int16array_join.ets @@ -14,7 +14,7 @@ */ const SINGLE = [1]; -const ARRAY = [32767,-1,0,1,2,3,4,5,6,7,8,9,-32768]; +const ARRAY: Array = [32767,-1,0,1,2,3,4,5,6,7,8,9,-32768]; const EMPTY_JOINED = "32767-10123456789-32768"; const COMMA_JOINED = "32767,-1,0,1,2,3,4,5,6,7,8,9,-32768"; const NSIGN_JOINED = "32767###-1###0###1###2###3###4###5###6###7###8###9###-32768"; diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/int16array_sort.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/int16array_sort.ets index 7c09201ed03aa1225a7d02d3c8965df106a8c641..f9db3f85aff82eceeae408dc895356a49a4792ce 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/int16array_sort.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/int16array_sort.ets @@ -15,7 +15,7 @@ const ARRAY_SIZE = 15; const AB_SIZE = ARRAY_SIZE * Short.BYTE_SIZE; -const UNSORTED = [5,3,127,2,4,-1,99,10,32767,7,0,45,1,88,-32768]; +const UNSORTED: Array = [5,3,127,2,4,-1,99,10,32767,7,0,45,1,88,-32768]; const SORTED = [-32768,-1,0,1,2,3,4,5,7,10,45,88,99,127,32767]; const SORTED_UNALIGNED = [-32768,-1,0,1,2,3,4,7,10,45,88,99,127,32767]; const SINGLE = [88]; @@ -27,11 +27,11 @@ function fillBuffer(buf: ArrayBuffer): void { if ((i % Short.BYTE_SIZE) == 0) { let v: short = UNSORTED[i/2] as short; if (Runtime.isLittleEndianPlatform()) { - buf.set(i, v as byte); - buf.set(i + 1, (v >>> 8) as byte); + buf.set(i, v.toByte()); + buf.set(i + 1, (v >>> 8).toByte()); } else { - buf.set(i, (v >>> 8) as byte); - buf.set(i + 1, v as byte); + buf.set(i, (v >>> 8).toByte()); + buf.set(i + 1, v.toByte()); } } } diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/int32array_join.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/int32array_join.ets index 66fa58a3214883506f09cfe06ca7c000f5e5c417..479d8626d7dc69a158b56243d534254ece9b45fa 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/int32array_join.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/int32array_join.ets @@ -14,7 +14,7 @@ */ const SINGLE = [1]; -const ARRAY = [Int.MAX_VALUE,-1,0,1,2,3,4,5,6,7,8,9,Int.MIN_VALUE]; +const ARRAY: Array = [Int.MAX_VALUE,-1,0,1,2,3,4,5,6,7,8,9,Int.MIN_VALUE]; const EMPTY_JOINED = "2147483647-10123456789-2147483648"; const COMMA_JOINED = "2147483647,-1,0,1,2,3,4,5,6,7,8,9,-2147483648"; const NSIGN_JOINED = "2147483647###-1###0###1###2###3###4###5###6###7###8###9###-2147483648"; diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/int32array_sort.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/int32array_sort.ets index e4a3ab96fcff072f8fb19119d1bd40fff26ee65b..bf5794a926d10903a0d3849b8b35dab0e03df579 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/int32array_sort.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/int32array_sort.ets @@ -15,7 +15,7 @@ const ARRAY_SIZE = 15; const AB_SIZE = ARRAY_SIZE * Int.BYTE_SIZE; -const UNSORTED = [5,3,Int.MAX_VALUE,2,4,-1,99,10,7,0,45,1,88,Int.MIN_VALUE,37]; +const UNSORTED: Array = [5,3,Int.MAX_VALUE,2,4,-1,99,10,7,0,45,1,88,Int.MIN_VALUE,37]; const SORTED = [Int.MIN_VALUE,-1,0,1,2,3,4,5,7,10,37,45,88,99,Int.MAX_VALUE]; const SORTED_UNALIGNED = [Int.MIN_VALUE,-1,0,1,2,3,4,7,10,37,45,88,99,Int.MAX_VALUE]; const SINGLE = [88]; @@ -27,15 +27,15 @@ function fillBuffer(buf: ArrayBuffer): void { if ((i % Int.BYTE_SIZE) == 0) { let v: int = UNSORTED[i/Int.BYTE_SIZE] as int; if (Runtime.isLittleEndianPlatform()) { - buf.set(i, v as byte); - buf.set(i + 1, (v >>> 8) as byte); - buf.set(i + 2, (v >>> 16) as byte); - buf.set(i + 3, (v >>> 24) as byte); + buf.set(i, v.toByte()); + buf.set(i + 1, (v >>> 8).toByte()); + buf.set(i + 2, (v >>> 16).toByte()); + buf.set(i + 3, (v >>> 24).toByte()); } else { - buf.set(i, (v >>> 24) as byte); - buf.set(i + 1, (v >>> 16) as byte); - buf.set(i + 2, (v >>> 8) as byte); - buf.set(i + 3, v as byte); + buf.set(i, (v >>> 24).toByte()); + buf.set(i + 1, (v >>> 16).toByte()); + buf.set(i + 2, (v >>> 8).toByte()); + buf.set(i + 3, v.toByte()); } } } diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/int8array_join.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/int8array_join.ets index 981d932df7d406f45b1ae338cd3e7936d7bf9a8a..ac429262ac1a0f04ec248d374d3317429fa86017 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/int8array_join.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/int8array_join.ets @@ -14,7 +14,7 @@ */ const SINGLE = [1]; -const ARRAY = [-128,-1,0,1,2,3,4,5,6,7,8,9,127]; +const ARRAY: Array = [-128,-1,0,1,2,3,4,5,6,7,8,9,127]; const EMPTY_JOINED = "-128-10123456789127"; const COMMA_JOINED = "-128,-1,0,1,2,3,4,5,6,7,8,9,127"; const NSIGN_JOINED = "-128###-1###0###1###2###3###4###5###6###7###8###9###127"; diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/int8array_sort.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/int8array_sort.ets index 76450af1901985c0e6d7fae2b1902e5f10a2bab0..00cf6aba3aab6fa394ca23b0a640f83ac7a3bce0 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/int8array_sort.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/int8array_sort.ets @@ -14,7 +14,7 @@ */ const ARRAY_SIZE = 15; -const UNSORTED = [5,3,127,2,4,-1,99,10,7,0,45,1,88,-127,37]; +const UNSORTED: Array = [5,3,127,2,4,-1,99,10,7,0,45,1,88,-127,37]; const SORTED = [-127,-1,0,1,2,3,4,5,7,10,37,45,88,99,127]; const SORTED_UNALIGNED = [-127,-1,0,1,2,3,4,7,10,37,45,88,99,127]; const SINGLE = [88]; @@ -22,7 +22,7 @@ const SINGLE = [88]; function fillBuffer(buf: ArrayBuffer): void { assertEQ(Byte.BYTE_SIZE, Int8Array.BYTES_PER_ELEMENT); for (let i = 0; i < ARRAY_SIZE; ++i) { - buf.set(i, UNSORTED[i] as byte); + buf.set(i, UNSORTED[i].toByte()); } } diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/isInteger.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/isInteger.ets index af65aab8fd7b8b65f3660c674a6f3559221ac3ef..1581db6910a00fc677cd1493609086831ffe7281 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/isInteger.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/isInteger.ets @@ -25,7 +25,7 @@ class IsIntegerDoubleTest { function main(): int { let ft = new IsIntegerFloatTest(); - ft.rightInteger = 1.0; + ft.rightInteger = 1.0f; ft.wrongInteger = 1.0 as float + Float.DELTA + Float.DELTA; if (Float.isInteger(Float.NaN) != false) return 1; diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/isSafeInteger.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/isSafeInteger.ets index e4fadfa2c6e46f5e1790594da6ca5232a220d300..e5051d1ffe86ae2125a860a0161cb0aea199aa09 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/isSafeInteger.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/isSafeInteger.ets @@ -25,13 +25,13 @@ class IsIntegerDoubleTest { function main(): int { let ft = new IsIntegerFloatTest(); - ft.safeInteger = 1.0; + ft.safeInteger = 1.0f; ft.unsafeInteger = 1.0 as float + Float.MAX_SAFE_INTEGER; if (Float.isSafeInteger(Float.NaN) != false) return 1; if (Float.isSafeInteger(Float.POSITIVE_INFINITY) != false) return 2; if (Float.isSafeInteger(Float.NEGATIVE_INFINITY) != false) return 3; - if (Float.isSafeInteger(Float.MAX_SAFE_INTEGER as float) != true) return 4; + if (Float.isSafeInteger(Float.MAX_SAFE_INTEGER.toFloat()) != true) return 4; if (Float.isSafeInteger(ft.safeInteger) != true) return 5; if (Float.isSafeInteger(ft.unsafeInteger) != false) return 6; diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/string_from_char_code.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/string_from_char_code.ets index 2ff2f507d0143085ab1ae198f19c51b00f4731c9..fb59af187745bf6f5048984e2a0a3d3fbef8be6d 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/string_from_char_code.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/string_from_char_code.ets @@ -192,10 +192,10 @@ function StringFromCpsSeqTest() { let cpsActual = ""; for (let i = 12; i < 0x10FFFF; i += 30009) { if (Char.codeUnitsToEncode(i) == 1) { - cpsActual += String.fromCharCode(i as number); + cpsActual += String.fromCharCode(Int.toDouble(i)); } else { - cpsActual += String.fromCharCode(Char.getHighSurrogate(i) as number); - cpsActual += String.fromCharCode(Char.getLowSurrogate(i) as number); + cpsActual += String.fromCharCode(Char.toDouble(Char.getHighSurrogate(i))); + cpsActual += String.fromCharCode(Char.toDouble(Char.getLowSurrogate(i))); } } assertEQ(cpsActual, cpsGolden, "cpsActual must be equal to cpsGolden"); @@ -234,13 +234,13 @@ function StringFromCharVarTest() { let alpha: char = 0x3B1; let beta: char = 0x3B2; assertEQ(string.fromCharCode(alpha, beta), "αβ", "Must be 'αβ'"); - assertEQ(string.fromCharCode(alpha as number, beta as number), "αβ", "Must be 'αβ'"); + assertEQ(string.fromCharCode(Char.toDouble(alpha), Char.toDouble(beta)), "αβ", "Must be 'αβ'"); } function StringFromSingleCharVarTest() { let beta: char = 0x3B2; assertEQ(string.fromCharCode(beta), "β", "Must be 'β'"); - assertEQ(string.fromCharCode(beta as number), "β", "Must be 'β'"); + assertEQ(string.fromCharCode(Char.toDouble(beta)), "β", "Must be 'β'"); } function StringFromCompositeSymbolTest() { diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/string_indexof.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/string_indexof.ets index 8203036e35b9fb8a9601980d296edb82b73978a5..48726dd087b754314dcb1bb12dd7181977e6c1d1 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/string_indexof.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/string_indexof.ets @@ -67,7 +67,7 @@ function main(): int { } for (let i = 0; i < Digits.getLength(); ++i) { - if (Digits.indexOf(Digits.charAt(i)) as char != i) { + if (Digits.indexOf(Digits.charAt(i)).toChar() != i) { return 9; } } diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/string_trim.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/string_trim.ets index 1d3b6ccbb1d1c60dd50b35dd104728785a2b7664..b1c6a689c39a3b87bfdaebcc501fbe44c906f5df 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/string_trim.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/string_trim.ets @@ -75,7 +75,7 @@ function main(): int { let wssCount: int = 0; for (let i = 0; i <= 0xFFFF; ++i) { - let c = i as char; + let c = i.toChar(); if (Char.isWhiteSpace(c)) { ++wssCount; assertNE(Wss.indexOf(c), -1, 'Bad char code is encountered: ' + i); diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/stringbuilder.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/stringbuilder.ets index bd359b05a2ae309c7c1001563a00be2be2c25610..6e65339722246ccc8f0f02f94d18b7cb7382b3db 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/stringbuilder.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/stringbuilder.ets @@ -30,7 +30,7 @@ const l1: long = Long.MIN_VALUE const l2: long = 0 as long const l3: long = Long.MAX_VALUE const f1: float = Float.MIN_VALUE as float -const f2: float = 0.0 as float +const f2: float = 0.0.toFloat() const f3: float = Float.MAX_VALUE as float const n1: number = Number.MIN_VALUE const n2: number = 0.0 @@ -89,10 +89,10 @@ function main(): int { let cpsActual = ""; for (let i = 12; i < 0x10FFFF; i += 30009) { if (Char.codeUnitsToEncode(i) == 1) { - cpsActual += String.fromCharCode(i as number); + cpsActual += String.fromCharCode(i.toDouble()); } else { - cpsActual += String.fromCharCode(Char.getHighSurrogate(i) as number); - cpsActual += String.fromCharCode(Char.getLowSurrogate(i) as number); + cpsActual += String.fromCharCode(Char.getHighSurrogate(i).toDouble()); + cpsActual += String.fromCharCode(Char.getLowSurrogate(i).toDouble()); } } if (cpsActual != cpsGolden) { diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint16array_join.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint16array_join.ets index ae0ac6ec8411a3a5b230c9e309004f9bfa38916a..27848b3085115fac0b0d46fff9ba6d32473c0b54 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint16array_join.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint16array_join.ets @@ -14,7 +14,7 @@ */ const SINGLE = [1]; -const ARRAY = [0,1,2,3,4,5,6,7,8,9,65535 as int]; +const ARRAY: Array = [0,1,2,3,4,5,6,7,8,9,65535 as int]; const EMPTY_JOINED = "012345678965535"; const COMMA_JOINED = "0,1,2,3,4,5,6,7,8,9,65535"; const NSIGN_JOINED = "0###1###2###3###4###5###6###7###8###9###65535"; diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint16array_sort.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint16array_sort.ets index 4fceed5088d12cfc503d244199926f77a93cc448..8cdf1dbc49d5f2f5968af0ae242eba51856a06a4 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint16array_sort.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint16array_sort.ets @@ -15,7 +15,7 @@ const ARRAY_SIZE = 15; const AB_SIZE = ARRAY_SIZE * Short.BYTE_SIZE; -const UNSORTED = [5,3,127,2,4,255,99,10,7,65535 as int,45,1,88,6,0]; +const UNSORTED: Array = [5,3,127,2,4,255,99,10,7,65535 as int,45,1,88,6,0]; const SORTED = [0,1,2,3,4,5,6,7,10,45,88,99,127,255,65535 as int]; const SORTED_UNALIGNED = [0,1,2,3,4,6,7,10,45,88,99,127,255,65535 as int]; const SINGLE = [88]; @@ -25,13 +25,13 @@ function fillBuffer(buf: ArrayBuffer): void { assertEQ(Short.BYTE_SIZE, 2); for (let i = 0; i < AB_SIZE; ++i) { if ((i % Short.BYTE_SIZE) == 0) { - let v: int = UNSORTED[i/2] as int; + let v: int = UNSORTED[i/2].toInt(); if (Runtime.isLittleEndianPlatform()) { - buf.set(i, v as byte); - buf.set(i + 1, (v >>> 8) as byte); + buf.set(i, v.toByte()); + buf.set(i + 1, (v >>> 8).toByte()); } else { - buf.set(i, (v >>> 8) as byte); - buf.set(i + 1, v as byte); + buf.set(i, (v >>> 8).toByte()); + buf.set(i + 1, v.toByte()); } } } diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint32array_join.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint32array_join.ets index c30c881cf0cd95a3cfe340fad2ef995581a0e91e..5c7b389146f420b811fc0e2e7f53b1b1f451226b 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint32array_join.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint32array_join.ets @@ -14,7 +14,7 @@ */ const SINGLE = [1]; -const ARRAY = [0,1,2,3,4,5,6,7,8,9,4294967295 as long]; +const ARRAY: Array = [0,1,2,3,4,5,6,7,8,9,4294967295 as long]; const EMPTY_JOINED = "01234567894294967295"; const COMMA_JOINED = "0,1,2,3,4,5,6,7,8,9,4294967295"; const NSIGN_JOINED = "0###1###2###3###4###5###6###7###8###9###4294967295"; diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint32array_sort.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint32array_sort.ets index 3564e47396531dab9859893999abd64a8e9d6881..8b52285b335387277e2f362dd8e00d9e2d29f6f6 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint32array_sort.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint32array_sort.ets @@ -15,7 +15,7 @@ const ARRAY_SIZE = 15; const AB_SIZE = ARRAY_SIZE * Int.BYTE_SIZE; -const UNSORTED = [5,3,127,2,4,255,99,10,7,0,45,1,88,6,4294967295 as long]; +const UNSORTED: Array = [5,3,127,2,4,255,99,10,7,0,45,1,88,6,4294967295 as long]; const SORTED = [0,1,2,3,4,5,6,7,10,45,88,99,127,255,4294967295 as long]; const SORTED_UNALIGNED = [0,1,2,3,4,6,7,10,45,88,99,127,255,4294967295 as long]; const SINGLE = [88]; @@ -27,15 +27,15 @@ function fillBuffer(buf: ArrayBuffer): void { if ((i % Int.BYTE_SIZE) == 0) { let v: long = UNSORTED[i/Int.BYTE_SIZE] as long; if (Runtime.isLittleEndianPlatform()) { - buf.set(i, v as byte); - buf.set(i + 1, (v >>> 8) as byte); - buf.set(i + 2, (v >>> 16) as byte); - buf.set(i + 3, (v >>> 24) as byte); + buf.set(i, v.toByte()); + buf.set(i + 1, (v >>> 8).toByte()); + buf.set(i + 2, (v >>> 16).toByte()); + buf.set(i + 3, (v >>> 24).toByte()); } else { - buf.set(i, (v >>> 24) as byte); - buf.set(i + 1, (v >>> 16) as byte); - buf.set(i + 2, (v >>> 8) as byte); - buf.set(i + 3, v as byte); + buf.set(i, (v >>> 24).toByte()); + buf.set(i + 1, (v >>> 16).toByte()); + buf.set(i + 2, (v >>> 8).toByte()); + buf.set(i + 3, v.toByte()); } } } diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint8array_join.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint8array_join.ets index 761871de29868e4ed448c3f3ef5488e3a180b149..aa53b5fe221d2a69dd6467a04878f6da524411d8 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint8array_join.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint8array_join.ets @@ -14,7 +14,7 @@ */ const SINGLE = [1]; -const ARRAY = [0,1,2,3,4,5,6,7,8,9,255]; +const ARRAY: Array = [0,1,2,3,4,5,6,7,8,9,255]; const EMPTY_JOINED = "0123456789255"; const COMMA_JOINED = "0,1,2,3,4,5,6,7,8,9,255"; const NSIGN_JOINED = "0###1###2###3###4###5###6###7###8###9###255"; diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint8array_sort.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint8array_sort.ets index d85623bcff68d8d226a4ca689618cdc11fae7d2c..70fbbf3a60669239dd74d16d9b77378f419ce611 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint8array_sort.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint8array_sort.ets @@ -14,7 +14,7 @@ */ const ARRAY_SIZE = 15; -const UNSORTED = [5,3,127,2,4,255 as short,99,10,7,0,45,1,88,6,37]; +const UNSORTED: Array = [5,3,127,2,4,255 as short,99,10,7,0,45,1,88,6,37]; const SORTED = [0,1,2,3,4,5,6,7,10,37,45,88,99,127,255 as short]; const SORTED_UNALIGNED = [0,1,2,3,4,6,7,10,37,45,88,99,127,255 as short]; const SINGLE = [88]; @@ -22,7 +22,7 @@ const SINGLE = [88]; function fillBuffer(buf: ArrayBuffer): void { assertEQ(Byte.BYTE_SIZE, Uint8Array.BYTES_PER_ELEMENT); for (let i = 0; i < ARRAY_SIZE; ++i) { - buf.set(i, UNSORTED[i] as byte); + buf.set(i, UNSORTED[i].toByte()); } } diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint8clampedarray_join.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint8clampedarray_join.ets index 44faf5f4965a6d3b054a36fcfcfb9bf24290687c..665430b9fbc795e1456b5fd5e73b178bbf50a9e5 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint8clampedarray_join.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint8clampedarray_join.ets @@ -14,7 +14,7 @@ */ const SINGLE = [1]; -const ARRAY = [0,1,2,3,4,5,6,7,8,9,255]; +const ARRAY: Array = [0,1,2,3,4,5,6,7,8,9,255]; const EMPTY_JOINED = "0123456789255"; const COMMA_JOINED = "0,1,2,3,4,5,6,7,8,9,255"; const NSIGN_JOINED = "0###1###2###3###4###5###6###7###8###9###255"; diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint8clampedarray_sort.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint8clampedarray_sort.ets index d8eca3ee90fd330fdfb7fa4fdc536fb2cea7ffe0..4d3f79d23cf90eed5572a9a5153ff9125b971f17 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint8clampedarray_sort.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/uint8clampedarray_sort.ets @@ -14,7 +14,7 @@ */ const ARRAY_SIZE = 15; -const UNSORTED = [5,3,127,2,4,255 as short,99,10,7,0,45,1,88,6,37]; +const UNSORTED: Array = [5,3,127,2,4,255 as short,99,10,7,0,45,1,88,6,37]; const SORTED = [0,1,2,3,4,5,6,7,10,37,45,88,99,127,255 as short]; const SORTED_UNALIGNED = [0,1,2,3,4,6,7,10,37,45,88,99,127,255 as short]; const SINGLE = [88]; @@ -22,7 +22,7 @@ const SINGLE = [88]; function fillBuffer(buf: ArrayBuffer): void { assertEQ(Byte.BYTE_SIZE, Uint8ClampedArray.BYTES_PER_ELEMENT); for (let i = 0; i < ARRAY_SIZE; ++i) { - buf.set(i, UNSORTED[i] as byte); + buf.set(i, UNSORTED[i].toByte()); } } diff --git a/static_core/plugins/ets/tests/ets-common-tests/package_static_block_test/package_with_static_block/package01.ets b/static_core/plugins/ets/tests/ets-common-tests/package_static_block_test/package_with_static_block/package01.ets index 02385e2e27a5ae2fb93343c027dded8b15f5dbfc..95a4b6a8ddaa13751f96e0cea61a837f53b7729b 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/package_static_block_test/package_with_static_block/package01.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/package_static_block_test/package_with_static_block/package01.ets @@ -34,7 +34,7 @@ function foo2(): boolean { } function foo3(): char { - return 'c'; + return c'c'; } function foo4(): string { diff --git a/static_core/plugins/ets/tests/ets-common-tests/stubs/istrue.ets b/static_core/plugins/ets/tests/ets-common-tests/stubs/istrue.ets index 421a60063a9596dbcf69cd391c283db4890d0458..e7a60981aef84c58c2adeec1353edae403eb60cd 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/stubs/istrue.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/stubs/istrue.ets @@ -67,7 +67,7 @@ function testNormal() { assertTrue(!istrue(new Double(0.0))); assertTrue(istrue(new Double(0.5))); assertTrue(!istrue(new Char(0 as char))); - assertTrue(istrue(new Char('0'))); + assertTrue(istrue(new Char(c'0'))); assertTrue(!istrue("")); assertTrue(istrue("Hello")); assertTrue(!istrue(false)); @@ -107,7 +107,7 @@ function testErase() { assertTrue(!istrue(erase(new Double(0.0)))); assertTrue(istrue(erase(new Double(0.5)))); assertTrue(!istrue(erase(new Char(0 as char)))); - assertTrue(istrue(erase(new Char('0')))); + assertTrue(istrue(erase(new Char(c'0')))); assertTrue(!istrue(erase(""))); assertTrue(istrue(erase("Hello"))); assertTrue(!istrue(erase(false))); diff --git a/static_core/plugins/ets/tests/ets-common-tests/stubs/typeof.ets b/static_core/plugins/ets/tests/ets-common-tests/stubs/typeof.ets index b0e4c646ab699f10a6c154a57941c79bceac62c0..0adf5acd35c74e563a1b057d8c011077cfe321c4 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/stubs/typeof.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/stubs/typeof.ets @@ -32,7 +32,7 @@ function testNumerics() { assertEQ(typeof (() => { let v: long = 123456789123; return v })(), "number"); assertEQ(typeof (() => { let v: float = 1.1f; return v })(), "number"); assertEQ(typeof (() => { let v: double = 1.1; return v })(), "number"); - assertEQ(typeof (() => { let v: char = 'a'; return v })(), "number"); + assertEQ(typeof (() => { let v: char = c'a'; return v })(), "number"); } function testNumerics2() { @@ -42,7 +42,7 @@ function testNumerics2() { let a4: long = 123456789123; let a5: float = 1.1f; let a6: double = 1.1; - let a7: char = 'a'; + let a7: char = c'a'; assertEQ(typeof erase(a1), "number"); assertEQ(typeof erase(a2), "number"); assertEQ(typeof erase(a3), "number"); @@ -169,7 +169,7 @@ class B extends Numeric { public toInt(): int { return 1 }; public toShort(): short { return 1 }; public toLong(): long { return 1 }; - public toFloat(): float { return 1.1 }; + public toFloat(): float { return 1.1f }; public toDouble(): double { return 1.1 }; } diff --git a/static_core/plugins/ets/tests/ets-common-tests/taskpool/common_tasks.ets b/static_core/plugins/ets/tests/ets-common-tests/taskpool/common_tasks.ets index a905bc1143587ecf743202cd786ca7b9dfdb0c9c..9717e53ee938c51f85f13a6dab4bb502a8990b2c 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/taskpool/common_tasks.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/taskpool/common_tasks.ets @@ -444,10 +444,10 @@ function main(): int { let task2 = new taskpool.Task(testCancelFunc, 300); let val: int = 0; let isExecuted = new Event(); - taskpool.execute(task2).then((value: boolean): void => { + taskpool.execute(task2).then((value: NullishType): void => { val = 1; isExecuted.fire(); - }).catch((e: object): void => { + }).catch((e: NullishType): void => { val = 2; isExecuted.fire(); }); @@ -797,7 +797,7 @@ function main(): int { } let allExecuted = new Event(); for (let i: int = 0; i < count; ++i) { - taskpool.execute(taskArray[i]).then((value: object): void => { + taskpool.execute(taskArray[i]).then((value: NullishType): void => { num++; if (num == count) { allExecuted.fire(); diff --git a/static_core/plugins/ets/tests/ets-func-tests-templates/spec/15.Semantic_Rules/Compatibility_Features/Extended_Conditional_Expressions/config-ext-cond-expr-false.yaml b/static_core/plugins/ets/tests/ets-func-tests-templates/spec/15.Semantic_Rules/Compatibility_Features/Extended_Conditional_Expressions/config-ext-cond-expr-false.yaml index 467d6e0b5ae0a9a359e067c6a8ab8cf8e1b5d6c6..e08b233954256675d1700d8ad21792738b0b04c7 100644 --- a/static_core/plugins/ets/tests/ets-func-tests-templates/spec/15.Semantic_Rules/Compatibility_Features/Extended_Conditional_Expressions/config-ext-cond-expr-false.yaml +++ b/static_core/plugins/ets/tests/ets-func-tests-templates/spec/15.Semantic_Rules/Compatibility_Features/Extended_Conditional_Expressions/config-ext-cond-expr-false.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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 @@ -22,7 +22,7 @@ expression_list: - 'string:"Hello World":short:0' - 'string:"Hello World":int:0' - 'string:"Hello World":long:0' - - 'string:"Hello World":float:0.0' + - 'string:"Hello World":float:0.0f' - 'string:"Hello World":double:0.0' - 'string:"Hello World":Boolean:false' - 'string:"Hello World":Byte:0' @@ -30,7 +30,7 @@ expression_list: - 'string:"Hello World":Short:0' - 'string:"Hello World":Int:0' - 'string:"Hello World":Long:0' - - 'string:"Hello World":Float:0.0' + - 'string:"Hello World":Float:0.0f' - 'string:"Hello World":Double:0' - 'string:"Hello World":Colors:Colors.Red' - 'string:"":string:"Hello World"' @@ -45,7 +45,7 @@ expression_list: - 'short:0:string:"Hello World"' - 'int:0:string:"Hello World"' - 'long:0:string:"Hello World"' - - 'float:0.0:string:"Hello World"' + - 'float:0.0f:string:"Hello World"' - 'double:0.0:string:"Hello World"' - 'Boolean:false:string:"Hello World"' - 'Byte:0:string:"Hello World"' @@ -53,7 +53,7 @@ expression_list: - 'Short:0:string:"Hello World"' - 'Int:0:string:"Hello World"' - 'Long:0:string:"Hello World"' - - 'Float:0.0:string:"Hello World"' + - 'Float:0.0f:string:"Hello World"' - 'Double:0:string:"Hello World"' - 'Colors:Colors.Red:string:"Hello World"' - 'Object | null | undefined:null:string:"Hello World"' diff --git a/static_core/plugins/ets/tests/ets-func-tests-templates/spec/15.Semantic_Rules/Compatibility_Features/Extended_Conditional_Expressions/config-ext-cond-expr.yaml b/static_core/plugins/ets/tests/ets-func-tests-templates/spec/15.Semantic_Rules/Compatibility_Features/Extended_Conditional_Expressions/config-ext-cond-expr.yaml index 3bb24430d21d6c63bdadaf9e56c514f3979214fc..3d22926325b011ed899be9cbe27a9075f3764a64 100644 --- a/static_core/plugins/ets/tests/ets-func-tests-templates/spec/15.Semantic_Rules/Compatibility_Features/Extended_Conditional_Expressions/config-ext-cond-expr.yaml +++ b/static_core/plugins/ets/tests/ets-func-tests-templates/spec/15.Semantic_Rules/Compatibility_Features/Extended_Conditional_Expressions/config-ext-cond-expr.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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 @@ -22,7 +22,7 @@ expression_list: - 'string:"Hello World":short:1024' - 'string:"Hello World":int:28' - 'string:"Hello World":long:28' - - 'string:"Hello World":float:1.0' + - 'string:"Hello World":float:1.0f' - 'string:"Hello World":double:28' - 'string:"Hello World":Boolean:true' - 'string:"Hello World":Byte:16' @@ -30,7 +30,7 @@ expression_list: - 'string:"Hello World":Short:1024' - 'string:"Hello World":Int:28' - 'string:"Hello World":Long:28' - - 'string:"Hello World":Float:1.0' + - 'string:"Hello World":Float:1.0f' - 'string:"Hello World":Double:28' - 'string:"Hello World":Colors:Colors.Yellow' - 'string:"Hello World":Object:new Object()' @@ -38,4 +38,4 @@ expression_list: - 'string:"Hello World":Object | null:new Object()' - 'string:"Hello World":Object | undefined:new Object()' sep: "---" -enum_type_def: "enum Colors {Red, Yellow, Green}" \ No newline at end of file +enum_type_def: "enum Colors {Red, Yellow, Green}" diff --git a/static_core/plugins/ets/tests/ets-templates/02.lexical_elements/09.literals/06.string_literals/codepoints.ets b/static_core/plugins/ets/tests/ets-templates/02.lexical_elements/09.literals/06.string_literals/codepoints.ets index 3cecabb079ba7fdd94e0432382db4329fb00f8ec..cc6197990204a2d918bffe4b3918bb32b289257c 100644 --- a/static_core/plugins/ets/tests/ets-templates/02.lexical_elements/09.literals/06.string_literals/codepoints.ets +++ b/static_core/plugins/ets/tests/ets-templates/02.lexical_elements/09.literals/06.string_literals/codepoints.ets @@ -23,10 +23,10 @@ function main() { let res = "" for (let i = 12; i < 0x10FFFF; i += 30009) { if (Char.codeUnitsToEncode(i) == 1) { - res += String.fromCharCode(i as number) + res += String.fromCharCode(Int.toDouble(i)) } else { - res += String.fromCharCode(Char.getHighSurrogate(i) as number) - res += String.fromCharCode(Char.getLowSurrogate(i) as number) + res += String.fromCharCode(Char.toDouble(Char.getHighSurrogate(i))) + res += String.fromCharCode(Char.toDouble(Char.getLowSurrogate(i))) } } assertEQ(s, res) diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/01.primitive_types/pt_constructor.ets b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/01.primitive_types/pt_constructor.ets index a00be07655d96476de7843c87c7cd19edfbe2654..5d1f72d20804219f396927ff2e0565f23c24787a 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/01.primitive_types/pt_constructor.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/01.primitive_types/pt_constructor.ets @@ -19,11 +19,11 @@ desc: >- The predefined value types are called primitive types. Primitive types have no methods. They only have the operations as referred herein (see Value Types). -tags: [negative, compile-only] +tags: [compile-only, negative] ---*/ function main() { - new {{p}}(); + new {{p.type}}(); } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/01.primitive_types/pt_constructor.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/01.primitive_types/pt_constructor.params.yaml index cc10e2160a3f0376890fc4d61eaf61443689bb68..f4dc8b40cc4a139d6c04facf673d2e217a95fb04 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/01.primitive_types/pt_constructor.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/01.primitive_types/pt_constructor.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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 @@ -13,15 +13,12 @@ --- primitives: - - 'boolean' - - 'byte' - - 'char' - - 'double' - - 'float' - - 'int' - - 'long' - - 'number' - - 'short' - - 'undefined' - - 'null' - - 'void' + - { stype: 'boolean' } + - { stype: 'byte' } + - { stype: 'char' } + - { stype: 'double' } + - { stype: 'float' } + - { stype: 'int' } + - { stype: 'long' } + - { stype: 'number' } + - { stype: 'short' } diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/01.primitive_types/pt_metod.ets b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/01.primitive_types/pt_metod.ets index b88f618bc551f863ae540fd8519627324fe69e3d..fba9c07ad2466ef1a2295a15638b9320fd2ba789 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/01.primitive_types/pt_metod.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/01.primitive_types/pt_metod.ets @@ -16,14 +16,12 @@ {% for p in primitives %} /*--- desc: >- - The predefined value types are called primitive types. - Primitive types have no methods. - They only have the operations as referred herein (see Value Types). -tags: [negative, compile-only] + Types number, byte, short, int, long, float, double, char, and boolean are primitive types. +tags: [{{p.tags}}] ---*/ function main() { - let i: {{p}}; + let i: {{p.type}}; i.toString(); } diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/01.primitive_types/pt_metod.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/01.primitive_types/pt_metod.params.yaml index cc10e2160a3f0376890fc4d61eaf61443689bb68..92f001b726119374b2b729723fe3eb6578b94eed 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/01.primitive_types/pt_metod.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/01.primitive_types/pt_metod.params.yaml @@ -13,15 +13,15 @@ --- primitives: - - 'boolean' - - 'byte' - - 'char' - - 'double' - - 'float' - - 'int' - - 'long' - - 'number' - - 'short' - - 'undefined' - - 'null' - - 'void' + - { type: 'boolean' } + - { type: 'byte' } + - { type: 'char' } + - { type: 'double' } + - { type: 'float' } + - { type: 'int' } + - { type: 'long' } + - { type: 'number' } + - { type: 'short' } + - { type: 'undefined', tags: 'compile-only, negative' } + - { type: 'null', tags: 'compile-only, negative' } + - { type: 'void', tags: 'compile-only, negative' } diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_00.ets b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_00.ets index 0835376727bd08a8daaa244c4dd968a9e486428f..0587c6d7b689037af7a0b802b0dea0f74c0d40e0 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_00.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_00.ets @@ -18,8 +18,8 @@ desc: Test floating-point comparison(<). ---*/ function main(): void { - let a: int = 10; - let b: int = 3; + let a: float = 10f; + let b: float = 3f; assertFalse(a < b); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_01.ets b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_01.ets index 1172b86e31bad5e1c040523c0254d9ef8d123457..f18fca4b9ff788a223999f3471ebbdb0fc2c1ddc 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_01.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_01.ets @@ -18,8 +18,8 @@ desc: Test floating-point comparison(>). ---*/ function main(): void { - let a: float = 10.5; - let b: float = 20.5; + let a: float = 10.5f; + let b: float = 20.5f; assertFalse(a > b); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_02.ets b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_02.ets index 10ccff8a36fe78fa0a40b234726919ecf2ad1daf..2029dfe5e0b1165d838324a9dbb5cc845d0a50e9 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_02.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_02.ets @@ -18,8 +18,8 @@ desc: Test floating-point comparison(<=). ---*/ function main(): void { - let a: float = 10.5; - let b: float = 20.5; + let a: float = 10.5f; + let b: float = 20.5f; assertTrue(a <= b); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_03.ets b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_03.ets index 5d3c0b0df29940e4ad8e417ad52170f68b7ed203..ed5170206cab09039f3c5bb2348e58b8ff9e6453 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_03.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_03.ets @@ -18,8 +18,8 @@ desc: Test floating-point comparison(>=). ---*/ function main(): void { - let a: float = 10.5; - let b: float = 20.5; + let a: float = 10.5f; + let b: float = 20.5f; assertFalse(a >= b); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_04.ets b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_04.ets index 3111795b02e206a3535575bcb839286c78a30993..dc0b07a9833a5a072f8a7070a07d2496b4811585 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_04.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_04.ets @@ -18,8 +18,8 @@ desc: Test floating-point comparison(=). ---*/ function main(): void { - let a: float = 10.5; - let b: float = 20.5; + let a: float = 10.5f; + let b: float = 20.5f; assertFalse(a === b); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_05.ets b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_05.ets index 8c114420294263f528f68d4950480fe1dd5bc347..39239ee8030ad2ce66fdb0655e136c4dfc27d615 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_05.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_05.ets @@ -18,8 +18,8 @@ desc: Test floating-point comparison(!=). ---*/ function main(): void { - let a: float = 10.5; - let b: float = 20.5; + let a: float = 10.5f; + let b: float = 20.5f; assertTrue(a !== b); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_06.ets b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_06.ets index 97910efb11fb9066d4fa5ef59781429d4bea43d6..67098fd8daf262000680b06e6bfa58dca4bded38 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_06.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_06.ets @@ -18,8 +18,8 @@ desc: Verify the negative value of floating-point numbers. ---*/ function main(): void { - let a: float = 10.5; + let a: float = 10.5f; let b = -a; - assertTrue(b === -10.5); + assertTrue(b === -10.5f); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_07.ets b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_07.ets index 3b11ebb5b68d75f801975f291dacee2efa2f75bb..df87eaf3987221b20731eb309ca5b79e3cccc529 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_07.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_07.ets @@ -18,8 +18,8 @@ desc: Verify the positive value of floating-point numbers. ---*/ function main(): void { - let a: float = 10.5; + let a: float = 10.5f; let b = +a; - assertTrue(b === 10.5); + assertTrue(b === 10.5f); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_08.ets b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_08.ets index 545eecfb39cc7a215f0b7efe196f2986835201dd..0aa0ee3e92e092e616a689226b7523a03f9abca3 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_08.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_08.ets @@ -18,9 +18,9 @@ desc: Test floating-point number operators(*). ---*/ function main(): void { - let a: float = 10.5; - let b: float = 3.5; + let a: float = 10.5f; + let b: float = 3.5f; let c = a * b; - assertTrue(c === 36.75); + assertTrue(c === 36.75f); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_09.ets b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_09.ets index 6745ae1927053844a3766257ebe7c35958bf44bd..fd862ba1cf1770cae4c76e41f4c78c0b4178f493 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_09.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_09.ets @@ -18,9 +18,9 @@ desc: Test floating-point number operators(/). ---*/ function main(): void { - let a: float = 10.5; - let b: float = 3.5; + let a: float = 10.5f; + let b: float = 3.5f; let c = a / b; - assertTrue(c === 3.0); + assertTrue(c === 3.0f); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_10.ets b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_10.ets index f04f29535da079fdc2b834673434454a5b609a8c..86f3237ade17458487b7455b4f6fed3762e3d6b1 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_10.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_10.ets @@ -18,8 +18,8 @@ desc: Test floating-point number operators(%). ---*/ function main(): void { - let a: float = 10.5; - let b: float = 3.5; + let a: float = 10.5f; + let b: float = 3.5f; let c = a % b; assertTrue(c === 0); diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_11.ets b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_11.ets index 406c6b68216034b3b0c16911adc9f673dcc13cd9..d94f9abe86a9db709d2df8459a24fea6383fc240 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_11.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_11.ets @@ -18,8 +18,8 @@ desc: Test floating-point number operators(% !=0). ---*/ function main(): void { - let a: float = 12.5; - let b: float = 3.5; + let a: float = 12.5f; + let b: float = 3.5f; let c = a % b; assertTrue(c === 2.0); diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_12.ets b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_12.ets index 217c6487b7d6e64671160b3eda8d7bfc328a008b..673c9f627b9810f30cf86cd71a808123ee03e646 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_12.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_12.ets @@ -18,9 +18,9 @@ desc: Test floating-point number operators(+). ---*/ function main(): void { - let a: float = 10.5; - let b: float = 3.5; + let a: float = 10.5f; + let b: float = 3.5f; let c = a + b; - assertTrue(c === 14.0); + assertTrue(c === 14.0f); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_13.ets b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_13.ets index 95cad87a69c4edca76d03be0595bdffb33fd0c29..c5a077f2ad35196cd774ae5eea511f4e579f4957 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_13.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_13.ets @@ -18,9 +18,9 @@ desc: Test floating-point number operators(-). ---*/ function main(): void { - let a: float = 10.5; - let b: float = 3.5; + let a: float = 10.5f; + let b: float = 3.5f; let c = a - b; - assertTrue(c === 7.0); + assertTrue(c === 7.0f); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_14.ets b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_14.ets index 206c84ebdfc7d77a28cdfbe39a52c989dc1da220..7b9a52e98f441e6671e301cc08b0cc6113b13923 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_14.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_14.ets @@ -18,8 +18,8 @@ desc: Test floating point self addition(++a). ---*/ function main(): void { - let a: float = 10.5; + let a: float = 10.5f; let b = ++a; - assertTrue(b === 11.5); + assertTrue(b === 11.5f); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_15.ets b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_15.ets index adb77f0049da6274a8c1e01af6aa62216577a8e1..77f9ea0dc81f1e019488aa01c3c8207598d41c15 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_15.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_15.ets @@ -18,8 +18,8 @@ desc: Test floating point self addition(a++). ---*/ function main(): void { - let a: float = 10.5; + let a: float = 10.5f; let b = a++; - assertTrue(a === 11.5); + assertTrue(a === 11.5f); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_16.ets b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_16.ets index f79d743012f4a78509c1046e2c9cb999a6ff58d0..14a532d8de1f5aa6f7fac3d4a32e76de9883de67 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_16.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_16.ets @@ -18,8 +18,8 @@ desc: Test floating point self reduction(--a). ---*/ function main(): void { - let a: float = 10.5; + let a: float = 10.5f; let b = --a; - assertTrue(b === 9.5); + assertTrue(b === 9.5f); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_17.ets b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_17.ets index 0751e60289ade6361b93552175e49e9675465619..3a1792bb384cf2777b72f758e87aed2e011441a7 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_17.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_17.ets @@ -18,8 +18,8 @@ desc: Test floating point self reduction(a--). ---*/ function main(): void { - let a: float = 10.5; + let a: float = 10.5f; let b = a--; - assertTrue(b === 10.5); + assertTrue(b === 10.5f); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_18.ets b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_18.ets index 6d1d8c45633a2a8b4de981afacf3f4579a75745e..539a43c5fdf7f8f1e83a7568f5c700cda7dcd808 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_18.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_18.ets @@ -18,8 +18,8 @@ desc: Test floating-point logical operators(true). ---*/ function main(): void { - let a: float = 10.5; - let b = a > 5 ? true : false; + let a: float = 10.5f; + let b = a > 5f ? true : false; assertTrue(b === true); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_19.ets b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_19.ets index db60ccc5e2fd4829a2122082732d577c2b77526d..53440efcf93077e00bff0ec6df257b38985a3d87 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_19.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/02.numeric_types/nt_float_19.ets @@ -18,8 +18,8 @@ desc: Test floating-point logical operators(false). ---*/ function main(): void { - let a: float = 10.5; - let b = a < 5 ? true : false; + let a: float = 10.5f; + let b = a < 5f ? true : false; assertTrue(b === false); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/arrays_declaration.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/arrays_declaration.params.yaml index f66b18ba9c63d6d763b9883c2e8bfd3502fc02f3..4b24204df51db59e6ed7ad6d7e451bca91a69db3 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/arrays_declaration.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/01.predefined_types/arrays_declaration.params.yaml @@ -24,7 +24,7 @@ default_value: - type: FixedArray value: "[0n, 1n]" - type: FixedArray - value: "[0.0, 1.0]" + value: "[0.0f, 1.0f]" - type: FixedArray value: "[0.0, 1.0]" - type: FixedArray diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/03.using_types/01.readonly_array_and_tuple_type/array_readonly.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/03.using_types/01.readonly_array_and_tuple_type/array_readonly.params.yaml index 3821085872aa8bf2a9146396dc537ea1c0d06eb2..943a88e831a570cbac022163320d1b82fd8828be 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/03.using_types/01.readonly_array_and_tuple_type/array_readonly.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/03.using_types/01.readonly_array_and_tuple_type/array_readonly.params.yaml @@ -22,7 +22,7 @@ cases: - type: long use: 1 - type: float - use: 1.0 + use: 1.0f - type: double use: 1.0 - type: char @@ -38,7 +38,7 @@ cases: - type: Long use: 1 - type: Float - use: 1.0 + use: 1.0f - type: Double use: 1.0 - type: Char diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/03.using_types/01.readonly_array_and_tuple_type/tuple_readonly.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/03.using_types/01.readonly_array_and_tuple_type/tuple_readonly.params.yaml index 3821085872aa8bf2a9146396dc537ea1c0d06eb2..943a88e831a570cbac022163320d1b82fd8828be 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/03.using_types/01.readonly_array_and_tuple_type/tuple_readonly.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/03.using_types/01.readonly_array_and_tuple_type/tuple_readonly.params.yaml @@ -22,7 +22,7 @@ cases: - type: long use: 1 - type: float - use: 1.0 + use: 1.0f - type: double use: 1.0 - type: char @@ -38,7 +38,7 @@ cases: - type: Long use: 1 - type: Float - use: 1.0 + use: 1.0f - type: Double use: 1.0 - type: Char diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/bitwise_and/bitwise_and_char.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/bitwise_and/bitwise_and_char.params.yaml index 54db1c0e1d2b2fa7b0926e6a3f0de5265dff7fb0..2876464195c9b01d6f81cf5ba8fa63d8010fead3 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/bitwise_and/bitwise_and_char.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/bitwise_and/bitwise_and_char.params.yaml @@ -16,8 +16,8 @@ values: - { left: 0, right: 0, result: 0 } - { left: 0, right: 1, result: 0 } - { left: 1, right: 1, result: 1 } -- { left: "Char.MIN_VALUE as char", right: "Char.MIN_VALUE as char", result: "Char.MIN_VALUE as int" } -- { left: "Char.MAX_VALUE as char", right: "Char.MAX_VALUE as char", result: "Char.MAX_VALUE as int" } +- { left: "Char.MIN_VALUE as char", right: "Char.MIN_VALUE as char", result: "Char.MIN_VALUE.toInt()" } +- { left: "Char.MAX_VALUE as char", right: "Char.MAX_VALUE as char", result: "Char.MAX_VALUE.toInt()" } - { left: "Char.MIN_VALUE as char", right: "Char.MAX_VALUE as char", result: 0 } - { left: 42, right: 42, result: 42 } - { left: "0x5555", right: "0xaaaa", result: 0 } diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/bitwise_complement/bitwise_complement_char.ets b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/bitwise_complement/bitwise_complement_char.ets index 98041d8c2e898ec16728d61f16ecd6c36c36e9e1..ced43249eefc7262c971d443dd9c87289741ef4b 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/bitwise_complement/bitwise_complement_char.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/bitwise_complement/bitwise_complement_char.ets @@ -21,7 +21,7 @@ desc: check bitwise complement of char function main(): void { const v: char = {{v.value}} {% if v.result == "Char.MAX_VALUE" %} - assertEQ( ~(v) as char, {{v.result}} as char ) + assertEQ( (~(v)).toChar(), {{v.result}}.toChar() ) {% else %} assertEQ( ~(v), {{v.result}} ) {% endif %} diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/bitwise_or/bitwise_or_char.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/bitwise_or/bitwise_or_char.params.yaml index 3536e5378d42b2a58361868b7495b3ed4dc7e6fe..380268539d89e0beb0d57efb2713a646a9e3137c 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/bitwise_or/bitwise_or_char.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/bitwise_or/bitwise_or_char.params.yaml @@ -16,8 +16,8 @@ values: - { left: 0, right: 0, result: 0 } - { left: 0, right: 1, result: 1 } - { left: 1, right: 1, result: 1 } -- { left: "Char.MIN_VALUE as char", right: "Char.MIN_VALUE as char", result: "Char.MIN_VALUE as int" } -- { left: "Char.MAX_VALUE as char", right: "Char.MAX_VALUE as char", result: "Char.MAX_VALUE as int" } -- { left: "Char.MIN_VALUE as char", right: "Char.MAX_VALUE as char", result: "Char.MAX_VALUE as int" } +- { left: "(Char.MIN_VALUE).toChar()", right: "(Char.MIN_VALUE).toChar()", result: "(Char.MIN_VALUE).toInt()" } +- { left: "(Char.MAX_VALUE).toChar()", right: "(Char.MAX_VALUE).toChar()", result: "(Char.MAX_VALUE).toInt()" } +- { left: "(Char.MIN_VALUE).toChar()", right: "(Char.MAX_VALUE).toChar()", result: "(Char.MAX_VALUE).toInt()" } - { left: 42, right: 42, result: 42 } - { left: "0x5555", right: "0xaaaa", result: 65535 } diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/division/division_by_zero_char.ets b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/division/division_by_zero_char.ets index e27c8b7473fc4212396ccbd6a95885c0f792929e..2cbf48c8d242af79f0e58a313948dc4e70455cf8 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/division/division_by_zero_char.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/division/division_by_zero_char.ets @@ -15,6 +15,7 @@ limitations under the License. /*--- desc: check division by zero for char operand +tags: [negative, compile-only] ---*/ function main(): void { diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/division/division_by_zero_int.ets b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/division/division_by_zero_int.ets index 3cc6aa5aa80b2b9e7670930f962f7504ed698aa7..b03e19c6d8d3b79f34d0b79d6a74f96b122ce2da 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/division/division_by_zero_int.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/division/division_by_zero_int.ets @@ -15,6 +15,7 @@ limitations under the License. /*--- desc: check division by zero for integer operand +tags: [negative, compile-only] ---*/ function main(): void { diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/division/division_by_zero_long.ets b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/division/division_by_zero_long.ets index 6b2122433883e0746e9543d520bf75e3977d4d43..483bbbe109f1ce42d7646b899389b0fe9c5a5bd3 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/division/division_by_zero_long.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/division/division_by_zero_long.ets @@ -15,6 +15,7 @@ limitations under the License. /*--- desc: check division by zero for long integer operand +tags: [negative, compile-only] ---*/ function main(): void { diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/multiplication/multiplication_char.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/multiplication/multiplication_char.params.yaml index f8d003e30cc47618450be4b1bb6964001bfcad90..67c46d80773424193d4ea8e83e1f9e15f6eecfa5 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/multiplication/multiplication_char.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/multiplication/multiplication_char.params.yaml @@ -17,8 +17,8 @@ values: - { left: 1, right: 1, result: 1 } - { left: 17882, right: 47212, result: 844244984 } - { left: 0, right: "Char.MAX_VALUE as char", result: 0 } -- { left: 1, right: "Char.MAX_VALUE as char", result: "Char.MAX_VALUE as int" } +- { left: 1, right: "Char.MAX_VALUE as char", result: "Char.MAX_VALUE.toInt()" } - { left: 0, right: "Char.MIN_VALUE as char", result: 0 } -- { left: 1, right: "Char.MIN_VALUE as char", result: "Char.MIN_VALUE as int" } +- { left: 1, right: "Char.MIN_VALUE as char", result: "Char.MIN_VALUE.toInt()" } - { left: "c'\uFFFF'", right: "c'\uFFFF'", result: -131071 } - { left: "Char.MIN_VALUE as char", right: "Char.MIN_VALUE as char", result: 0 } diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/postfix_decrement/postfix_decrement_char.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/postfix_decrement/postfix_decrement_char.params.yaml index d604300d88bb2bd621f32229397896e169727ebd..fca52ceeb09d7804d99be39c0e4342658dd296cc 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/postfix_decrement/postfix_decrement_char.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/postfix_decrement/postfix_decrement_char.params.yaml @@ -15,6 +15,6 @@ values: - { value: 1, result: 0 } - { value: 2, result: 1 } -- { value: "Char.MIN_VALUE as char", result: "Char.MAX_VALUE as char" } -- { value: "Char.MAX_VALUE as char", result: 65534 } +- { value: "(Char.MIN_VALUE).toChar()", result: "(Char.MAX_VALUE).toChar()" } +- { value: "(Char.MAX_VALUE).toChar()", result: 65534 } - { value: 34567, result: 34566 } diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/remainder/remainder_by_zero_char.ets b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/remainder/remainder_by_zero_char.ets index 63f14ba3c4df668f9204ae4a27ae9cd679781a0d..7e9f47aed67d25b364d3465b37542ac9ca0755fe 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/remainder/remainder_by_zero_char.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/remainder/remainder_by_zero_char.ets @@ -15,6 +15,7 @@ limitations under the License. /*--- desc: check remainder of division by zero for char operands +tags: [compile-only, negative] ---*/ function main(): void { diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/remainder/remainder_by_zero_int.ets b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/remainder/remainder_by_zero_int.ets index b2fd7739fee7cad59209fad4dbd2d4d4dc77e8b4..e42050a7900480a4a4ab955523d1970c1d67aff9 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/remainder/remainder_by_zero_int.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/remainder/remainder_by_zero_int.ets @@ -15,6 +15,7 @@ limitations under the License. /*--- desc: check remainder of division by zero for integer operands +tags: [compile-only, negative] ---*/ function main(): void { diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/remainder/remainder_by_zero_long.ets b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/remainder/remainder_by_zero_long.ets index f678d9802e09e7419a4c7de8e94595e29cb7827c..f4a7eae0794a84d24000a99d54c860b5a4bd7c5d 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/remainder/remainder_by_zero_long.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/01.integer_types_and_operations/remainder/remainder_by_zero_long.ets @@ -15,6 +15,7 @@ limitations under the License. /*--- desc: check remainder of division by zero for long integer operands +tags: [compile-only, negative] ---*/ function main(): void { diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/addition/addition_float.ets b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/addition/addition_float.ets index 39dfe62a5dedadd75e4c1b58b169814e07adbe82..1da8a5ad93bf903f818c820f3cb5784e7e5242c8 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/addition/addition_float.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/addition/addition_float.ets @@ -19,9 +19,9 @@ desc: check addition of two floats ---*/ function main(): void { - const a: float = {{v.left}} as float - const b: float = {{v.right}} as float - const v: float = {{v.result}} as float + const a: float = ( {{v.left}} ).toFloat() + const b: float = ( {{v.right}} ).toFloat() + const v: float = ( {{v.result}} ).toFloat() const r: float = a + b if (Float.isNaN(v)) { assertTrue(Float.isNaN(r)) diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/division/division_float.ets b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/division/division_float.ets index 545dbe292531d69c603445131066be63d5ce07f5..32d9754ac47075062929592124d5f733d3cbbdc4 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/division/division_float.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/division/division_float.ets @@ -19,9 +19,9 @@ desc: check division of two floats ---*/ function main(): void { - const a: float = {{v.left}} as float - const b: float = {{v.right}} as float - const v: float = {{v.result}} as float + const a: float = ( {{v.left}} ).toFloat() + const b: float = ( {{v.right}} ).toFloat() + const v: float = ( {{v.result}} ).toFloat() const r: float = a / b if (Float.isNaN(v)) { assertTrue(Float.isNaN(r)) diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/less_than/less_than_float.ets b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/less_than/less_than_float.ets index 5bb31cf9c31f2d36730f0d6c01def2ea8ed51256..513787e4f5051f70756c9d42813b8c7880e95b9d 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/less_than/less_than_float.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/less_than/less_than_float.ets @@ -19,8 +19,8 @@ desc: check less than operation for two floats ---*/ function main(): void { - const a: float = {{v.left}} as float - const b: float = {{v.right}} as float + const a: float = ( {{v.left}} ).toFloat() + const b: float = ( {{v.right}} ).toFloat() assertEQ( (a < b), {{v.result}} ) } diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/multiplication/multiplication_float.ets b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/multiplication/multiplication_float.ets index c212afafb090cea30f70e671a614061a44f41fc0..750e4ca16d9149a3fed31dc8148ca73d13378c47 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/multiplication/multiplication_float.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/multiplication/multiplication_float.ets @@ -19,9 +19,9 @@ desc: check addition of two floats ---*/ function main(): void { - const a: float = {{v.left}} as float - const b: float = {{v.right}} as float - const v: float = {{v.result}} as float + const a: float = ( {{v.left}} ).toFloat() + const b: float = ( {{v.right}} ).toFloat() + const v: float = ( {{v.result}} ).toFloat() const r: float = a * b if (Float.isNaN(v)) { assertTrue(Float.isNaN(r)) diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/not_equal/not_equal_float.ets b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/not_equal/not_equal_float.ets index 29bcb5f7f63a9e8afa07fbdaa7d862893c47f46c..df7ea1eeb8e141ee9ae3a7f54254e036cbab6314 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/not_equal/not_equal_float.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/not_equal/not_equal_float.ets @@ -19,8 +19,8 @@ desc: check not equality of two floats ---*/ function main(): void { - const a: float = {{v.left}} as float - const b: float = {{v.right}} as float + const a: float = ( {{v.left}} ).toFloat() + const b: float = ( {{v.right}} ).toFloat() assertEQ( (a != b), {{v.result}} ) } diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/subtraction/subtraction_float.ets b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/subtraction/subtraction_float.ets index 5fa9483175e4664ec5069596f8e1a8023a0c1181..bf5886a76701f0bf0475213e483bb4d347cf3a76 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/subtraction/subtraction_float.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/subtraction/subtraction_float.ets @@ -19,9 +19,9 @@ desc: check subtraction of two floats ---*/ function main(): void { - const a: float = {{v.left}} as float - const b: float = {{v.right}} as float - const v: float = {{v.result}} as float + const a: float = ( {{v.left}} ).toFloat() + const b: float = ( {{v.right}} ).toFloat() + const v: float = ( {{v.result}} ).toFloat() const r: float = a - b if (Float.isNaN(v)) { assertTrue(Float.isNaN(r)) diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/unary_minus/unary_minus_float.ets b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/unary_minus/unary_minus_float.ets index 3d9421cd75dff53e2abecb59d9bc25ec925c9291..abd4ae617129a6ba5864bbf84295952140fab793 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/unary_minus/unary_minus_float.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/unary_minus/unary_minus_float.ets @@ -19,8 +19,8 @@ desc: check unary minus operation for float operand ---*/ function main(): void { - const v: float = {{v.value}} as float - const r: float = {{v.result}} as float + const v: float = ( {{v.value}} ).toFloat() + const r: float = ( {{v.result}} ).toFloat() if (Float.isNaN(v)) { assertTrue(Float.isNaN(r)) } else { diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/unary_plus/unary_plus_float.ets b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/unary_plus/unary_plus_float.ets index 9fbfe7afe892cf45251e91c7d00134f9fa671189..1f26339690abbf6b3b1334f746a09d6004308747 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/unary_plus/unary_plus_float.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/06.value_types/02.floating-point_types_and_operations/unary_plus/unary_plus_float.ets @@ -19,8 +19,8 @@ desc: check unary plus operation for float operand ---*/ function main(): void { - const v: float = {{v.value}} as float - const r: float = {{v.result}} as float + const v: float = ( {{v.value}} ).toFloat() + const r: float = ( {{v.result}} ).toFloat() if (Float.isNaN(v)) { assertTrue(Float.isNaN(r)) } else { diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/14.type_bigint/bint_arr.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/14.type_bigint/bint_arr.params.yaml index 3c19ceb5619b880bf64ba143c3c09558a1917d2c..e5b71626b08cc8f8ba65478493c9bc2ab63bfb99 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/14.type_bigint/bint_arr.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/14.type_bigint/bint_arr.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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,39 +15,39 @@ cases: - from_type: byte values: - - { expr: 0 as byte, val: 0n } - - { expr: 0x7F as byte, val: 127n } - - { expr: 0x80 as byte, val: -128n } + - { expr: (0).toByte(), val: 0n } + - { expr: (0x7F).toByte(), val: 127n } + - { expr: (0x80).toByte(), val: -128n } - from_type: short values: - - { expr: 0 as short, val: 0n } - - { expr: 0x007F as short, val: 127n } - - { expr: 0xFF80 as short, val: -128n } - - { expr: 0x7FFF as short, val: 32767n } - - { expr: 0x8000 as short, val: -32768n } + - { expr: (0).toShort(), val: 0n } + - { expr: (0x007F).toShort(), val: 127n } + - { expr: (0xFF80).toShort(), val: -128n } + - { expr: (0x7FFF).toShort(), val: 32767n } + - { expr: (0x8000).toShort(), val: -32768n } - from_type: int values: - - { expr: 0 as int, val: 0n } - - { expr: 0x0000007F as int, val: 127n } - - { expr: 0xFFFFFF80 as int, val: -128n } - - { expr: 0x00007FFF as int, val: 32767n } - - { expr: 0xFFFF8000 as int, val: -32768n } - - { expr: 0x7FFFFFFF as int, val: 2147483647n } - - { expr: 0x80000000 as int, val: -2147483648n } + - { expr: (0).toInt(), val: 0n } + - { expr: (0x0000007F).toInt(), val: 127n } + - { expr: (0xFFFFFF80).toInt(), val: -128n } + - { expr: (0x00007FFF).toInt(), val: 32767n } + - { expr: (0xFFFF8000).toInt(), val: -32768n } + - { expr: (0x7FFFFFFF).toInt(), val: 2147483647n } + - { expr: (0x80000000).toInt(), val: -2147483648n } - from_type: long values: - - { expr: 0 as long, val: 0n } - - { expr: 0x000000000000007F as long, val: 127n } - - { expr: 0xFFFFFFFFFFFFFF80 as long, val: -128n } - - { expr: 0x0000000000007FFF as long, val: 32767n } - - { expr: 0xFFFFFFFFFFFF8000 as long, val: -32768n } - - { expr: 0x000000007FFFFFFF as long, val: 2147483647n } - - { expr: 0xFFFFFFFF80000000 as long, val: -2147483648n } - - { expr: 0x8000000000000000 as long, val: -9223372036854775808n } - - { expr: 0x7FFFFFFFFFFFFFFF as long, val: 9223372036854775807n } + - { expr: (0).toLong(), val: 0n } + - { expr: (0x000000000000007F).toLong(), val: 127n } + - { expr: (0xFFFFFFFFFFFFFF80).toLong(), val: -128n } + - { expr: (0x0000000000007FFF).toLong(), val: 32767n } + - { expr: (0xFFFFFFFFFFFF8000).toLong(), val: -32768n } + - { expr: (0x000000007FFFFFFF).toLong(), val: 2147483647n } + - { expr: (0xFFFFFFFF80000000).toLong(), val: -2147483648n } + - { expr: (0x8000000000000000).toLong(), val: -9223372036854775808n } + - { expr: (0x7FFFFFFFFFFFFFFF).toLong(), val: 9223372036854775807n } - from_type: float values: diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/14.type_bigint/bint_clss.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/14.type_bigint/bint_clss.params.yaml index 3c19ceb5619b880bf64ba143c3c09558a1917d2c..e5b71626b08cc8f8ba65478493c9bc2ab63bfb99 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/14.type_bigint/bint_clss.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/14.type_bigint/bint_clss.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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,39 +15,39 @@ cases: - from_type: byte values: - - { expr: 0 as byte, val: 0n } - - { expr: 0x7F as byte, val: 127n } - - { expr: 0x80 as byte, val: -128n } + - { expr: (0).toByte(), val: 0n } + - { expr: (0x7F).toByte(), val: 127n } + - { expr: (0x80).toByte(), val: -128n } - from_type: short values: - - { expr: 0 as short, val: 0n } - - { expr: 0x007F as short, val: 127n } - - { expr: 0xFF80 as short, val: -128n } - - { expr: 0x7FFF as short, val: 32767n } - - { expr: 0x8000 as short, val: -32768n } + - { expr: (0).toShort(), val: 0n } + - { expr: (0x007F).toShort(), val: 127n } + - { expr: (0xFF80).toShort(), val: -128n } + - { expr: (0x7FFF).toShort(), val: 32767n } + - { expr: (0x8000).toShort(), val: -32768n } - from_type: int values: - - { expr: 0 as int, val: 0n } - - { expr: 0x0000007F as int, val: 127n } - - { expr: 0xFFFFFF80 as int, val: -128n } - - { expr: 0x00007FFF as int, val: 32767n } - - { expr: 0xFFFF8000 as int, val: -32768n } - - { expr: 0x7FFFFFFF as int, val: 2147483647n } - - { expr: 0x80000000 as int, val: -2147483648n } + - { expr: (0).toInt(), val: 0n } + - { expr: (0x0000007F).toInt(), val: 127n } + - { expr: (0xFFFFFF80).toInt(), val: -128n } + - { expr: (0x00007FFF).toInt(), val: 32767n } + - { expr: (0xFFFF8000).toInt(), val: -32768n } + - { expr: (0x7FFFFFFF).toInt(), val: 2147483647n } + - { expr: (0x80000000).toInt(), val: -2147483648n } - from_type: long values: - - { expr: 0 as long, val: 0n } - - { expr: 0x000000000000007F as long, val: 127n } - - { expr: 0xFFFFFFFFFFFFFF80 as long, val: -128n } - - { expr: 0x0000000000007FFF as long, val: 32767n } - - { expr: 0xFFFFFFFFFFFF8000 as long, val: -32768n } - - { expr: 0x000000007FFFFFFF as long, val: 2147483647n } - - { expr: 0xFFFFFFFF80000000 as long, val: -2147483648n } - - { expr: 0x8000000000000000 as long, val: -9223372036854775808n } - - { expr: 0x7FFFFFFFFFFFFFFF as long, val: 9223372036854775807n } + - { expr: (0).toLong(), val: 0n } + - { expr: (0x000000000000007F).toLong(), val: 127n } + - { expr: (0xFFFFFFFFFFFFFF80).toLong(), val: -128n } + - { expr: (0x0000000000007FFF).toLong(), val: 32767n } + - { expr: (0xFFFFFFFFFFFF8000).toLong(), val: -32768n } + - { expr: (0x000000007FFFFFFF).toLong(), val: 2147483647n } + - { expr: (0xFFFFFFFF80000000).toLong(), val: -2147483648n } + - { expr: (0x8000000000000000).toLong(), val: -9223372036854775808n } + - { expr: (0x7FFFFFFFFFFFFFFF).toLong(), val: 9223372036854775807n } - from_type: float values: diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/14.type_bigint/bint_lmbd.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/14.type_bigint/bint_lmbd.params.yaml index 3c19ceb5619b880bf64ba143c3c09558a1917d2c..e5b71626b08cc8f8ba65478493c9bc2ab63bfb99 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/14.type_bigint/bint_lmbd.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/14.type_bigint/bint_lmbd.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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,39 +15,39 @@ cases: - from_type: byte values: - - { expr: 0 as byte, val: 0n } - - { expr: 0x7F as byte, val: 127n } - - { expr: 0x80 as byte, val: -128n } + - { expr: (0).toByte(), val: 0n } + - { expr: (0x7F).toByte(), val: 127n } + - { expr: (0x80).toByte(), val: -128n } - from_type: short values: - - { expr: 0 as short, val: 0n } - - { expr: 0x007F as short, val: 127n } - - { expr: 0xFF80 as short, val: -128n } - - { expr: 0x7FFF as short, val: 32767n } - - { expr: 0x8000 as short, val: -32768n } + - { expr: (0).toShort(), val: 0n } + - { expr: (0x007F).toShort(), val: 127n } + - { expr: (0xFF80).toShort(), val: -128n } + - { expr: (0x7FFF).toShort(), val: 32767n } + - { expr: (0x8000).toShort(), val: -32768n } - from_type: int values: - - { expr: 0 as int, val: 0n } - - { expr: 0x0000007F as int, val: 127n } - - { expr: 0xFFFFFF80 as int, val: -128n } - - { expr: 0x00007FFF as int, val: 32767n } - - { expr: 0xFFFF8000 as int, val: -32768n } - - { expr: 0x7FFFFFFF as int, val: 2147483647n } - - { expr: 0x80000000 as int, val: -2147483648n } + - { expr: (0).toInt(), val: 0n } + - { expr: (0x0000007F).toInt(), val: 127n } + - { expr: (0xFFFFFF80).toInt(), val: -128n } + - { expr: (0x00007FFF).toInt(), val: 32767n } + - { expr: (0xFFFF8000).toInt(), val: -32768n } + - { expr: (0x7FFFFFFF).toInt(), val: 2147483647n } + - { expr: (0x80000000).toInt(), val: -2147483648n } - from_type: long values: - - { expr: 0 as long, val: 0n } - - { expr: 0x000000000000007F as long, val: 127n } - - { expr: 0xFFFFFFFFFFFFFF80 as long, val: -128n } - - { expr: 0x0000000000007FFF as long, val: 32767n } - - { expr: 0xFFFFFFFFFFFF8000 as long, val: -32768n } - - { expr: 0x000000007FFFFFFF as long, val: 2147483647n } - - { expr: 0xFFFFFFFF80000000 as long, val: -2147483648n } - - { expr: 0x8000000000000000 as long, val: -9223372036854775808n } - - { expr: 0x7FFFFFFFFFFFFFFF as long, val: 9223372036854775807n } + - { expr: (0).toLong(), val: 0n } + - { expr: (0x000000000000007F).toLong(), val: 127n } + - { expr: (0xFFFFFFFFFFFFFF80).toLong(), val: -128n } + - { expr: (0x0000000000007FFF).toLong(), val: 32767n } + - { expr: (0xFFFFFFFFFFFF8000).toLong(), val: -32768n } + - { expr: (0x000000007FFFFFFF).toLong(), val: 2147483647n } + - { expr: (0xFFFFFFFF80000000).toLong(), val: -2147483648n } + - { expr: (0x8000000000000000).toLong(), val: -9223372036854775808n } + - { expr: (0x7FFFFFFFFFFFFFFF).toLong(), val: 9223372036854775807n } - from_type: float values: diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/14.type_bigint/bint_tup.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/14.type_bigint/bint_tup.params.yaml index 3c19ceb5619b880bf64ba143c3c09558a1917d2c..e5b71626b08cc8f8ba65478493c9bc2ab63bfb99 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/14.type_bigint/bint_tup.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/14.type_bigint/bint_tup.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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,39 +15,39 @@ cases: - from_type: byte values: - - { expr: 0 as byte, val: 0n } - - { expr: 0x7F as byte, val: 127n } - - { expr: 0x80 as byte, val: -128n } + - { expr: (0).toByte(), val: 0n } + - { expr: (0x7F).toByte(), val: 127n } + - { expr: (0x80).toByte(), val: -128n } - from_type: short values: - - { expr: 0 as short, val: 0n } - - { expr: 0x007F as short, val: 127n } - - { expr: 0xFF80 as short, val: -128n } - - { expr: 0x7FFF as short, val: 32767n } - - { expr: 0x8000 as short, val: -32768n } + - { expr: (0).toShort(), val: 0n } + - { expr: (0x007F).toShort(), val: 127n } + - { expr: (0xFF80).toShort(), val: -128n } + - { expr: (0x7FFF).toShort(), val: 32767n } + - { expr: (0x8000).toShort(), val: -32768n } - from_type: int values: - - { expr: 0 as int, val: 0n } - - { expr: 0x0000007F as int, val: 127n } - - { expr: 0xFFFFFF80 as int, val: -128n } - - { expr: 0x00007FFF as int, val: 32767n } - - { expr: 0xFFFF8000 as int, val: -32768n } - - { expr: 0x7FFFFFFF as int, val: 2147483647n } - - { expr: 0x80000000 as int, val: -2147483648n } + - { expr: (0).toInt(), val: 0n } + - { expr: (0x0000007F).toInt(), val: 127n } + - { expr: (0xFFFFFF80).toInt(), val: -128n } + - { expr: (0x00007FFF).toInt(), val: 32767n } + - { expr: (0xFFFF8000).toInt(), val: -32768n } + - { expr: (0x7FFFFFFF).toInt(), val: 2147483647n } + - { expr: (0x80000000).toInt(), val: -2147483648n } - from_type: long values: - - { expr: 0 as long, val: 0n } - - { expr: 0x000000000000007F as long, val: 127n } - - { expr: 0xFFFFFFFFFFFFFF80 as long, val: -128n } - - { expr: 0x0000000000007FFF as long, val: 32767n } - - { expr: 0xFFFFFFFFFFFF8000 as long, val: -32768n } - - { expr: 0x000000007FFFFFFF as long, val: 2147483647n } - - { expr: 0xFFFFFFFF80000000 as long, val: -2147483648n } - - { expr: 0x8000000000000000 as long, val: -9223372036854775808n } - - { expr: 0x7FFFFFFFFFFFFFFF as long, val: 9223372036854775807n } + - { expr: (0).toLong(), val: 0n } + - { expr: (0x000000000000007F).toLong(), val: 127n } + - { expr: (0xFFFFFFFFFFFFFF80).toLong(), val: -128n } + - { expr: (0x0000000000007FFF).toLong(), val: 32767n } + - { expr: (0xFFFFFFFFFFFF8000).toLong(), val: -32768n } + - { expr: (0x000000007FFFFFFF).toLong(), val: 2147483647n } + - { expr: (0xFFFFFFFF80000000).toLong(), val: -2147483648n } + - { expr: (0x8000000000000000).toLong(), val: -9223372036854775808n } + - { expr: (0x7FFFFFFFFFFFFFFF).toLong(), val: 9223372036854775807n } - from_type: float values: diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/14.type_bigint/bint_un.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/14.type_bigint/bint_un.params.yaml index 3c19ceb5619b880bf64ba143c3c09558a1917d2c..3da303e39381908fe337ba81bf83ee45d08d6de9 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/14.type_bigint/bint_un.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/14.type_bigint/bint_un.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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 @@ -13,64 +13,65 @@ --- cases: - - from_type: byte + - from_type: Byte values: - - { expr: 0 as byte, val: 0n } - - { expr: 0x7F as byte, val: 127n } - - { expr: 0x80 as byte, val: -128n } + - { expr: (0).toByte(), val: 0n } + - { expr: (0x7F).toByte(), val: 127n } + - { expr: (0x80).toByte(), val: -128n } - - from_type: short + - from_type: Short values: - - { expr: 0 as short, val: 0n } - - { expr: 0x007F as short, val: 127n } - - { expr: 0xFF80 as short, val: -128n } - - { expr: 0x7FFF as short, val: 32767n } - - { expr: 0x8000 as short, val: -32768n } + - { expr: (0).toShort(), val: 0n } + - { expr: (0x007F).toShort(), val: 127n } + - { expr: (0xFF80).toShort(), val: -128n } + - { expr: (0x7FFF).toShort(), val: 32767n } + - { expr: (0x8000).toShort(), val: -32768n } - - from_type: int + - from_type: Int values: - - { expr: 0 as int, val: 0n } - - { expr: 0x0000007F as int, val: 127n } - - { expr: 0xFFFFFF80 as int, val: -128n } - - { expr: 0x00007FFF as int, val: 32767n } - - { expr: 0xFFFF8000 as int, val: -32768n } - - { expr: 0x7FFFFFFF as int, val: 2147483647n } - - { expr: 0x80000000 as int, val: -2147483648n } + - { expr: (0).toInt(), val: 0n } + - { expr: (0x0000007F).toInt(), val: 127n } + - { expr: (0xFFFFFF80).toInt(), val: -128n } + - { expr: (0x00007FFF).toInt(), val: 32767n } + - { expr: (0xFFFF8000).toInt(), val: -32768n } + - { expr: (0x7FFFFFFF).toInt(), val: 2147483647n } + - { expr: (0x80000000).toInt(), val: -2147483648n } - - from_type: long + - from_type: Long values: - - { expr: 0 as long, val: 0n } - - { expr: 0x000000000000007F as long, val: 127n } - - { expr: 0xFFFFFFFFFFFFFF80 as long, val: -128n } - - { expr: 0x0000000000007FFF as long, val: 32767n } - - { expr: 0xFFFFFFFFFFFF8000 as long, val: -32768n } - - { expr: 0x000000007FFFFFFF as long, val: 2147483647n } - - { expr: 0xFFFFFFFF80000000 as long, val: -2147483648n } - - { expr: 0x8000000000000000 as long, val: -9223372036854775808n } - - { expr: 0x7FFFFFFFFFFFFFFF as long, val: 9223372036854775807n } + - { expr: (0).toLong(), val: 0n } + - { expr: (0x000000000000007F).toLong(), val: 127n } + - { expr: (0xFFFFFFFFFFFFFF80).toLong(), val: -128n } + - { expr: (0x0000000000007FFF).toLong(), val: 32767n } + - { expr: (0xFFFFFFFFFFFF8000).toLong(), val: -32768n } + - { expr: (0x000000007FFFFFFF).toLong(), val: 2147483647n } + - { expr: (0xFFFFFFFF80000000).toLong(), val: -2147483648n } + - { expr: (0x8000000000000000).toLong(), val: -9223372036854775808n } + - { expr: (0x7FFFFFFFFFFFFFFF).toLong(), val: 9223372036854775807n } - - from_type: float + - from_type: Float values: - { expr: +0.0000000000f, val: 0n } - { expr: -0.00f, val: 0n } - { expr: 1e10f, val: 10000000000n } - - from_type: double + - from_type: Double values: - { expr: '+0.0', val: 0n } - { expr: '-0.0', val: 0n } - { expr: '1.234567890123456e15', val: 1234567890123456n } - - from_type: number + # former number + - from_type: Double values: - { expr: '+0.0e0', val: 0n } - { expr: '-0.0e-0', val: 0n } - { expr: '-1234567890123456.0', val: -1234567890123456n } - - from_type: float + - from_type: Float values: - { expr: Float.MAX_VALUE, val: new BigInt(Float.MAX_VALUE) } - - from_type: double + - from_type: Double values: - { expr: Double.MAX_VALUE, val: new BigInt(Double.MAX_VALUE) } diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/16.array_types/01.resizable_array_types/rar1.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/16.array_types/01.resizable_array_types/rar1.params.yaml index a995f65c487e712d8a67ebb3110a34a0baca8f52..e207dfbfc1b963d221055662a124524a9b19535f 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/16.array_types/01.resizable_array_types/rar1.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/16.array_types/01.resizable_array_types/rar1.params.yaml @@ -15,12 +15,12 @@ cases: # primitives - type: byte - vals: '0x80 as byte, 0x7f as byte' - val: '0x55 as byte' + vals: '(0x80).toByte(), (0x7f).toByte()' + val: '(0x55).toByte()' - type: short - vals: '0x8000 as short, 0x7fff as short' - val: '0x0505 as short' + vals: '(0x8000).toShort(), (0x7fff).toShort()' + val: '(0x0505).toShort()' - type: int vals: '0x80000000, 0x7fffffff' diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/16.array_types/types.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/16.array_types/types.params.yaml index aaff5c36d116b91e91f5234ccb892447de80fa03..279ce94325fb0d6bdef9758ac6c8d95a590245cf 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/16.array_types/types.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/16.array_types/types.params.yaml @@ -18,7 +18,7 @@ cases: - { type: 'FixedArray', vals: '[3, 2, 1]', val: '0x7fff', assert: 'arr[0] == Short.MAX_VALUE' } - { type: 'int[]', vals: '[3, 2, 1]', val: '0x7fffffff', assert: 'arr[0] == Int.MAX_VALUE' } - { type: 'long[]', vals: '[3, 2, 1]', val: '0x7fffffffffffffff', assert: 'arr[0] == Long.MAX_VALUE' } - - { type: 'FixedArray', vals: '[3, 2, 1]', val: 1.5, assert: 'arr[0] == 1.5' } + - { type: 'FixedArray', vals: '[3, 2, 1]', val: 1.5f, assert: 'arr[0] == 1.5f' } - { type: 'double[]', vals: '[3, 1, 2]', val: -1.5, assert: 'arr[0] == -1.5' } - { type: 'char[]', vals: "[c'A', c'B', c'C']", val: c'Z', assert: "arr[0] == c'Z'" } - { type: 'boolean[]', vals: '[true, false, true]', val: 'false', assert: 'arr[0] == false' } @@ -30,7 +30,7 @@ cases: assert: 'arr[0] == Color.Green' # reference types - - { type: 'Byte[]', vals: '[new Byte(127 as byte), new Byte(2 as byte), new Byte(1 as byte)]', val: new Byte(42 as byte), assert: 'arr[0].unboxed() == 42' } + - { type: 'Byte[]', vals: '[new Byte((127).toByte()), new Byte((2).toByte()), new Byte((1).toByte())]', val: new Byte((42).toByte()), assert: 'arr[0].unboxed() == 42' } - { type: 'Error[]', vals: '[new Error("A"), new Error("B"), new Error("C")]', val: new Error("D"), assert: 'arr[0].message == "D"' } # type aliases diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/17.tuple_types/tt2.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/17.tuple_types/tt2.params.yaml index 3f1229835e87172a3d8b1fac44b5730840a23d27..3715f6f340799797baa5d2e5ade75ee72c794b62 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/17.tuple_types/tt2.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/17.tuple_types/tt2.params.yaml @@ -24,7 +24,7 @@ cases: - { type: number, val: -0.0000001 } - { type: Byte, val: new Byte(-128 as byte) } - - { type: Short, val: '(Short.MIN_VALUE + 1) as short' } + - { type: Short, val: '(Short.MIN_VALUE + 1).toShort()' } - { type: Int, val: '42 * 42' } - { type: Long, val: 'Long.MAX_VALUE - 1' } - { type: Boolean, val: 'true' } diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/19.union_types/01.union_types_normalization/norm.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/19.union_types/01.union_types_normalization/norm.params.yaml index 3c2c4f5d30229c143abc2d33756def421de03c67..d2aa34dea7dedecf991286d63241070e23122c21 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/19.union_types/01.union_types_normalization/norm.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/19.union_types/01.union_types_normalization/norm.params.yaml @@ -98,17 +98,20 @@ cases: type AB = 'A' | 'B' type UT = 'A' | string | AB // => string let v: UT = '' + let c: Char = new Char(c'\u0000') pos: - |- v = 'abc' assertEQ(v, 'abc') v = '\u0000' + '\u0000' + '\u0000' assertEQ(v, '\u0000\u0000\u0000') - v = c'X' + c = c'X' + v = c.toString() assertEQ(v, 'X') - neg: - |- - v = new Char(c'\u0000') + v = c.toString() + assertEQ(typeof v, 'string') + neg: - |- v = null - |- @@ -122,11 +125,12 @@ cases: type C = string | 'byte' type UT = A | B | C // => string let v: UT = '' + let c: char = c'3' pos: - |- v = new String('1') assertEQ(v, '1') - v = c'3' + v = c.toString() assertEQ(v, '3') neg: - |- diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/19.union_types/union_type_assignment.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/19.union_types/union_type_assignment.params.yaml index 8a86fc8111211a87f9919f42d8c9544a3fc4c3c7..d5a8b39cdd0025d2b2ae0791c3529e4eac77cfb2 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/19.union_types/union_type_assignment.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/19.union_types/union_type_assignment.params.yaml @@ -23,7 +23,7 @@ cases2: - desc: Basic union type(number - int). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = 66; assertEQ(value, 66); @@ -31,7 +31,7 @@ cases2: - desc: Basic union type(number calculation). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = 3 * 3; assertEQ(value, 9); @@ -39,7 +39,7 @@ cases2: - desc: Basic union type(number - float). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = 66.6; assertEQ(value, 66.6); @@ -47,15 +47,15 @@ cases2: - desc: Basic union type(number - double). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = 66.6666666666; - assertEQ(value, 66.6666666666); + assertEQ(value, 66.6666666666); - desc: Basic union type(number - negative number). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = -0.001; assertEQ(value, -0.001); @@ -63,7 +63,7 @@ cases2: - desc: Basic union type(number - scientific notation). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = 5e3; assertEQ(value, 5000); @@ -71,7 +71,7 @@ cases2: - desc: Basic union type(number - negative scientific notation). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = -2.5e2; assertEQ(value, -250); @@ -79,23 +79,23 @@ cases2: - desc: Basic union type(number infinity). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = Infinity; - assertEQ(value, Infinity); + assertEQ(value, Infinity); - desc: Basic union type(number -infinity). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = -Infinity; - assertEQ(value, -Infinity); + assertEQ(value, -Infinity); - desc: Basic union type(number - precision). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = 0.1 + 0.2; assertEQ(value, 0.30000000000000004); @@ -103,23 +103,23 @@ cases2: - desc: Basic union type(number - binary). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = 0b1010; - assertEQ(value, 0b1010); + assertEQ(value, 0b1010); - desc: Basic union type(number - octal). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = 0o755; - assertEQ(value, 0o755); + assertEQ(value, 0o755); - desc: Basic union type(number - hexadecimal). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = 0x1A3F; assertEQ(value, 0x1A3F); @@ -127,7 +127,7 @@ cases2: - desc: Basic union type(bigint). dec1: |- type StringOrNumber = string | bigint; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = 123456789012345678901234567890n; assertEQ(value, 123456789012345678901234567890n); @@ -135,7 +135,7 @@ cases2: - desc: Basic union type(boolean). dec1: |- type StringOrNumber = string | boolean; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = true; assertEQ(value, true); @@ -143,31 +143,31 @@ cases2: - desc: Basic union type(boolean-false). dec1: |- type StringOrNumber = string | boolean; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = false; - assertEQ(value, false); + assertEQ(value, false); - desc: Basic union type(null). dec1: |- type StringOrNumber = string | null; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = null; - assertEQ(value, null); + assertEQ(value, null); - desc: Basic union type(undefined). dec1: |- type StringOrNumber = string | undefined; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = undefined; - assertEQ(value, undefined); + assertEQ(value, undefined); - desc: Basic union type(string - template). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- let name: string = "Alice"; let age: number = 25; @@ -177,31 +177,31 @@ cases2: - desc: Basic union type(string - '\n'). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = "Hello\nArkTS!"; - assertEQ(value, "Hello\nArkTS!"); + assertEQ(value, "Hello\nArkTS!"); - desc: Basic union type(string - '\t'). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = "Hello\tArkTS!"; - assertEQ(value, "Hello\tArkTS!"); + assertEQ(value, "Hello\tArkTS!"); - desc: Basic union type(use the string method to assign values). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = ("Hello tArkTS!").length; - assertEQ(value, 13); + assertEQ(value, 13); - desc: Basic union type(string trim). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = ("Hello").trim(); assertEQ(value, "Hello"); @@ -209,7 +209,7 @@ cases2: - desc: Basic union type(string toUpperCase). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = ("Hello").toUpperCase(); assertEQ(value, "HELLO"); @@ -217,7 +217,7 @@ cases2: - desc: Basic union type(string substring). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = ("Hello").substring(0, 1); assertEQ(value, "H"); @@ -225,7 +225,7 @@ cases2: - desc: Basic union type(string indexOf). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = ("Hello").indexOf("Hello"); assertEQ(value, 0); @@ -233,7 +233,7 @@ cases2: - desc: Basic union type(string replace). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = ("Hello").replace("Hello", 'h'); assertEQ(value, 'h'); @@ -241,15 +241,15 @@ cases2: - desc: Basic union type(string charat). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- - value = ("Hello").charAt(0) as string; + value = ("Hello").charAt(0).toString(); assertEQ(value, 'H'); - desc: Basic union type(string lastIndexOf). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = ("Hello").lastIndexOf('1'); assertEQ(value, -1); @@ -257,7 +257,7 @@ cases2: - desc: Basic union type(string replaceAll). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = "hello".replaceAll('l', 'x'); assertEQ(value, 'hexxo'); @@ -265,36 +265,36 @@ cases2: - desc: Basic union type(string charcodeat). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- - value = ("ArkTS").charCodeAt(0) as number; + value = ("ArkTS").charCodeAt(0).toDouble(); assertEQ(value, 65); - desc: Basic union type(string lastIndexOf). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber = ("Hello ArkTS, welcome to ArkTS".lastIndexOf("ArkTS")); + let value: StringOrNumber = ("Hello ArkTS, welcome to ArkTS".lastIndexOf("ArkTS")); check: |- assertEQ(value, 24); - desc: Basic union type(string repeat). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber = ("Hello").repeat(0); + let value: StringOrNumber = ("Hello").repeat(0); check: |- assertEQ(value, ""); - desc: Basic union type(string padStart). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber = ("5").padStart(3, "0"); + let value: StringOrNumber = ("5").padStart(3, "0"); check: |- assertEQ(value, "005"); - desc: Basic union type(string padEnd). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber = ("Hi").padEnd(5, "!"); + let value: StringOrNumber = ("Hi").padEnd(5, "!"); check: |- assertEQ(value, "Hi!!!"); @@ -311,9 +311,9 @@ cases2: dec1: |- function printValue(value: string | number): string { return(`Value: ${value}`); - } + } check: |- - assertEQ(printValue("hello"), "Value: hello"); + assertEQ(printValue("hello"), "Value: hello"); - desc: Union types are assigned as attributes of a class(modify properties). dec1: |- @@ -329,7 +329,7 @@ cases2: printInfo(): string { return(`Name: ${this.name}, Age: ${this.age}`); } - } + } check: |- let person1 = new Person("Alice", 30); person1.age = 31; @@ -338,7 +338,7 @@ cases2: - desc: Union types as map types. dec1: |- type ID = string | number; - const users = new Map(); + const users = new Map(); check: |- users.set("u1", "Alice"); assertEQ(users.get("u1"), "Alice"); @@ -346,21 +346,21 @@ cases2: - desc: Union type + readonly modifier. dec1: |- type ReadonlyData = readonly (string | number)[]; - const data: ReadonlyData = ["A", 1, "B", 2]; + const data: ReadonlyData = ["A", 1, "B", 2]; check: |- assertEQ(data[0], 'A'); - desc: Basic union type(use the string method to assign values). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = ("Hello tArkTS!").length; assertEQ(value, 13); - desc: union type + literal type. dec1: |- - type Status = "success" | "error" | "loading"; + type Status = "success" | "error" | "loading"; check: |- let value: Status; value = 'success'; @@ -370,7 +370,7 @@ cases2: dec1: |- function printIfValid(value: T) { return(`Valid value: ${value}`); - } + } check: |- assertEQ(printIfValid('test'), "Valid value: test"); @@ -390,7 +390,7 @@ cases2: setData(newData: string | number) { this.data = newData; } - } + } check: |- const storage = new Storage("hello"); assertEQ(storage.getData(), 'hello'); @@ -433,7 +433,7 @@ cases2: class Frog { name: string = 'frog'; } - type Animal = Cat | Dog | Frog | number; + type Animal = Cat | Dog | Frog | number; check: |- let animal: Animal = new Cat(); assertEQ(animal.name, 'cat'); @@ -443,9 +443,9 @@ cases2: function getData(flag: boolean): string | int { if (flag) { return "Data is a string"; - } + } return "no string" - } + } check: |- assertEQ(getData(true), "Data is a string"); @@ -454,9 +454,9 @@ cases2: function getData(flag: string): boolean | int { if (flag === 'yes') { return true; - } + } return false - } + } check: |- assertEQ(getData('yes'), true); @@ -465,7 +465,7 @@ cases2: function getData(flag: string): boolean | number { if (flag === 'float') { return 3 * 3; - } + } return false } check: |- @@ -521,7 +521,7 @@ cases2: - desc: Basic union type(string - ''). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = 'hello'; assertEQ(value, 'hello'); @@ -529,14 +529,14 @@ cases2: - desc: Basic union type(string toLowerCase). dec1: |- type StringOrNumber = string | number; - let value: StringOrNumber; + let value: StringOrNumber; check: |- value = ("Hello").toLowerCase(); assertEQ(value, "hello"); - desc: Basic union type(string concat). dec1: |- - type StringOrNumber = string | number; + type StringOrNumber = string | number; check: |- let value: StringOrNumber = "Hello"; let value1: StringOrNumber = "ArkTS"; @@ -544,58 +544,58 @@ cases2: - desc: Basic union type(string lastIndexOf). dec1: |- - type StringOrNumber = string | number; + type StringOrNumber = string | number; check: |- let value: StringOrNumber = ("Hello ArkTS, welcome to ArkTS".lastIndexOf("ArkTS")); assertEQ(value, 24); - desc: Basic union type(string includes). dec1: |- - type StringOrNumber = string | number; + type StringOrNumber = string | number; check: |- let value: StringOrNumber = "Hello ArkTS, welcome to ArkTS"; assertEQ(value.includes("ArkTS"), true); - desc: Basic union type(string startsWith). dec1: |- - type StringOrNumber = string | number; + type StringOrNumber = string | number; check: |- let value: StringOrNumber = "Hello ArkTS, welcome to ArkTS"; assertEQ(value.startsWith("Hel"), true); - desc: Basic union type(string endsWith). dec1: |- - type StringOrNumber = string | number; + type StringOrNumber = string | number; check: |- let value: StringOrNumber = "Hello ArkTS, welcome to ArkTS"; assertEQ(value.endsWith("ArkTS"), true); - desc: Basic union type(string repeat). dec1: |- - type StringOrNumber = string | number; + type StringOrNumber = string | number; check: |- let value: StringOrNumber = ("Hello").repeat(0); assertEQ(value, ""); - desc: Basic union type(number calculation except). dec1: |- - type StringOrNumber = string | number; + type StringOrNumber = string | number; check: |- let value: StringOrNumber = 3 / 3; - assertEQ(value, 1); + assertEQ(value, 1); - desc: Basic union type(number calculation delivery). dec1: |- - type StringOrNumber = string | number; + type StringOrNumber = string | number; check: |- let value: StringOrNumber = 3 % 3; - assertEQ(value, 0); + assertEQ(value, 0); - desc: Union types are assigned as parameters(number). dec1: |- function printValue(value: string | number): string { return(`Value: ${value}`); - } + } check: |- assertEQ(printValue(6), "Value: 6"); @@ -638,7 +638,7 @@ cases2: printInfo(): string { return(`Name: ${this.name}, Age: ${this.age}`); } - } + } check: |- let person1 = new Person("Alice", 30); assertEQ(person1.printInfo(), 'Name: Alice, Age: 30'); @@ -657,7 +657,7 @@ cases2: printInfo(): string { return(`Name: ${this.name}, Age: ${this.age}`); } - } + } check: |- let person1 = new Person("Bob", "thirty"); assertEQ(person1.printInfo(), 'Name: Bob, Age: thirty'); @@ -676,7 +676,7 @@ cases2: printInfo(): string { return(`Name: ${this.name}, Age: ${this.age}`); } - } + } check: |- let person1 = new Person("Alice", 30); person1.name = 'Bob'; @@ -684,7 +684,7 @@ cases2: - desc: Union type + null or undefined. dec1: |- - type StringOrNumberOrNull = string | number | null | undefined; + type StringOrNumberOrNull = string | number | null | undefined; check: |- let value: StringOrNumberOrNull; value = null; @@ -692,7 +692,7 @@ cases2: - desc: Union type + array (mixed type). dec1: |- - type MixedArray = (string | number | boolean)[]; + type MixedArray = (string | number | boolean)[]; check: |- let user: MixedArray; user = ["hello", 42, true]; @@ -700,7 +700,7 @@ cases2: - desc: Union type + array (mixed type output number). dec1: |- - type MixedArray = (string | number | boolean)[]; + type MixedArray = (string | number | boolean)[]; check: |- let user: MixedArray; user = ["hello", 42, true]; @@ -708,7 +708,7 @@ cases2: - desc: Union type + array (array operation assignment). dec1: |- - type MixedArray = (string | number | boolean)[]; + type MixedArray = (string | number | boolean)[]; check: |- let user: MixedArray; user = ["hello", 42, true]; @@ -717,7 +717,7 @@ cases2: - desc: Union type + array (array operation assignment length). dec1: |- - type MixedArray = (string | number | boolean)[]; + type MixedArray = (string | number | boolean)[]; check: |- let user: MixedArray; user = ["hello", 42, true]; @@ -754,7 +754,7 @@ cases2: function getData(flag: string): boolean | int { if (flag === 'int') { return 66; - } + } return false } check: |- @@ -765,7 +765,7 @@ cases2: function getData(flag: string): boolean | int { if (flag === 'yes') { return true; - } + } return false } check: |- diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/19.union_types/ut.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/19.union_types/ut.params.yaml index e5acaa75a199e1eb2fec2ebec0e1f3041aa2e7d9..9fc071f8f5d2f817fe34df7c7b09b64e0a08acdf 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/19.union_types/ut.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/19.union_types/ut.params.yaml @@ -201,9 +201,9 @@ cases: - decl: |- type UT = char | short - let v: UT = -32768 + let v: UT = -32768 as short use: |- - v = -32768 + v = -32768 as short assertEQ(v, -32768) v = c'\uFFFF' assertEQ(v, c'\uFFFF') diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/19.union_types/ut_2.sts b/static_core/plugins/ets/tests/ets-templates/03.types/19.union_types/ut_2.ets similarity index 100% rename from static_core/plugins/ets/tests/ets-templates/03.types/19.union_types/ut_2.sts rename to static_core/plugins/ets/tests/ets-templates/03.types/19.union_types/ut_2.ets diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/19.union_types/ut_n2.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/19.union_types/ut_n2.params.yaml index b45bf075171e60ae7557e0ccc31d27fcac913ea7..a0753a80cf5a2a20914d8fa79a49620271c2affe 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/19.union_types/ut_n2.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/19.union_types/ut_n2.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2025 Huawei Device Co., Ltd. + # Copyright (c) 2025 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 @@ -29,4 +29,4 @@ types1: - Short - Long - Float - - Double \ No newline at end of file + - Double diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/20.nullish_types/reference_nullable_types.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/20.nullish_types/reference_nullable_types.params.yaml index 31575bc5545596eb775ae884fbb907dae0a1b267..d0d934a33020d1fdef7f8f35c43a958078b35c93 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/20.nullish_types/reference_nullable_types.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/20.nullish_types/reference_nullable_types.params.yaml @@ -22,7 +22,7 @@ nullables: - {type: "Int|null", value: "null"} - {type: "Long|null", value: "5 as long"} - {type: "Long|null", value: "null"} - - {type: "Float|null", value: "5.0"} + - {type: "Float|null", value: "5.0f"} - {type: "Float|null", value: "null"} - {type: "Double|null", value: "5.0"} - {type: "Double|null", value: "null"} @@ -40,7 +40,7 @@ nullables: - {type: "Int|undefined", value: "undefined"} - {type: "Long|undefined", value: "5 as long"} - {type: "Long|undefined", value: "undefined"} - - {type: "Float|undefined", value: "5.0"} + - {type: "Float|undefined", value: "5.0f"} - {type: "Float|undefined", value: "undefined"} - {type: "Double|undefined", value: "5.0"} - {type: "Double|undefined", value: "undefined"} @@ -58,7 +58,7 @@ nullables: - {type: "Int|undefined|null", value: "undefined"} - {type: "Long|undefined|null", value: "5 as long"} - {type: "Long|undefined|null", value: "undefined"} - - {type: "Float|undefined|null", value: "5.0"} + - {type: "Float|undefined|null", value: "5.0f"} - {type: "Float|undefined|null", value: "undefined"} - {type: "Double|undefined|null", value: "5.0"} - {type: "Double|undefined|null", value: "undefined"} diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/assn_var/assn-var.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/assn_var/assn-var.params.yaml index 99b4f8ee31f2bfb7935770cea71494fdc8b2f846..062ff7564ed980d1cf54a8be50b3efc5d0a5728d 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/assn_var/assn-var.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/assn_var/assn-var.params.yaml @@ -225,10 +225,10 @@ cases: values: - { expr: +0.0 as float, val: +0.0 as double } - { expr: -0.0 as float, val: -0.0 as double } - - { expr: Float.MIN_VALUE, val: Float.MIN_VALUE as double} - - { expr: Float.MAX_VALUE, val: Float.MAX_VALUE as double } - - { expr: Float.NEGATIVE_INFINITY, val: Float.NEGATIVE_INFINITY as double } - - { expr: Float.POSITIVE_INFINITY, val: Float.POSITIVE_INFINITY as double } + - { expr: Float.MIN_VALUE, val: Float.MIN_VALUE.toDouble() } + - { expr: Float.MAX_VALUE, val: Float.MAX_VALUE.toDouble() } + - { expr: Float.NEGATIVE_INFINITY, val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: Float.POSITIVE_INFINITY, val: Float.POSITIVE_INFINITY.toDouble() } - from_type: double to_type: Double diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/call_cons/call-cons-neg.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/call_cons/call-cons-neg.params.yaml index 5281a647dd239aceea93eb2ea2b48d61b24a5183..7dedb3ce2abd76a5a17a72403a33f7a311f48d93 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/call_cons/call-cons-neg.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/call_cons/call-cons-neg.params.yaml @@ -21,38 +21,38 @@ cases: - { from_type: boolean, to_type: Double, expr: 'true' } - { from_type: boolean, to_type: Char, expr: 'true' } - - { from_type: byte, to_type: Boolean, expr: 127 as byte } - - { from_type: short, to_type: Boolean, expr: 32767 as byte } - - { from_type: int, to_type: Boolean, expr: 2147483647 as int } - - { from_type: long, to_type: Boolean, expr: 9223372036854775807 as long } - - { from_type: float, to_type: Boolean, expr: -1.111 as float } - - { from_type: double, to_type: Boolean, expr: -2.222 as double } + - { from_type: byte, to_type: Boolean, expr: (127).toByte() } + - { from_type: short, to_type: Boolean, expr: (32767).toByte() } + - { from_type: int, to_type: Boolean, expr: (2147483647).toInt() } + - { from_type: long, to_type: Boolean, expr: (9223372036854775807).toLong() } + - { from_type: float, to_type: Boolean, expr: (-1.111).toFloat() } + - { from_type: double, to_type: Boolean, expr: (-2.222).toDouble() } - { from_type: char, to_type: Boolean, expr: "c'\\uCAFE'" } - - { from_type: short, to_type: Byte, expr: 32767 as byte } - - { from_type: int, to_type: Byte, expr: 2147483647 as int } - - { from_type: long, to_type: Byte, expr: 9223372036854775807 as long } - - { from_type: float, to_type: Byte, expr: -1.111 as float } - - { from_type: double, to_type: Byte, expr: -2.222 as double } + - { from_type: short, to_type: Byte, expr: (32767).toByte() } + - { from_type: int, to_type: Byte, expr: (2147483647).toInt() } + - { from_type: long, to_type: Byte, expr: (9223372036854775807).toLong() } + - { from_type: float, to_type: Byte, expr: (-1.111).toFloat() } + - { from_type: double, to_type: Byte, expr: (-2.222).toDouble() } - { from_type: char, to_type: Byte, expr: "c'\\uCAFE'" } - - { from_type: int, to_type: Short, expr: 2147483647 as int } - - { from_type: long, to_type: Short, expr: 9223372036854775807 as long } - - { from_type: float, to_type: Short, expr: -1.111 as float } - - { from_type: double, to_type: Short, expr: -2.222 as double } + - { from_type: int, to_type: Short, expr: (2147483647).toInt() } + - { from_type: long, to_type: Short, expr: (9223372036854775807).toLong() } + - { from_type: float, to_type: Short, expr: (-1.111).toFloat() } + - { from_type: double, to_type: Short, expr: (-2.222).toDouble() } - { from_type: char, to_type: Short, expr: "c'\\uCAFE'" } - - { from_type: long, to_type: Int, expr: 9223372036854775807 as long } - - { from_type: float, to_type: Int, expr: -1.111 as float } - - { from_type: double, to_type: Int, expr: -2.222 as double } + - { from_type: long, to_type: Int, expr: 9223372036854775807).toLong() } + - { from_type: float, to_type: Int, expr: (-1.111).toFloat() } + - { from_type: double, to_type: Int, expr: (-2.222).toDouble() } - - { from_type: float, to_type: Long, expr: -1.111 as float } - - { from_type: double, to_type: Long, expr: -2.222 as double } + - { from_type: float, to_type: Long, expr: (-1.111).toFloat() } + - { from_type: double, to_type: Long, expr: (-2.222).toDouble() } - - { from_type: double, to_type: Float, expr: -2.222 as double } + - { from_type: double, to_type: Float, expr: (-2.222).toDouble() } - - { from_type: short, to_type: Char, expr: 32767 as byte } - - { from_type: int, to_type: Char, expr: 2147483647 as int } - - { from_type: long, to_type: Char, expr: 9223372036854775807 as long } - - { from_type: float, to_type: Char, expr: -1.111 as float } - - { from_type: double, to_type: Char, expr: -2.222 as double } + - { from_type: short, to_type: Char, expr: (32767).toByte() } + - { from_type: int, to_type: Char, expr: (2147483647).toInt() } + - { from_type: long, to_type: Char, expr: (9223372036854775807).toLong() } + - { from_type: float, to_type: Char, expr: (-1.111).toFloat() } + - { from_type: double, to_type: Char, expr: (-2.222).toDouble() } diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/call_cons/call-cons.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/call_cons/call-cons.params.yaml index 99b4f8ee31f2bfb7935770cea71494fdc8b2f846..e075d34d39c4148a20b3c1125c23d4a09e454f9d 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/call_cons/call-cons.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/call_cons/call-cons.params.yaml @@ -16,52 +16,52 @@ cases: - from_type: byte to_type: Byte values: - - { expr: 0 as byte, val: 0 } - - { expr: 0x7F as byte, val: 127 } - - { expr: 0x80 as byte, val: -128 } + - { expr: (0).toByte(), val: 0 } + - { expr: (0x7F).toByte(), val: 127 } + - { expr: (0x80).toByte(), val: -128 } - from_type: byte to_type: Short values: - - { expr: 0 as byte, val: 0 } - - { expr: 0x7F as byte, val: 127 } - - { expr: 0x80 as byte, val: -128 } + - { expr: (0).toByte(), val: 0 } + - { expr: (0x7F).toByte(), val: 127 } + - { expr: (0x80).toByte(), val: -128 } - from_type: short to_type: Short values: - - { expr: 0 as short, val: 0 } - - { expr: 0x007F as short, val: 127 } - - { expr: 0xFF80 as short, val: -128 } - - { expr: 0x7FFF as short, val: 32767 } - - { expr: 0x8000 as short, val: -32768 } + - { expr: (0).toShort(), val: 0 } + - { expr: (0x007F).toShort(), val: 127 } + - { expr: (0xFF80).toShort(), val: -128 } + - { expr: (0x7FFF).toShort(), val: 32767 } + - { expr: (0x8000).toShort(), val: -32768 } - from_type: byte to_type: Int values: - - { expr: 0 as byte, val: 0 } - - { expr: 0x7F as byte, val: 127 } - - { expr: 0x80 as byte, val: -128 } + - { expr: (0).toByte(), val: 0 } + - { expr: (0x7F).toByte(), val: 127 } + - { expr: (0x80).toByte(), val: -128 } - from_type: short to_type: Int values: - - { expr: 0 as short, val: 0 } - - { expr: 0x007F as short, val: 127 } - - { expr: 0xFF80 as short, val: -128 } - - { expr: 0x7FFF as short, val: 32767 } - - { expr: 0x8000 as short, val: -32768 } + - { expr: (0).toShort(), val: 0 } + - { expr: (0x007F).toShort(), val: 127 } + - { expr: (0xFF80).toShort(), val: -128 } + - { expr: (0x7FFF).toShort(), val: 32767 } + - { expr: (0x8000).toShort(), val: -32768 } - from_type: int to_type: Int values: - - { expr: 0 as int, val: 0 } - - { expr: 0x0000007F as int, val: 127 } - - { expr: 0xFFFFFF80 as int, val: -128 } - - { expr: 0x00007FFF as int, val: 32767 } - - { expr: 0xFFFF8000 as int, val: -32768 } - - { expr: 0x7FFFFFFF as int, val: 2147483647 } - - { expr: 0x80000000 as int, val: -2147483648 } + - { expr: (0).toInt(), val: 0 } + - { expr: (0x0000007F).toInt(), val: 127 } + - { expr: (0xFFFFFF80).toInt(), val: -128 } + - { expr: (0x00007FFF).toInt(), val: 32767 } + - { expr: (0xFFFF8000).toInt(), val: -32768 } + - { expr: (0x7FFFFFFF).toInt(), val: 2147483647 } + - { expr: (0x80000000).toInt(), val: -2147483648 } - from_type: char to_type: Int @@ -75,42 +75,42 @@ cases: - from_type: byte to_type: Long values: - - { expr: 0 as byte, val: 0 } - - { expr: 0x7F as byte, val: 127 } - - { expr: 0x80 as byte, val: -128 } + - { expr: (0).toByte(), val: 0 } + - { expr: (0x7F).toByte(), val: 127 } + - { expr: (0x80).toByte(), val: -128 } - from_type: short to_type: Long values: - - { expr: 0 as short, val: 0 } - - { expr: 0x007F as short, val: 127 } - - { expr: 0xFF80 as short, val: -128 } - - { expr: 0x7FFF as short, val: 32767 } - - { expr: 0x8000 as short, val: -32768 } + - { expr: (0).toShort(), val: 0 } + - { expr: (0x007F).toShort(), val: 127 } + - { expr: (0xFF80).toShort(), val: -128 } + - { expr: (0x7FFF).toShort(), val: 32767 } + - { expr: (0x8000).toShort(), val: -32768 } - from_type: int to_type: Long values: - - { expr: 0 as int, val: 0 } - - { expr: 0x0000007F as int, val: 127 } - - { expr: 0xFFFFFF80 as int, val: -128 } - - { expr: 0x00007FFF as int, val: 32767 } - - { expr: 0xFFFF8000 as int, val: -32768 } - - { expr: 0x7FFFFFFF as int, val: 2147483647 } - - { expr: 0x80000000 as int, val: -2147483648 } + - { expr: (0).toInt(), val: 0 } + - { expr: (0x0000007F).toInt(), val: 127 } + - { expr: (0xFFFFFF80).toInt(), val: -128 } + - { expr: (0x00007FFF).toInt(), val: 32767 } + - { expr: (0xFFFF8000).toInt(), val: -32768 } + - { expr: (0x7FFFFFFF).toInt(), val: 2147483647 } + - { expr: (0x80000000).toInt(), val: -2147483648 } - from_type: long to_type: Long values: - - { expr: 0 as long, val: 0 } - - { expr: 0x000000000000007F as long, val: 127 } - - { expr: 0xFFFFFFFFFFFFFF80 as long, val: -128 } - - { expr: 0x0000000000007FFF as long, val: 32767 } - - { expr: 0xFFFFFFFFFFFF8000 as long, val: -32768 } - - { expr: 0x000000007FFFFFFF as long, val: 2147483647 } - - { expr: 0xFFFFFFFF80000000 as long, val: -2147483648 } - - { expr: 0x8000000000000000 as long, val: -9223372036854775808 } - - { expr: 0x7FFFFFFFFFFFFFFF as long, val: 9223372036854775807 } + - { expr: (0).toLong(), val: 0 } + - { expr: (0x000000000000007F).toLong(), val: 127 } + - { expr: (0xFFFFFFFFFFFFFF80).toLong(), val: -128 } + - { expr: (0x0000000000007FFF).toLong(), val: 32767 } + - { expr: (0xFFFFFFFFFFFF8000).toLong(), val: -32768 } + - { expr: (0x000000007FFFFFFF).toLong(), val: 2147483647 } + - { expr: (0xFFFFFFFF80000000).toLong(), val: -2147483648 } + - { expr: (0x8000000000000000).toLong(), val: -9223372036854775808 } + - { expr: (0x7FFFFFFFFFFFFFFF).toLong(), val: 9223372036854775807 } - from_type: char to_type: Long @@ -124,48 +124,48 @@ cases: - from_type: byte to_type: Float values: - - { expr: 0 as byte, val: 0.0 as float } - - { expr: 0x7F as byte, val: 127.0 as float } - - { expr: 0x80 as byte, val: -128.0 as float } + - { expr: (0).toByte(), val: (0.0).toFloat() } + - { expr: (0x7F).toByte(), val: (127.0).toFloat() } + - { expr: (0x80).toByte(), val: (-128.0).toFloat() } - from_type: short to_type: Float values: - - { expr: 0 as short, val: 0.0 as float } - - { expr: 0x007F as short, val: 127.0 as float } - - { expr: 0xFF80 as short, val: -128.0 as float } - - { expr: 0x7FFF as short, val: 32767.0 as float } - - { expr: 0x8000 as short, val: -32768.0 as float } + - { expr: (0).toShort(), val: (0.0).toFloat() } + - { expr: (0x007F).toShort(), val: (127.0).toFloat() } + - { expr: (0xFF80).toShort(), val: (-128.0).toFloat() } + - { expr: (0x7FFF).toShort(), val: (32767.0).toFloat() } + - { expr: (0x8000).toShort(), val: (-32768.0).toFloat() } - from_type: int to_type: Float values: - - { expr: 0 as int, val: 0 } - - { expr: 0x0000007F as int, val: 127.0 as float } - - { expr: 0xFFFFFF80 as int, val: -128.0 as float } - - { expr: 0x00007FFF as int, val: 32767.0 as float } - - { expr: 0xFFFF8000 as int, val: -32768.0 as float } - - { expr: 0x7FFFFFFF as int, val: 2147483647.0 as float } - - { expr: 0x80000000 as int, val: -2147483648.0 as float } + - { expr: (0).toInt(), val: 0 } + - { expr: (0x0000007F).toInt(), val: (127.0).toFloat() } + - { expr: (0xFFFFFF80).toInt(), val: (-128.0).toFloat() } + - { expr: (0x00007FFF).toInt(), val: (32767.0).toFloat() } + - { expr: (0xFFFF8000).toInt(), val: (-32768.0).toFloat() } + - { expr: (0x7FFFFFFF).toInt(), val: (2147483647.0).toFloat() } + - { expr: (0x80000000).toInt(), val: (-2147483648.0).toFloat() } - from_type: long to_type: Float values: - - { expr: 0 as long, val: 0 } - - { expr: 0x000000000000007F as long, val: 127.0 as float } - - { expr: 0xFFFFFFFFFFFFFF80 as long, val: -128.0 as float } - - { expr: 0x0000000000007FFF as long, val: 32767.0 as float } - - { expr: 0xFFFFFFFFFFFF8000 as long, val: -32768.0 as float } - - { expr: 0x000000007FFFFFFF as long, val: 2147483647.0 as float } - - { expr: 0xFFFFFFFF80000000 as long, val: -2147483648.0 as float } - - { expr: 0x8000000000000000 as long, val: -9223372036854775808.0 as float } - - { expr: 0x7FFFFFFFFFFFFFFF as long, val: 9223372036854775807.0 as float } + - { expr: (0).toLong(), val: 0 } + - { expr: (0x000000000000007F).toLong(), val: (127.0).toFloat() } + - { expr: (0xFFFFFFFFFFFFFF80).toLong(), val: (-128.0).toFloat() } + - { expr: (0x0000000000007FFF).toLong(), val: (32767.0).toFloat() } + - { expr: (0xFFFFFFFFFFFF8000).toLong(), val: (-32768.0).toFloat() } + - { expr: (0x000000007FFFFFFF).toLong(), val: (2147483647.0).toFloat() } + - { expr: (0xFFFFFFFF80000000).toLong(), val: (-2147483648.0).toFloat() } + - { expr: (0x8000000000000000).toLong(), val: (-9223372036854775808.0).toFloat() } + - { expr: (0x7FFFFFFFFFFFFFFF).toLong(), val: (9223372036854775807.0).toFloat() } - from_type: float to_type: Float values: - - { expr: +0.0 as float, val: +0.0 as float } - - { expr: -0.0 as float, val: -0.0 as float } + - { expr: (+0.0).toFloat(), val: (+0.0).toFloat() } + - { expr: (-0.0).toFloat(), val: (-0.0).toFloat() } - { expr: Float.MIN_VALUE, val: Float.MIN_VALUE } - { expr: Float.MAX_VALUE, val: Float.MAX_VALUE } - { expr: Float.NEGATIVE_INFINITY, val: Float.NEGATIVE_INFINITY } @@ -174,67 +174,67 @@ cases: - from_type: char to_type: Float values: - - { expr: "c'\\u0000'", val: 0.0 as float } - - { expr: "c'\\u007F'", val: 127.0 as float } - - { expr: "c'\\u8000'", val: 32768.0 as float } - - { expr: "c'\\uFF80'", val: 65408.0 as float } - - { expr: "c'\\uFFFF'", val: 65535.0 as float } + - { expr: "c'\\u0000'", val: (0.0).toFloat() } + - { expr: "c'\\u007F'", val: (127.0).toFloat() } + - { expr: "c'\\u8000'", val: (32768.0).toFloat() } + - { expr: "c'\\uFF80'", val: (65408.0).toFloat() } + - { expr: "c'\\uFFFF'", val: (65535.0).toFloat() } - from_type: byte to_type: Double values: - - { expr: 0 as byte, val: 0.0 } - - { expr: 0x7F as byte, val: 127.0 } - - { expr: 0x80 as byte, val: -128.0 } + - { expr: (0).toByte(), val: 0.0 } + - { expr: (0x7F).toByte(), val: 127.0 } + - { expr: (0x80).toByte(), val: -128.0 } - from_type: short to_type: Double values: - - { expr: 0 as short, val: 0.0 as double } - - { expr: 0x007F as short, val: 127.0 as double } - - { expr: 0xFF80 as short, val: -128.0 as double } - - { expr: 0x7FFF as short, val: 32767.0 as double } - - { expr: 0x8000 as short, val: -32768.0 as double } + - { expr: (0).toShort(), val: (0.0).toDouble() } + - { expr: (0x007F).toShort(), val: (127.0).toDouble() } + - { expr: (0xFF80).toShort(), val: (-128.0).toDouble() } + - { expr: (0x7FFF).toShort(), val: (32767.0).toDouble() } + - { expr: (0x8000).toShort(), val: (-32768.0).toDouble() } - from_type: int to_type: Double values: - - { expr: 0 as int, val: 0.0 as double } - - { expr: 0x0000007F as int, val: 127.0 as double } - - { expr: 0xFFFFFF80 as int, val: -128.0 as double } - - { expr: 0x00007FFF as int, val: 32767.0 as double } - - { expr: 0xFFFF8000 as int, val: -32768.0 as double } - - { expr: 0x7FFFFFFF as int, val: 2147483647.0 as double } - - { expr: 0x80000000 as int, val: -2147483648.0 as double } + - { expr: (0).toInt(), val: (0.0).toDouble() } + - { expr: (0x0000007F).toInt(), val: (127.0).toDouble() } + - { expr: (0xFFFFFF80).toInt(), val: (-128.0).toDouble() } + - { expr: (0x00007FFF).toInt(), val: (32767.0).toDouble() } + - { expr: (0xFFFF8000).toInt(), val: (-32768.0).toDouble() } + - { expr: (0x7FFFFFFF).toInt(), val: (2147483647.0).toDouble() } + - { expr: (0x80000000).toInt(), val: (-2147483648.0).toDouble() } - from_type: long to_type: Double values: - - { expr: 0 as long, val: 0 } - - { expr: 0x000000000000007F as long, val: 127.0 as double } - - { expr: 0xFFFFFFFFFFFFFF80 as long, val: -128.0 as double } - - { expr: 0x0000000000007FFF as long, val: 32767.0 as double } - - { expr: 0xFFFFFFFFFFFF8000 as long, val: -32768.0 as double } - - { expr: 0x000000007FFFFFFF as long, val: 2147483647.0 as double } - - { expr: 0xFFFFFFFF80000000 as long, val: -2147483648.0 as double } - - { expr: 0x8000000000000000 as long, val: -9223372036854775808.0 as double } - - { expr: 0x7FFFFFFFFFFFFFFF as long, val: 9223372036854775807.0 as double } + - { expr: (0).toLong(), val: 0 } + - { expr: (0x000000000000007F).toLong(), val: (127.0).toDouble() } + - { expr: (0xFFFFFFFFFFFFFF80).toLong(), val: (-128.0).toDouble() } + - { expr: (0x0000000000007FFF).toLong(), val: (32767.0).toDouble() } + - { expr: (0xFFFFFFFFFFFF8000).toLong(), val: (-32768.0).toDouble() } + - { expr: (0x000000007FFFFFFF).toLong(), val: (2147483647.0).toDouble() } + - { expr: (0xFFFFFFFF80000000).toLong(), val: (-2147483648.0).toDouble() } + - { expr: (0x8000000000000000).toLong(), val: (-9223372036854775808.0).toDouble() } + - { expr: (0x7FFFFFFFFFFFFFFF).toLong(), val: (9223372036854775807.0).toDouble() } - from_type: float to_type: Double values: - - { expr: +0.0 as float, val: +0.0 as double } - - { expr: -0.0 as float, val: -0.0 as double } - - { expr: Float.MIN_VALUE, val: Float.MIN_VALUE as double} - - { expr: Float.MAX_VALUE, val: Float.MAX_VALUE as double } - - { expr: Float.NEGATIVE_INFINITY, val: Float.NEGATIVE_INFINITY as double } - - { expr: Float.POSITIVE_INFINITY, val: Float.POSITIVE_INFINITY as double } + - { expr: (+0.0).toFloat(), val: (+0.0).toDouble() } + - { expr: (-0.0).toFloat(), val: (-0.0).toDouble() } + - { expr: Float.MIN_VALUE, val: (Float.MIN_VALUE).toDouble()} + - { expr: Float.MAX_VALUE, val: (Float.MAX_VALUE).toDouble() } + - { expr: Float.NEGATIVE_INFINITY, val: (Float.NEGATIVE_INFINITY).toDouble() } + - { expr: Float.POSITIVE_INFINITY, val: (Float.POSITIVE_INFINITY).toDouble() } - from_type: double to_type: Double values: - - { expr: '+0.0', val: +0.0 as double } - - { expr: '-0.0', val: -0.0 as double } + - { expr: '+0.0', val: (+0.0).toDouble() } + - { expr: '-0.0', val: (-0.0).toDouble() } - { expr: Double.MIN_VALUE, val: Double.MIN_VALUE } - { expr: Double.MAX_VALUE, val: Double.MAX_VALUE } - { expr: Double.NEGATIVE_INFINITY, val: Double.NEGATIVE_INFINITY } @@ -243,17 +243,17 @@ cases: - from_type: char to_type: Double values: - - { expr: "c'\\u0000'", val: 0.0 as double } - - { expr: "c'\\u007F'", val: 127.0 as double } - - { expr: "c'\\u8000'", val: 32768.0 as double } - - { expr: "c'\\uFF80'", val: 65408.0 as double } - - { expr: "c'\\uFFFF'", val: 65535.0 as double } + - { expr: "c'\\u0000'", val: (0.0).toDouble() } + - { expr: "c'\\u007F'", val: (127.0).toDouble() } + - { expr: "c'\\u8000'", val: (32768.0).toDouble() } + - { expr: "c'\\uFF80'", val: (65408.0).toDouble() } + - { expr: "c'\\uFFFF'", val: (65535.0).toDouble() } - from_type: number to_type: Number values: - - { expr: '+0.0', val: +0.0 as number } - - { expr: '-0.0', val: -0.0 as number } + - { expr: '+0.0', val: +0.0 } + - { expr: '-0.0', val: -0.0 } - { expr: Number.MIN_VALUE, val: Number.MIN_VALUE } - { expr: Number.MAX_VALUE, val: Number.MAX_VALUE } - { expr: Number.NEGATIVE_INFINITY, val: Number.NEGATIVE_INFINITY } @@ -262,9 +262,9 @@ cases: - from_type: byte to_type: Char values: - - { expr: 0 as byte, val: "c'\\u0000'" } - - { expr: 127 as byte, val: "c'\\u007F'" } - - { expr: -128 as byte, val: "c'\\uFF80'" } + - { expr: (0).toByte(), val: "c'\\u0000'" } + - { expr: (127).toByte(), val: "c'\\u007F'" } + - { expr: (-128).toByte(), val: "c'\\uFF80'" } - from_type: char to_type: Char diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/call_func/call-func.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/call_func/call-func.params.yaml index 99b4f8ee31f2bfb7935770cea71494fdc8b2f846..062ff7564ed980d1cf54a8be50b3efc5d0a5728d 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/call_func/call-func.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/call_func/call-func.params.yaml @@ -225,10 +225,10 @@ cases: values: - { expr: +0.0 as float, val: +0.0 as double } - { expr: -0.0 as float, val: -0.0 as double } - - { expr: Float.MIN_VALUE, val: Float.MIN_VALUE as double} - - { expr: Float.MAX_VALUE, val: Float.MAX_VALUE as double } - - { expr: Float.NEGATIVE_INFINITY, val: Float.NEGATIVE_INFINITY as double } - - { expr: Float.POSITIVE_INFINITY, val: Float.POSITIVE_INFINITY as double } + - { expr: Float.MIN_VALUE, val: Float.MIN_VALUE.toDouble() } + - { expr: Float.MAX_VALUE, val: Float.MAX_VALUE.toDouble() } + - { expr: Float.NEGATIVE_INFINITY, val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: Float.POSITIVE_INFINITY, val: Float.POSITIVE_INFINITY.toDouble() } - from_type: double to_type: Double diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/call_lmbd/call-lmbd.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/call_lmbd/call-lmbd.params.yaml index 99b4f8ee31f2bfb7935770cea71494fdc8b2f846..e075d34d39c4148a20b3c1125c23d4a09e454f9d 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/call_lmbd/call-lmbd.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/call_lmbd/call-lmbd.params.yaml @@ -16,52 +16,52 @@ cases: - from_type: byte to_type: Byte values: - - { expr: 0 as byte, val: 0 } - - { expr: 0x7F as byte, val: 127 } - - { expr: 0x80 as byte, val: -128 } + - { expr: (0).toByte(), val: 0 } + - { expr: (0x7F).toByte(), val: 127 } + - { expr: (0x80).toByte(), val: -128 } - from_type: byte to_type: Short values: - - { expr: 0 as byte, val: 0 } - - { expr: 0x7F as byte, val: 127 } - - { expr: 0x80 as byte, val: -128 } + - { expr: (0).toByte(), val: 0 } + - { expr: (0x7F).toByte(), val: 127 } + - { expr: (0x80).toByte(), val: -128 } - from_type: short to_type: Short values: - - { expr: 0 as short, val: 0 } - - { expr: 0x007F as short, val: 127 } - - { expr: 0xFF80 as short, val: -128 } - - { expr: 0x7FFF as short, val: 32767 } - - { expr: 0x8000 as short, val: -32768 } + - { expr: (0).toShort(), val: 0 } + - { expr: (0x007F).toShort(), val: 127 } + - { expr: (0xFF80).toShort(), val: -128 } + - { expr: (0x7FFF).toShort(), val: 32767 } + - { expr: (0x8000).toShort(), val: -32768 } - from_type: byte to_type: Int values: - - { expr: 0 as byte, val: 0 } - - { expr: 0x7F as byte, val: 127 } - - { expr: 0x80 as byte, val: -128 } + - { expr: (0).toByte(), val: 0 } + - { expr: (0x7F).toByte(), val: 127 } + - { expr: (0x80).toByte(), val: -128 } - from_type: short to_type: Int values: - - { expr: 0 as short, val: 0 } - - { expr: 0x007F as short, val: 127 } - - { expr: 0xFF80 as short, val: -128 } - - { expr: 0x7FFF as short, val: 32767 } - - { expr: 0x8000 as short, val: -32768 } + - { expr: (0).toShort(), val: 0 } + - { expr: (0x007F).toShort(), val: 127 } + - { expr: (0xFF80).toShort(), val: -128 } + - { expr: (0x7FFF).toShort(), val: 32767 } + - { expr: (0x8000).toShort(), val: -32768 } - from_type: int to_type: Int values: - - { expr: 0 as int, val: 0 } - - { expr: 0x0000007F as int, val: 127 } - - { expr: 0xFFFFFF80 as int, val: -128 } - - { expr: 0x00007FFF as int, val: 32767 } - - { expr: 0xFFFF8000 as int, val: -32768 } - - { expr: 0x7FFFFFFF as int, val: 2147483647 } - - { expr: 0x80000000 as int, val: -2147483648 } + - { expr: (0).toInt(), val: 0 } + - { expr: (0x0000007F).toInt(), val: 127 } + - { expr: (0xFFFFFF80).toInt(), val: -128 } + - { expr: (0x00007FFF).toInt(), val: 32767 } + - { expr: (0xFFFF8000).toInt(), val: -32768 } + - { expr: (0x7FFFFFFF).toInt(), val: 2147483647 } + - { expr: (0x80000000).toInt(), val: -2147483648 } - from_type: char to_type: Int @@ -75,42 +75,42 @@ cases: - from_type: byte to_type: Long values: - - { expr: 0 as byte, val: 0 } - - { expr: 0x7F as byte, val: 127 } - - { expr: 0x80 as byte, val: -128 } + - { expr: (0).toByte(), val: 0 } + - { expr: (0x7F).toByte(), val: 127 } + - { expr: (0x80).toByte(), val: -128 } - from_type: short to_type: Long values: - - { expr: 0 as short, val: 0 } - - { expr: 0x007F as short, val: 127 } - - { expr: 0xFF80 as short, val: -128 } - - { expr: 0x7FFF as short, val: 32767 } - - { expr: 0x8000 as short, val: -32768 } + - { expr: (0).toShort(), val: 0 } + - { expr: (0x007F).toShort(), val: 127 } + - { expr: (0xFF80).toShort(), val: -128 } + - { expr: (0x7FFF).toShort(), val: 32767 } + - { expr: (0x8000).toShort(), val: -32768 } - from_type: int to_type: Long values: - - { expr: 0 as int, val: 0 } - - { expr: 0x0000007F as int, val: 127 } - - { expr: 0xFFFFFF80 as int, val: -128 } - - { expr: 0x00007FFF as int, val: 32767 } - - { expr: 0xFFFF8000 as int, val: -32768 } - - { expr: 0x7FFFFFFF as int, val: 2147483647 } - - { expr: 0x80000000 as int, val: -2147483648 } + - { expr: (0).toInt(), val: 0 } + - { expr: (0x0000007F).toInt(), val: 127 } + - { expr: (0xFFFFFF80).toInt(), val: -128 } + - { expr: (0x00007FFF).toInt(), val: 32767 } + - { expr: (0xFFFF8000).toInt(), val: -32768 } + - { expr: (0x7FFFFFFF).toInt(), val: 2147483647 } + - { expr: (0x80000000).toInt(), val: -2147483648 } - from_type: long to_type: Long values: - - { expr: 0 as long, val: 0 } - - { expr: 0x000000000000007F as long, val: 127 } - - { expr: 0xFFFFFFFFFFFFFF80 as long, val: -128 } - - { expr: 0x0000000000007FFF as long, val: 32767 } - - { expr: 0xFFFFFFFFFFFF8000 as long, val: -32768 } - - { expr: 0x000000007FFFFFFF as long, val: 2147483647 } - - { expr: 0xFFFFFFFF80000000 as long, val: -2147483648 } - - { expr: 0x8000000000000000 as long, val: -9223372036854775808 } - - { expr: 0x7FFFFFFFFFFFFFFF as long, val: 9223372036854775807 } + - { expr: (0).toLong(), val: 0 } + - { expr: (0x000000000000007F).toLong(), val: 127 } + - { expr: (0xFFFFFFFFFFFFFF80).toLong(), val: -128 } + - { expr: (0x0000000000007FFF).toLong(), val: 32767 } + - { expr: (0xFFFFFFFFFFFF8000).toLong(), val: -32768 } + - { expr: (0x000000007FFFFFFF).toLong(), val: 2147483647 } + - { expr: (0xFFFFFFFF80000000).toLong(), val: -2147483648 } + - { expr: (0x8000000000000000).toLong(), val: -9223372036854775808 } + - { expr: (0x7FFFFFFFFFFFFFFF).toLong(), val: 9223372036854775807 } - from_type: char to_type: Long @@ -124,48 +124,48 @@ cases: - from_type: byte to_type: Float values: - - { expr: 0 as byte, val: 0.0 as float } - - { expr: 0x7F as byte, val: 127.0 as float } - - { expr: 0x80 as byte, val: -128.0 as float } + - { expr: (0).toByte(), val: (0.0).toFloat() } + - { expr: (0x7F).toByte(), val: (127.0).toFloat() } + - { expr: (0x80).toByte(), val: (-128.0).toFloat() } - from_type: short to_type: Float values: - - { expr: 0 as short, val: 0.0 as float } - - { expr: 0x007F as short, val: 127.0 as float } - - { expr: 0xFF80 as short, val: -128.0 as float } - - { expr: 0x7FFF as short, val: 32767.0 as float } - - { expr: 0x8000 as short, val: -32768.0 as float } + - { expr: (0).toShort(), val: (0.0).toFloat() } + - { expr: (0x007F).toShort(), val: (127.0).toFloat() } + - { expr: (0xFF80).toShort(), val: (-128.0).toFloat() } + - { expr: (0x7FFF).toShort(), val: (32767.0).toFloat() } + - { expr: (0x8000).toShort(), val: (-32768.0).toFloat() } - from_type: int to_type: Float values: - - { expr: 0 as int, val: 0 } - - { expr: 0x0000007F as int, val: 127.0 as float } - - { expr: 0xFFFFFF80 as int, val: -128.0 as float } - - { expr: 0x00007FFF as int, val: 32767.0 as float } - - { expr: 0xFFFF8000 as int, val: -32768.0 as float } - - { expr: 0x7FFFFFFF as int, val: 2147483647.0 as float } - - { expr: 0x80000000 as int, val: -2147483648.0 as float } + - { expr: (0).toInt(), val: 0 } + - { expr: (0x0000007F).toInt(), val: (127.0).toFloat() } + - { expr: (0xFFFFFF80).toInt(), val: (-128.0).toFloat() } + - { expr: (0x00007FFF).toInt(), val: (32767.0).toFloat() } + - { expr: (0xFFFF8000).toInt(), val: (-32768.0).toFloat() } + - { expr: (0x7FFFFFFF).toInt(), val: (2147483647.0).toFloat() } + - { expr: (0x80000000).toInt(), val: (-2147483648.0).toFloat() } - from_type: long to_type: Float values: - - { expr: 0 as long, val: 0 } - - { expr: 0x000000000000007F as long, val: 127.0 as float } - - { expr: 0xFFFFFFFFFFFFFF80 as long, val: -128.0 as float } - - { expr: 0x0000000000007FFF as long, val: 32767.0 as float } - - { expr: 0xFFFFFFFFFFFF8000 as long, val: -32768.0 as float } - - { expr: 0x000000007FFFFFFF as long, val: 2147483647.0 as float } - - { expr: 0xFFFFFFFF80000000 as long, val: -2147483648.0 as float } - - { expr: 0x8000000000000000 as long, val: -9223372036854775808.0 as float } - - { expr: 0x7FFFFFFFFFFFFFFF as long, val: 9223372036854775807.0 as float } + - { expr: (0).toLong(), val: 0 } + - { expr: (0x000000000000007F).toLong(), val: (127.0).toFloat() } + - { expr: (0xFFFFFFFFFFFFFF80).toLong(), val: (-128.0).toFloat() } + - { expr: (0x0000000000007FFF).toLong(), val: (32767.0).toFloat() } + - { expr: (0xFFFFFFFFFFFF8000).toLong(), val: (-32768.0).toFloat() } + - { expr: (0x000000007FFFFFFF).toLong(), val: (2147483647.0).toFloat() } + - { expr: (0xFFFFFFFF80000000).toLong(), val: (-2147483648.0).toFloat() } + - { expr: (0x8000000000000000).toLong(), val: (-9223372036854775808.0).toFloat() } + - { expr: (0x7FFFFFFFFFFFFFFF).toLong(), val: (9223372036854775807.0).toFloat() } - from_type: float to_type: Float values: - - { expr: +0.0 as float, val: +0.0 as float } - - { expr: -0.0 as float, val: -0.0 as float } + - { expr: (+0.0).toFloat(), val: (+0.0).toFloat() } + - { expr: (-0.0).toFloat(), val: (-0.0).toFloat() } - { expr: Float.MIN_VALUE, val: Float.MIN_VALUE } - { expr: Float.MAX_VALUE, val: Float.MAX_VALUE } - { expr: Float.NEGATIVE_INFINITY, val: Float.NEGATIVE_INFINITY } @@ -174,67 +174,67 @@ cases: - from_type: char to_type: Float values: - - { expr: "c'\\u0000'", val: 0.0 as float } - - { expr: "c'\\u007F'", val: 127.0 as float } - - { expr: "c'\\u8000'", val: 32768.0 as float } - - { expr: "c'\\uFF80'", val: 65408.0 as float } - - { expr: "c'\\uFFFF'", val: 65535.0 as float } + - { expr: "c'\\u0000'", val: (0.0).toFloat() } + - { expr: "c'\\u007F'", val: (127.0).toFloat() } + - { expr: "c'\\u8000'", val: (32768.0).toFloat() } + - { expr: "c'\\uFF80'", val: (65408.0).toFloat() } + - { expr: "c'\\uFFFF'", val: (65535.0).toFloat() } - from_type: byte to_type: Double values: - - { expr: 0 as byte, val: 0.0 } - - { expr: 0x7F as byte, val: 127.0 } - - { expr: 0x80 as byte, val: -128.0 } + - { expr: (0).toByte(), val: 0.0 } + - { expr: (0x7F).toByte(), val: 127.0 } + - { expr: (0x80).toByte(), val: -128.0 } - from_type: short to_type: Double values: - - { expr: 0 as short, val: 0.0 as double } - - { expr: 0x007F as short, val: 127.0 as double } - - { expr: 0xFF80 as short, val: -128.0 as double } - - { expr: 0x7FFF as short, val: 32767.0 as double } - - { expr: 0x8000 as short, val: -32768.0 as double } + - { expr: (0).toShort(), val: (0.0).toDouble() } + - { expr: (0x007F).toShort(), val: (127.0).toDouble() } + - { expr: (0xFF80).toShort(), val: (-128.0).toDouble() } + - { expr: (0x7FFF).toShort(), val: (32767.0).toDouble() } + - { expr: (0x8000).toShort(), val: (-32768.0).toDouble() } - from_type: int to_type: Double values: - - { expr: 0 as int, val: 0.0 as double } - - { expr: 0x0000007F as int, val: 127.0 as double } - - { expr: 0xFFFFFF80 as int, val: -128.0 as double } - - { expr: 0x00007FFF as int, val: 32767.0 as double } - - { expr: 0xFFFF8000 as int, val: -32768.0 as double } - - { expr: 0x7FFFFFFF as int, val: 2147483647.0 as double } - - { expr: 0x80000000 as int, val: -2147483648.0 as double } + - { expr: (0).toInt(), val: (0.0).toDouble() } + - { expr: (0x0000007F).toInt(), val: (127.0).toDouble() } + - { expr: (0xFFFFFF80).toInt(), val: (-128.0).toDouble() } + - { expr: (0x00007FFF).toInt(), val: (32767.0).toDouble() } + - { expr: (0xFFFF8000).toInt(), val: (-32768.0).toDouble() } + - { expr: (0x7FFFFFFF).toInt(), val: (2147483647.0).toDouble() } + - { expr: (0x80000000).toInt(), val: (-2147483648.0).toDouble() } - from_type: long to_type: Double values: - - { expr: 0 as long, val: 0 } - - { expr: 0x000000000000007F as long, val: 127.0 as double } - - { expr: 0xFFFFFFFFFFFFFF80 as long, val: -128.0 as double } - - { expr: 0x0000000000007FFF as long, val: 32767.0 as double } - - { expr: 0xFFFFFFFFFFFF8000 as long, val: -32768.0 as double } - - { expr: 0x000000007FFFFFFF as long, val: 2147483647.0 as double } - - { expr: 0xFFFFFFFF80000000 as long, val: -2147483648.0 as double } - - { expr: 0x8000000000000000 as long, val: -9223372036854775808.0 as double } - - { expr: 0x7FFFFFFFFFFFFFFF as long, val: 9223372036854775807.0 as double } + - { expr: (0).toLong(), val: 0 } + - { expr: (0x000000000000007F).toLong(), val: (127.0).toDouble() } + - { expr: (0xFFFFFFFFFFFFFF80).toLong(), val: (-128.0).toDouble() } + - { expr: (0x0000000000007FFF).toLong(), val: (32767.0).toDouble() } + - { expr: (0xFFFFFFFFFFFF8000).toLong(), val: (-32768.0).toDouble() } + - { expr: (0x000000007FFFFFFF).toLong(), val: (2147483647.0).toDouble() } + - { expr: (0xFFFFFFFF80000000).toLong(), val: (-2147483648.0).toDouble() } + - { expr: (0x8000000000000000).toLong(), val: (-9223372036854775808.0).toDouble() } + - { expr: (0x7FFFFFFFFFFFFFFF).toLong(), val: (9223372036854775807.0).toDouble() } - from_type: float to_type: Double values: - - { expr: +0.0 as float, val: +0.0 as double } - - { expr: -0.0 as float, val: -0.0 as double } - - { expr: Float.MIN_VALUE, val: Float.MIN_VALUE as double} - - { expr: Float.MAX_VALUE, val: Float.MAX_VALUE as double } - - { expr: Float.NEGATIVE_INFINITY, val: Float.NEGATIVE_INFINITY as double } - - { expr: Float.POSITIVE_INFINITY, val: Float.POSITIVE_INFINITY as double } + - { expr: (+0.0).toFloat(), val: (+0.0).toDouble() } + - { expr: (-0.0).toFloat(), val: (-0.0).toDouble() } + - { expr: Float.MIN_VALUE, val: (Float.MIN_VALUE).toDouble()} + - { expr: Float.MAX_VALUE, val: (Float.MAX_VALUE).toDouble() } + - { expr: Float.NEGATIVE_INFINITY, val: (Float.NEGATIVE_INFINITY).toDouble() } + - { expr: Float.POSITIVE_INFINITY, val: (Float.POSITIVE_INFINITY).toDouble() } - from_type: double to_type: Double values: - - { expr: '+0.0', val: +0.0 as double } - - { expr: '-0.0', val: -0.0 as double } + - { expr: '+0.0', val: (+0.0).toDouble() } + - { expr: '-0.0', val: (-0.0).toDouble() } - { expr: Double.MIN_VALUE, val: Double.MIN_VALUE } - { expr: Double.MAX_VALUE, val: Double.MAX_VALUE } - { expr: Double.NEGATIVE_INFINITY, val: Double.NEGATIVE_INFINITY } @@ -243,17 +243,17 @@ cases: - from_type: char to_type: Double values: - - { expr: "c'\\u0000'", val: 0.0 as double } - - { expr: "c'\\u007F'", val: 127.0 as double } - - { expr: "c'\\u8000'", val: 32768.0 as double } - - { expr: "c'\\uFF80'", val: 65408.0 as double } - - { expr: "c'\\uFFFF'", val: 65535.0 as double } + - { expr: "c'\\u0000'", val: (0.0).toDouble() } + - { expr: "c'\\u007F'", val: (127.0).toDouble() } + - { expr: "c'\\u8000'", val: (32768.0).toDouble() } + - { expr: "c'\\uFF80'", val: (65408.0).toDouble() } + - { expr: "c'\\uFFFF'", val: (65535.0).toDouble() } - from_type: number to_type: Number values: - - { expr: '+0.0', val: +0.0 as number } - - { expr: '-0.0', val: -0.0 as number } + - { expr: '+0.0', val: +0.0 } + - { expr: '-0.0', val: -0.0 } - { expr: Number.MIN_VALUE, val: Number.MIN_VALUE } - { expr: Number.MAX_VALUE, val: Number.MAX_VALUE } - { expr: Number.NEGATIVE_INFINITY, val: Number.NEGATIVE_INFINITY } @@ -262,9 +262,9 @@ cases: - from_type: byte to_type: Char values: - - { expr: 0 as byte, val: "c'\\u0000'" } - - { expr: 127 as byte, val: "c'\\u007F'" } - - { expr: -128 as byte, val: "c'\\uFF80'" } + - { expr: (0).toByte(), val: "c'\\u0000'" } + - { expr: (127).toByte(), val: "c'\\u007F'" } + - { expr: (-128).toByte(), val: "c'\\uFF80'" } - from_type: char to_type: Char diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/call_meth/call-meth.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/call_meth/call-meth.params.yaml index 99b4f8ee31f2bfb7935770cea71494fdc8b2f846..062ff7564ed980d1cf54a8be50b3efc5d0a5728d 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/call_meth/call-meth.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/call_meth/call-meth.params.yaml @@ -225,10 +225,10 @@ cases: values: - { expr: +0.0 as float, val: +0.0 as double } - { expr: -0.0 as float, val: -0.0 as double } - - { expr: Float.MIN_VALUE, val: Float.MIN_VALUE as double} - - { expr: Float.MAX_VALUE, val: Float.MAX_VALUE as double } - - { expr: Float.NEGATIVE_INFINITY, val: Float.NEGATIVE_INFINITY as double } - - { expr: Float.POSITIVE_INFINITY, val: Float.POSITIVE_INFINITY as double } + - { expr: Float.MIN_VALUE, val: Float.MIN_VALUE.toDouble() } + - { expr: Float.MAX_VALUE, val: Float.MAX_VALUE.toDouble() } + - { expr: Float.NEGATIVE_INFINITY, val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: Float.POSITIVE_INFINITY, val: Float.POSITIVE_INFINITY.toDouble() } - from_type: double to_type: Double diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/comp_arr/comp-arr.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/comp_arr/comp-arr.params.yaml index 99b4f8ee31f2bfb7935770cea71494fdc8b2f846..c221a6b9317ac27c07114a8ca7135de0249f5af2 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/comp_arr/comp-arr.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/comp_arr/comp-arr.params.yaml @@ -225,10 +225,10 @@ cases: values: - { expr: +0.0 as float, val: +0.0 as double } - { expr: -0.0 as float, val: -0.0 as double } - - { expr: Float.MIN_VALUE, val: Float.MIN_VALUE as double} - - { expr: Float.MAX_VALUE, val: Float.MAX_VALUE as double } - - { expr: Float.NEGATIVE_INFINITY, val: Float.NEGATIVE_INFINITY as double } - - { expr: Float.POSITIVE_INFINITY, val: Float.POSITIVE_INFINITY as double } + - { expr: Float.MIN_VALUE, val: Float.MIN_VALUE.toDouble()} + - { expr: Float.MAX_VALUE, val: Float.MAX_VALUE.toDouble() } + - { expr: Float.NEGATIVE_INFINITY, val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: Float.POSITIVE_INFINITY, val: Float.POSITIVE_INFINITY.toDouble() } - from_type: double to_type: Double diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/comp_obj/comp-clss.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/comp_obj/comp-clss.params.yaml index 0a671c37ff5e53e5be07361ac7f1afdf43a29b9b..47bc373e1db762a8456474080081f64999bbee19 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/comp_obj/comp-clss.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/comp_obj/comp-clss.params.yaml @@ -248,10 +248,10 @@ cases: values: - { expr: +0.0 as float, val: +0.0 as double } - { expr: -0.0 as float, val: -0.0 as double } - - { expr: Float.MIN_VALUE, val: Float.MIN_VALUE as double} - - { expr: Float.MAX_VALUE, val: Float.MAX_VALUE as double } - - { expr: Float.NEGATIVE_INFINITY, val: Float.NEGATIVE_INFINITY as double } - - { expr: Float.POSITIVE_INFINITY, val: Float.POSITIVE_INFINITY as double } + - { expr: Float.MIN_VALUE, val: Float.MIN_VALUE.toDouble() } + - { expr: Float.MAX_VALUE, val: Float.MAX_VALUE.toDouble() } + - { expr: Float.NEGATIVE_INFINITY, val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: Float.POSITIVE_INFINITY, val: Float.POSITIVE_INFINITY.toDouble() } - from_type: double to_type: Double diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/comp_obj/comp-intf.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/comp_obj/comp-intf.params.yaml index 99b4f8ee31f2bfb7935770cea71494fdc8b2f846..062ff7564ed980d1cf54a8be50b3efc5d0a5728d 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/comp_obj/comp-intf.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/comp_obj/comp-intf.params.yaml @@ -225,10 +225,10 @@ cases: values: - { expr: +0.0 as float, val: +0.0 as double } - { expr: -0.0 as float, val: -0.0 as double } - - { expr: Float.MIN_VALUE, val: Float.MIN_VALUE as double} - - { expr: Float.MAX_VALUE, val: Float.MAX_VALUE as double } - - { expr: Float.NEGATIVE_INFINITY, val: Float.NEGATIVE_INFINITY as double } - - { expr: Float.POSITIVE_INFINITY, val: Float.POSITIVE_INFINITY as double } + - { expr: Float.MIN_VALUE, val: Float.MIN_VALUE.toDouble() } + - { expr: Float.MAX_VALUE, val: Float.MAX_VALUE.toDouble() } + - { expr: Float.NEGATIVE_INFINITY, val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: Float.POSITIVE_INFINITY, val: Float.POSITIVE_INFINITY.toDouble() } - from_type: double to_type: Double diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/decl_const/decl-const.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/decl_const/decl-const.params.yaml index 99b4f8ee31f2bfb7935770cea71494fdc8b2f846..062ff7564ed980d1cf54a8be50b3efc5d0a5728d 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/decl_const/decl-const.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/decl_const/decl-const.params.yaml @@ -225,10 +225,10 @@ cases: values: - { expr: +0.0 as float, val: +0.0 as double } - { expr: -0.0 as float, val: -0.0 as double } - - { expr: Float.MIN_VALUE, val: Float.MIN_VALUE as double} - - { expr: Float.MAX_VALUE, val: Float.MAX_VALUE as double } - - { expr: Float.NEGATIVE_INFINITY, val: Float.NEGATIVE_INFINITY as double } - - { expr: Float.POSITIVE_INFINITY, val: Float.POSITIVE_INFINITY as double } + - { expr: Float.MIN_VALUE, val: Float.MIN_VALUE.toDouble() } + - { expr: Float.MAX_VALUE, val: Float.MAX_VALUE.toDouble() } + - { expr: Float.NEGATIVE_INFINITY, val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: Float.POSITIVE_INFINITY, val: Float.POSITIVE_INFINITY.toDouble() } - from_type: double to_type: Double diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/decl_field/decl-field.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/decl_field/decl-field.params.yaml index 99b4f8ee31f2bfb7935770cea71494fdc8b2f846..062ff7564ed980d1cf54a8be50b3efc5d0a5728d 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/decl_field/decl-field.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/decl_field/decl-field.params.yaml @@ -225,10 +225,10 @@ cases: values: - { expr: +0.0 as float, val: +0.0 as double } - { expr: -0.0 as float, val: -0.0 as double } - - { expr: Float.MIN_VALUE, val: Float.MIN_VALUE as double} - - { expr: Float.MAX_VALUE, val: Float.MAX_VALUE as double } - - { expr: Float.NEGATIVE_INFINITY, val: Float.NEGATIVE_INFINITY as double } - - { expr: Float.POSITIVE_INFINITY, val: Float.POSITIVE_INFINITY as double } + - { expr: Float.MIN_VALUE, val: Float.MIN_VALUE.toDouble() } + - { expr: Float.MAX_VALUE, val: Float.MAX_VALUE.toDouble() } + - { expr: Float.NEGATIVE_INFINITY, val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: Float.POSITIVE_INFINITY, val: Float.POSITIVE_INFINITY.toDouble() } - from_type: double to_type: Double diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/decl_var/decl-var-neg.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/decl_var/decl-var-neg.params.yaml index 5281a647dd239aceea93eb2ea2b48d61b24a5183..dbef613db82a30726bede9bb88d5791518225a85 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/decl_var/decl-var-neg.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/decl_var/decl-var-neg.params.yaml @@ -21,38 +21,38 @@ cases: - { from_type: boolean, to_type: Double, expr: 'true' } - { from_type: boolean, to_type: Char, expr: 'true' } - - { from_type: byte, to_type: Boolean, expr: 127 as byte } - - { from_type: short, to_type: Boolean, expr: 32767 as byte } - - { from_type: int, to_type: Boolean, expr: 2147483647 as int } - - { from_type: long, to_type: Boolean, expr: 9223372036854775807 as long } - - { from_type: float, to_type: Boolean, expr: -1.111 as float } - - { from_type: double, to_type: Boolean, expr: -2.222 as double } + - { from_type: byte, to_type: Boolean, expr: (127).toByte() } + - { from_type: short, to_type: Boolean, expr: (32767).toByte() } + - { from_type: int, to_type: Boolean, expr: (2147483647).toInt() } + - { from_type: long, to_type: Boolean, expr: (9223372036854775807).toLong() } + - { from_type: float, to_type: Boolean, expr: (-1.111).toFloat() } + - { from_type: double, to_type: Boolean, expr: (-2.222).toDouble() } - { from_type: char, to_type: Boolean, expr: "c'\\uCAFE'" } - - { from_type: short, to_type: Byte, expr: 32767 as byte } - - { from_type: int, to_type: Byte, expr: 2147483647 as int } - - { from_type: long, to_type: Byte, expr: 9223372036854775807 as long } - - { from_type: float, to_type: Byte, expr: -1.111 as float } - - { from_type: double, to_type: Byte, expr: -2.222 as double } + - { from_type: short, to_type: Byte, expr: (32767).toByte() } + - { from_type: int, to_type: Byte, expr: (2147483647).toInt() } + - { from_type: long, to_type: Byte, expr: (9223372036854775807).toLong() } + - { from_type: float, to_type: Byte, expr: (-1.111).toFloat() } + - { from_type: double, to_type: Byte, expr: (-2.222).toDouble() } - { from_type: char, to_type: Byte, expr: "c'\\uCAFE'" } - - { from_type: int, to_type: Short, expr: 2147483647 as int } - - { from_type: long, to_type: Short, expr: 9223372036854775807 as long } - - { from_type: float, to_type: Short, expr: -1.111 as float } - - { from_type: double, to_type: Short, expr: -2.222 as double } + - { from_type: int, to_type: Short, expr: (2147483647).toInt() } + - { from_type: long, to_type: Short, expr: (9223372036854775807).toLong() } + - { from_type: float, to_type: Short, expr: (-1.111).toFloat() } + - { from_type: double, to_type: Short, expr: (-2.222).toDouble() } - { from_type: char, to_type: Short, expr: "c'\\uCAFE'" } - - { from_type: long, to_type: Int, expr: 9223372036854775807 as long } - - { from_type: float, to_type: Int, expr: -1.111 as float } - - { from_type: double, to_type: Int, expr: -2.222 as double } + - { from_type: long, to_type: Int, expr: (9223372036854775807).toLong() } + - { from_type: float, to_type: Int, expr: (-1.111).toFloat() } + - { from_type: double, to_type: Int, expr: (-2.222).toDouble() } - - { from_type: float, to_type: Long, expr: -1.111 as float } - - { from_type: double, to_type: Long, expr: -2.222 as double } + - { from_type: float, to_type: Long, expr: (-1.111).toFloat() } + - { from_type: double, to_type: Long, expr: (-2.222).toDouble() } - - { from_type: double, to_type: Float, expr: -2.222 as double } + - { from_type: double, to_type: Float, expr: (-2.222).toDouble() } - - { from_type: short, to_type: Char, expr: 32767 as byte } - - { from_type: int, to_type: Char, expr: 2147483647 as int } - - { from_type: long, to_type: Char, expr: 9223372036854775807 as long } - - { from_type: float, to_type: Char, expr: -1.111 as float } - - { from_type: double, to_type: Char, expr: -2.222 as double } + - { from_type: short, to_type: Char, expr: (32767).toByte() } + - { from_type: int, to_type: Char, expr: (2147483647).toInt() } + - { from_type: long, to_type: Char, expr: (9223372036854775807).toLong() } + - { from_type: float, to_type: Char, expr: (-1.111).toFloat() } + - { from_type: double, to_type: Char, expr: (-2.222).toDouble() } diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/decl_var/decl-var.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/decl_var/decl-var.params.yaml index 99b4f8ee31f2bfb7935770cea71494fdc8b2f846..062ff7564ed980d1cf54a8be50b3efc5d0a5728d 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/decl_var/decl-var.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_conversion/decl_var/decl-var.params.yaml @@ -225,10 +225,10 @@ cases: values: - { expr: +0.0 as float, val: +0.0 as double } - { expr: -0.0 as float, val: -0.0 as double } - - { expr: Float.MIN_VALUE, val: Float.MIN_VALUE as double} - - { expr: Float.MAX_VALUE, val: Float.MAX_VALUE as double } - - { expr: Float.NEGATIVE_INFINITY, val: Float.NEGATIVE_INFINITY as double } - - { expr: Float.POSITIVE_INFINITY, val: Float.POSITIVE_INFINITY as double } + - { expr: Float.MIN_VALUE, val: Float.MIN_VALUE.toDouble() } + - { expr: Float.MAX_VALUE, val: Float.MAX_VALUE.toDouble() } + - { expr: Float.NEGATIVE_INFINITY, val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: Float.POSITIVE_INFINITY, val: Float.POSITIVE_INFINITY.toDouble() } - from_type: double to_type: Double diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/assn_var/assn-var.ets b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/assn_var/assn-var.ets index 526187b27bf5b34d226955ff5930e6f32f3414f8..ad220bed04dfdec39a80f0be602be39465421ee7 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/assn_var/assn-var.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/assn_var/assn-var.ets @@ -22,14 +22,11 @@ params: from {{c.from_type}} to {{c.to_type}} let d{{loop.index}}: {{c.to_type}} {%- endfor %} -function main(): int { +function main() { {%- for t in c['values'] %} let s{{loop.index}}: {{c.from_type}} = {{t.expr|safe}} d{{loop.index}} = s{{loop.index}} - if (d{{loop.index}} != {{t.val}}) { - return 1 - } + assertEQ(d{{loop.index}}, {{t.val}}, "Assert fails on item {{loop.index}}") {%- endfor %} - return 0 } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/assn_var/assn-var.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/assn_var/assn-var.params.yaml index ea52b4d29e003d7a2e75a9d1f5f9bdca46bebfa8..2cec623ad19cac71cd545202f2859e450b8eaba5 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/assn_var/assn-var.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/assn_var/assn-var.params.yaml @@ -17,50 +17,50 @@ cases: to_type: byte values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: short values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: int values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: long values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: float values: - - { expr: new Byte(), val: 0.0 as float } - - { expr: new Byte(127 as byte), val: 127.0 as float } - - { expr: new Byte(-128 as byte), val: -128.0 as float } + - { expr: new Byte(), val: 0.0f } + - { expr: new Byte(127), val: 127.0f } + - { expr: new Byte(-128), val: -128.0f } - from_type: Byte to_type: double values: - { expr: new Byte(), val: 0.0 } - - { expr: new Byte(127 as byte), val: 127.0 } - - { expr: new Byte(-128 as byte), val: -128.0 } + - { expr: new Byte(127), val: 127.0 } + - { expr: new Byte(-128), val: -128.0 } - from_type: Short to_type: short values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -68,8 +68,8 @@ cases: to_type: int values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -77,8 +77,8 @@ cases: to_type: long values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -86,17 +86,17 @@ cases: to_type: float values: - { expr: new Short(), val: 0.0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128.0 as float } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127.0 as float } - - { expr: new Short(Short.MIN_VALUE), val: -32768.0 as float } - - { expr: new Short(Short.MAX_VALUE), val: 32767.0 as float } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128.0f } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127.0f } + - { expr: new Short(Short.MIN_VALUE), val: -32768.0f } + - { expr: new Short(Short.MAX_VALUE), val: 32767.0f } - from_type: Short to_type: double values: - { expr: new Short(), val: 0.0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -104,10 +104,10 @@ cases: to_type: int values: - { expr: new Int(), val: 0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647 } @@ -115,10 +115,10 @@ cases: to_type: long values: - { expr: new Int(), val: 0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647 } @@ -126,21 +126,21 @@ cases: to_type: float values: - { expr: new Int(), val: 0.0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128.0 as float } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127.0 as float } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768.0 as float } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767.0 as float } - - { expr: new Int(Int.MIN_VALUE), val: -2147483600.0 as float } # loss of precision - - { expr: new Int(Int.MAX_VALUE), val: 2147483600.0 as float } # loss of precision + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128.0f } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127.0f } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768.0f } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767.0f } + - { expr: new Int(Int.MIN_VALUE), val: -2147483600.0f } # loss of precision + - { expr: new Int(Int.MAX_VALUE), val: 2147483600.0f } # loss of precision - from_type: Int to_type: double values: - { expr: new Int(), val: 0.0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128.0 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127.0 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768.0 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767.0 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128.0 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127.0 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768.0 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767.0 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648.0 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647.0 } @@ -148,12 +148,12 @@ cases: to_type: long values: - { expr: new Long(), val: 0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128 } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127 } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768 } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767 } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483648 } - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483647 } + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128 } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127 } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768 } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767 } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483648 } + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483647 } - { expr: new Long(Long.MIN_VALUE), val: -9223372036854775808 } - { expr: new Long(Long.MAX_VALUE), val: 9223372036854775807 } @@ -161,85 +161,85 @@ cases: to_type: float values: - { expr: new Long(), val: 0.0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128.0 as float } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127.0 as float } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768.0 as float } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767.0 as float } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483600.0 as float } # loss of precision - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483600.0 as float } # loss of precision - - { expr: new Long(Long.MIN_VALUE), val: -9223372000000000000.0 as float } # loss of precision - - { expr: new Long(Long.MAX_VALUE), val: 9223372000000000000.0 as float } # loss of precision + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128.0f } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127.0f } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768.0f } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767.0f } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483600.0f } # loss of precision + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483600.0f } # loss of precision + - { expr: new Long(Long.MIN_VALUE), val: -9223372000000000000.0f } # loss of precision + - { expr: new Long(Long.MAX_VALUE), val: 9223372000000000000.0f } # loss of precision - from_type: Long to_type: double values: - { expr: new Long(), val: 0.0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128.0 } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127.0 } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768.0 } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767.0 } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483648.0 } - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483647.0 } + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128.0 } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127.0 } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768.0 } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767.0 } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483648.0 } + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483647.0 } - { expr: new Long(Long.MIN_VALUE), val: -9223372036854775808.0 } - { expr: new Long(Long.MAX_VALUE), val: 9223372036854775807.0 } - from_type: Float to_type: float values: - - { expr: new Float(+0.0 as float), val: +0.0 as float } - - { expr: new Float(-0.0 as float), val: -0.0 as float } - - { expr: new Float(Byte.MIN_VALUE as float), val: -128.0 as float } - - { expr: new Float(Byte.MAX_VALUE as float), val: 127.0 as float } - - { expr: new Float(Short.MIN_VALUE as float), val: -32768.0 as float } - - { expr: new Float(Short.MAX_VALUE as float), val: 32767.0 as float } - - { expr: new Float(Int.MIN_VALUE as float), val: -2.14748365E9 as float } # loss of precision - - { expr: new Float(Int.MAX_VALUE as float), val: 2.14748365E9 as float } # loss of precision - - { expr: new Float(Long.MIN_VALUE as float), val: -9.223372E18 as float } # loss of precision - - { expr: new Float(Long.MAX_VALUE as float), val: 9.223372E18 as float } # loss of precision - - { expr: new Float(Float.MIN_VALUE), val: 1.4E-45 as float } - - { expr: new Float(Float.MAX_VALUE), val: 3.4028235E38 as float } - - { expr: new Float(Float.NEGATIVE_INFINITY as float), val: Float.NEGATIVE_INFINITY } - - { expr: new Float(Float.POSITIVE_INFINITY as float), val: Float.POSITIVE_INFINITY } + - { expr: new Float(+0.0f), val: +0.0f } + - { expr: new Float(-0.0f), val: -0.0f } + - { expr: new Float(Byte.MIN_VALUE.toFloat()), val: -128.0f } + - { expr: new Float(Byte.MAX_VALUE.toFloat()), val: 127.0f } + - { expr: new Float(Short.MIN_VALUE.toFloat()), val: -32768.0f } + - { expr: new Float(Short.MAX_VALUE.toFloat()), val: 32767.0f } + - { expr: new Float(Int.MIN_VALUE.toFloat()), val: -2.14748365E9f } # loss of precision + - { expr: new Float(Int.MAX_VALUE.toFloat()), val: 2.14748365E9f } # loss of precision + - { expr: new Float(Long.MIN_VALUE.toFloat()), val: -9.223372E18f } # loss of precision + - { expr: new Float(Long.MAX_VALUE.toFloat()), val: 9.223372E18f } # loss of precision + - { expr: new Float(Float.MIN_VALUE), val: 1.4E-45f } + - { expr: new Float(Float.MAX_VALUE), val: 3.4028235E38f } + - { expr: new Float(Float.NEGATIVE_INFINITY.toFloat()), val: Float.NEGATIVE_INFINITY } + - { expr: new Float(Float.POSITIVE_INFINITY.toFloat()), val: Float.POSITIVE_INFINITY } - from_type: Float to_type: double values: - - { expr: new Float(+0.0 as float), val: +0.0 } - - { expr: new Float(-0.0 as float), val: -0.0 } - - { expr: new Float(Byte.MIN_VALUE as float), val: -128.0 } - - { expr: new Float(Byte.MAX_VALUE as float), val: 127.0 } - - { expr: new Float(Short.MIN_VALUE as float), val: -32768.0 } - - { expr: new Float(Short.MAX_VALUE as float), val: 32767.0 } - - { expr: new Float(Int.MIN_VALUE as float), val: -2.147483648E9 } # loss of precision - - { expr: new Float(Int.MAX_VALUE as float), val: 2.147483648E9 } # loss of precision - - { expr: new Float(Long.MIN_VALUE as float), val: -9.223372036854776E18 } # loss of precision - - { expr: new Float(Long.MAX_VALUE as float), val: 9.223372036854776E18 } # loss of precision + - { expr: new Float(+0.0f), val: +0.0 } + - { expr: new Float(-0.0f), val: -0.0 } + - { expr: new Float(Byte.MIN_VALUE.toFloat()), val: -128.0 } + - { expr: new Float(Byte.MAX_VALUE.toFloat()), val: 127.0 } + - { expr: new Float(Short.MIN_VALUE.toFloat()), val: -32768.0 } + - { expr: new Float(Short.MAX_VALUE.toFloat()), val: 32767.0 } + - { expr: new Float(Int.MIN_VALUE.toFloat()), val: -2.147483648E9 } # loss of precision + - { expr: new Float(Int.MAX_VALUE.toFloat()), val: 2.147483648E9 } # loss of precision + - { expr: new Float(Long.MIN_VALUE.toFloat()), val: -9.223372036854776E18 } # loss of precision + - { expr: new Float(Long.MAX_VALUE.toFloat()), val: 9.223372036854776E18 } # loss of precision - { expr: new Float(Float.MIN_VALUE), val: 1.401298464324817E-45 } - { expr: new Float(Float.MAX_VALUE), val: 3.4028234663852886E38 } - - { expr: new Float(Float.NEGATIVE_INFINITY as float), val: Float.NEGATIVE_INFINITY as double } - - { expr: new Float(Float.POSITIVE_INFINITY as float), val: Float.POSITIVE_INFINITY as double } + - { expr: new Float(Float.NEGATIVE_INFINITY.toFloat()), val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: new Float(Float.POSITIVE_INFINITY.toFloat()), val: Float.POSITIVE_INFINITY.toDouble() } - from_type: Double to_type: double values: - - { expr: new Double(+0.0 as float), val: +0.0 } - - { expr: new Double(-0.0 as float), val: -0.0 } - - { expr: new Double(Byte.MIN_VALUE as double), val: -128.0 } - - { expr: new Double(Byte.MAX_VALUE as double), val: 127.0 } - - { expr: new Double(Short.MIN_VALUE as double), val: -32768.0 } - - { expr: new Double(Short.MAX_VALUE as double), val: 32767.0 } - - { expr: new Double(Int.MIN_VALUE as double), val: -2147483648.0 } - - { expr: new Double(Int.MAX_VALUE as double), val: 2147483647.0 } - - { expr: new Double(Long.MIN_VALUE as double), val: -9223372036854775808.0 } - - { expr: new Double(Long.MAX_VALUE as double), val: 9223372036854775807.0 } - - { expr: new Double(Float.MIN_VALUE as double), val: Float.MIN_VALUE as double } - - { expr: new Double(Float.MAX_VALUE as double), val: Float.MAX_VALUE as double } - - { expr: new Double(Float.NEGATIVE_INFINITY as double), val: Float.NEGATIVE_INFINITY as double } - - { expr: new Double(Float.POSITIVE_INFINITY as double), val: Float.POSITIVE_INFINITY as double } + - { expr: new Double(+0.0f), val: +0.0 } + - { expr: new Double(-0.0f), val: -0.0 } + - { expr: new Double(Byte.MIN_VALUE.toDouble()), val: -128.0 } + - { expr: new Double(Byte.MAX_VALUE.toDouble()), val: 127.0 } + - { expr: new Double(Short.MIN_VALUE.toDouble()), val: -32768.0 } + - { expr: new Double(Short.MAX_VALUE.toDouble()), val: 32767.0 } + - { expr: new Double(Int.MIN_VALUE.toDouble()), val: -2147483648.0 } + - { expr: new Double(Int.MAX_VALUE.toDouble()), val: 2147483647.0 } + - { expr: new Double(Long.MIN_VALUE.toDouble()), val: -9223372036854775808.0 } + - { expr: new Double(Long.MAX_VALUE.toDouble()), val: 9223372036854775807.0 } + - { expr: new Double(Float.MIN_VALUE.toDouble()), val: Float.MIN_VALUE.toDouble() } + - { expr: new Double(Float.MAX_VALUE.toDouble()), val: Float.MAX_VALUE.toDouble() } + - { expr: new Double(Float.NEGATIVE_INFINITY.toDouble()), val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: new Double(Float.POSITIVE_INFINITY.toDouble()), val: Float.POSITIVE_INFINITY.toDouble() } - { expr: new Double(Double.MIN_VALUE), val: Double.MIN_VALUE } - { expr: new Double(Double.MAX_VALUE), val: Double.MAX_VALUE } - - { expr: new Double(Double.NEGATIVE_INFINITY as double), val: Double.NEGATIVE_INFINITY as double } - - { expr: new Double(Double.POSITIVE_INFINITY as double), val: Double.POSITIVE_INFINITY as double } + - { expr: new Double(Double.NEGATIVE_INFINITY.toDouble()), val: Double.NEGATIVE_INFINITY.toDouble() } + - { expr: new Double(Double.POSITIVE_INFINITY.toDouble()), val: Double.POSITIVE_INFINITY.toDouble() } - from_type: Char to_type: char @@ -266,24 +266,24 @@ cases: - from_type: Char to_type: long values: - - { expr: "new Char(c'\\u0000')", val: 0 as long } - - { expr: "new Char(c'\\u007f')", val: 127 as long } - - { expr: "new Char(c'\\u8000')", val: 32768 as long } - - { expr: "new Char(c'\\uff80')", val: 65408 as long } - - { expr: "new Char(c'\\uffff')", val: 65535 as long } - - { expr: "new Char(c'\\ucafe')", val: 51966 as long } - - { expr: "new Char(c'R')", val: 82 as long } + - { expr: "new Char(c'\\u0000')", val: 0 } + - { expr: "new Char(c'\\u007f')", val: 127 } + - { expr: "new Char(c'\\u8000')", val: 32768 } + - { expr: "new Char(c'\\uff80')", val: 65408 } + - { expr: "new Char(c'\\uffff')", val: 65535 } + - { expr: "new Char(c'\\ucafe')", val: 51966 } + - { expr: "new Char(c'R')", val: 82 } - from_type: Char to_type: float values: - - { expr: "new Char(c'\\u0000')", val: 0.0 as float } - - { expr: "new Char(c'\\u007f')", val: 127.0 as float } - - { expr: "new Char(c'\\u8000')", val: 32768.0 as float } - - { expr: "new Char(c'\\uff80')", val: 65408.0 as float } - - { expr: "new Char(c'\\uffff')", val: 65535.0 as float } - - { expr: "new Char(c'\\ucafe')", val: 51966.0 as float } - - { expr: "new Char(c'R')", val: 82.0 as float } + - { expr: "new Char(c'\\u0000')", val: 0.0f } + - { expr: "new Char(c'\\u007f')", val: 127.0f } + - { expr: "new Char(c'\\u8000')", val: 32768.0f } + - { expr: "new Char(c'\\uff80')", val: 65408.0f } + - { expr: "new Char(c'\\uffff')", val: 65535.0f } + - { expr: "new Char(c'\\ucafe')", val: 51966.0f } + - { expr: "new Char(c'R')", val: 82.0f } - from_type: Char to_type: double diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_cons/call-cons.ets b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_cons/call-cons.ets index 38559db2f33744cae6100fbe70539979f9f0cc14..e1b764d365915950de324913bcd519fec8fcac45 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_cons/call-cons.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_cons/call-cons.ets @@ -24,13 +24,10 @@ class A { constructor(p: {{c.to_type}}) { this.f = p } } -function main(): int { +function main() { {%- for t in c['values'] %} let s{{loop.index}}: {{c.from_type}} = {{t.expr|safe}} - if (new A(s{{loop.index}}).f != {{t.val}}) { - return 1 - } + assertEQ(new A(s{{loop.index}}).f, {{t.val}}, "Assert fails on item {{loop.index}}") {%- endfor %} - return 0 } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_cons/call-cons.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_cons/call-cons.params.yaml index ea52b4d29e003d7a2e75a9d1f5f9bdca46bebfa8..e5e05ed6b6f57af0c86e98521188e99092fed5f9 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_cons/call-cons.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_cons/call-cons.params.yaml @@ -10,57 +10,56 @@ # 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. - --- cases: - from_type: Byte to_type: byte values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: short values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: int values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: long values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: float values: - - { expr: new Byte(), val: 0.0 as float } - - { expr: new Byte(127 as byte), val: 127.0 as float } - - { expr: new Byte(-128 as byte), val: -128.0 as float } + - { expr: new Byte(), val: 0.0f } + - { expr: new Byte(127), val: 127.0f } + - { expr: new Byte(-128), val: -128.0f } - from_type: Byte to_type: double values: - { expr: new Byte(), val: 0.0 } - - { expr: new Byte(127 as byte), val: 127.0 } - - { expr: new Byte(-128 as byte), val: -128.0 } + - { expr: new Byte(127), val: 127.0 } + - { expr: new Byte(-128), val: -128 } - from_type: Short to_type: short values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -68,8 +67,8 @@ cases: to_type: int values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -77,8 +76,8 @@ cases: to_type: long values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -86,17 +85,17 @@ cases: to_type: float values: - { expr: new Short(), val: 0.0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128.0 as float } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127.0 as float } - - { expr: new Short(Short.MIN_VALUE), val: -32768.0 as float } - - { expr: new Short(Short.MAX_VALUE), val: 32767.0 as float } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128.0f } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127.0f } + - { expr: new Short(Short.MIN_VALUE), val: -32768.0f } + - { expr: new Short(Short.MAX_VALUE), val: 32767.0f } - from_type: Short to_type: double values: - { expr: new Short(), val: 0.0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -104,10 +103,10 @@ cases: to_type: int values: - { expr: new Int(), val: 0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647 } @@ -115,10 +114,10 @@ cases: to_type: long values: - { expr: new Int(), val: 0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647 } @@ -126,21 +125,21 @@ cases: to_type: float values: - { expr: new Int(), val: 0.0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128.0 as float } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127.0 as float } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768.0 as float } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767.0 as float } - - { expr: new Int(Int.MIN_VALUE), val: -2147483600.0 as float } # loss of precision - - { expr: new Int(Int.MAX_VALUE), val: 2147483600.0 as float } # loss of precision + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128.0f } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127.0f } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768.0f } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767.0f } + - { expr: new Int(Int.MIN_VALUE), val: -2147483600.0f } # loss of precision + - { expr: new Int(Int.MAX_VALUE), val: 2147483600.0f } # loss of precision - from_type: Int to_type: double values: - { expr: new Int(), val: 0.0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128.0 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127.0 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768.0 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767.0 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128.0 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127.0 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768.0 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767.0 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648.0 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647.0 } @@ -148,12 +147,12 @@ cases: to_type: long values: - { expr: new Long(), val: 0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128 } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127 } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768 } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767 } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483648 } - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483647 } + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128 } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127 } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768 } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767 } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483648 } + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483647 } - { expr: new Long(Long.MIN_VALUE), val: -9223372036854775808 } - { expr: new Long(Long.MAX_VALUE), val: 9223372036854775807 } @@ -161,85 +160,85 @@ cases: to_type: float values: - { expr: new Long(), val: 0.0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128.0 as float } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127.0 as float } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768.0 as float } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767.0 as float } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483600.0 as float } # loss of precision - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483600.0 as float } # loss of precision - - { expr: new Long(Long.MIN_VALUE), val: -9223372000000000000.0 as float } # loss of precision - - { expr: new Long(Long.MAX_VALUE), val: 9223372000000000000.0 as float } # loss of precision + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128.0f } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127.0f } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768.0f } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767.0f } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483600.0f } # loss of precision + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483600.0f } # loss of precision + - { expr: new Long(Long.MIN_VALUE), val: -9223372000000000000.0f } # loss of precision + - { expr: new Long(Long.MAX_VALUE), val: 9223372000000000000.0f } # loss of precision - from_type: Long to_type: double values: - { expr: new Long(), val: 0.0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128.0 } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127.0 } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768.0 } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767.0 } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483648.0 } - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483647.0 } + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128 } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127.0 } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768 } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767.0 } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483648 } + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483647.0 } - { expr: new Long(Long.MIN_VALUE), val: -9223372036854775808.0 } - { expr: new Long(Long.MAX_VALUE), val: 9223372036854775807.0 } - from_type: Float to_type: float values: - - { expr: new Float(+0.0 as float), val: +0.0 as float } - - { expr: new Float(-0.0 as float), val: -0.0 as float } - - { expr: new Float(Byte.MIN_VALUE as float), val: -128.0 as float } - - { expr: new Float(Byte.MAX_VALUE as float), val: 127.0 as float } - - { expr: new Float(Short.MIN_VALUE as float), val: -32768.0 as float } - - { expr: new Float(Short.MAX_VALUE as float), val: 32767.0 as float } - - { expr: new Float(Int.MIN_VALUE as float), val: -2.14748365E9 as float } # loss of precision - - { expr: new Float(Int.MAX_VALUE as float), val: 2.14748365E9 as float } # loss of precision - - { expr: new Float(Long.MIN_VALUE as float), val: -9.223372E18 as float } # loss of precision - - { expr: new Float(Long.MAX_VALUE as float), val: 9.223372E18 as float } # loss of precision - - { expr: new Float(Float.MIN_VALUE), val: 1.4E-45 as float } - - { expr: new Float(Float.MAX_VALUE), val: 3.4028235E38 as float } - - { expr: new Float(Float.NEGATIVE_INFINITY as float), val: Float.NEGATIVE_INFINITY } - - { expr: new Float(Float.POSITIVE_INFINITY as float), val: Float.POSITIVE_INFINITY } + - { expr: new Float(+0.0f), val: +0.0f } + - { expr: new Float(-0.0f), val: -0.0f } + - { expr: new Float(Byte.MIN_VALUE.toFloat()), val: -128.0f } + - { expr: new Float(Byte.MAX_VALUE.toFloat()), val: 127.0f } + - { expr: new Float(Short.MIN_VALUE.toFloat()), val: -32768.0f } + - { expr: new Float(Short.MAX_VALUE.toFloat()), val: 32767.0f } + - { expr: new Float(Int.MIN_VALUE.toFloat()), val: -2.14748365E9f } # loss of precision + - { expr: new Float(Int.MAX_VALUE.toFloat()), val: 2.14748365E9f } # loss of precision + - { expr: new Float(Long.MIN_VALUE.toFloat()), val: -9.223372E18f } # loss of precision + - { expr: new Float(Long.MAX_VALUE.toFloat()), val: 9.223372E18f } # loss of precision + - { expr: new Float(Float.MIN_VALUE), val: 1.4E-45f } + - { expr: new Float(Float.MAX_VALUE), val: 3.4028235E38f } + - { expr: new Float(Float.NEGATIVE_INFINITY.toFloat()), val: Float.NEGATIVE_INFINITY } + - { expr: new Float(Float.POSITIVE_INFINITY.toFloat()), val: Float.POSITIVE_INFINITY } - from_type: Float to_type: double values: - - { expr: new Float(+0.0 as float), val: +0.0 } - - { expr: new Float(-0.0 as float), val: -0.0 } - - { expr: new Float(Byte.MIN_VALUE as float), val: -128.0 } - - { expr: new Float(Byte.MAX_VALUE as float), val: 127.0 } - - { expr: new Float(Short.MIN_VALUE as float), val: -32768.0 } - - { expr: new Float(Short.MAX_VALUE as float), val: 32767.0 } - - { expr: new Float(Int.MIN_VALUE as float), val: -2.147483648E9 } # loss of precision - - { expr: new Float(Int.MAX_VALUE as float), val: 2.147483648E9 } # loss of precision - - { expr: new Float(Long.MIN_VALUE as float), val: -9.223372036854776E18 } # loss of precision - - { expr: new Float(Long.MAX_VALUE as float), val: 9.223372036854776E18 } # loss of precision + - { expr: new Float(+0.0f), val: +0.0f } + - { expr: new Float(-0.0f), val: -0.0f } + - { expr: new Float(Byte.MIN_VALUE.toFloat()), val: -128.0 } + - { expr: new Float(Byte.MAX_VALUE.toFloat()), val: 127.0 } + - { expr: new Float(Short.MIN_VALUE.toFloat()), val: -32768.0 } + - { expr: new Float(Short.MAX_VALUE.toFloat()), val: 32767.0 } + - { expr: new Float(Int.MIN_VALUE.toFloat()), val: -2.147483648E9 } # loss of precision + - { expr: new Float(Int.MAX_VALUE.toFloat()), val: 2.147483648E9 } # loss of precision + - { expr: new Float(Long.MIN_VALUE.toFloat()), val: -9.223372036854776E18 } # loss of precision + - { expr: new Float(Long.MAX_VALUE.toFloat()), val: 9.223372036854776E18 } # loss of precision - { expr: new Float(Float.MIN_VALUE), val: 1.401298464324817E-45 } - { expr: new Float(Float.MAX_VALUE), val: 3.4028234663852886E38 } - - { expr: new Float(Float.NEGATIVE_INFINITY as float), val: Float.NEGATIVE_INFINITY as double } - - { expr: new Float(Float.POSITIVE_INFINITY as float), val: Float.POSITIVE_INFINITY as double } + - { expr: new Float(Float.NEGATIVE_INFINITY.toFloat()), val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: new Float(Float.POSITIVE_INFINITY.toFloat()), val: Float.POSITIVE_INFINITY.toDouble() } - from_type: Double to_type: double values: - - { expr: new Double(+0.0 as float), val: +0.0 } - - { expr: new Double(-0.0 as float), val: -0.0 } - - { expr: new Double(Byte.MIN_VALUE as double), val: -128.0 } - - { expr: new Double(Byte.MAX_VALUE as double), val: 127.0 } - - { expr: new Double(Short.MIN_VALUE as double), val: -32768.0 } - - { expr: new Double(Short.MAX_VALUE as double), val: 32767.0 } - - { expr: new Double(Int.MIN_VALUE as double), val: -2147483648.0 } - - { expr: new Double(Int.MAX_VALUE as double), val: 2147483647.0 } - - { expr: new Double(Long.MIN_VALUE as double), val: -9223372036854775808.0 } - - { expr: new Double(Long.MAX_VALUE as double), val: 9223372036854775807.0 } - - { expr: new Double(Float.MIN_VALUE as double), val: Float.MIN_VALUE as double } - - { expr: new Double(Float.MAX_VALUE as double), val: Float.MAX_VALUE as double } - - { expr: new Double(Float.NEGATIVE_INFINITY as double), val: Float.NEGATIVE_INFINITY as double } - - { expr: new Double(Float.POSITIVE_INFINITY as double), val: Float.POSITIVE_INFINITY as double } + - { expr: new Double(+0.0f), val: +0.0 } + - { expr: new Double(-0.0f), val: -0.0 } + - { expr: new Double(Byte.MIN_VALUE.toDouble()), val: -128.0 } + - { expr: new Double(Byte.MAX_VALUE.toDouble()), val: 127.0 } + - { expr: new Double(Short.MIN_VALUE.toDouble()), val: -32768.0 } + - { expr: new Double(Short.MAX_VALUE.toDouble()), val: 32767.0 } + - { expr: new Double(Int.MIN_VALUE.toDouble()), val: -2147483648.0 } + - { expr: new Double(Int.MAX_VALUE.toDouble()), val: 2147483647.0 } + - { expr: new Double(Long.MIN_VALUE.toDouble()), val: -9223372036854775808.0 } + - { expr: new Double(Long.MAX_VALUE.toDouble()), val: 9223372036854775807.0 } + - { expr: new Double(Float.MIN_VALUE.toDouble()), val: Float.MIN_VALUE } + - { expr: new Double(Float.MAX_VALUE.toDouble()), val: Float.MAX_VALUE } + - { expr: new Double(Float.NEGATIVE_INFINITY.toDouble()), val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: new Double(Float.POSITIVE_INFINITY.toDouble()), val: Float.POSITIVE_INFINITY.toDouble() } - { expr: new Double(Double.MIN_VALUE), val: Double.MIN_VALUE } - { expr: new Double(Double.MAX_VALUE), val: Double.MAX_VALUE } - - { expr: new Double(Double.NEGATIVE_INFINITY as double), val: Double.NEGATIVE_INFINITY as double } - - { expr: new Double(Double.POSITIVE_INFINITY as double), val: Double.POSITIVE_INFINITY as double } + - { expr: new Double(Double.NEGATIVE_INFINITY.toDouble()), val: Double.NEGATIVE_INFINITY.toDouble() } + - { expr: new Double(Double.POSITIVE_INFINITY.toDouble()), val: Double.POSITIVE_INFINITY.toDouble() } - from_type: Char to_type: char @@ -266,24 +265,24 @@ cases: - from_type: Char to_type: long values: - - { expr: "new Char(c'\\u0000')", val: 0 as long } - - { expr: "new Char(c'\\u007f')", val: 127 as long } - - { expr: "new Char(c'\\u8000')", val: 32768 as long } - - { expr: "new Char(c'\\uff80')", val: 65408 as long } - - { expr: "new Char(c'\\uffff')", val: 65535 as long } - - { expr: "new Char(c'\\ucafe')", val: 51966 as long } - - { expr: "new Char(c'R')", val: 82 as long } + - { expr: "new Char(c'\\u0000')", val: 0 } + - { expr: "new Char(c'\\u007f')", val: 127 } + - { expr: "new Char(c'\\u8000')", val: 32768 } + - { expr: "new Char(c'\\uff80')", val: 65408 } + - { expr: "new Char(c'\\uffff')", val: 65535 } + - { expr: "new Char(c'\\ucafe')", val: 51966 } + - { expr: "new Char(c'R')", val: 82 } - from_type: Char to_type: float values: - - { expr: "new Char(c'\\u0000')", val: 0.0 as float } - - { expr: "new Char(c'\\u007f')", val: 127.0 as float } - - { expr: "new Char(c'\\u8000')", val: 32768.0 as float } - - { expr: "new Char(c'\\uff80')", val: 65408.0 as float } - - { expr: "new Char(c'\\uffff')", val: 65535.0 as float } - - { expr: "new Char(c'\\ucafe')", val: 51966.0 as float } - - { expr: "new Char(c'R')", val: 82.0 as float } + - { expr: "new Char(c'\\u0000')", val: 0.0f } + - { expr: "new Char(c'\\u007f')", val: 127.0f } + - { expr: "new Char(c'\\u8000')", val: 32768.0f } + - { expr: "new Char(c'\\uff80')", val: 65408.0f } + - { expr: "new Char(c'\\uffff')", val: 65535.0f } + - { expr: "new Char(c'\\ucafe')", val: 51966.0f } + - { expr: "new Char(c'R')", val: 82.0f } - from_type: Char to_type: double diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_func/call-func.ets b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_func/call-func.ets index 82b2553a20c30cead4310fcdff4f9f5c02bf9f72..ba2cc344417c44480ca3fd7ec60cd55aa45780cd 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_func/call-func.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_func/call-func.ets @@ -21,13 +21,10 @@ params: from {{c.from_type}} to {{c.to_type}} function foo(p: {{c.to_type}}): {{c.to_type}} { return p } -function main(): int { +function main() { {%- for t in c['values'] %} let s{{loop.index}}: {{c.from_type}} = {{t.expr|safe}} - if (foo(s{{loop.index}}) != {{t.val}}) { - return 1 - } + assertEQ(foo(s{{loop.index}}), {{t.val}}, "Assert fails on item {{loop.index}}") {%- endfor %} - return 0 } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_func/call-func.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_func/call-func.params.yaml index ea52b4d29e003d7a2e75a9d1f5f9bdca46bebfa8..2009d51171f01afe4cb87f25d43b801e80db45d2 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_func/call-func.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_func/call-func.params.yaml @@ -17,50 +17,50 @@ cases: to_type: byte values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: short values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: int values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: long values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: float values: - - { expr: new Byte(), val: 0.0 as float } - - { expr: new Byte(127 as byte), val: 127.0 as float } - - { expr: new Byte(-128 as byte), val: -128.0 as float } + - { expr: new Byte(), val: 0.0 } + - { expr: new Byte(127), val: 127.0f } + - { expr: new Byte(-128), val: -128.0f } - from_type: Byte to_type: double values: - { expr: new Byte(), val: 0.0 } - - { expr: new Byte(127 as byte), val: 127.0 } - - { expr: new Byte(-128 as byte), val: -128.0 } + - { expr: new Byte(127), val: 127.0 } + - { expr: new Byte(-128), val: -128.0 } - from_type: Short to_type: short values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -68,8 +68,8 @@ cases: to_type: int values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -77,8 +77,8 @@ cases: to_type: long values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -86,17 +86,17 @@ cases: to_type: float values: - { expr: new Short(), val: 0.0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128.0 as float } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127.0 as float } - - { expr: new Short(Short.MIN_VALUE), val: -32768.0 as float } - - { expr: new Short(Short.MAX_VALUE), val: 32767.0 as float } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128.0f } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127.0f } + - { expr: new Short(Short.MIN_VALUE), val: -32768.0f } + - { expr: new Short(Short.MAX_VALUE), val: 32767.0f } - from_type: Short to_type: double values: - { expr: new Short(), val: 0.0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -104,10 +104,10 @@ cases: to_type: int values: - { expr: new Int(), val: 0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647 } @@ -115,10 +115,10 @@ cases: to_type: long values: - { expr: new Int(), val: 0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647 } @@ -126,21 +126,21 @@ cases: to_type: float values: - { expr: new Int(), val: 0.0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128.0 as float } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127.0 as float } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768.0 as float } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767.0 as float } - - { expr: new Int(Int.MIN_VALUE), val: -2147483600.0 as float } # loss of precision - - { expr: new Int(Int.MAX_VALUE), val: 2147483600.0 as float } # loss of precision + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128.0f } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127.0f } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768.0f } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767.0f } + - { expr: new Int(Int.MIN_VALUE), val: -2147483600.0f } # loss of precision + - { expr: new Int(Int.MAX_VALUE), val: 2147483600.0f } # loss of precision - from_type: Int to_type: double values: - { expr: new Int(), val: 0.0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128.0 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127.0 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768.0 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767.0 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128.0 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127.0 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768.0 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767.0 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648.0 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647.0 } @@ -148,12 +148,12 @@ cases: to_type: long values: - { expr: new Long(), val: 0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128 } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127 } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768 } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767 } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483648 } - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483647 } + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128 } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127 } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768 } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767 } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483648 } + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483647 } - { expr: new Long(Long.MIN_VALUE), val: -9223372036854775808 } - { expr: new Long(Long.MAX_VALUE), val: 9223372036854775807 } @@ -161,85 +161,85 @@ cases: to_type: float values: - { expr: new Long(), val: 0.0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128.0 as float } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127.0 as float } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768.0 as float } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767.0 as float } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483600.0 as float } # loss of precision - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483600.0 as float } # loss of precision - - { expr: new Long(Long.MIN_VALUE), val: -9223372000000000000.0 as float } # loss of precision - - { expr: new Long(Long.MAX_VALUE), val: 9223372000000000000.0 as float } # loss of precision + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128.0f } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127.0f } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768.0f } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767.0f } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483600.0f } # loss of precision + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483600.0f } # loss of precision + - { expr: new Long(Long.MIN_VALUE), val: -9223372000000000000.0f } # loss of precision + - { expr: new Long(Long.MAX_VALUE), val: 9223372000000000000.0f } # loss of precision - from_type: Long to_type: double values: - { expr: new Long(), val: 0.0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128.0 } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127.0 } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768.0 } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767.0 } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483648.0 } - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483647.0 } + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128.0 } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127.0 } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768.0 } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767.0 } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483648.0 } + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483647.0 } - { expr: new Long(Long.MIN_VALUE), val: -9223372036854775808.0 } - { expr: new Long(Long.MAX_VALUE), val: 9223372036854775807.0 } - from_type: Float to_type: float values: - - { expr: new Float(+0.0 as float), val: +0.0 as float } - - { expr: new Float(-0.0 as float), val: -0.0 as float } - - { expr: new Float(Byte.MIN_VALUE as float), val: -128.0 as float } - - { expr: new Float(Byte.MAX_VALUE as float), val: 127.0 as float } - - { expr: new Float(Short.MIN_VALUE as float), val: -32768.0 as float } - - { expr: new Float(Short.MAX_VALUE as float), val: 32767.0 as float } - - { expr: new Float(Int.MIN_VALUE as float), val: -2.14748365E9 as float } # loss of precision - - { expr: new Float(Int.MAX_VALUE as float), val: 2.14748365E9 as float } # loss of precision - - { expr: new Float(Long.MIN_VALUE as float), val: -9.223372E18 as float } # loss of precision - - { expr: new Float(Long.MAX_VALUE as float), val: 9.223372E18 as float } # loss of precision - - { expr: new Float(Float.MIN_VALUE), val: 1.4E-45 as float } - - { expr: new Float(Float.MAX_VALUE), val: 3.4028235E38 as float } - - { expr: new Float(Float.NEGATIVE_INFINITY as float), val: Float.NEGATIVE_INFINITY } - - { expr: new Float(Float.POSITIVE_INFINITY as float), val: Float.POSITIVE_INFINITY } + - { expr: new Float(+0.0f), val: +0.0f } + - { expr: new Float(-0.0f), val: -0.0f } + - { expr: new Float(Byte.MIN_VALUE.toFloat()), val: -128.0f } + - { expr: new Float(Byte.MAX_VALUE.toFloat()), val: 127.0f } + - { expr: new Float(Short.MIN_VALUE.toFloat()), val: -32768.0f } + - { expr: new Float(Short.MAX_VALUE.toFloat()), val: 32767.0f } + - { expr: new Float(Int.MIN_VALUE.toFloat()), val: -2.14748365E9f } # loss of precision + - { expr: new Float(Int.MAX_VALUE.toFloat()), val: 2.14748365E9f } # loss of precision + - { expr: new Float(Long.MIN_VALUE.toFloat()), val: -9.223372E18f } # loss of precision + - { expr: new Float(Long.MAX_VALUE.toFloat()), val: 9.223372E18f } # loss of precision + - { expr: new Float(Float.MIN_VALUE), val: 1.4E-45f } + - { expr: new Float(Float.MAX_VALUE), val: 3.4028235E38f } + - { expr: new Float(Float.NEGATIVE_INFINITY.toFloat()), val: Float.NEGATIVE_INFINITY } + - { expr: new Float(Float.POSITIVE_INFINITY.toFloat()), val: Float.POSITIVE_INFINITY } - from_type: Float to_type: double values: - - { expr: new Float(+0.0 as float), val: +0.0 } - - { expr: new Float(-0.0 as float), val: -0.0 } - - { expr: new Float(Byte.MIN_VALUE as float), val: -128.0 } - - { expr: new Float(Byte.MAX_VALUE as float), val: 127.0 } - - { expr: new Float(Short.MIN_VALUE as float), val: -32768.0 } - - { expr: new Float(Short.MAX_VALUE as float), val: 32767.0 } - - { expr: new Float(Int.MIN_VALUE as float), val: -2.147483648E9 } # loss of precision - - { expr: new Float(Int.MAX_VALUE as float), val: 2.147483648E9 } # loss of precision - - { expr: new Float(Long.MIN_VALUE as float), val: -9.223372036854776E18 } # loss of precision - - { expr: new Float(Long.MAX_VALUE as float), val: 9.223372036854776E18 } # loss of precision + - { expr: new Float(+0.0f), val: +0.0 } + - { expr: new Float(-0.0f), val: -0.0 } + - { expr: new Float(Byte.MIN_VALUE.toFloat()), val: -128.0 } + - { expr: new Float(Byte.MAX_VALUE.toFloat()), val: 127.0 } + - { expr: new Float(Short.MIN_VALUE.toFloat()), val: -32768.0 } + - { expr: new Float(Short.MAX_VALUE.toFloat()), val: 32767.0 } + - { expr: new Float(Int.MIN_VALUE.toFloat()), val: -2.147483648E9 } # loss of precision + - { expr: new Float(Int.MAX_VALUE.toFloat()), val: 2.147483648E9 } # loss of precision + - { expr: new Float(Long.MIN_VALUE.toFloat()), val: -9.223372036854776E18 } # loss of precision + - { expr: new Float(Long.MAX_VALUE.toFloat()), val: 9.223372036854776E18 } # loss of precision - { expr: new Float(Float.MIN_VALUE), val: 1.401298464324817E-45 } - { expr: new Float(Float.MAX_VALUE), val: 3.4028234663852886E38 } - - { expr: new Float(Float.NEGATIVE_INFINITY as float), val: Float.NEGATIVE_INFINITY as double } - - { expr: new Float(Float.POSITIVE_INFINITY as float), val: Float.POSITIVE_INFINITY as double } + - { expr: new Float(Float.NEGATIVE_INFINITY.toFloat()), val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: new Float(Float.POSITIVE_INFINITY.toFloat()), val: Float.POSITIVE_INFINITY.toDouble() } - from_type: Double to_type: double values: - - { expr: new Double(+0.0 as float), val: +0.0 } - - { expr: new Double(-0.0 as float), val: -0.0 } - - { expr: new Double(Byte.MIN_VALUE as double), val: -128.0 } - - { expr: new Double(Byte.MAX_VALUE as double), val: 127.0 } - - { expr: new Double(Short.MIN_VALUE as double), val: -32768.0 } - - { expr: new Double(Short.MAX_VALUE as double), val: 32767.0 } - - { expr: new Double(Int.MIN_VALUE as double), val: -2147483648.0 } - - { expr: new Double(Int.MAX_VALUE as double), val: 2147483647.0 } - - { expr: new Double(Long.MIN_VALUE as double), val: -9223372036854775808.0 } - - { expr: new Double(Long.MAX_VALUE as double), val: 9223372036854775807.0 } - - { expr: new Double(Float.MIN_VALUE as double), val: Float.MIN_VALUE as double } - - { expr: new Double(Float.MAX_VALUE as double), val: Float.MAX_VALUE as double } - - { expr: new Double(Float.NEGATIVE_INFINITY as double), val: Float.NEGATIVE_INFINITY as double } - - { expr: new Double(Float.POSITIVE_INFINITY as double), val: Float.POSITIVE_INFINITY as double } + - { expr: new Double(+0.0f), val: +0.0 } + - { expr: new Double(-0.0f), val: -0.0 } + - { expr: new Double(Byte.MIN_VALUE.toDouble()), val: -128.0 } + - { expr: new Double(Byte.MAX_VALUE.toDouble()), val: 127.0 } + - { expr: new Double(Short.MIN_VALUE.toDouble()), val: -32768.0 } + - { expr: new Double(Short.MAX_VALUE.toDouble()), val: 32767.0 } + - { expr: new Double(Int.MIN_VALUE.toDouble()), val: -2147483648.0 } + - { expr: new Double(Int.MAX_VALUE.toDouble()), val: 2147483647.0 } + - { expr: new Double(Long.MIN_VALUE.toDouble()), val: -9223372036854775808.0 } + - { expr: new Double(Long.MAX_VALUE.toDouble()), val: 9223372036854775807.0 } + - { expr: new Double(Float.MIN_VALUE.toDouble()), val: Float.MIN_VALUE.toDouble() } + - { expr: new Double(Float.MAX_VALUE.toDouble()), val: Float.MAX_VALUE.toDouble() } + - { expr: new Double(Float.NEGATIVE_INFINITY.toDouble()), val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: new Double(Float.POSITIVE_INFINITY.toDouble()), val: Float.POSITIVE_INFINITY.toDouble() } - { expr: new Double(Double.MIN_VALUE), val: Double.MIN_VALUE } - { expr: new Double(Double.MAX_VALUE), val: Double.MAX_VALUE } - - { expr: new Double(Double.NEGATIVE_INFINITY as double), val: Double.NEGATIVE_INFINITY as double } - - { expr: new Double(Double.POSITIVE_INFINITY as double), val: Double.POSITIVE_INFINITY as double } + - { expr: new Double(Double.NEGATIVE_INFINITY.toDouble()), val: Double.NEGATIVE_INFINITY.toDouble() } + - { expr: new Double(Double.POSITIVE_INFINITY.toDouble()), val: Double.POSITIVE_INFINITY.toDouble() } - from_type: Char to_type: char @@ -266,24 +266,24 @@ cases: - from_type: Char to_type: long values: - - { expr: "new Char(c'\\u0000')", val: 0 as long } - - { expr: "new Char(c'\\u007f')", val: 127 as long } - - { expr: "new Char(c'\\u8000')", val: 32768 as long } - - { expr: "new Char(c'\\uff80')", val: 65408 as long } - - { expr: "new Char(c'\\uffff')", val: 65535 as long } - - { expr: "new Char(c'\\ucafe')", val: 51966 as long } - - { expr: "new Char(c'R')", val: 82 as long } + - { expr: "new Char(c'\\u0000')", val: 0 } + - { expr: "new Char(c'\\u007f')", val: 127 } + - { expr: "new Char(c'\\u8000')", val: 32768 } + - { expr: "new Char(c'\\uff80')", val: 65408 } + - { expr: "new Char(c'\\uffff')", val: 65535 } + - { expr: "new Char(c'\\ucafe')", val: 51966 } + - { expr: "new Char(c'R')", val: 82 } - from_type: Char to_type: float values: - - { expr: "new Char(c'\\u0000')", val: 0.0 as float } - - { expr: "new Char(c'\\u007f')", val: 127.0 as float } - - { expr: "new Char(c'\\u8000')", val: 32768.0 as float } - - { expr: "new Char(c'\\uff80')", val: 65408.0 as float } - - { expr: "new Char(c'\\uffff')", val: 65535.0 as float } - - { expr: "new Char(c'\\ucafe')", val: 51966.0 as float } - - { expr: "new Char(c'R')", val: 82.0 as float } + - { expr: "new Char(c'\\u0000')", val: 0.0f } + - { expr: "new Char(c'\\u007f')", val: 127.0f } + - { expr: "new Char(c'\\u8000')", val: 32768.0f } + - { expr: "new Char(c'\\uff80')", val: 65408.0f } + - { expr: "new Char(c'\\uffff')", val: 65535.0f } + - { expr: "new Char(c'\\ucafe')", val: 51966.0f } + - { expr: "new Char(c'R')", val: 82.0f } - from_type: Char to_type: double diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_lmbd/call-lmbd.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_lmbd/call-lmbd.params.yaml index 52248ef55b65d8ac6c3bf6ba89cdcf05b04c82cc..92882c40cc3a175317bb36c8b1d6290ad7f0431a 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_lmbd/call-lmbd.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_lmbd/call-lmbd.params.yaml @@ -17,15 +17,15 @@ cases: to_type: byte values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Short to_type: short values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -33,10 +33,10 @@ cases: to_type: int values: - { expr: new Int(), val: 0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647 } @@ -44,54 +44,54 @@ cases: to_type: long values: - { expr: new Long(), val: 0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128 } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127 } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768 } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767 } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483648 } - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483647 } + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128 } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127 } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768 } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767 } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483648 } + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483647 } - { expr: new Long(Long.MIN_VALUE), val: -9223372036854775808 } - { expr: new Long(Long.MAX_VALUE), val: 9223372036854775807 } - from_type: Float to_type: float values: - - { expr: new Float(+0.0 as float), val: +0.0 as float } - - { expr: new Float(-0.0 as float), val: -0.0 as float } - - { expr: new Float(Byte.MIN_VALUE as float), val: -128.0 as float } - - { expr: new Float(Byte.MAX_VALUE as float), val: 127.0 as float } - - { expr: new Float(Short.MIN_VALUE as float), val: -32768.0 as float } - - { expr: new Float(Short.MAX_VALUE as float), val: 32767.0 as float } - - { expr: new Float(Int.MIN_VALUE as float), val: -2.14748365E9 as float } # loss of precision - - { expr: new Float(Int.MAX_VALUE as float), val: 2.14748365E9 as float } # loss of precision - - { expr: new Float(Long.MIN_VALUE as float), val: -9.223372E18 as float } # loss of precision - - { expr: new Float(Long.MAX_VALUE as float), val: 9.223372E18 as float } # loss of precision - - { expr: new Float(Float.MIN_VALUE), val: 1.4E-45 as float } - - { expr: new Float(Float.MAX_VALUE), val: 3.4028235E38 as float } - - { expr: new Float(Float.NEGATIVE_INFINITY as float), val: Float.NEGATIVE_INFINITY } - - { expr: new Float(Float.POSITIVE_INFINITY as float), val: Float.POSITIVE_INFINITY } + - { expr: new Float(+0.0f), val: +0.0f } + - { expr: new Float(-0.0f), val: -0.0f } + - { expr: new Float(Byte.MIN_VALUE.toFloat()), val: -128.0f } + - { expr: new Float(Byte.MAX_VALUE.toFloat()), val: 127.0f } + - { expr: new Float(Short.MIN_VALUE.toFloat()), val: -32768.0f } + - { expr: new Float(Short.MAX_VALUE.toFloat()), val: 32767.0f } + - { expr: new Float(Int.MIN_VALUE.toFloat()), val: -2.14748365E9f } # loss of precision + - { expr: new Float(Int.MAX_VALUE.toFloat()), val: 2.14748365E9f } # loss of precision + - { expr: new Float(Long.MIN_VALUE.toFloat()), val: -9.223372E18f } # loss of precision + - { expr: new Float(Long.MAX_VALUE.toFloat()), val: 9.223372E18f } # loss of precision + - { expr: new Float(Float.MIN_VALUE), val: 1.4E-45f } + - { expr: new Float(Float.MAX_VALUE), val: 3.4028235E38f } + - { expr: new Float(Float.NEGATIVE_INFINITY.toFloat()), val: Float.NEGATIVE_INFINITY } + - { expr: new Float(Float.POSITIVE_INFINITY.toFloat()), val: Float.POSITIVE_INFINITY } - from_type: Double to_type: double values: - - { expr: new Double(+0.0 as float), val: +0.0 } - - { expr: new Double(-0.0 as float), val: -0.0 } - - { expr: new Double(Byte.MIN_VALUE as double), val: -128.0 } - - { expr: new Double(Byte.MAX_VALUE as double), val: 127.0 } - - { expr: new Double(Short.MIN_VALUE as double), val: -32768.0 } - - { expr: new Double(Short.MAX_VALUE as double), val: 32767.0 } - - { expr: new Double(Int.MIN_VALUE as double), val: -2147483648.0 } - - { expr: new Double(Int.MAX_VALUE as double), val: 2147483647.0 } - - { expr: new Double(Long.MIN_VALUE as double), val: -9223372036854775808.0 } - - { expr: new Double(Long.MAX_VALUE as double), val: 9223372036854775807.0 } - - { expr: new Double(Float.MIN_VALUE as double), val: Float.MIN_VALUE as double } - - { expr: new Double(Float.MAX_VALUE as double), val: Float.MAX_VALUE as double } - - { expr: new Double(Float.NEGATIVE_INFINITY as double), val: Float.NEGATIVE_INFINITY as double } - - { expr: new Double(Float.POSITIVE_INFINITY as double), val: Float.POSITIVE_INFINITY as double } + - { expr: new Double(+0.0f), val: +0.0 } + - { expr: new Double(-0.0f), val: -0.0 } + - { expr: new Double(Byte.MIN_VALUE.toDouble()), val: -128.0 } + - { expr: new Double(Byte.MAX_VALUE.toDouble()), val: 127.0 } + - { expr: new Double(Short.MIN_VALUE.toDouble()), val: -32768.0 } + - { expr: new Double(Short.MAX_VALUE.toDouble()), val: 32767.0 } + - { expr: new Double(Int.MIN_VALUE.toDouble()), val: -2147483648.0 } + - { expr: new Double(Int.MAX_VALUE.toDouble()), val: 2147483647.0 } + - { expr: new Double(Long.MIN_VALUE.toDouble()), val: -9223372036854775808.0 } + - { expr: new Double(Long.MAX_VALUE.toDouble()), val: 9223372036854775807.0 } + - { expr: new Double(Float.MIN_VALUE.toDouble()), val: Float.MIN_VALUE.toDouble() } + - { expr: new Double(Float.MAX_VALUE.toDouble()), val: Float.MAX_VALUE.toDouble() } + - { expr: new Double(Float.NEGATIVE_INFINITY.toDouble()), val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: new Double(Float.POSITIVE_INFINITY.toDouble()), val: Float.POSITIVE_INFINITY.toDouble() } - { expr: new Double(Double.MIN_VALUE), val: Double.MIN_VALUE } - { expr: new Double(Double.MAX_VALUE), val: Double.MAX_VALUE } - - { expr: new Double(Double.NEGATIVE_INFINITY as double), val: Double.NEGATIVE_INFINITY as double } - - { expr: new Double(Double.POSITIVE_INFINITY as double), val: Double.POSITIVE_INFINITY as double } + - { expr: new Double(Double.NEGATIVE_INFINITY.toDouble()), val: Double.NEGATIVE_INFINITY.toDouble() } + - { expr: new Double(Double.POSITIVE_INFINITY.toDouble()), val: Double.POSITIVE_INFINITY.toDouble() } - from_type: Char to_type: char diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_meth/call-meth.ets b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_meth/call-meth.ets index 0af984276e32fe3ff4ae651afe065a0f4f8ac4b4..a2519e2ff7ce9ff51c687a6a2db73fc8529dda36 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_meth/call-meth.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_meth/call-meth.ets @@ -23,14 +23,11 @@ class A { meth(p: {{c.to_type}}): {{c.to_type}} { return p } } -function main(): int { +function main() { let a: A = new A() {%- for t in c['values'] %} let s{{loop.index}}: {{c.from_type}} = {{t.expr|safe}} - if (a.meth(s{{loop.index}}) != {{t.val}}) { - return 1 - } + assertEQ(a.meth(s{{loop.index}}), {{t.val}}, "Assert fails on item {{loop.index}}") {%- endfor %} - return 0 } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_meth/call-meth.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_meth/call-meth.params.yaml index ea52b4d29e003d7a2e75a9d1f5f9bdca46bebfa8..14d10adce09a0b8f3387cc103b34b5dbc6a04670 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_meth/call-meth.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/call_meth/call-meth.params.yaml @@ -17,50 +17,50 @@ cases: to_type: byte values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: short values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: int values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: long values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: float values: - - { expr: new Byte(), val: 0.0 as float } - - { expr: new Byte(127 as byte), val: 127.0 as float } - - { expr: new Byte(-128 as byte), val: -128.0 as float } + - { expr: new Byte(), val: 0.0f } + - { expr: new Byte(127), val: 127.0f } + - { expr: new Byte(-128), val: -128.0f } - from_type: Byte to_type: double values: - { expr: new Byte(), val: 0.0 } - - { expr: new Byte(127 as byte), val: 127.0 } - - { expr: new Byte(-128 as byte), val: -128.0 } + - { expr: new Byte(127), val: 127.0 } + - { expr: new Byte(-128), val: -128.0 } - from_type: Short to_type: short values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -68,8 +68,8 @@ cases: to_type: int values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -77,8 +77,8 @@ cases: to_type: long values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -86,17 +86,17 @@ cases: to_type: float values: - { expr: new Short(), val: 0.0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128.0 as float } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127.0 as float } - - { expr: new Short(Short.MIN_VALUE), val: -32768.0 as float } - - { expr: new Short(Short.MAX_VALUE), val: 32767.0 as float } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128.0f } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127.0f } + - { expr: new Short(Short.MIN_VALUE), val: -32768.0f } + - { expr: new Short(Short.MAX_VALUE), val: 32767.0f } - from_type: Short to_type: double values: - { expr: new Short(), val: 0.0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -104,10 +104,10 @@ cases: to_type: int values: - { expr: new Int(), val: 0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647 } @@ -115,10 +115,10 @@ cases: to_type: long values: - { expr: new Int(), val: 0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647 } @@ -126,21 +126,21 @@ cases: to_type: float values: - { expr: new Int(), val: 0.0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128.0 as float } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127.0 as float } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768.0 as float } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767.0 as float } - - { expr: new Int(Int.MIN_VALUE), val: -2147483600.0 as float } # loss of precision - - { expr: new Int(Int.MAX_VALUE), val: 2147483600.0 as float } # loss of precision + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128.0f } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127.0f } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768.0f } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767.0f } + - { expr: new Int(Int.MIN_VALUE), val: -2147483600.0f } # loss of precision + - { expr: new Int(Int.MAX_VALUE), val: 2147483600.0f } # loss of precision - from_type: Int to_type: double values: - { expr: new Int(), val: 0.0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128.0 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127.0 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768.0 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767.0 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128.0 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127.0 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768.0 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767.0 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648.0 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647.0 } @@ -148,12 +148,12 @@ cases: to_type: long values: - { expr: new Long(), val: 0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128 } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127 } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768 } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767 } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483648 } - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483647 } + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128 } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127 } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768 } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767 } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483648 } + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483647 } - { expr: new Long(Long.MIN_VALUE), val: -9223372036854775808 } - { expr: new Long(Long.MAX_VALUE), val: 9223372036854775807 } @@ -161,85 +161,85 @@ cases: to_type: float values: - { expr: new Long(), val: 0.0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128.0 as float } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127.0 as float } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768.0 as float } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767.0 as float } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483600.0 as float } # loss of precision - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483600.0 as float } # loss of precision - - { expr: new Long(Long.MIN_VALUE), val: -9223372000000000000.0 as float } # loss of precision - - { expr: new Long(Long.MAX_VALUE), val: 9223372000000000000.0 as float } # loss of precision + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128.0f } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127.0f } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768.0f } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767.0f } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483600.0f } # loss of precision + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483600.0f } # loss of precision + - { expr: new Long(Long.MIN_VALUE), val: -9223372000000000000.0f } # loss of precision + - { expr: new Long(Long.MAX_VALUE), val: 9223372000000000000.0f } # loss of precision - from_type: Long to_type: double values: - { expr: new Long(), val: 0.0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128.0 } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127.0 } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768.0 } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767.0 } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483648.0 } - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483647.0 } + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128.0 } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127.0 } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768.0 } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767.0 } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483648.0 } + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483647.0 } - { expr: new Long(Long.MIN_VALUE), val: -9223372036854775808.0 } - { expr: new Long(Long.MAX_VALUE), val: 9223372036854775807.0 } - from_type: Float to_type: float values: - - { expr: new Float(+0.0 as float), val: +0.0 as float } - - { expr: new Float(-0.0 as float), val: -0.0 as float } - - { expr: new Float(Byte.MIN_VALUE as float), val: -128.0 as float } - - { expr: new Float(Byte.MAX_VALUE as float), val: 127.0 as float } - - { expr: new Float(Short.MIN_VALUE as float), val: -32768.0 as float } - - { expr: new Float(Short.MAX_VALUE as float), val: 32767.0 as float } - - { expr: new Float(Int.MIN_VALUE as float), val: -2.14748365E9 as float } # loss of precision - - { expr: new Float(Int.MAX_VALUE as float), val: 2.14748365E9 as float } # loss of precision - - { expr: new Float(Long.MIN_VALUE as float), val: -9.223372E18 as float } # loss of precision - - { expr: new Float(Long.MAX_VALUE as float), val: 9.223372E18 as float } # loss of precision - - { expr: new Float(Float.MIN_VALUE), val: 1.4E-45 as float } - - { expr: new Float(Float.MAX_VALUE), val: 3.4028235E38 as float } - - { expr: new Float(Float.NEGATIVE_INFINITY as float), val: Float.NEGATIVE_INFINITY } - - { expr: new Float(Float.POSITIVE_INFINITY as float), val: Float.POSITIVE_INFINITY } + - { expr: new Float(+0.0f), val: +0.0f } + - { expr: new Float(-0.0f), val: -0.0f } + - { expr: new Float(Byte.MIN_VALUE.toFloat()), val: -128.0f } + - { expr: new Float(Byte.MAX_VALUE.toFloat()), val: 127.0f } + - { expr: new Float(Short.MIN_VALUE.toFloat()), val: -32768.0f } + - { expr: new Float(Short.MAX_VALUE.toFloat()), val: 32767.0f } + - { expr: new Float(Int.MIN_VALUE.toFloat()), val: -2.14748365E9f } # loss of precision + - { expr: new Float(Int.MAX_VALUE.toFloat()), val: 2.14748365E9f} # loss of precision + - { expr: new Float(Long.MIN_VALUE.toFloat()), val: -9.223372E18f } # loss of precision + - { expr: new Float(Long.MAX_VALUE.toFloat()), val: 9.223372E18f} # loss of precision + - { expr: new Float(Float.MIN_VALUE), val: 1.4E-45f } + - { expr: new Float(Float.MAX_VALUE), val: 3.4028235E38f } + - { expr: new Float(Float.NEGATIVE_INFINITY.toFloat()), val: Float.NEGATIVE_INFINITY } + - { expr: new Float(Float.POSITIVE_INFINITY.toFloat()), val: Float.POSITIVE_INFINITY } - from_type: Float to_type: double values: - - { expr: new Float(+0.0 as float), val: +0.0 } - - { expr: new Float(-0.0 as float), val: -0.0 } - - { expr: new Float(Byte.MIN_VALUE as float), val: -128.0 } - - { expr: new Float(Byte.MAX_VALUE as float), val: 127.0 } - - { expr: new Float(Short.MIN_VALUE as float), val: -32768.0 } - - { expr: new Float(Short.MAX_VALUE as float), val: 32767.0 } - - { expr: new Float(Int.MIN_VALUE as float), val: -2.147483648E9 } # loss of precision - - { expr: new Float(Int.MAX_VALUE as float), val: 2.147483648E9 } # loss of precision - - { expr: new Float(Long.MIN_VALUE as float), val: -9.223372036854776E18 } # loss of precision - - { expr: new Float(Long.MAX_VALUE as float), val: 9.223372036854776E18 } # loss of precision + - { expr: new Float(+0.0f), val: +0.0 } + - { expr: new Float(-0.0f), val: -0.0 } + - { expr: new Float(Byte.MIN_VALUE.toFloat()), val: -128.0 } + - { expr: new Float(Byte.MAX_VALUE.toFloat()), val: 127.0 } + - { expr: new Float(Short.MIN_VALUE.toFloat()), val: -32768.0 } + - { expr: new Float(Short.MAX_VALUE.toFloat()), val: 32767.0 } + - { expr: new Float(Int.MIN_VALUE.toFloat()), val: -2.147483648E9 } # loss of precision + - { expr: new Float(Int.MAX_VALUE.toFloat()), val: 2.147483648E9 } # loss of precision + - { expr: new Float(Long.MIN_VALUE.toFloat()), val: -9.223372036854776E18 } # loss of precision + - { expr: new Float(Long.MAX_VALUE.toFloat()), val: 9.223372036854776E18 } # loss of precision - { expr: new Float(Float.MIN_VALUE), val: 1.401298464324817E-45 } - { expr: new Float(Float.MAX_VALUE), val: 3.4028234663852886E38 } - - { expr: new Float(Float.NEGATIVE_INFINITY as float), val: Float.NEGATIVE_INFINITY as double } - - { expr: new Float(Float.POSITIVE_INFINITY as float), val: Float.POSITIVE_INFINITY as double } + - { expr: new Float(Float.NEGATIVE_INFINITY.toFloat()), val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: new Float(Float.POSITIVE_INFINITY.toFloat()), val: Float.POSITIVE_INFINITY.toDouble() } - from_type: Double to_type: double values: - - { expr: new Double(+0.0 as float), val: +0.0 } - - { expr: new Double(-0.0 as float), val: -0.0 } - - { expr: new Double(Byte.MIN_VALUE as double), val: -128.0 } - - { expr: new Double(Byte.MAX_VALUE as double), val: 127.0 } - - { expr: new Double(Short.MIN_VALUE as double), val: -32768.0 } - - { expr: new Double(Short.MAX_VALUE as double), val: 32767.0 } - - { expr: new Double(Int.MIN_VALUE as double), val: -2147483648.0 } - - { expr: new Double(Int.MAX_VALUE as double), val: 2147483647.0 } - - { expr: new Double(Long.MIN_VALUE as double), val: -9223372036854775808.0 } - - { expr: new Double(Long.MAX_VALUE as double), val: 9223372036854775807.0 } - - { expr: new Double(Float.MIN_VALUE as double), val: Float.MIN_VALUE as double } - - { expr: new Double(Float.MAX_VALUE as double), val: Float.MAX_VALUE as double } - - { expr: new Double(Float.NEGATIVE_INFINITY as double), val: Float.NEGATIVE_INFINITY as double } - - { expr: new Double(Float.POSITIVE_INFINITY as double), val: Float.POSITIVE_INFINITY as double } + - { expr: new Double(+0.0f), val: +0.0 } + - { expr: new Double(-0.0f), val: -0.0 } + - { expr: new Double(Byte.MIN_VALUE.toDouble()), val: -128.0 } + - { expr: new Double(Byte.MAX_VALUE.toDouble()), val: 127.0 } + - { expr: new Double(Short.MIN_VALUE.toDouble()), val: -32768.0 } + - { expr: new Double(Short.MAX_VALUE.toDouble()), val: 32767.0 } + - { expr: new Double(Int.MIN_VALUE.toDouble()), val: -2147483648.0 } + - { expr: new Double(Int.MAX_VALUE.toDouble()), val: 2147483647.0 } + - { expr: new Double(Long.MIN_VALUE.toDouble()), val: -9223372036854775808.0 } + - { expr: new Double(Long.MAX_VALUE.toDouble()), val: 9223372036854775807.0 } + - { expr: new Double(Float.MIN_VALUE.toDouble()), val: Float.MIN_VALUE.toDouble() } + - { expr: new Double(Float.MAX_VALUE.toDouble()), val: Float.MAX_VALUE.toDouble() } + - { expr: new Double(Float.NEGATIVE_INFINITY.toDouble()), val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: new Double(Float.POSITIVE_INFINITY.toDouble()), val: Float.POSITIVE_INFINITY.toDouble() } - { expr: new Double(Double.MIN_VALUE), val: Double.MIN_VALUE } - { expr: new Double(Double.MAX_VALUE), val: Double.MAX_VALUE } - - { expr: new Double(Double.NEGATIVE_INFINITY as double), val: Double.NEGATIVE_INFINITY as double } - - { expr: new Double(Double.POSITIVE_INFINITY as double), val: Double.POSITIVE_INFINITY as double } + - { expr: new Double(Double.NEGATIVE_INFINITY.toDouble()), val: Double.NEGATIVE_INFINITY.toDouble() } + - { expr: new Double(Double.POSITIVE_INFINITY.toDouble()), val: Double.POSITIVE_INFINITY.toDouble() } - from_type: Char to_type: char @@ -266,24 +266,24 @@ cases: - from_type: Char to_type: long values: - - { expr: "new Char(c'\\u0000')", val: 0 as long } - - { expr: "new Char(c'\\u007f')", val: 127 as long } - - { expr: "new Char(c'\\u8000')", val: 32768 as long } - - { expr: "new Char(c'\\uff80')", val: 65408 as long } - - { expr: "new Char(c'\\uffff')", val: 65535 as long } - - { expr: "new Char(c'\\ucafe')", val: 51966 as long } - - { expr: "new Char(c'R')", val: 82 as long } + - { expr: "new Char(c'\\u0000')", val: 0 } + - { expr: "new Char(c'\\u007f')", val: 127 } + - { expr: "new Char(c'\\u8000')", val: 32768 } + - { expr: "new Char(c'\\uff80')", val: 65408 } + - { expr: "new Char(c'\\uffff')", val: 65535 } + - { expr: "new Char(c'\\ucafe')", val: 51966 } + - { expr: "new Char(c'R')", val: 82 } - from_type: Char to_type: float values: - - { expr: "new Char(c'\\u0000')", val: 0.0 as float } - - { expr: "new Char(c'\\u007f')", val: 127.0 as float } - - { expr: "new Char(c'\\u8000')", val: 32768.0 as float } - - { expr: "new Char(c'\\uff80')", val: 65408.0 as float } - - { expr: "new Char(c'\\uffff')", val: 65535.0 as float } - - { expr: "new Char(c'\\ucafe')", val: 51966.0 as float } - - { expr: "new Char(c'R')", val: 82.0 as float } + - { expr: "new Char(c'\\u0000')", val: 0.0f } + - { expr: "new Char(c'\\u007f')", val: 127.0f } + - { expr: "new Char(c'\\u8000')", val: 32768.0f } + - { expr: "new Char(c'\\uff80')", val: 65408.0f } + - { expr: "new Char(c'\\uffff')", val: 65535.0f } + - { expr: "new Char(c'\\ucafe')", val: 51966.0f } + - { expr: "new Char(c'R')", val: 82.0f } - from_type: Char to_type: double diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/comp_arr/comp-arr.ets b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/comp_arr/comp-arr.ets index 44fbbe8b4a946e0d197eedd3db4f4e912b7c0524..c8e8e92761fa527e6e2942dff3e0559494701f5a 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/comp_arr/comp-arr.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/comp_arr/comp-arr.ets @@ -22,15 +22,12 @@ params: from {{c.from_type}} to {{c.to_type}} let s{{loop.index}}: {{c.from_type}} = {{t.expr|safe}} {%- endfor %} -function main(): int { +function main() { {%- for t in c['values'] %} let d{{loop.index}}: {{c.to_type}}[] = [s{{loop.index}}, s{{loop.index}}] d{{loop.index}} = [] d{{loop.index}} = [s{{loop.index}}] - if (d{{loop.index}}[0] != {{t.val}}) { - return 1 - } + assertEQ(d{{loop.index}}[0], {{t.val}}, "Assert fails on item {{loop.index}}") {%- endfor %} - return 0 } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/comp_arr/comp-arr.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/comp_arr/comp-arr.params.yaml index ea52b4d29e003d7a2e75a9d1f5f9bdca46bebfa8..93b18891e38bf87356a4c06978e9dfc52d8bd891 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/comp_arr/comp-arr.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/comp_arr/comp-arr.params.yaml @@ -17,50 +17,50 @@ cases: to_type: byte values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: short values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: int values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: long values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: float values: - - { expr: new Byte(), val: 0.0 as float } - - { expr: new Byte(127 as byte), val: 127.0 as float } - - { expr: new Byte(-128 as byte), val: -128.0 as float } + - { expr: new Byte(), val: 0.0f } + - { expr: new Byte(127), val: 127.0f } + - { expr: new Byte(-128), val: -128.0f } - from_type: Byte to_type: double values: - { expr: new Byte(), val: 0.0 } - - { expr: new Byte(127 as byte), val: 127.0 } - - { expr: new Byte(-128 as byte), val: -128.0 } + - { expr: new Byte(127), val: 127.0 } + - { expr: new Byte(-128), val: -128.0 } - from_type: Short to_type: short values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -68,8 +68,8 @@ cases: to_type: int values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -77,8 +77,8 @@ cases: to_type: long values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -86,17 +86,17 @@ cases: to_type: float values: - { expr: new Short(), val: 0.0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128.0 as float } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127.0 as float } - - { expr: new Short(Short.MIN_VALUE), val: -32768.0 as float } - - { expr: new Short(Short.MAX_VALUE), val: 32767.0 as float } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128.0f } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127.0f } + - { expr: new Short(Short.MIN_VALUE), val: -32768.0f } + - { expr: new Short(Short.MAX_VALUE), val: 32767.0f } - from_type: Short to_type: double values: - { expr: new Short(), val: 0.0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -104,10 +104,10 @@ cases: to_type: int values: - { expr: new Int(), val: 0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647 } @@ -115,10 +115,10 @@ cases: to_type: long values: - { expr: new Int(), val: 0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647 } @@ -126,21 +126,21 @@ cases: to_type: float values: - { expr: new Int(), val: 0.0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128.0 as float } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127.0 as float } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768.0 as float } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767.0 as float } - - { expr: new Int(Int.MIN_VALUE), val: -2147483600.0 as float } # loss of precision - - { expr: new Int(Int.MAX_VALUE), val: 2147483600.0 as float } # loss of precision + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128.0f } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127.0f } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768.0f } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767.0f } + - { expr: new Int(Int.MIN_VALUE), val: -2147483600.0f } # loss of precision + - { expr: new Int(Int.MAX_VALUE), val: 2147483600.0f } # loss of precision - from_type: Int to_type: double values: - { expr: new Int(), val: 0.0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128.0 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127.0 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768.0 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767.0 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128.0 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127.0 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768.0 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767.0 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648.0 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647.0 } @@ -148,12 +148,12 @@ cases: to_type: long values: - { expr: new Long(), val: 0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128 } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127 } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768 } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767 } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483648 } - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483647 } + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128 } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127 } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768 } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767 } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483648 } + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483647 } - { expr: new Long(Long.MIN_VALUE), val: -9223372036854775808 } - { expr: new Long(Long.MAX_VALUE), val: 9223372036854775807 } @@ -161,85 +161,85 @@ cases: to_type: float values: - { expr: new Long(), val: 0.0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128.0 as float } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127.0 as float } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768.0 as float } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767.0 as float } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483600.0 as float } # loss of precision - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483600.0 as float } # loss of precision - - { expr: new Long(Long.MIN_VALUE), val: -9223372000000000000.0 as float } # loss of precision - - { expr: new Long(Long.MAX_VALUE), val: 9223372000000000000.0 as float } # loss of precision + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128.0f } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127.0f } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768.0f } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767.0f } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483600.0f } # loss of precision + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483600.0f } # loss of precision + - { expr: new Long(Long.MIN_VALUE), val: -9223372000000000000.0f } # loss of precision + - { expr: new Long(Long.MAX_VALUE), val: 9223372000000000000.0f } # loss of precision - from_type: Long to_type: double values: - { expr: new Long(), val: 0.0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128.0 } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127.0 } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768.0 } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767.0 } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483648.0 } - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483647.0 } + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128.0 } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127.0 } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768.0 } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767.0 } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483648.0 } + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483647.0 } - { expr: new Long(Long.MIN_VALUE), val: -9223372036854775808.0 } - { expr: new Long(Long.MAX_VALUE), val: 9223372036854775807.0 } - from_type: Float to_type: float values: - - { expr: new Float(+0.0 as float), val: +0.0 as float } - - { expr: new Float(-0.0 as float), val: -0.0 as float } - - { expr: new Float(Byte.MIN_VALUE as float), val: -128.0 as float } - - { expr: new Float(Byte.MAX_VALUE as float), val: 127.0 as float } - - { expr: new Float(Short.MIN_VALUE as float), val: -32768.0 as float } - - { expr: new Float(Short.MAX_VALUE as float), val: 32767.0 as float } - - { expr: new Float(Int.MIN_VALUE as float), val: -2.14748365E9 as float } # loss of precision - - { expr: new Float(Int.MAX_VALUE as float), val: 2.14748365E9 as float } # loss of precision - - { expr: new Float(Long.MIN_VALUE as float), val: -9.223372E18 as float } # loss of precision - - { expr: new Float(Long.MAX_VALUE as float), val: 9.223372E18 as float } # loss of precision - - { expr: new Float(Float.MIN_VALUE), val: 1.4E-45 as float } - - { expr: new Float(Float.MAX_VALUE), val: 3.4028235E38 as float } - - { expr: new Float(Float.NEGATIVE_INFINITY as float), val: Float.NEGATIVE_INFINITY } - - { expr: new Float(Float.POSITIVE_INFINITY as float), val: Float.POSITIVE_INFINITY } + - { expr: new Float(+0.0f), val: +0.0f } + - { expr: new Float(-0.0f), val: -0.0f } + - { expr: new Float(Byte.MIN_VALUE.toFloat()), val: -128.0f } + - { expr: new Float(Byte.MAX_VALUE.toFloat()), val: 127.0f } + - { expr: new Float(Short.MIN_VALUE.toFloat()), val: -32768.0f } + - { expr: new Float(Short.MAX_VALUE.toFloat()), val: 32767.0f } + - { expr: new Float(Int.MIN_VALUE.toFloat()), val: -2.14748365E9f } # loss of precision + - { expr: new Float(Int.MAX_VALUE.toFloat()), val: 2.14748365E9f } # loss of precision + - { expr: new Float(Long.MIN_VALUE.toFloat()), val: -9.223372E18f } # loss of precision + - { expr: new Float(Long.MAX_VALUE.toFloat()), val: 9.223372E18f } # loss of precision + - { expr: new Float(Float.MIN_VALUE), val: 1.4E-45f} + - { expr: new Float(Float.MAX_VALUE), val: 3.4028235E38f } + - { expr: new Float(Float.NEGATIVE_INFINITY.toFloat()), val: Float.NEGATIVE_INFINITY } + - { expr: new Float(Float.POSITIVE_INFINITY.toFloat()), val: Float.POSITIVE_INFINITY } - from_type: Float to_type: double values: - - { expr: new Float(+0.0 as float), val: +0.0 } - - { expr: new Float(-0.0 as float), val: -0.0 } - - { expr: new Float(Byte.MIN_VALUE as float), val: -128.0 } - - { expr: new Float(Byte.MAX_VALUE as float), val: 127.0 } - - { expr: new Float(Short.MIN_VALUE as float), val: -32768.0 } - - { expr: new Float(Short.MAX_VALUE as float), val: 32767.0 } - - { expr: new Float(Int.MIN_VALUE as float), val: -2.147483648E9 } # loss of precision - - { expr: new Float(Int.MAX_VALUE as float), val: 2.147483648E9 } # loss of precision - - { expr: new Float(Long.MIN_VALUE as float), val: -9.223372036854776E18 } # loss of precision - - { expr: new Float(Long.MAX_VALUE as float), val: 9.223372036854776E18 } # loss of precision + - { expr: new Float(+0.0f), val: +0.0 } + - { expr: new Float(-0.0f), val: -0.0 } + - { expr: new Float(Byte.MIN_VALUE.toFloat()), val: -128.0 } + - { expr: new Float(Byte.MAX_VALUE.toFloat()), val: 127.0 } + - { expr: new Float(Short.MIN_VALUE.toFloat()), val: -32768.0 } + - { expr: new Float(Short.MAX_VALUE.toFloat()), val: 32767.0 } + - { expr: new Float(Int.MIN_VALUE.toFloat()), val: -2.147483648E9 } # loss of precision + - { expr: new Float(Int.MAX_VALUE.toFloat()), val: 2.147483648E9 } # loss of precision + - { expr: new Float(Long.MIN_VALUE.toFloat()), val: -9.223372036854776E18 } # loss of precision + - { expr: new Float(Long.MAX_VALUE.toFloat()), val: 9.223372036854776E18 } # loss of precision - { expr: new Float(Float.MIN_VALUE), val: 1.401298464324817E-45 } - { expr: new Float(Float.MAX_VALUE), val: 3.4028234663852886E38 } - - { expr: new Float(Float.NEGATIVE_INFINITY as float), val: Float.NEGATIVE_INFINITY as double } - - { expr: new Float(Float.POSITIVE_INFINITY as float), val: Float.POSITIVE_INFINITY as double } + - { expr: new Float(Float.NEGATIVE_INFINITY.toFloat()), val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: new Float(Float.POSITIVE_INFINITY.toFloat()), val: Float.POSITIVE_INFINITY.toDouble() } - from_type: Double to_type: double values: - - { expr: new Double(+0.0 as float), val: +0.0 } - - { expr: new Double(-0.0 as float), val: -0.0 } - - { expr: new Double(Byte.MIN_VALUE as double), val: -128.0 } - - { expr: new Double(Byte.MAX_VALUE as double), val: 127.0 } - - { expr: new Double(Short.MIN_VALUE as double), val: -32768.0 } - - { expr: new Double(Short.MAX_VALUE as double), val: 32767.0 } - - { expr: new Double(Int.MIN_VALUE as double), val: -2147483648.0 } - - { expr: new Double(Int.MAX_VALUE as double), val: 2147483647.0 } - - { expr: new Double(Long.MIN_VALUE as double), val: -9223372036854775808.0 } - - { expr: new Double(Long.MAX_VALUE as double), val: 9223372036854775807.0 } - - { expr: new Double(Float.MIN_VALUE as double), val: Float.MIN_VALUE as double } - - { expr: new Double(Float.MAX_VALUE as double), val: Float.MAX_VALUE as double } - - { expr: new Double(Float.NEGATIVE_INFINITY as double), val: Float.NEGATIVE_INFINITY as double } - - { expr: new Double(Float.POSITIVE_INFINITY as double), val: Float.POSITIVE_INFINITY as double } + - { expr: new Double(+0.0f), val: +0.0 } + - { expr: new Double(-0.0f), val: -0.0 } + - { expr: new Double(Byte.MIN_VALUE.toDouble()), val: -128.0 } + - { expr: new Double(Byte.MAX_VALUE.toDouble()), val: 127.0 } + - { expr: new Double(Short.MIN_VALUE.toDouble()), val: -32768.0 } + - { expr: new Double(Short.MAX_VALUE.toDouble()), val: 32767.0 } + - { expr: new Double(Int.MIN_VALUE.toDouble()), val: -2147483648.0 } + - { expr: new Double(Int.MAX_VALUE.toDouble()), val: 2147483647.0 } + - { expr: new Double(Long.MIN_VALUE.toDouble()), val: -9223372036854775808.0 } + - { expr: new Double(Long.MAX_VALUE.toDouble()), val: 9223372036854775807.0 } + - { expr: new Double(Float.MIN_VALUE.toDouble()), val: Float.MIN_VALUE.toDouble() } + - { expr: new Double(Float.MAX_VALUE.toDouble()), val: Float.MAX_VALUE.toDouble() } + - { expr: new Double(Float.NEGATIVE_INFINITY.toDouble()), val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: new Double(Float.POSITIVE_INFINITY.toDouble()), val: Float.POSITIVE_INFINITY.toDouble() } - { expr: new Double(Double.MIN_VALUE), val: Double.MIN_VALUE } - { expr: new Double(Double.MAX_VALUE), val: Double.MAX_VALUE } - - { expr: new Double(Double.NEGATIVE_INFINITY as double), val: Double.NEGATIVE_INFINITY as double } - - { expr: new Double(Double.POSITIVE_INFINITY as double), val: Double.POSITIVE_INFINITY as double } + - { expr: new Double(Double.NEGATIVE_INFINITY.toDouble()), val: Double.NEGATIVE_INFINITY.toDouble() } + - { expr: new Double(Double.POSITIVE_INFINITY.toDouble()), val: Double.POSITIVE_INFINITY.toDouble() } - from_type: Char to_type: char @@ -266,24 +266,24 @@ cases: - from_type: Char to_type: long values: - - { expr: "new Char(c'\\u0000')", val: 0 as long } - - { expr: "new Char(c'\\u007f')", val: 127 as long } - - { expr: "new Char(c'\\u8000')", val: 32768 as long } - - { expr: "new Char(c'\\uff80')", val: 65408 as long } - - { expr: "new Char(c'\\uffff')", val: 65535 as long } - - { expr: "new Char(c'\\ucafe')", val: 51966 as long } - - { expr: "new Char(c'R')", val: 82 as long } + - { expr: "new Char(c'\\u0000')", val: 0 } + - { expr: "new Char(c'\\u007f')", val: 127 } + - { expr: "new Char(c'\\u8000')", val: 32768 } + - { expr: "new Char(c'\\uff80')", val: 65408 } + - { expr: "new Char(c'\\uffff')", val: 65535 } + - { expr: "new Char(c'\\ucafe')", val: 51966 } + - { expr: "new Char(c'R')", val: 82 } - from_type: Char to_type: float values: - - { expr: "new Char(c'\\u0000')", val: 0.0 as float } - - { expr: "new Char(c'\\u007f')", val: 127.0 as float } - - { expr: "new Char(c'\\u8000')", val: 32768.0 as float } - - { expr: "new Char(c'\\uff80')", val: 65408.0 as float } - - { expr: "new Char(c'\\uffff')", val: 65535.0 as float } - - { expr: "new Char(c'\\ucafe')", val: 51966.0 as float } - - { expr: "new Char(c'R')", val: 82.0 as float } + - { expr: "new Char(c'\\u0000')", val: 0.0f } + - { expr: "new Char(c'\\u007f')", val: 127.0f } + - { expr: "new Char(c'\\u8000')", val: 32768.0f } + - { expr: "new Char(c'\\uff80')", val: 65408.0f } + - { expr: "new Char(c'\\uffff')", val: 65535.0f } + - { expr: "new Char(c'\\ucafe')", val: 51966.0f } + - { expr: "new Char(c'R')", val: 82.0f } - from_type: Char to_type: double diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/comp_obj/comp-clss.ets b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/comp_obj/comp-clss.ets index d06f8cb9e9b82c915f857c00c1b879e39604763f..348234d0e54420b55a05da927bed71962e3f4366 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/comp_obj/comp-clss.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/comp_obj/comp-clss.ets @@ -23,13 +23,10 @@ class A{{loop.index}} { fld: {{c.to_type}} } let s{{loop.index}}: {{c.from_type}} = {{t.expr|safe}}; {%- endfor %} -function main(): int { +function main() { {%- for t in c['values'] %} let d{{loop.index}}: A{{loop.index}} = { fld: s{{loop.index}} } - if (d{{loop.index}}.fld != {{t.val}}) { - return 1 - } + assertEQ(d{{loop.index}}.fld, {{t.val}}, "Assert fails on item {{loop.index}}") {%- endfor %} - return 0 } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/comp_obj/comp-clss.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/comp_obj/comp-clss.params.yaml index ea52b4d29e003d7a2e75a9d1f5f9bdca46bebfa8..2cec623ad19cac71cd545202f2859e450b8eaba5 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/comp_obj/comp-clss.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/comp_obj/comp-clss.params.yaml @@ -17,50 +17,50 @@ cases: to_type: byte values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: short values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: int values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: long values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: float values: - - { expr: new Byte(), val: 0.0 as float } - - { expr: new Byte(127 as byte), val: 127.0 as float } - - { expr: new Byte(-128 as byte), val: -128.0 as float } + - { expr: new Byte(), val: 0.0f } + - { expr: new Byte(127), val: 127.0f } + - { expr: new Byte(-128), val: -128.0f } - from_type: Byte to_type: double values: - { expr: new Byte(), val: 0.0 } - - { expr: new Byte(127 as byte), val: 127.0 } - - { expr: new Byte(-128 as byte), val: -128.0 } + - { expr: new Byte(127), val: 127.0 } + - { expr: new Byte(-128), val: -128.0 } - from_type: Short to_type: short values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -68,8 +68,8 @@ cases: to_type: int values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -77,8 +77,8 @@ cases: to_type: long values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -86,17 +86,17 @@ cases: to_type: float values: - { expr: new Short(), val: 0.0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128.0 as float } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127.0 as float } - - { expr: new Short(Short.MIN_VALUE), val: -32768.0 as float } - - { expr: new Short(Short.MAX_VALUE), val: 32767.0 as float } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128.0f } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127.0f } + - { expr: new Short(Short.MIN_VALUE), val: -32768.0f } + - { expr: new Short(Short.MAX_VALUE), val: 32767.0f } - from_type: Short to_type: double values: - { expr: new Short(), val: 0.0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -104,10 +104,10 @@ cases: to_type: int values: - { expr: new Int(), val: 0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647 } @@ -115,10 +115,10 @@ cases: to_type: long values: - { expr: new Int(), val: 0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647 } @@ -126,21 +126,21 @@ cases: to_type: float values: - { expr: new Int(), val: 0.0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128.0 as float } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127.0 as float } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768.0 as float } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767.0 as float } - - { expr: new Int(Int.MIN_VALUE), val: -2147483600.0 as float } # loss of precision - - { expr: new Int(Int.MAX_VALUE), val: 2147483600.0 as float } # loss of precision + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128.0f } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127.0f } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768.0f } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767.0f } + - { expr: new Int(Int.MIN_VALUE), val: -2147483600.0f } # loss of precision + - { expr: new Int(Int.MAX_VALUE), val: 2147483600.0f } # loss of precision - from_type: Int to_type: double values: - { expr: new Int(), val: 0.0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128.0 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127.0 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768.0 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767.0 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128.0 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127.0 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768.0 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767.0 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648.0 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647.0 } @@ -148,12 +148,12 @@ cases: to_type: long values: - { expr: new Long(), val: 0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128 } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127 } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768 } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767 } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483648 } - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483647 } + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128 } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127 } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768 } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767 } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483648 } + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483647 } - { expr: new Long(Long.MIN_VALUE), val: -9223372036854775808 } - { expr: new Long(Long.MAX_VALUE), val: 9223372036854775807 } @@ -161,85 +161,85 @@ cases: to_type: float values: - { expr: new Long(), val: 0.0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128.0 as float } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127.0 as float } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768.0 as float } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767.0 as float } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483600.0 as float } # loss of precision - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483600.0 as float } # loss of precision - - { expr: new Long(Long.MIN_VALUE), val: -9223372000000000000.0 as float } # loss of precision - - { expr: new Long(Long.MAX_VALUE), val: 9223372000000000000.0 as float } # loss of precision + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128.0f } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127.0f } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768.0f } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767.0f } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483600.0f } # loss of precision + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483600.0f } # loss of precision + - { expr: new Long(Long.MIN_VALUE), val: -9223372000000000000.0f } # loss of precision + - { expr: new Long(Long.MAX_VALUE), val: 9223372000000000000.0f } # loss of precision - from_type: Long to_type: double values: - { expr: new Long(), val: 0.0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128.0 } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127.0 } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768.0 } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767.0 } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483648.0 } - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483647.0 } + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128.0 } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127.0 } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768.0 } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767.0 } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483648.0 } + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483647.0 } - { expr: new Long(Long.MIN_VALUE), val: -9223372036854775808.0 } - { expr: new Long(Long.MAX_VALUE), val: 9223372036854775807.0 } - from_type: Float to_type: float values: - - { expr: new Float(+0.0 as float), val: +0.0 as float } - - { expr: new Float(-0.0 as float), val: -0.0 as float } - - { expr: new Float(Byte.MIN_VALUE as float), val: -128.0 as float } - - { expr: new Float(Byte.MAX_VALUE as float), val: 127.0 as float } - - { expr: new Float(Short.MIN_VALUE as float), val: -32768.0 as float } - - { expr: new Float(Short.MAX_VALUE as float), val: 32767.0 as float } - - { expr: new Float(Int.MIN_VALUE as float), val: -2.14748365E9 as float } # loss of precision - - { expr: new Float(Int.MAX_VALUE as float), val: 2.14748365E9 as float } # loss of precision - - { expr: new Float(Long.MIN_VALUE as float), val: -9.223372E18 as float } # loss of precision - - { expr: new Float(Long.MAX_VALUE as float), val: 9.223372E18 as float } # loss of precision - - { expr: new Float(Float.MIN_VALUE), val: 1.4E-45 as float } - - { expr: new Float(Float.MAX_VALUE), val: 3.4028235E38 as float } - - { expr: new Float(Float.NEGATIVE_INFINITY as float), val: Float.NEGATIVE_INFINITY } - - { expr: new Float(Float.POSITIVE_INFINITY as float), val: Float.POSITIVE_INFINITY } + - { expr: new Float(+0.0f), val: +0.0f } + - { expr: new Float(-0.0f), val: -0.0f } + - { expr: new Float(Byte.MIN_VALUE.toFloat()), val: -128.0f } + - { expr: new Float(Byte.MAX_VALUE.toFloat()), val: 127.0f } + - { expr: new Float(Short.MIN_VALUE.toFloat()), val: -32768.0f } + - { expr: new Float(Short.MAX_VALUE.toFloat()), val: 32767.0f } + - { expr: new Float(Int.MIN_VALUE.toFloat()), val: -2.14748365E9f } # loss of precision + - { expr: new Float(Int.MAX_VALUE.toFloat()), val: 2.14748365E9f } # loss of precision + - { expr: new Float(Long.MIN_VALUE.toFloat()), val: -9.223372E18f } # loss of precision + - { expr: new Float(Long.MAX_VALUE.toFloat()), val: 9.223372E18f } # loss of precision + - { expr: new Float(Float.MIN_VALUE), val: 1.4E-45f } + - { expr: new Float(Float.MAX_VALUE), val: 3.4028235E38f } + - { expr: new Float(Float.NEGATIVE_INFINITY.toFloat()), val: Float.NEGATIVE_INFINITY } + - { expr: new Float(Float.POSITIVE_INFINITY.toFloat()), val: Float.POSITIVE_INFINITY } - from_type: Float to_type: double values: - - { expr: new Float(+0.0 as float), val: +0.0 } - - { expr: new Float(-0.0 as float), val: -0.0 } - - { expr: new Float(Byte.MIN_VALUE as float), val: -128.0 } - - { expr: new Float(Byte.MAX_VALUE as float), val: 127.0 } - - { expr: new Float(Short.MIN_VALUE as float), val: -32768.0 } - - { expr: new Float(Short.MAX_VALUE as float), val: 32767.0 } - - { expr: new Float(Int.MIN_VALUE as float), val: -2.147483648E9 } # loss of precision - - { expr: new Float(Int.MAX_VALUE as float), val: 2.147483648E9 } # loss of precision - - { expr: new Float(Long.MIN_VALUE as float), val: -9.223372036854776E18 } # loss of precision - - { expr: new Float(Long.MAX_VALUE as float), val: 9.223372036854776E18 } # loss of precision + - { expr: new Float(+0.0f), val: +0.0 } + - { expr: new Float(-0.0f), val: -0.0 } + - { expr: new Float(Byte.MIN_VALUE.toFloat()), val: -128.0 } + - { expr: new Float(Byte.MAX_VALUE.toFloat()), val: 127.0 } + - { expr: new Float(Short.MIN_VALUE.toFloat()), val: -32768.0 } + - { expr: new Float(Short.MAX_VALUE.toFloat()), val: 32767.0 } + - { expr: new Float(Int.MIN_VALUE.toFloat()), val: -2.147483648E9 } # loss of precision + - { expr: new Float(Int.MAX_VALUE.toFloat()), val: 2.147483648E9 } # loss of precision + - { expr: new Float(Long.MIN_VALUE.toFloat()), val: -9.223372036854776E18 } # loss of precision + - { expr: new Float(Long.MAX_VALUE.toFloat()), val: 9.223372036854776E18 } # loss of precision - { expr: new Float(Float.MIN_VALUE), val: 1.401298464324817E-45 } - { expr: new Float(Float.MAX_VALUE), val: 3.4028234663852886E38 } - - { expr: new Float(Float.NEGATIVE_INFINITY as float), val: Float.NEGATIVE_INFINITY as double } - - { expr: new Float(Float.POSITIVE_INFINITY as float), val: Float.POSITIVE_INFINITY as double } + - { expr: new Float(Float.NEGATIVE_INFINITY.toFloat()), val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: new Float(Float.POSITIVE_INFINITY.toFloat()), val: Float.POSITIVE_INFINITY.toDouble() } - from_type: Double to_type: double values: - - { expr: new Double(+0.0 as float), val: +0.0 } - - { expr: new Double(-0.0 as float), val: -0.0 } - - { expr: new Double(Byte.MIN_VALUE as double), val: -128.0 } - - { expr: new Double(Byte.MAX_VALUE as double), val: 127.0 } - - { expr: new Double(Short.MIN_VALUE as double), val: -32768.0 } - - { expr: new Double(Short.MAX_VALUE as double), val: 32767.0 } - - { expr: new Double(Int.MIN_VALUE as double), val: -2147483648.0 } - - { expr: new Double(Int.MAX_VALUE as double), val: 2147483647.0 } - - { expr: new Double(Long.MIN_VALUE as double), val: -9223372036854775808.0 } - - { expr: new Double(Long.MAX_VALUE as double), val: 9223372036854775807.0 } - - { expr: new Double(Float.MIN_VALUE as double), val: Float.MIN_VALUE as double } - - { expr: new Double(Float.MAX_VALUE as double), val: Float.MAX_VALUE as double } - - { expr: new Double(Float.NEGATIVE_INFINITY as double), val: Float.NEGATIVE_INFINITY as double } - - { expr: new Double(Float.POSITIVE_INFINITY as double), val: Float.POSITIVE_INFINITY as double } + - { expr: new Double(+0.0f), val: +0.0 } + - { expr: new Double(-0.0f), val: -0.0 } + - { expr: new Double(Byte.MIN_VALUE.toDouble()), val: -128.0 } + - { expr: new Double(Byte.MAX_VALUE.toDouble()), val: 127.0 } + - { expr: new Double(Short.MIN_VALUE.toDouble()), val: -32768.0 } + - { expr: new Double(Short.MAX_VALUE.toDouble()), val: 32767.0 } + - { expr: new Double(Int.MIN_VALUE.toDouble()), val: -2147483648.0 } + - { expr: new Double(Int.MAX_VALUE.toDouble()), val: 2147483647.0 } + - { expr: new Double(Long.MIN_VALUE.toDouble()), val: -9223372036854775808.0 } + - { expr: new Double(Long.MAX_VALUE.toDouble()), val: 9223372036854775807.0 } + - { expr: new Double(Float.MIN_VALUE.toDouble()), val: Float.MIN_VALUE.toDouble() } + - { expr: new Double(Float.MAX_VALUE.toDouble()), val: Float.MAX_VALUE.toDouble() } + - { expr: new Double(Float.NEGATIVE_INFINITY.toDouble()), val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: new Double(Float.POSITIVE_INFINITY.toDouble()), val: Float.POSITIVE_INFINITY.toDouble() } - { expr: new Double(Double.MIN_VALUE), val: Double.MIN_VALUE } - { expr: new Double(Double.MAX_VALUE), val: Double.MAX_VALUE } - - { expr: new Double(Double.NEGATIVE_INFINITY as double), val: Double.NEGATIVE_INFINITY as double } - - { expr: new Double(Double.POSITIVE_INFINITY as double), val: Double.POSITIVE_INFINITY as double } + - { expr: new Double(Double.NEGATIVE_INFINITY.toDouble()), val: Double.NEGATIVE_INFINITY.toDouble() } + - { expr: new Double(Double.POSITIVE_INFINITY.toDouble()), val: Double.POSITIVE_INFINITY.toDouble() } - from_type: Char to_type: char @@ -266,24 +266,24 @@ cases: - from_type: Char to_type: long values: - - { expr: "new Char(c'\\u0000')", val: 0 as long } - - { expr: "new Char(c'\\u007f')", val: 127 as long } - - { expr: "new Char(c'\\u8000')", val: 32768 as long } - - { expr: "new Char(c'\\uff80')", val: 65408 as long } - - { expr: "new Char(c'\\uffff')", val: 65535 as long } - - { expr: "new Char(c'\\ucafe')", val: 51966 as long } - - { expr: "new Char(c'R')", val: 82 as long } + - { expr: "new Char(c'\\u0000')", val: 0 } + - { expr: "new Char(c'\\u007f')", val: 127 } + - { expr: "new Char(c'\\u8000')", val: 32768 } + - { expr: "new Char(c'\\uff80')", val: 65408 } + - { expr: "new Char(c'\\uffff')", val: 65535 } + - { expr: "new Char(c'\\ucafe')", val: 51966 } + - { expr: "new Char(c'R')", val: 82 } - from_type: Char to_type: float values: - - { expr: "new Char(c'\\u0000')", val: 0.0 as float } - - { expr: "new Char(c'\\u007f')", val: 127.0 as float } - - { expr: "new Char(c'\\u8000')", val: 32768.0 as float } - - { expr: "new Char(c'\\uff80')", val: 65408.0 as float } - - { expr: "new Char(c'\\uffff')", val: 65535.0 as float } - - { expr: "new Char(c'\\ucafe')", val: 51966.0 as float } - - { expr: "new Char(c'R')", val: 82.0 as float } + - { expr: "new Char(c'\\u0000')", val: 0.0f } + - { expr: "new Char(c'\\u007f')", val: 127.0f } + - { expr: "new Char(c'\\u8000')", val: 32768.0f } + - { expr: "new Char(c'\\uff80')", val: 65408.0f } + - { expr: "new Char(c'\\uffff')", val: 65535.0f } + - { expr: "new Char(c'\\ucafe')", val: 51966.0f } + - { expr: "new Char(c'R')", val: 82.0f } - from_type: Char to_type: double diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/comp_obj/comp-intf.ets b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/comp_obj/comp-intf.ets index 8050299faef7c82a7d90048ba60f2a6ba1dbb764..7757f618d919ac9d162f94dee985408326ac1153 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/comp_obj/comp-intf.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/comp_obj/comp-intf.ets @@ -23,13 +23,10 @@ interface J{{loop.index}} { fld: {{c.to_type}} } let s{{loop.index}}: {{c.from_type}} = {{t.expr|safe}}; {%- endfor %} -function main(): int { +function main() { {%- for t in c['values'] %} let d{{loop.index}}: J{{loop.index}} = { fld: s{{loop.index}} } - if (d{{loop.index}}.fld != {{t.val}}) { - return 1 - } + assertEQ(d{{loop.index}}.fld, {{t.val}}, "Assert fails on item {{loop.index}}") {%- endfor %} - return 0 } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/comp_obj/comp-intf.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/comp_obj/comp-intf.params.yaml index ea52b4d29e003d7a2e75a9d1f5f9bdca46bebfa8..2cec623ad19cac71cd545202f2859e450b8eaba5 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/comp_obj/comp-intf.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/comp_obj/comp-intf.params.yaml @@ -17,50 +17,50 @@ cases: to_type: byte values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: short values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: int values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: long values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: float values: - - { expr: new Byte(), val: 0.0 as float } - - { expr: new Byte(127 as byte), val: 127.0 as float } - - { expr: new Byte(-128 as byte), val: -128.0 as float } + - { expr: new Byte(), val: 0.0f } + - { expr: new Byte(127), val: 127.0f } + - { expr: new Byte(-128), val: -128.0f } - from_type: Byte to_type: double values: - { expr: new Byte(), val: 0.0 } - - { expr: new Byte(127 as byte), val: 127.0 } - - { expr: new Byte(-128 as byte), val: -128.0 } + - { expr: new Byte(127), val: 127.0 } + - { expr: new Byte(-128), val: -128.0 } - from_type: Short to_type: short values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -68,8 +68,8 @@ cases: to_type: int values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -77,8 +77,8 @@ cases: to_type: long values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -86,17 +86,17 @@ cases: to_type: float values: - { expr: new Short(), val: 0.0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128.0 as float } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127.0 as float } - - { expr: new Short(Short.MIN_VALUE), val: -32768.0 as float } - - { expr: new Short(Short.MAX_VALUE), val: 32767.0 as float } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128.0f } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127.0f } + - { expr: new Short(Short.MIN_VALUE), val: -32768.0f } + - { expr: new Short(Short.MAX_VALUE), val: 32767.0f } - from_type: Short to_type: double values: - { expr: new Short(), val: 0.0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -104,10 +104,10 @@ cases: to_type: int values: - { expr: new Int(), val: 0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647 } @@ -115,10 +115,10 @@ cases: to_type: long values: - { expr: new Int(), val: 0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647 } @@ -126,21 +126,21 @@ cases: to_type: float values: - { expr: new Int(), val: 0.0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128.0 as float } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127.0 as float } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768.0 as float } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767.0 as float } - - { expr: new Int(Int.MIN_VALUE), val: -2147483600.0 as float } # loss of precision - - { expr: new Int(Int.MAX_VALUE), val: 2147483600.0 as float } # loss of precision + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128.0f } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127.0f } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768.0f } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767.0f } + - { expr: new Int(Int.MIN_VALUE), val: -2147483600.0f } # loss of precision + - { expr: new Int(Int.MAX_VALUE), val: 2147483600.0f } # loss of precision - from_type: Int to_type: double values: - { expr: new Int(), val: 0.0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128.0 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127.0 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768.0 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767.0 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128.0 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127.0 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768.0 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767.0 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648.0 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647.0 } @@ -148,12 +148,12 @@ cases: to_type: long values: - { expr: new Long(), val: 0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128 } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127 } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768 } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767 } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483648 } - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483647 } + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128 } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127 } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768 } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767 } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483648 } + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483647 } - { expr: new Long(Long.MIN_VALUE), val: -9223372036854775808 } - { expr: new Long(Long.MAX_VALUE), val: 9223372036854775807 } @@ -161,85 +161,85 @@ cases: to_type: float values: - { expr: new Long(), val: 0.0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128.0 as float } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127.0 as float } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768.0 as float } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767.0 as float } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483600.0 as float } # loss of precision - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483600.0 as float } # loss of precision - - { expr: new Long(Long.MIN_VALUE), val: -9223372000000000000.0 as float } # loss of precision - - { expr: new Long(Long.MAX_VALUE), val: 9223372000000000000.0 as float } # loss of precision + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128.0f } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127.0f } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768.0f } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767.0f } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483600.0f } # loss of precision + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483600.0f } # loss of precision + - { expr: new Long(Long.MIN_VALUE), val: -9223372000000000000.0f } # loss of precision + - { expr: new Long(Long.MAX_VALUE), val: 9223372000000000000.0f } # loss of precision - from_type: Long to_type: double values: - { expr: new Long(), val: 0.0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128.0 } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127.0 } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768.0 } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767.0 } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483648.0 } - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483647.0 } + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128.0 } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127.0 } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768.0 } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767.0 } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483648.0 } + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483647.0 } - { expr: new Long(Long.MIN_VALUE), val: -9223372036854775808.0 } - { expr: new Long(Long.MAX_VALUE), val: 9223372036854775807.0 } - from_type: Float to_type: float values: - - { expr: new Float(+0.0 as float), val: +0.0 as float } - - { expr: new Float(-0.0 as float), val: -0.0 as float } - - { expr: new Float(Byte.MIN_VALUE as float), val: -128.0 as float } - - { expr: new Float(Byte.MAX_VALUE as float), val: 127.0 as float } - - { expr: new Float(Short.MIN_VALUE as float), val: -32768.0 as float } - - { expr: new Float(Short.MAX_VALUE as float), val: 32767.0 as float } - - { expr: new Float(Int.MIN_VALUE as float), val: -2.14748365E9 as float } # loss of precision - - { expr: new Float(Int.MAX_VALUE as float), val: 2.14748365E9 as float } # loss of precision - - { expr: new Float(Long.MIN_VALUE as float), val: -9.223372E18 as float } # loss of precision - - { expr: new Float(Long.MAX_VALUE as float), val: 9.223372E18 as float } # loss of precision - - { expr: new Float(Float.MIN_VALUE), val: 1.4E-45 as float } - - { expr: new Float(Float.MAX_VALUE), val: 3.4028235E38 as float } - - { expr: new Float(Float.NEGATIVE_INFINITY as float), val: Float.NEGATIVE_INFINITY } - - { expr: new Float(Float.POSITIVE_INFINITY as float), val: Float.POSITIVE_INFINITY } + - { expr: new Float(+0.0f), val: +0.0f } + - { expr: new Float(-0.0f), val: -0.0f } + - { expr: new Float(Byte.MIN_VALUE.toFloat()), val: -128.0f } + - { expr: new Float(Byte.MAX_VALUE.toFloat()), val: 127.0f } + - { expr: new Float(Short.MIN_VALUE.toFloat()), val: -32768.0f } + - { expr: new Float(Short.MAX_VALUE.toFloat()), val: 32767.0f } + - { expr: new Float(Int.MIN_VALUE.toFloat()), val: -2.14748365E9f } # loss of precision + - { expr: new Float(Int.MAX_VALUE.toFloat()), val: 2.14748365E9f } # loss of precision + - { expr: new Float(Long.MIN_VALUE.toFloat()), val: -9.223372E18f } # loss of precision + - { expr: new Float(Long.MAX_VALUE.toFloat()), val: 9.223372E18f } # loss of precision + - { expr: new Float(Float.MIN_VALUE), val: 1.4E-45f } + - { expr: new Float(Float.MAX_VALUE), val: 3.4028235E38f } + - { expr: new Float(Float.NEGATIVE_INFINITY.toFloat()), val: Float.NEGATIVE_INFINITY } + - { expr: new Float(Float.POSITIVE_INFINITY.toFloat()), val: Float.POSITIVE_INFINITY } - from_type: Float to_type: double values: - - { expr: new Float(+0.0 as float), val: +0.0 } - - { expr: new Float(-0.0 as float), val: -0.0 } - - { expr: new Float(Byte.MIN_VALUE as float), val: -128.0 } - - { expr: new Float(Byte.MAX_VALUE as float), val: 127.0 } - - { expr: new Float(Short.MIN_VALUE as float), val: -32768.0 } - - { expr: new Float(Short.MAX_VALUE as float), val: 32767.0 } - - { expr: new Float(Int.MIN_VALUE as float), val: -2.147483648E9 } # loss of precision - - { expr: new Float(Int.MAX_VALUE as float), val: 2.147483648E9 } # loss of precision - - { expr: new Float(Long.MIN_VALUE as float), val: -9.223372036854776E18 } # loss of precision - - { expr: new Float(Long.MAX_VALUE as float), val: 9.223372036854776E18 } # loss of precision + - { expr: new Float(+0.0f), val: +0.0 } + - { expr: new Float(-0.0f), val: -0.0 } + - { expr: new Float(Byte.MIN_VALUE.toFloat()), val: -128.0 } + - { expr: new Float(Byte.MAX_VALUE.toFloat()), val: 127.0 } + - { expr: new Float(Short.MIN_VALUE.toFloat()), val: -32768.0 } + - { expr: new Float(Short.MAX_VALUE.toFloat()), val: 32767.0 } + - { expr: new Float(Int.MIN_VALUE.toFloat()), val: -2.147483648E9 } # loss of precision + - { expr: new Float(Int.MAX_VALUE.toFloat()), val: 2.147483648E9 } # loss of precision + - { expr: new Float(Long.MIN_VALUE.toFloat()), val: -9.223372036854776E18 } # loss of precision + - { expr: new Float(Long.MAX_VALUE.toFloat()), val: 9.223372036854776E18 } # loss of precision - { expr: new Float(Float.MIN_VALUE), val: 1.401298464324817E-45 } - { expr: new Float(Float.MAX_VALUE), val: 3.4028234663852886E38 } - - { expr: new Float(Float.NEGATIVE_INFINITY as float), val: Float.NEGATIVE_INFINITY as double } - - { expr: new Float(Float.POSITIVE_INFINITY as float), val: Float.POSITIVE_INFINITY as double } + - { expr: new Float(Float.NEGATIVE_INFINITY.toFloat()), val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: new Float(Float.POSITIVE_INFINITY.toFloat()), val: Float.POSITIVE_INFINITY.toDouble() } - from_type: Double to_type: double values: - - { expr: new Double(+0.0 as float), val: +0.0 } - - { expr: new Double(-0.0 as float), val: -0.0 } - - { expr: new Double(Byte.MIN_VALUE as double), val: -128.0 } - - { expr: new Double(Byte.MAX_VALUE as double), val: 127.0 } - - { expr: new Double(Short.MIN_VALUE as double), val: -32768.0 } - - { expr: new Double(Short.MAX_VALUE as double), val: 32767.0 } - - { expr: new Double(Int.MIN_VALUE as double), val: -2147483648.0 } - - { expr: new Double(Int.MAX_VALUE as double), val: 2147483647.0 } - - { expr: new Double(Long.MIN_VALUE as double), val: -9223372036854775808.0 } - - { expr: new Double(Long.MAX_VALUE as double), val: 9223372036854775807.0 } - - { expr: new Double(Float.MIN_VALUE as double), val: Float.MIN_VALUE as double } - - { expr: new Double(Float.MAX_VALUE as double), val: Float.MAX_VALUE as double } - - { expr: new Double(Float.NEGATIVE_INFINITY as double), val: Float.NEGATIVE_INFINITY as double } - - { expr: new Double(Float.POSITIVE_INFINITY as double), val: Float.POSITIVE_INFINITY as double } + - { expr: new Double(+0.0f), val: +0.0 } + - { expr: new Double(-0.0f), val: -0.0 } + - { expr: new Double(Byte.MIN_VALUE.toDouble()), val: -128.0 } + - { expr: new Double(Byte.MAX_VALUE.toDouble()), val: 127.0 } + - { expr: new Double(Short.MIN_VALUE.toDouble()), val: -32768.0 } + - { expr: new Double(Short.MAX_VALUE.toDouble()), val: 32767.0 } + - { expr: new Double(Int.MIN_VALUE.toDouble()), val: -2147483648.0 } + - { expr: new Double(Int.MAX_VALUE.toDouble()), val: 2147483647.0 } + - { expr: new Double(Long.MIN_VALUE.toDouble()), val: -9223372036854775808.0 } + - { expr: new Double(Long.MAX_VALUE.toDouble()), val: 9223372036854775807.0 } + - { expr: new Double(Float.MIN_VALUE.toDouble()), val: Float.MIN_VALUE.toDouble() } + - { expr: new Double(Float.MAX_VALUE.toDouble()), val: Float.MAX_VALUE.toDouble() } + - { expr: new Double(Float.NEGATIVE_INFINITY.toDouble()), val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: new Double(Float.POSITIVE_INFINITY.toDouble()), val: Float.POSITIVE_INFINITY.toDouble() } - { expr: new Double(Double.MIN_VALUE), val: Double.MIN_VALUE } - { expr: new Double(Double.MAX_VALUE), val: Double.MAX_VALUE } - - { expr: new Double(Double.NEGATIVE_INFINITY as double), val: Double.NEGATIVE_INFINITY as double } - - { expr: new Double(Double.POSITIVE_INFINITY as double), val: Double.POSITIVE_INFINITY as double } + - { expr: new Double(Double.NEGATIVE_INFINITY.toDouble()), val: Double.NEGATIVE_INFINITY.toDouble() } + - { expr: new Double(Double.POSITIVE_INFINITY.toDouble()), val: Double.POSITIVE_INFINITY.toDouble() } - from_type: Char to_type: char @@ -266,24 +266,24 @@ cases: - from_type: Char to_type: long values: - - { expr: "new Char(c'\\u0000')", val: 0 as long } - - { expr: "new Char(c'\\u007f')", val: 127 as long } - - { expr: "new Char(c'\\u8000')", val: 32768 as long } - - { expr: "new Char(c'\\uff80')", val: 65408 as long } - - { expr: "new Char(c'\\uffff')", val: 65535 as long } - - { expr: "new Char(c'\\ucafe')", val: 51966 as long } - - { expr: "new Char(c'R')", val: 82 as long } + - { expr: "new Char(c'\\u0000')", val: 0 } + - { expr: "new Char(c'\\u007f')", val: 127 } + - { expr: "new Char(c'\\u8000')", val: 32768 } + - { expr: "new Char(c'\\uff80')", val: 65408 } + - { expr: "new Char(c'\\uffff')", val: 65535 } + - { expr: "new Char(c'\\ucafe')", val: 51966 } + - { expr: "new Char(c'R')", val: 82 } - from_type: Char to_type: float values: - - { expr: "new Char(c'\\u0000')", val: 0.0 as float } - - { expr: "new Char(c'\\u007f')", val: 127.0 as float } - - { expr: "new Char(c'\\u8000')", val: 32768.0 as float } - - { expr: "new Char(c'\\uff80')", val: 65408.0 as float } - - { expr: "new Char(c'\\uffff')", val: 65535.0 as float } - - { expr: "new Char(c'\\ucafe')", val: 51966.0 as float } - - { expr: "new Char(c'R')", val: 82.0 as float } + - { expr: "new Char(c'\\u0000')", val: 0.0f } + - { expr: "new Char(c'\\u007f')", val: 127.0f } + - { expr: "new Char(c'\\u8000')", val: 32768.0f } + - { expr: "new Char(c'\\uff80')", val: 65408.0f } + - { expr: "new Char(c'\\uffff')", val: 65535.0f } + - { expr: "new Char(c'\\ucafe')", val: 51966.0f } + - { expr: "new Char(c'R')", val: 82.0f } - from_type: Char to_type: double diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/decl_const/decl-const.ets b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/decl_const/decl-const.ets index 8be4a5752f5dbaad804871577d59c1837ae36ba4..a6e15ede2134013b721a8aa4c8d0b17a889d4688 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/decl_const/decl-const.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/decl_const/decl-const.ets @@ -19,13 +19,11 @@ desc: Declaration context, constant, unboxing conversion, implicit params: from {{c.from_type}} to {{c.to_type}} ---*/ -function main(): int { +function main() { {%- for t in c['values'] %} let s{{loop.index}}: {{c.from_type}} = {{t.expr|safe}} const d{{loop.index}}: {{c.to_type}} = s{{loop.index}} - if (d{{loop.index}} != {{t.val}}) { - return 1 - } + assertEQ(d{{loop.index}}, {{t.val}}, "Assert fails on item {{loop.index}}") {%- endfor %} return 0 } diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/decl_const/decl-const.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/decl_const/decl-const.params.yaml index ea52b4d29e003d7a2e75a9d1f5f9bdca46bebfa8..2cec623ad19cac71cd545202f2859e450b8eaba5 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/decl_const/decl-const.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/decl_const/decl-const.params.yaml @@ -17,50 +17,50 @@ cases: to_type: byte values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: short values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: int values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: long values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: float values: - - { expr: new Byte(), val: 0.0 as float } - - { expr: new Byte(127 as byte), val: 127.0 as float } - - { expr: new Byte(-128 as byte), val: -128.0 as float } + - { expr: new Byte(), val: 0.0f } + - { expr: new Byte(127), val: 127.0f } + - { expr: new Byte(-128), val: -128.0f } - from_type: Byte to_type: double values: - { expr: new Byte(), val: 0.0 } - - { expr: new Byte(127 as byte), val: 127.0 } - - { expr: new Byte(-128 as byte), val: -128.0 } + - { expr: new Byte(127), val: 127.0 } + - { expr: new Byte(-128), val: -128.0 } - from_type: Short to_type: short values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -68,8 +68,8 @@ cases: to_type: int values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -77,8 +77,8 @@ cases: to_type: long values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -86,17 +86,17 @@ cases: to_type: float values: - { expr: new Short(), val: 0.0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128.0 as float } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127.0 as float } - - { expr: new Short(Short.MIN_VALUE), val: -32768.0 as float } - - { expr: new Short(Short.MAX_VALUE), val: 32767.0 as float } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128.0f } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127.0f } + - { expr: new Short(Short.MIN_VALUE), val: -32768.0f } + - { expr: new Short(Short.MAX_VALUE), val: 32767.0f } - from_type: Short to_type: double values: - { expr: new Short(), val: 0.0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -104,10 +104,10 @@ cases: to_type: int values: - { expr: new Int(), val: 0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647 } @@ -115,10 +115,10 @@ cases: to_type: long values: - { expr: new Int(), val: 0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647 } @@ -126,21 +126,21 @@ cases: to_type: float values: - { expr: new Int(), val: 0.0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128.0 as float } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127.0 as float } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768.0 as float } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767.0 as float } - - { expr: new Int(Int.MIN_VALUE), val: -2147483600.0 as float } # loss of precision - - { expr: new Int(Int.MAX_VALUE), val: 2147483600.0 as float } # loss of precision + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128.0f } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127.0f } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768.0f } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767.0f } + - { expr: new Int(Int.MIN_VALUE), val: -2147483600.0f } # loss of precision + - { expr: new Int(Int.MAX_VALUE), val: 2147483600.0f } # loss of precision - from_type: Int to_type: double values: - { expr: new Int(), val: 0.0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128.0 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127.0 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768.0 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767.0 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128.0 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127.0 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768.0 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767.0 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648.0 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647.0 } @@ -148,12 +148,12 @@ cases: to_type: long values: - { expr: new Long(), val: 0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128 } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127 } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768 } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767 } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483648 } - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483647 } + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128 } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127 } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768 } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767 } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483648 } + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483647 } - { expr: new Long(Long.MIN_VALUE), val: -9223372036854775808 } - { expr: new Long(Long.MAX_VALUE), val: 9223372036854775807 } @@ -161,85 +161,85 @@ cases: to_type: float values: - { expr: new Long(), val: 0.0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128.0 as float } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127.0 as float } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768.0 as float } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767.0 as float } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483600.0 as float } # loss of precision - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483600.0 as float } # loss of precision - - { expr: new Long(Long.MIN_VALUE), val: -9223372000000000000.0 as float } # loss of precision - - { expr: new Long(Long.MAX_VALUE), val: 9223372000000000000.0 as float } # loss of precision + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128.0f } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127.0f } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768.0f } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767.0f } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483600.0f } # loss of precision + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483600.0f } # loss of precision + - { expr: new Long(Long.MIN_VALUE), val: -9223372000000000000.0f } # loss of precision + - { expr: new Long(Long.MAX_VALUE), val: 9223372000000000000.0f } # loss of precision - from_type: Long to_type: double values: - { expr: new Long(), val: 0.0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128.0 } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127.0 } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768.0 } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767.0 } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483648.0 } - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483647.0 } + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128.0 } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127.0 } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768.0 } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767.0 } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483648.0 } + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483647.0 } - { expr: new Long(Long.MIN_VALUE), val: -9223372036854775808.0 } - { expr: new Long(Long.MAX_VALUE), val: 9223372036854775807.0 } - from_type: Float to_type: float values: - - { expr: new Float(+0.0 as float), val: +0.0 as float } - - { expr: new Float(-0.0 as float), val: -0.0 as float } - - { expr: new Float(Byte.MIN_VALUE as float), val: -128.0 as float } - - { expr: new Float(Byte.MAX_VALUE as float), val: 127.0 as float } - - { expr: new Float(Short.MIN_VALUE as float), val: -32768.0 as float } - - { expr: new Float(Short.MAX_VALUE as float), val: 32767.0 as float } - - { expr: new Float(Int.MIN_VALUE as float), val: -2.14748365E9 as float } # loss of precision - - { expr: new Float(Int.MAX_VALUE as float), val: 2.14748365E9 as float } # loss of precision - - { expr: new Float(Long.MIN_VALUE as float), val: -9.223372E18 as float } # loss of precision - - { expr: new Float(Long.MAX_VALUE as float), val: 9.223372E18 as float } # loss of precision - - { expr: new Float(Float.MIN_VALUE), val: 1.4E-45 as float } - - { expr: new Float(Float.MAX_VALUE), val: 3.4028235E38 as float } - - { expr: new Float(Float.NEGATIVE_INFINITY as float), val: Float.NEGATIVE_INFINITY } - - { expr: new Float(Float.POSITIVE_INFINITY as float), val: Float.POSITIVE_INFINITY } + - { expr: new Float(+0.0f), val: +0.0f } + - { expr: new Float(-0.0f), val: -0.0f } + - { expr: new Float(Byte.MIN_VALUE.toFloat()), val: -128.0f } + - { expr: new Float(Byte.MAX_VALUE.toFloat()), val: 127.0f } + - { expr: new Float(Short.MIN_VALUE.toFloat()), val: -32768.0f } + - { expr: new Float(Short.MAX_VALUE.toFloat()), val: 32767.0f } + - { expr: new Float(Int.MIN_VALUE.toFloat()), val: -2.14748365E9f } # loss of precision + - { expr: new Float(Int.MAX_VALUE.toFloat()), val: 2.14748365E9f } # loss of precision + - { expr: new Float(Long.MIN_VALUE.toFloat()), val: -9.223372E18f } # loss of precision + - { expr: new Float(Long.MAX_VALUE.toFloat()), val: 9.223372E18f } # loss of precision + - { expr: new Float(Float.MIN_VALUE), val: 1.4E-45f } + - { expr: new Float(Float.MAX_VALUE), val: 3.4028235E38f } + - { expr: new Float(Float.NEGATIVE_INFINITY.toFloat()), val: Float.NEGATIVE_INFINITY } + - { expr: new Float(Float.POSITIVE_INFINITY.toFloat()), val: Float.POSITIVE_INFINITY } - from_type: Float to_type: double values: - - { expr: new Float(+0.0 as float), val: +0.0 } - - { expr: new Float(-0.0 as float), val: -0.0 } - - { expr: new Float(Byte.MIN_VALUE as float), val: -128.0 } - - { expr: new Float(Byte.MAX_VALUE as float), val: 127.0 } - - { expr: new Float(Short.MIN_VALUE as float), val: -32768.0 } - - { expr: new Float(Short.MAX_VALUE as float), val: 32767.0 } - - { expr: new Float(Int.MIN_VALUE as float), val: -2.147483648E9 } # loss of precision - - { expr: new Float(Int.MAX_VALUE as float), val: 2.147483648E9 } # loss of precision - - { expr: new Float(Long.MIN_VALUE as float), val: -9.223372036854776E18 } # loss of precision - - { expr: new Float(Long.MAX_VALUE as float), val: 9.223372036854776E18 } # loss of precision + - { expr: new Float(+0.0f), val: +0.0 } + - { expr: new Float(-0.0f), val: -0.0 } + - { expr: new Float(Byte.MIN_VALUE.toFloat()), val: -128.0 } + - { expr: new Float(Byte.MAX_VALUE.toFloat()), val: 127.0 } + - { expr: new Float(Short.MIN_VALUE.toFloat()), val: -32768.0 } + - { expr: new Float(Short.MAX_VALUE.toFloat()), val: 32767.0 } + - { expr: new Float(Int.MIN_VALUE.toFloat()), val: -2.147483648E9 } # loss of precision + - { expr: new Float(Int.MAX_VALUE.toFloat()), val: 2.147483648E9 } # loss of precision + - { expr: new Float(Long.MIN_VALUE.toFloat()), val: -9.223372036854776E18 } # loss of precision + - { expr: new Float(Long.MAX_VALUE.toFloat()), val: 9.223372036854776E18 } # loss of precision - { expr: new Float(Float.MIN_VALUE), val: 1.401298464324817E-45 } - { expr: new Float(Float.MAX_VALUE), val: 3.4028234663852886E38 } - - { expr: new Float(Float.NEGATIVE_INFINITY as float), val: Float.NEGATIVE_INFINITY as double } - - { expr: new Float(Float.POSITIVE_INFINITY as float), val: Float.POSITIVE_INFINITY as double } + - { expr: new Float(Float.NEGATIVE_INFINITY.toFloat()), val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: new Float(Float.POSITIVE_INFINITY.toFloat()), val: Float.POSITIVE_INFINITY.toDouble() } - from_type: Double to_type: double values: - - { expr: new Double(+0.0 as float), val: +0.0 } - - { expr: new Double(-0.0 as float), val: -0.0 } - - { expr: new Double(Byte.MIN_VALUE as double), val: -128.0 } - - { expr: new Double(Byte.MAX_VALUE as double), val: 127.0 } - - { expr: new Double(Short.MIN_VALUE as double), val: -32768.0 } - - { expr: new Double(Short.MAX_VALUE as double), val: 32767.0 } - - { expr: new Double(Int.MIN_VALUE as double), val: -2147483648.0 } - - { expr: new Double(Int.MAX_VALUE as double), val: 2147483647.0 } - - { expr: new Double(Long.MIN_VALUE as double), val: -9223372036854775808.0 } - - { expr: new Double(Long.MAX_VALUE as double), val: 9223372036854775807.0 } - - { expr: new Double(Float.MIN_VALUE as double), val: Float.MIN_VALUE as double } - - { expr: new Double(Float.MAX_VALUE as double), val: Float.MAX_VALUE as double } - - { expr: new Double(Float.NEGATIVE_INFINITY as double), val: Float.NEGATIVE_INFINITY as double } - - { expr: new Double(Float.POSITIVE_INFINITY as double), val: Float.POSITIVE_INFINITY as double } + - { expr: new Double(+0.0f), val: +0.0 } + - { expr: new Double(-0.0f), val: -0.0 } + - { expr: new Double(Byte.MIN_VALUE.toDouble()), val: -128.0 } + - { expr: new Double(Byte.MAX_VALUE.toDouble()), val: 127.0 } + - { expr: new Double(Short.MIN_VALUE.toDouble()), val: -32768.0 } + - { expr: new Double(Short.MAX_VALUE.toDouble()), val: 32767.0 } + - { expr: new Double(Int.MIN_VALUE.toDouble()), val: -2147483648.0 } + - { expr: new Double(Int.MAX_VALUE.toDouble()), val: 2147483647.0 } + - { expr: new Double(Long.MIN_VALUE.toDouble()), val: -9223372036854775808.0 } + - { expr: new Double(Long.MAX_VALUE.toDouble()), val: 9223372036854775807.0 } + - { expr: new Double(Float.MIN_VALUE.toDouble()), val: Float.MIN_VALUE.toDouble() } + - { expr: new Double(Float.MAX_VALUE.toDouble()), val: Float.MAX_VALUE.toDouble() } + - { expr: new Double(Float.NEGATIVE_INFINITY.toDouble()), val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: new Double(Float.POSITIVE_INFINITY.toDouble()), val: Float.POSITIVE_INFINITY.toDouble() } - { expr: new Double(Double.MIN_VALUE), val: Double.MIN_VALUE } - { expr: new Double(Double.MAX_VALUE), val: Double.MAX_VALUE } - - { expr: new Double(Double.NEGATIVE_INFINITY as double), val: Double.NEGATIVE_INFINITY as double } - - { expr: new Double(Double.POSITIVE_INFINITY as double), val: Double.POSITIVE_INFINITY as double } + - { expr: new Double(Double.NEGATIVE_INFINITY.toDouble()), val: Double.NEGATIVE_INFINITY.toDouble() } + - { expr: new Double(Double.POSITIVE_INFINITY.toDouble()), val: Double.POSITIVE_INFINITY.toDouble() } - from_type: Char to_type: char @@ -266,24 +266,24 @@ cases: - from_type: Char to_type: long values: - - { expr: "new Char(c'\\u0000')", val: 0 as long } - - { expr: "new Char(c'\\u007f')", val: 127 as long } - - { expr: "new Char(c'\\u8000')", val: 32768 as long } - - { expr: "new Char(c'\\uff80')", val: 65408 as long } - - { expr: "new Char(c'\\uffff')", val: 65535 as long } - - { expr: "new Char(c'\\ucafe')", val: 51966 as long } - - { expr: "new Char(c'R')", val: 82 as long } + - { expr: "new Char(c'\\u0000')", val: 0 } + - { expr: "new Char(c'\\u007f')", val: 127 } + - { expr: "new Char(c'\\u8000')", val: 32768 } + - { expr: "new Char(c'\\uff80')", val: 65408 } + - { expr: "new Char(c'\\uffff')", val: 65535 } + - { expr: "new Char(c'\\ucafe')", val: 51966 } + - { expr: "new Char(c'R')", val: 82 } - from_type: Char to_type: float values: - - { expr: "new Char(c'\\u0000')", val: 0.0 as float } - - { expr: "new Char(c'\\u007f')", val: 127.0 as float } - - { expr: "new Char(c'\\u8000')", val: 32768.0 as float } - - { expr: "new Char(c'\\uff80')", val: 65408.0 as float } - - { expr: "new Char(c'\\uffff')", val: 65535.0 as float } - - { expr: "new Char(c'\\ucafe')", val: 51966.0 as float } - - { expr: "new Char(c'R')", val: 82.0 as float } + - { expr: "new Char(c'\\u0000')", val: 0.0f } + - { expr: "new Char(c'\\u007f')", val: 127.0f } + - { expr: "new Char(c'\\u8000')", val: 32768.0f } + - { expr: "new Char(c'\\uff80')", val: 65408.0f } + - { expr: "new Char(c'\\uffff')", val: 65535.0f } + - { expr: "new Char(c'\\ucafe')", val: 51966.0f } + - { expr: "new Char(c'R')", val: 82.0f } - from_type: Char to_type: double diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/decl_field/decl-field.ets b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/decl_field/decl-field.ets index 89575b511a0a9cb8d90b03905e166543076c43f7..d23a2d94ae9eaa5c3808d99765a0420cb2181c6b 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/decl_field/decl-field.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/decl_field/decl-field.ets @@ -26,13 +26,10 @@ class A{{loop.index}} { } {%- endfor %} -function main(): int { +function main() { {%- for t in c['values'] %} let a{{loop.index}}: A{{loop.index}} = new A{{loop.index}}() - if (a{{loop.index}}.d != {{t.val}}) { - return 1 - } + assertEQ(a{{loop.index}}.d, {{t.val}}, "Assert fails on item {{loop.index}}") {%- endfor %} - return 0 } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/decl_field/decl-field.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/decl_field/decl-field.params.yaml index ea52b4d29e003d7a2e75a9d1f5f9bdca46bebfa8..2cec623ad19cac71cd545202f2859e450b8eaba5 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/decl_field/decl-field.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/decl_field/decl-field.params.yaml @@ -17,50 +17,50 @@ cases: to_type: byte values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: short values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: int values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: long values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: float values: - - { expr: new Byte(), val: 0.0 as float } - - { expr: new Byte(127 as byte), val: 127.0 as float } - - { expr: new Byte(-128 as byte), val: -128.0 as float } + - { expr: new Byte(), val: 0.0f } + - { expr: new Byte(127), val: 127.0f } + - { expr: new Byte(-128), val: -128.0f } - from_type: Byte to_type: double values: - { expr: new Byte(), val: 0.0 } - - { expr: new Byte(127 as byte), val: 127.0 } - - { expr: new Byte(-128 as byte), val: -128.0 } + - { expr: new Byte(127), val: 127.0 } + - { expr: new Byte(-128), val: -128.0 } - from_type: Short to_type: short values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -68,8 +68,8 @@ cases: to_type: int values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -77,8 +77,8 @@ cases: to_type: long values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -86,17 +86,17 @@ cases: to_type: float values: - { expr: new Short(), val: 0.0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128.0 as float } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127.0 as float } - - { expr: new Short(Short.MIN_VALUE), val: -32768.0 as float } - - { expr: new Short(Short.MAX_VALUE), val: 32767.0 as float } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128.0f } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127.0f } + - { expr: new Short(Short.MIN_VALUE), val: -32768.0f } + - { expr: new Short(Short.MAX_VALUE), val: 32767.0f } - from_type: Short to_type: double values: - { expr: new Short(), val: 0.0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -104,10 +104,10 @@ cases: to_type: int values: - { expr: new Int(), val: 0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647 } @@ -115,10 +115,10 @@ cases: to_type: long values: - { expr: new Int(), val: 0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647 } @@ -126,21 +126,21 @@ cases: to_type: float values: - { expr: new Int(), val: 0.0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128.0 as float } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127.0 as float } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768.0 as float } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767.0 as float } - - { expr: new Int(Int.MIN_VALUE), val: -2147483600.0 as float } # loss of precision - - { expr: new Int(Int.MAX_VALUE), val: 2147483600.0 as float } # loss of precision + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128.0f } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127.0f } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768.0f } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767.0f } + - { expr: new Int(Int.MIN_VALUE), val: -2147483600.0f } # loss of precision + - { expr: new Int(Int.MAX_VALUE), val: 2147483600.0f } # loss of precision - from_type: Int to_type: double values: - { expr: new Int(), val: 0.0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128.0 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127.0 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768.0 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767.0 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128.0 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127.0 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768.0 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767.0 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648.0 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647.0 } @@ -148,12 +148,12 @@ cases: to_type: long values: - { expr: new Long(), val: 0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128 } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127 } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768 } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767 } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483648 } - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483647 } + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128 } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127 } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768 } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767 } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483648 } + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483647 } - { expr: new Long(Long.MIN_VALUE), val: -9223372036854775808 } - { expr: new Long(Long.MAX_VALUE), val: 9223372036854775807 } @@ -161,85 +161,85 @@ cases: to_type: float values: - { expr: new Long(), val: 0.0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128.0 as float } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127.0 as float } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768.0 as float } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767.0 as float } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483600.0 as float } # loss of precision - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483600.0 as float } # loss of precision - - { expr: new Long(Long.MIN_VALUE), val: -9223372000000000000.0 as float } # loss of precision - - { expr: new Long(Long.MAX_VALUE), val: 9223372000000000000.0 as float } # loss of precision + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128.0f } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127.0f } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768.0f } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767.0f } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483600.0f } # loss of precision + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483600.0f } # loss of precision + - { expr: new Long(Long.MIN_VALUE), val: -9223372000000000000.0f } # loss of precision + - { expr: new Long(Long.MAX_VALUE), val: 9223372000000000000.0f } # loss of precision - from_type: Long to_type: double values: - { expr: new Long(), val: 0.0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128.0 } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127.0 } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768.0 } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767.0 } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483648.0 } - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483647.0 } + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128.0 } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127.0 } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768.0 } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767.0 } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483648.0 } + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483647.0 } - { expr: new Long(Long.MIN_VALUE), val: -9223372036854775808.0 } - { expr: new Long(Long.MAX_VALUE), val: 9223372036854775807.0 } - from_type: Float to_type: float values: - - { expr: new Float(+0.0 as float), val: +0.0 as float } - - { expr: new Float(-0.0 as float), val: -0.0 as float } - - { expr: new Float(Byte.MIN_VALUE as float), val: -128.0 as float } - - { expr: new Float(Byte.MAX_VALUE as float), val: 127.0 as float } - - { expr: new Float(Short.MIN_VALUE as float), val: -32768.0 as float } - - { expr: new Float(Short.MAX_VALUE as float), val: 32767.0 as float } - - { expr: new Float(Int.MIN_VALUE as float), val: -2.14748365E9 as float } # loss of precision - - { expr: new Float(Int.MAX_VALUE as float), val: 2.14748365E9 as float } # loss of precision - - { expr: new Float(Long.MIN_VALUE as float), val: -9.223372E18 as float } # loss of precision - - { expr: new Float(Long.MAX_VALUE as float), val: 9.223372E18 as float } # loss of precision - - { expr: new Float(Float.MIN_VALUE), val: 1.4E-45 as float } - - { expr: new Float(Float.MAX_VALUE), val: 3.4028235E38 as float } - - { expr: new Float(Float.NEGATIVE_INFINITY as float), val: Float.NEGATIVE_INFINITY } - - { expr: new Float(Float.POSITIVE_INFINITY as float), val: Float.POSITIVE_INFINITY } + - { expr: new Float(+0.0f), val: +0.0f } + - { expr: new Float(-0.0f), val: -0.0f } + - { expr: new Float(Byte.MIN_VALUE.toFloat()), val: -128.0f } + - { expr: new Float(Byte.MAX_VALUE.toFloat()), val: 127.0f } + - { expr: new Float(Short.MIN_VALUE.toFloat()), val: -32768.0f } + - { expr: new Float(Short.MAX_VALUE.toFloat()), val: 32767.0f } + - { expr: new Float(Int.MIN_VALUE.toFloat()), val: -2.14748365E9f } # loss of precision + - { expr: new Float(Int.MAX_VALUE.toFloat()), val: 2.14748365E9f } # loss of precision + - { expr: new Float(Long.MIN_VALUE.toFloat()), val: -9.223372E18f } # loss of precision + - { expr: new Float(Long.MAX_VALUE.toFloat()), val: 9.223372E18f } # loss of precision + - { expr: new Float(Float.MIN_VALUE), val: 1.4E-45f } + - { expr: new Float(Float.MAX_VALUE), val: 3.4028235E38f } + - { expr: new Float(Float.NEGATIVE_INFINITY.toFloat()), val: Float.NEGATIVE_INFINITY } + - { expr: new Float(Float.POSITIVE_INFINITY.toFloat()), val: Float.POSITIVE_INFINITY } - from_type: Float to_type: double values: - - { expr: new Float(+0.0 as float), val: +0.0 } - - { expr: new Float(-0.0 as float), val: -0.0 } - - { expr: new Float(Byte.MIN_VALUE as float), val: -128.0 } - - { expr: new Float(Byte.MAX_VALUE as float), val: 127.0 } - - { expr: new Float(Short.MIN_VALUE as float), val: -32768.0 } - - { expr: new Float(Short.MAX_VALUE as float), val: 32767.0 } - - { expr: new Float(Int.MIN_VALUE as float), val: -2.147483648E9 } # loss of precision - - { expr: new Float(Int.MAX_VALUE as float), val: 2.147483648E9 } # loss of precision - - { expr: new Float(Long.MIN_VALUE as float), val: -9.223372036854776E18 } # loss of precision - - { expr: new Float(Long.MAX_VALUE as float), val: 9.223372036854776E18 } # loss of precision + - { expr: new Float(+0.0f), val: +0.0 } + - { expr: new Float(-0.0f), val: -0.0 } + - { expr: new Float(Byte.MIN_VALUE.toFloat()), val: -128.0 } + - { expr: new Float(Byte.MAX_VALUE.toFloat()), val: 127.0 } + - { expr: new Float(Short.MIN_VALUE.toFloat()), val: -32768.0 } + - { expr: new Float(Short.MAX_VALUE.toFloat()), val: 32767.0 } + - { expr: new Float(Int.MIN_VALUE.toFloat()), val: -2.147483648E9 } # loss of precision + - { expr: new Float(Int.MAX_VALUE.toFloat()), val: 2.147483648E9 } # loss of precision + - { expr: new Float(Long.MIN_VALUE.toFloat()), val: -9.223372036854776E18 } # loss of precision + - { expr: new Float(Long.MAX_VALUE.toFloat()), val: 9.223372036854776E18 } # loss of precision - { expr: new Float(Float.MIN_VALUE), val: 1.401298464324817E-45 } - { expr: new Float(Float.MAX_VALUE), val: 3.4028234663852886E38 } - - { expr: new Float(Float.NEGATIVE_INFINITY as float), val: Float.NEGATIVE_INFINITY as double } - - { expr: new Float(Float.POSITIVE_INFINITY as float), val: Float.POSITIVE_INFINITY as double } + - { expr: new Float(Float.NEGATIVE_INFINITY.toFloat()), val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: new Float(Float.POSITIVE_INFINITY.toFloat()), val: Float.POSITIVE_INFINITY.toDouble() } - from_type: Double to_type: double values: - - { expr: new Double(+0.0 as float), val: +0.0 } - - { expr: new Double(-0.0 as float), val: -0.0 } - - { expr: new Double(Byte.MIN_VALUE as double), val: -128.0 } - - { expr: new Double(Byte.MAX_VALUE as double), val: 127.0 } - - { expr: new Double(Short.MIN_VALUE as double), val: -32768.0 } - - { expr: new Double(Short.MAX_VALUE as double), val: 32767.0 } - - { expr: new Double(Int.MIN_VALUE as double), val: -2147483648.0 } - - { expr: new Double(Int.MAX_VALUE as double), val: 2147483647.0 } - - { expr: new Double(Long.MIN_VALUE as double), val: -9223372036854775808.0 } - - { expr: new Double(Long.MAX_VALUE as double), val: 9223372036854775807.0 } - - { expr: new Double(Float.MIN_VALUE as double), val: Float.MIN_VALUE as double } - - { expr: new Double(Float.MAX_VALUE as double), val: Float.MAX_VALUE as double } - - { expr: new Double(Float.NEGATIVE_INFINITY as double), val: Float.NEGATIVE_INFINITY as double } - - { expr: new Double(Float.POSITIVE_INFINITY as double), val: Float.POSITIVE_INFINITY as double } + - { expr: new Double(+0.0f), val: +0.0 } + - { expr: new Double(-0.0f), val: -0.0 } + - { expr: new Double(Byte.MIN_VALUE.toDouble()), val: -128.0 } + - { expr: new Double(Byte.MAX_VALUE.toDouble()), val: 127.0 } + - { expr: new Double(Short.MIN_VALUE.toDouble()), val: -32768.0 } + - { expr: new Double(Short.MAX_VALUE.toDouble()), val: 32767.0 } + - { expr: new Double(Int.MIN_VALUE.toDouble()), val: -2147483648.0 } + - { expr: new Double(Int.MAX_VALUE.toDouble()), val: 2147483647.0 } + - { expr: new Double(Long.MIN_VALUE.toDouble()), val: -9223372036854775808.0 } + - { expr: new Double(Long.MAX_VALUE.toDouble()), val: 9223372036854775807.0 } + - { expr: new Double(Float.MIN_VALUE.toDouble()), val: Float.MIN_VALUE.toDouble() } + - { expr: new Double(Float.MAX_VALUE.toDouble()), val: Float.MAX_VALUE.toDouble() } + - { expr: new Double(Float.NEGATIVE_INFINITY.toDouble()), val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: new Double(Float.POSITIVE_INFINITY.toDouble()), val: Float.POSITIVE_INFINITY.toDouble() } - { expr: new Double(Double.MIN_VALUE), val: Double.MIN_VALUE } - { expr: new Double(Double.MAX_VALUE), val: Double.MAX_VALUE } - - { expr: new Double(Double.NEGATIVE_INFINITY as double), val: Double.NEGATIVE_INFINITY as double } - - { expr: new Double(Double.POSITIVE_INFINITY as double), val: Double.POSITIVE_INFINITY as double } + - { expr: new Double(Double.NEGATIVE_INFINITY.toDouble()), val: Double.NEGATIVE_INFINITY.toDouble() } + - { expr: new Double(Double.POSITIVE_INFINITY.toDouble()), val: Double.POSITIVE_INFINITY.toDouble() } - from_type: Char to_type: char @@ -266,24 +266,24 @@ cases: - from_type: Char to_type: long values: - - { expr: "new Char(c'\\u0000')", val: 0 as long } - - { expr: "new Char(c'\\u007f')", val: 127 as long } - - { expr: "new Char(c'\\u8000')", val: 32768 as long } - - { expr: "new Char(c'\\uff80')", val: 65408 as long } - - { expr: "new Char(c'\\uffff')", val: 65535 as long } - - { expr: "new Char(c'\\ucafe')", val: 51966 as long } - - { expr: "new Char(c'R')", val: 82 as long } + - { expr: "new Char(c'\\u0000')", val: 0 } + - { expr: "new Char(c'\\u007f')", val: 127 } + - { expr: "new Char(c'\\u8000')", val: 32768 } + - { expr: "new Char(c'\\uff80')", val: 65408 } + - { expr: "new Char(c'\\uffff')", val: 65535 } + - { expr: "new Char(c'\\ucafe')", val: 51966 } + - { expr: "new Char(c'R')", val: 82 } - from_type: Char to_type: float values: - - { expr: "new Char(c'\\u0000')", val: 0.0 as float } - - { expr: "new Char(c'\\u007f')", val: 127.0 as float } - - { expr: "new Char(c'\\u8000')", val: 32768.0 as float } - - { expr: "new Char(c'\\uff80')", val: 65408.0 as float } - - { expr: "new Char(c'\\uffff')", val: 65535.0 as float } - - { expr: "new Char(c'\\ucafe')", val: 51966.0 as float } - - { expr: "new Char(c'R')", val: 82.0 as float } + - { expr: "new Char(c'\\u0000')", val: 0.0f } + - { expr: "new Char(c'\\u007f')", val: 127.0f } + - { expr: "new Char(c'\\u8000')", val: 32768.0f } + - { expr: "new Char(c'\\uff80')", val: 65408.0f } + - { expr: "new Char(c'\\uffff')", val: 65535.0f } + - { expr: "new Char(c'\\ucafe')", val: 51966.0f } + - { expr: "new Char(c'R')", val: 82.0f } - from_type: Char to_type: double diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/decl_var/decl-var.ets b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/decl_var/decl-var.ets index 4e49d6c7cb590c99e84aefb78ee042c2d8774144..18d8523e5c5621c6231e93e1501464a94b356c6e 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/decl_var/decl-var.ets +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/decl_var/decl-var.ets @@ -19,14 +19,11 @@ desc: Declaration context, variable, unboxing conversion, implicit params: from {{c.from_type}} to {{c.to_type}} ---*/ -function main(): int { +function main() { {%- for t in c['values'] %} let s{{loop.index}}: {{c.from_type}} = {{t.expr|safe}} let d{{loop.index}}: {{c.to_type}} = s{{loop.index}} - if (d{{loop.index}} != {{t.val}}) { - return 1 - } + assertEQ(d{{loop.index}}, {{t.val}}, "Assert fails on item {{loop.index}}") {%- endfor %} - return 0 } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/decl_var/decl-var.params.yaml b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/decl_var/decl-var.params.yaml index ea52b4d29e003d7a2e75a9d1f5f9bdca46bebfa8..2cec623ad19cac71cd545202f2859e450b8eaba5 100644 --- a/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/decl_var/decl-var.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/03.types/alias_unconversion/decl_var/decl-var.params.yaml @@ -17,50 +17,50 @@ cases: to_type: byte values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: short values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: int values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: long values: - { expr: new Byte(), val: 0 } - - { expr: new Byte(127 as byte), val: 127 } - - { expr: new Byte(-128 as byte), val: -128 } + - { expr: new Byte(127), val: 127 } + - { expr: new Byte(-128), val: -128 } - from_type: Byte to_type: float values: - - { expr: new Byte(), val: 0.0 as float } - - { expr: new Byte(127 as byte), val: 127.0 as float } - - { expr: new Byte(-128 as byte), val: -128.0 as float } + - { expr: new Byte(), val: 0.0f } + - { expr: new Byte(127), val: 127.0f } + - { expr: new Byte(-128), val: -128.0f } - from_type: Byte to_type: double values: - { expr: new Byte(), val: 0.0 } - - { expr: new Byte(127 as byte), val: 127.0 } - - { expr: new Byte(-128 as byte), val: -128.0 } + - { expr: new Byte(127), val: 127.0 } + - { expr: new Byte(-128), val: -128.0 } - from_type: Short to_type: short values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -68,8 +68,8 @@ cases: to_type: int values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -77,8 +77,8 @@ cases: to_type: long values: - { expr: new Short(), val: 0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -86,17 +86,17 @@ cases: to_type: float values: - { expr: new Short(), val: 0.0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128.0 as float } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127.0 as float } - - { expr: new Short(Short.MIN_VALUE), val: -32768.0 as float } - - { expr: new Short(Short.MAX_VALUE), val: 32767.0 as float } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128.0f } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127.0f } + - { expr: new Short(Short.MIN_VALUE), val: -32768.0f } + - { expr: new Short(Short.MAX_VALUE), val: 32767.0f } - from_type: Short to_type: double values: - { expr: new Short(), val: 0.0 } - - { expr: new Short(Byte.MIN_VALUE as short), val: -128 } - - { expr: new Short(Byte.MAX_VALUE as short), val: 127 } + - { expr: new Short(Byte.MIN_VALUE.toShort()), val: -128 } + - { expr: new Short(Byte.MAX_VALUE.toShort()), val: 127 } - { expr: new Short(Short.MIN_VALUE), val: -32768 } - { expr: new Short(Short.MAX_VALUE), val: 32767 } @@ -104,10 +104,10 @@ cases: to_type: int values: - { expr: new Int(), val: 0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647 } @@ -115,10 +115,10 @@ cases: to_type: long values: - { expr: new Int(), val: 0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647 } @@ -126,21 +126,21 @@ cases: to_type: float values: - { expr: new Int(), val: 0.0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128.0 as float } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127.0 as float } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768.0 as float } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767.0 as float } - - { expr: new Int(Int.MIN_VALUE), val: -2147483600.0 as float } # loss of precision - - { expr: new Int(Int.MAX_VALUE), val: 2147483600.0 as float } # loss of precision + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128.0f } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127.0f } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768.0f } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767.0f } + - { expr: new Int(Int.MIN_VALUE), val: -2147483600.0f } # loss of precision + - { expr: new Int(Int.MAX_VALUE), val: 2147483600.0f } # loss of precision - from_type: Int to_type: double values: - { expr: new Int(), val: 0.0 } - - { expr: new Int(Byte.MIN_VALUE as int), val: -128.0 } - - { expr: new Int(Byte.MAX_VALUE as int), val: 127.0 } - - { expr: new Int(Short.MIN_VALUE as int), val: -32768.0 } - - { expr: new Int(Short.MAX_VALUE as int), val: 32767.0 } + - { expr: new Int(Byte.MIN_VALUE.toInt()), val: -128.0 } + - { expr: new Int(Byte.MAX_VALUE.toInt()), val: 127.0 } + - { expr: new Int(Short.MIN_VALUE.toInt()), val: -32768.0 } + - { expr: new Int(Short.MAX_VALUE.toInt()), val: 32767.0 } - { expr: new Int(Int.MIN_VALUE), val: -2147483648.0 } - { expr: new Int(Int.MAX_VALUE), val: 2147483647.0 } @@ -148,12 +148,12 @@ cases: to_type: long values: - { expr: new Long(), val: 0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128 } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127 } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768 } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767 } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483648 } - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483647 } + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128 } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127 } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768 } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767 } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483648 } + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483647 } - { expr: new Long(Long.MIN_VALUE), val: -9223372036854775808 } - { expr: new Long(Long.MAX_VALUE), val: 9223372036854775807 } @@ -161,85 +161,85 @@ cases: to_type: float values: - { expr: new Long(), val: 0.0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128.0 as float } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127.0 as float } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768.0 as float } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767.0 as float } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483600.0 as float } # loss of precision - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483600.0 as float } # loss of precision - - { expr: new Long(Long.MIN_VALUE), val: -9223372000000000000.0 as float } # loss of precision - - { expr: new Long(Long.MAX_VALUE), val: 9223372000000000000.0 as float } # loss of precision + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128.0f } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127.0f } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768.0f } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767.0f } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483600.0f } # loss of precision + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483600.0f } # loss of precision + - { expr: new Long(Long.MIN_VALUE), val: -9223372000000000000.0f } # loss of precision + - { expr: new Long(Long.MAX_VALUE), val: 9223372000000000000.0f } # loss of precision - from_type: Long to_type: double values: - { expr: new Long(), val: 0.0 } - - { expr: new Long(Byte.MIN_VALUE as long), val: -128.0 } - - { expr: new Long(Byte.MAX_VALUE as long), val: 127.0 } - - { expr: new Long(Short.MIN_VALUE as long), val: -32768.0 } - - { expr: new Long(Short.MAX_VALUE as long), val: 32767.0 } - - { expr: new Long(Int.MIN_VALUE as long), val: -2147483648.0 } - - { expr: new Long(Int.MAX_VALUE as long), val: 2147483647.0 } + - { expr: new Long(Byte.MIN_VALUE.toLong()), val: -128.0 } + - { expr: new Long(Byte.MAX_VALUE.toLong()), val: 127.0 } + - { expr: new Long(Short.MIN_VALUE.toLong()), val: -32768.0 } + - { expr: new Long(Short.MAX_VALUE.toLong()), val: 32767.0 } + - { expr: new Long(Int.MIN_VALUE.toLong()), val: -2147483648.0 } + - { expr: new Long(Int.MAX_VALUE.toLong()), val: 2147483647.0 } - { expr: new Long(Long.MIN_VALUE), val: -9223372036854775808.0 } - { expr: new Long(Long.MAX_VALUE), val: 9223372036854775807.0 } - from_type: Float to_type: float values: - - { expr: new Float(+0.0 as float), val: +0.0 as float } - - { expr: new Float(-0.0 as float), val: -0.0 as float } - - { expr: new Float(Byte.MIN_VALUE as float), val: -128.0 as float } - - { expr: new Float(Byte.MAX_VALUE as float), val: 127.0 as float } - - { expr: new Float(Short.MIN_VALUE as float), val: -32768.0 as float } - - { expr: new Float(Short.MAX_VALUE as float), val: 32767.0 as float } - - { expr: new Float(Int.MIN_VALUE as float), val: -2.14748365E9 as float } # loss of precision - - { expr: new Float(Int.MAX_VALUE as float), val: 2.14748365E9 as float } # loss of precision - - { expr: new Float(Long.MIN_VALUE as float), val: -9.223372E18 as float } # loss of precision - - { expr: new Float(Long.MAX_VALUE as float), val: 9.223372E18 as float } # loss of precision - - { expr: new Float(Float.MIN_VALUE), val: 1.4E-45 as float } - - { expr: new Float(Float.MAX_VALUE), val: 3.4028235E38 as float } - - { expr: new Float(Float.NEGATIVE_INFINITY as float), val: Float.NEGATIVE_INFINITY } - - { expr: new Float(Float.POSITIVE_INFINITY as float), val: Float.POSITIVE_INFINITY } + - { expr: new Float(+0.0f), val: +0.0f } + - { expr: new Float(-0.0f), val: -0.0f } + - { expr: new Float(Byte.MIN_VALUE.toFloat()), val: -128.0f } + - { expr: new Float(Byte.MAX_VALUE.toFloat()), val: 127.0f } + - { expr: new Float(Short.MIN_VALUE.toFloat()), val: -32768.0f } + - { expr: new Float(Short.MAX_VALUE.toFloat()), val: 32767.0f } + - { expr: new Float(Int.MIN_VALUE.toFloat()), val: -2.14748365E9f } # loss of precision + - { expr: new Float(Int.MAX_VALUE.toFloat()), val: 2.14748365E9f } # loss of precision + - { expr: new Float(Long.MIN_VALUE.toFloat()), val: -9.223372E18f } # loss of precision + - { expr: new Float(Long.MAX_VALUE.toFloat()), val: 9.223372E18f } # loss of precision + - { expr: new Float(Float.MIN_VALUE), val: 1.4E-45f } + - { expr: new Float(Float.MAX_VALUE), val: 3.4028235E38f } + - { expr: new Float(Float.NEGATIVE_INFINITY.toFloat()), val: Float.NEGATIVE_INFINITY } + - { expr: new Float(Float.POSITIVE_INFINITY.toFloat()), val: Float.POSITIVE_INFINITY } - from_type: Float to_type: double values: - - { expr: new Float(+0.0 as float), val: +0.0 } - - { expr: new Float(-0.0 as float), val: -0.0 } - - { expr: new Float(Byte.MIN_VALUE as float), val: -128.0 } - - { expr: new Float(Byte.MAX_VALUE as float), val: 127.0 } - - { expr: new Float(Short.MIN_VALUE as float), val: -32768.0 } - - { expr: new Float(Short.MAX_VALUE as float), val: 32767.0 } - - { expr: new Float(Int.MIN_VALUE as float), val: -2.147483648E9 } # loss of precision - - { expr: new Float(Int.MAX_VALUE as float), val: 2.147483648E9 } # loss of precision - - { expr: new Float(Long.MIN_VALUE as float), val: -9.223372036854776E18 } # loss of precision - - { expr: new Float(Long.MAX_VALUE as float), val: 9.223372036854776E18 } # loss of precision + - { expr: new Float(+0.0f), val: +0.0 } + - { expr: new Float(-0.0f), val: -0.0 } + - { expr: new Float(Byte.MIN_VALUE.toFloat()), val: -128.0 } + - { expr: new Float(Byte.MAX_VALUE.toFloat()), val: 127.0 } + - { expr: new Float(Short.MIN_VALUE.toFloat()), val: -32768.0 } + - { expr: new Float(Short.MAX_VALUE.toFloat()), val: 32767.0 } + - { expr: new Float(Int.MIN_VALUE.toFloat()), val: -2.147483648E9 } # loss of precision + - { expr: new Float(Int.MAX_VALUE.toFloat()), val: 2.147483648E9 } # loss of precision + - { expr: new Float(Long.MIN_VALUE.toFloat()), val: -9.223372036854776E18 } # loss of precision + - { expr: new Float(Long.MAX_VALUE.toFloat()), val: 9.223372036854776E18 } # loss of precision - { expr: new Float(Float.MIN_VALUE), val: 1.401298464324817E-45 } - { expr: new Float(Float.MAX_VALUE), val: 3.4028234663852886E38 } - - { expr: new Float(Float.NEGATIVE_INFINITY as float), val: Float.NEGATIVE_INFINITY as double } - - { expr: new Float(Float.POSITIVE_INFINITY as float), val: Float.POSITIVE_INFINITY as double } + - { expr: new Float(Float.NEGATIVE_INFINITY.toFloat()), val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: new Float(Float.POSITIVE_INFINITY.toFloat()), val: Float.POSITIVE_INFINITY.toDouble() } - from_type: Double to_type: double values: - - { expr: new Double(+0.0 as float), val: +0.0 } - - { expr: new Double(-0.0 as float), val: -0.0 } - - { expr: new Double(Byte.MIN_VALUE as double), val: -128.0 } - - { expr: new Double(Byte.MAX_VALUE as double), val: 127.0 } - - { expr: new Double(Short.MIN_VALUE as double), val: -32768.0 } - - { expr: new Double(Short.MAX_VALUE as double), val: 32767.0 } - - { expr: new Double(Int.MIN_VALUE as double), val: -2147483648.0 } - - { expr: new Double(Int.MAX_VALUE as double), val: 2147483647.0 } - - { expr: new Double(Long.MIN_VALUE as double), val: -9223372036854775808.0 } - - { expr: new Double(Long.MAX_VALUE as double), val: 9223372036854775807.0 } - - { expr: new Double(Float.MIN_VALUE as double), val: Float.MIN_VALUE as double } - - { expr: new Double(Float.MAX_VALUE as double), val: Float.MAX_VALUE as double } - - { expr: new Double(Float.NEGATIVE_INFINITY as double), val: Float.NEGATIVE_INFINITY as double } - - { expr: new Double(Float.POSITIVE_INFINITY as double), val: Float.POSITIVE_INFINITY as double } + - { expr: new Double(+0.0f), val: +0.0 } + - { expr: new Double(-0.0f), val: -0.0 } + - { expr: new Double(Byte.MIN_VALUE.toDouble()), val: -128.0 } + - { expr: new Double(Byte.MAX_VALUE.toDouble()), val: 127.0 } + - { expr: new Double(Short.MIN_VALUE.toDouble()), val: -32768.0 } + - { expr: new Double(Short.MAX_VALUE.toDouble()), val: 32767.0 } + - { expr: new Double(Int.MIN_VALUE.toDouble()), val: -2147483648.0 } + - { expr: new Double(Int.MAX_VALUE.toDouble()), val: 2147483647.0 } + - { expr: new Double(Long.MIN_VALUE.toDouble()), val: -9223372036854775808.0 } + - { expr: new Double(Long.MAX_VALUE.toDouble()), val: 9223372036854775807.0 } + - { expr: new Double(Float.MIN_VALUE.toDouble()), val: Float.MIN_VALUE.toDouble() } + - { expr: new Double(Float.MAX_VALUE.toDouble()), val: Float.MAX_VALUE.toDouble() } + - { expr: new Double(Float.NEGATIVE_INFINITY.toDouble()), val: Float.NEGATIVE_INFINITY.toDouble() } + - { expr: new Double(Float.POSITIVE_INFINITY.toDouble()), val: Float.POSITIVE_INFINITY.toDouble() } - { expr: new Double(Double.MIN_VALUE), val: Double.MIN_VALUE } - { expr: new Double(Double.MAX_VALUE), val: Double.MAX_VALUE } - - { expr: new Double(Double.NEGATIVE_INFINITY as double), val: Double.NEGATIVE_INFINITY as double } - - { expr: new Double(Double.POSITIVE_INFINITY as double), val: Double.POSITIVE_INFINITY as double } + - { expr: new Double(Double.NEGATIVE_INFINITY.toDouble()), val: Double.NEGATIVE_INFINITY.toDouble() } + - { expr: new Double(Double.POSITIVE_INFINITY.toDouble()), val: Double.POSITIVE_INFINITY.toDouble() } - from_type: Char to_type: char @@ -266,24 +266,24 @@ cases: - from_type: Char to_type: long values: - - { expr: "new Char(c'\\u0000')", val: 0 as long } - - { expr: "new Char(c'\\u007f')", val: 127 as long } - - { expr: "new Char(c'\\u8000')", val: 32768 as long } - - { expr: "new Char(c'\\uff80')", val: 65408 as long } - - { expr: "new Char(c'\\uffff')", val: 65535 as long } - - { expr: "new Char(c'\\ucafe')", val: 51966 as long } - - { expr: "new Char(c'R')", val: 82 as long } + - { expr: "new Char(c'\\u0000')", val: 0 } + - { expr: "new Char(c'\\u007f')", val: 127 } + - { expr: "new Char(c'\\u8000')", val: 32768 } + - { expr: "new Char(c'\\uff80')", val: 65408 } + - { expr: "new Char(c'\\uffff')", val: 65535 } + - { expr: "new Char(c'\\ucafe')", val: 51966 } + - { expr: "new Char(c'R')", val: 82 } - from_type: Char to_type: float values: - - { expr: "new Char(c'\\u0000')", val: 0.0 as float } - - { expr: "new Char(c'\\u007f')", val: 127.0 as float } - - { expr: "new Char(c'\\u8000')", val: 32768.0 as float } - - { expr: "new Char(c'\\uff80')", val: 65408.0 as float } - - { expr: "new Char(c'\\uffff')", val: 65535.0 as float } - - { expr: "new Char(c'\\ucafe')", val: 51966.0 as float } - - { expr: "new Char(c'R')", val: 82.0 as float } + - { expr: "new Char(c'\\u0000')", val: 0.0f } + - { expr: "new Char(c'\\u007f')", val: 127.0f } + - { expr: "new Char(c'\\u8000')", val: 32768.0f } + - { expr: "new Char(c'\\uff80')", val: 65408.0f } + - { expr: "new Char(c'\\uffff')", val: 65535.0f } + - { expr: "new Char(c'\\ucafe')", val: 51966.0f } + - { expr: "new Char(c'R')", val: 82.0f } - from_type: Char to_type: double diff --git a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/05.accessible/type_name_const.ets b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/05.accessible/type_name_const.ets index e96351a85fc2a5dbe28319bfec3f3a76c0a36898..7dccef7d5477a471d8c4433b45441f48f1d77f0e 100644 --- a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/05.accessible/type_name_const.ets +++ b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/05.accessible/type_name_const.ets @@ -54,46 +54,10 @@ function foo(i: char) { return 7; } -function foo(i: boolean) { +function foo(i: string) { return 8; } -function foo(i: Byte) { - return 11; -} - -function foo(i: Short) { - return 12; -} - -function foo(i: Int) { - return 13; -} - -function foo(i: Long) { - return 14; -} - -function foo(i: Float) { - return 15; -} - -function foo(i: Number) { - return 16; -} - -function foo(i: Char) { - return 17; -} - -function foo(i: String) { - return 18; -} - -function foo(i: Boolean) { - return 19; -} - function foo(i: FixedArray) { return 21; } diff --git a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/05.accessible/type_name_const.params.yaml b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/05.accessible/type_name_const.params.yaml index 82cbec04f0e2b57ed1fdd166c2a6a59d507bbce0..ce8f6b29ea5c814b22462d24784ee476beabdba0 100644 --- a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/05.accessible/type_name_const.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/05.accessible/type_name_const.params.yaml @@ -78,12 +78,13 @@ cases: assertEQ(foo(a), 7); } + #8 - decl: |- type T = boolean const a: T = true; check: |- function main() { - assertEQ(foo(a), 8); + assertEQ(foo(a), -1); } # Boxed @@ -92,7 +93,7 @@ cases: const a: T = new Byte(0x7F as byte); check: |- function main() { - assertEQ(foo(a), 11); + assertEQ(foo(a), 1); } - decl: |- @@ -100,7 +101,7 @@ cases: const a: T = new Short(2 as short); check: |- function main() { - assertEQ(foo(a), 12); + assertEQ(foo(a), 2); } - decl: |- @@ -108,7 +109,7 @@ cases: const a: T = new Int(3 as int); check: |- function main() { - assertEQ(foo(a), 13); + assertEQ(foo(a), 3); } - decl: |- @@ -116,7 +117,7 @@ cases: const a: T = new Long(4 as long); check: |- function main() { - assertEQ(foo(a), 14); + assertEQ(foo(a), 4); } - decl: |- @@ -124,7 +125,7 @@ cases: const a: T = new Float(0.1 as float); check: |- function main() { - assertEQ(foo(a), 15); + assertEQ(foo(a), 5); } - decl: |- @@ -132,7 +133,7 @@ cases: const a: T = new Double(0.1 as double); check: |- function main() { - assertEQ(foo(a), 16); // Double is an alias to Number + assertEQ(foo(a), 6); // Double is an alias to Number } - decl: |- @@ -140,7 +141,7 @@ cases: const a: T = new Number(0.1 as number); check: |- function main() { - assertEQ(foo(a), 16); + assertEQ(foo(a), 6); } - decl: |- @@ -148,7 +149,7 @@ cases: const a: T = new Char(c'b'); check: |- function main() { - assertEQ(foo(a), 17); + assertEQ(foo(a), 7); } - decl: |- @@ -156,7 +157,7 @@ cases: const a: T = "some string"; check: |- function main() { - assertEQ(foo(a), 18); // string is an alias to String + assertEQ(foo(a), 8); // string is an alias to String } - decl: |- @@ -164,7 +165,7 @@ cases: const a: T = new String("some string"); check: |- function main() { - assertEQ(foo(a), 18); + assertEQ(foo(a), 8); } - decl: |- @@ -172,7 +173,7 @@ cases: const a: T = new Boolean(false); check: |- function main() { - assertEQ(foo(a), 19); + assertEQ(foo(a), -1); } # Custom diff --git a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/05.accessible/type_name_const_enum.ets b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/05.accessible/type_name_const_enum.ets index db9355de63f9b85fe5f8b9b58ca8b753cc2b7b30..f90294328a9bd75426fdbf3420d4eb402a804f08 100644 --- a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/05.accessible/type_name_const_enum.ets +++ b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/05.accessible/type_name_const_enum.ets @@ -55,43 +55,7 @@ function foo(i: char) { } function foo(i: boolean) { - return 8; -} - -function foo(i: Byte) { - return 11; -} - -function foo(i: Short) { - return 12; -} - -function foo(i: Int) { - return 13; -} - -function foo(i: Long) { - return 14; -} - -function foo(i: Float) { - return 15; -} - -function foo(i: Number) { - return 16; -} - -function foo(i: Char) { - return 17; -} - -function foo(i: String) { - return 18; -} - -function foo(i: Boolean) { - return 19; + return 9; } function foo(i: int[]) { diff --git a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/05.accessible/type_name_variable.ets b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/05.accessible/type_name_variable.ets index b1a2c92d9d02fc5dc7cb1d13d89c3f4c0fdc4d35..534873ac92bed7c375a9cf0035cf6444d1a3ff35 100644 --- a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/05.accessible/type_name_variable.ets +++ b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/05.accessible/type_name_variable.ets @@ -54,43 +54,11 @@ function foo(i: char) { } function foo(i: boolean) { - return 8; -} - -function foo(i: Byte) { - return 11; -} - -function foo(i: Short) { - return 12; -} - -function foo(i: Int) { - return 13; -} - -function foo(i: Long) { - return 14; + return 9; } -function foo(i: Float) { - return 15; -} - -function foo(i: Number) { - return 16; -} - -function foo(i: Char) { - return 17; -} - -function foo(i: String) { - return 18; -} - -function foo(i: Boolean) { - return 19; +function foo(i: string) { + return 8; } function foo(i: FixedArray) { diff --git a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/05.accessible/type_name_variable.params.yaml b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/05.accessible/type_name_variable.params.yaml index fe920f79f3745e12710f6a615e3000e12d49b5cc..f94eaaf26a4e0f77ef50b2cc78104e81820efde2 100644 --- a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/05.accessible/type_name_variable.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/05.accessible/type_name_variable.params.yaml @@ -83,7 +83,7 @@ cases: check: |- function main() { let a: T = true; - assertEQ(foo(a), 8); + assertEQ(foo(a), 9); } # Boxed @@ -92,7 +92,7 @@ cases: check: |- function main() { let a: T = new Byte(0x7F as byte); - assertEQ(foo(a), 11); + assertEQ(foo(a), 1); } - decl: |- @@ -100,7 +100,7 @@ cases: check: |- function main() { let a: T = new Short(2 as short); - assertEQ(foo(a), 12); + assertEQ(foo(a), 2); } - decl: |- @@ -108,7 +108,7 @@ cases: check: |- function main() { let a: T = new Int(3 as int); - assertEQ(foo(a), 13); + assertEQ(foo(a), 3); } - decl: |- @@ -116,7 +116,7 @@ cases: check: |- function main() { let a: T = new Long(4 as long); - assertEQ(foo(a), 14); + assertEQ(foo(a), 4); } - decl: |- @@ -124,7 +124,7 @@ cases: check: |- function main() { let a: T = new Float(0.1 as float); - assertEQ(foo(a), 15); + assertEQ(foo(a), 5); } - decl: |- @@ -132,7 +132,7 @@ cases: check: |- function main() { let a: T = new Double(0.1 as double); - assertEQ(foo(a), 16); // Double is an alias to Number + assertEQ(foo(a), 6); // Double is an alias to Number } - decl: |- @@ -140,7 +140,7 @@ cases: check: |- function main() { let a: T = new Number(0.1 as number); - assertEQ(foo(a), 16); + assertEQ(foo(a), 6); } - decl: |- @@ -148,7 +148,7 @@ cases: check: |- function main() { let a: T = new Char(c'b'); - assertEQ(foo(a), 17); + assertEQ(foo(a), 7); } - decl: |- @@ -156,7 +156,7 @@ cases: check: |- function main() { let a: T = "some string"; - assertEQ(foo(a), 18); // string is an alias to String + assertEQ(foo(a), 8); // string is an alias to String } - decl: |- @@ -164,7 +164,7 @@ cases: check: |- function main() { let a: T = new String("some string"); - assertEQ(foo(a), 18); + assertEQ(foo(a), 8); } - decl: |- @@ -172,7 +172,7 @@ cases: check: |- function main() { let a: T = new Boolean(false); - assertEQ(foo(a), 19); + assertEQ(foo(a), 9); } # Custom diff --git a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/05.accessible/type_name_variable_enum.ets b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/05.accessible/type_name_variable_enum.ets index aeceeb86a1ddf8ecf05ac408de3aecfb96d465bd..c6b8e765237c614d8d3acd3d4f7c3b55bddbb0e7 100644 --- a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/05.accessible/type_name_variable_enum.ets +++ b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/05.accessible/type_name_variable_enum.ets @@ -55,43 +55,7 @@ function foo(i: char) { } function foo(i: boolean) { - return 8; -} - -function foo(i: Byte) { - return 11; -} - -function foo(i: Short) { - return 12; -} - -function foo(i: Int) { - return 13; -} - -function foo(i: Long) { - return 14; -} - -function foo(i: Float) { - return 15; -} - -function foo(i: Number) { - return 16; -} - -function foo(i: Char) { - return 17; -} - -function foo(i: String) { - return 18; -} - -function foo(i: Boolean) { - return 19; + return 9; } function foo(i: int[]) { diff --git a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/07.variable_and_constant_declarations/04.type_inference_from_initializer/infer2.params.yaml b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/07.variable_and_constant_declarations/04.type_inference_from_initializer/infer2.params.yaml index dcd36f55f234a7eb46037f6aeeeae2b750d316b7..db172f90e1ee5e9567c3de4dfcc4ad4cad48daac 100644 --- a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/07.variable_and_constant_declarations/04.type_inference_from_initializer/infer2.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/07.variable_and_constant_declarations/04.type_inference_from_initializer/infer2.params.yaml @@ -72,6 +72,7 @@ cases: function foo(p: Int): int { return 1 } function foo(p: int): int { return 2 } function foo(p: number): int { return 3 } + tags: 'compile-only, negative' use: |- const b = cond ? 1 : 2 // type of b is int assertEQ(typeof b, "number") @@ -82,6 +83,7 @@ cases: function foo(p: Int): int { return 1 } function foo(p: int): int { return 2 } function foo(p: number): int { return 3 } + tags: 'compile-only, negative' use: |- const b = cond ? 3 : 3.14 // type of b is double assertEQ(typeof b, "number") @@ -101,6 +103,7 @@ cases: function foo(p: int): int { return 2 } function foo(p: "one"): int { return 3 } function foo(p: Int|"one"): int { return 4 } + tags: 'compile-only, negative' use: |- const b = cond ? 1 : "one" // type of b is "one" | Int assertTrue(b instanceof Int|"one") @@ -111,7 +114,7 @@ cases: let a = { name: "John" } // CTE expected - tags: 'negative' - decl: |- + decl: |- let arr = new (Object|undefined)[1]; // inferred array of Error|undefined use: |- assertEQ(arr[0], new Object[1]) diff --git a/static_core/plugins/ets/tests/ets-templates/05.generics/01.type_parameters/01.type_parameter_constraint/generic_methods/generic_method_with_body_wrong_constraint.params.yaml b/static_core/plugins/ets/tests/ets-templates/05.generics/01.type_parameters/01.type_parameter_constraint/generic_methods/generic_method_with_body_wrong_constraint.params.yaml index 7a96e5cf82c20f17dbcead70a99db7a1bad47bee..98e6e2893a43238414201715816a1e0474564692 100644 --- a/static_core/plugins/ets/tests/ets-templates/05.generics/01.type_parameters/01.type_parameter_constraint/generic_methods/generic_method_with_body_wrong_constraint.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/05.generics/01.type_parameters/01.type_parameter_constraint/generic_methods/generic_method_with_body_wrong_constraint.params.yaml @@ -32,5 +32,3 @@ constraints: use: char - type: char use: string - - type: void - use: void diff --git a/static_core/plugins/ets/tests/ets-templates/05.generics/generic_declarations/create_array_using_generic_types/create_array_using_generic_types.params.yaml b/static_core/plugins/ets/tests/ets-templates/05.generics/generic_declarations/create_array_using_generic_types/create_array_using_generic_types.params.yaml index bb617f03148f2639c3243555a9ea2b4adc6492e5..9a144378da985f04415868e2a6209fd3d4ea8132 100644 --- a/static_core/plugins/ets/tests/ets-templates/05.generics/generic_declarations/create_array_using_generic_types/create_array_using_generic_types.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/05.generics/generic_declarations/create_array_using_generic_types/create_array_using_generic_types.params.yaml @@ -64,9 +64,9 @@ cases_two: values: "1, 2, 3" expected_values: [1, 2, 3] - - type: float + - type: Float desc: Instantiated array T[] with float type. - values: "1.1, 2.1, 3.9" + values: "1.1f, 2.1f, 3.9f" expected_values: [1.1f, 2.1f, 3.9f] - type: double diff --git a/static_core/plugins/ets/tests/ets-templates/05.generics/generic_declarations/generic_classes/test_bridge_methods_in_generic_overrides/bridge_methods_generic.params.yaml b/static_core/plugins/ets/tests/ets-templates/05.generics/generic_declarations/generic_classes/test_bridge_methods_in_generic_overrides/bridge_methods_generic.params.yaml index 1891f774806bd758b8391ac006ee8ce33ab0ce0c..6cc22eddbe02808b28886fdb28287e7f8dba4d0b 100644 --- a/static_core/plugins/ets/tests/ets-templates/05.generics/generic_declarations/generic_classes/test_bridge_methods_in_generic_overrides/bridge_methods_generic.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/05.generics/generic_declarations/generic_classes/test_bridge_methods_in_generic_overrides/bridge_methods_generic.params.yaml @@ -148,7 +148,7 @@ bridge_methods_generic: } class Child extends Parent { - process(a: string, b: number): [string, number] { + process(a: string, b: number): [string, double] { return [a.toUpperCase(), b * 2]; } } @@ -214,7 +214,7 @@ bridge_methods_generic: class Child extends Parent { process(value: string): string { - return value.charAt(1); + return value.charAt(1).toString(); } } check: |- diff --git a/static_core/plugins/ets/tests/ets-templates/05.generics/generic_declarations/generic_interfaces/check_return_value_type.params.yaml b/static_core/plugins/ets/tests/ets-templates/05.generics/generic_declarations/generic_interfaces/check_return_value_type.params.yaml index 793bb60c24a1aaa8fc8d159d092bd4e5bf6473cd..c3f67ea72be853435df57e19d693e3e0b6e6f1c4 100644 --- a/static_core/plugins/ets/tests/ets-templates/05.generics/generic_declarations/generic_interfaces/check_return_value_type.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/05.generics/generic_declarations/generic_interfaces/check_return_value_type.params.yaml @@ -163,7 +163,7 @@ cases: } class Animal { - name: float = 66.66; + name: float = 66.66f; } class GenericClass implements GenericInterface { @@ -383,7 +383,7 @@ cases: } logic: |- let stringValue = new EnumValue(); - assertEQ(stringValue.getEnumValue() as number, 1); + assertEQ(Int.toDouble(stringValue.getEnumValue()), 1); - desc: The return value type of a generic interface method is a enum type(string). decl: |- diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/array_primitive.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/array_primitive.ets index d71a9d1dfe743a8a4fde16220cd64b109092c0e3..4f89acbf0683b306c501d78c31ff927dc7bc01a6 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/array_primitive.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/array_primitive.ets @@ -17,9 +17,7 @@ /*--- desc: Assignment contexts does not allow the assignment for arrays if one has elements of a primitive types params: Assignment from '{{c.src_type}}' to '{{c.dst_type}}' -tags: -- negative -- compile-only +tags: [compile-only] ---*/ function main() { diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/identity.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/identity.params.yaml index 7c9e1a69245f356894a602c1dad84fe8a44ccd9f..e80052c3615690b3463b86598ac74ed2da5fb24a 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/identity.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/identity.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 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 @@ -19,7 +19,7 @@ cases: - { type: short, expr: 32_767, op: '!=' } - { type: int, expr: 2_147_483_647, op: '!=' } - { type: long, expr: 9_223_372_036_854_775_807, op: '!=' } - - { type: float, expr: 3.40282346e38, op: '!=' } + - { type: float, expr: 3.40282346e38f, op: '!=' } - { type: double, expr: 1.7976931348623157e308, op: '!=' } - { type: char, expr: "c'A'", op: '!=' } - { type: Boolean, expr: new Boolean(false), op: '!==' } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/prim_boxing.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/prim_boxing.params.yaml index 36bdc22fd3a855184e6d4e4035e0f676938568ba..713db99872d6d7dbb100e562d3688d1ed16573d3 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/prim_boxing.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/prim_boxing.params.yaml @@ -19,5 +19,5 @@ boxing_conversions: - {origin: char, dest: Char, value: "c'a'"} - {origin: int, dest: Int, value: 1} - {origin: long, dest: Long, value: 1} - - {origin: float, dest: Float, value: 1.0} + - {origin: float, dest: Float, value: 1.0f} - {origin: double, dest: Double, value: 1.0} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/prim_boxing_nan.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/prim_boxing_nan.ets index b1bbd3620fb0f914a4b6e89f8cc10ab751a69615..9b9c98aa901d3b8dca8786201c207effb7009cc7 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/prim_boxing_nan.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/prim_boxing_nan.ets @@ -19,7 +19,7 @@ desc: Boxing conversion for floating-point types (NaN) ---*/ -let origin: {{conv.origin}} = 0.0 / 0.0; +let origin: {{conv.origin}} = 0.0f / 0.0f; let dest: {{conv.dest}}; function main(): void { diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/prim_narrowing.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/prim_narrowing.ets index a2e829f81fbbd269f74e315eae80523e29d2fff2..30620d2bbb931d8d02eb92ad7d15b85e0cae05fc 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/prim_narrowing.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/prim_narrowing.ets @@ -25,13 +25,10 @@ desc: |- - double to byte, short, char, int, long, or float ---*/ -function main(): int { +function main() { {%- for t in case['types'] %} let src_{{loop.index}}: {{t.stype}} = {{t.src|safe}}; - if ((src_{{loop.index}} as {{t.dtype}}) != ({{t.dst|safe}}) ) { - return 1; - } + assertEQ((src_{{loop.index}}.to{{t.dtype}}()), ({{t.dst|safe}}), "Assert fails on item {{loop.index}}" ) {% endfor %} - return 0; } {% endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/prim_narrowing.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/prim_narrowing.params.yaml index 45475ecf16bf90ad13175d46d3dd7e0537977004..451452f9ca943b4518b463f49fe77ea73c3f1fcf 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/prim_narrowing.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/prim_narrowing.params.yaml @@ -14,90 +14,90 @@ --- cases: - types: - - { stype: short, src: Short.MIN_VALUE, dtype: byte, dst: 0 as byte } - - { stype: short, src: Short.MAX_VALUE, dtype: byte, dst: (-1) as byte } - - { stype: short, src: Short.MIN_VALUE, dtype: char, dst: "c'\\u8000'" } - - { stype: short, src: Short.MAX_VALUE, dtype: char, dst: "c'\\u7fff'" } + - { stype: short, src: Short.MIN_VALUE, dtype: Byte, dst: 0 } + - { stype: short, src: Short.MAX_VALUE, dtype: Byte, dst: (-1) } + - { stype: short, src: Short.MIN_VALUE, dtype: Char, dst: "c'\\u8000'" } + - { stype: short, src: Short.MAX_VALUE, dtype: Char, dst: "c'\\u7fff'" } - - { stype: char, src: "c'\\u0000'", dtype: byte, dst: 0 as byte } - - { stype: char, src: "c'\\uffff'", dtype: byte, dst: (-1) as byte } - - { stype: char, src: "c'\\u0000'", dtype: short, dst: 0 as short } - - { stype: char, src: "c'\\uffff'", dtype: short, dst: (-1) as short } + - { stype: char, src: "c'\\u0000'", dtype: Byte, dst: 0 } + - { stype: char, src: "c'\\uffff'", dtype: Byte, dst: (-1) } + - { stype: char, src: "c'\\u0000'", dtype: Short, dst: 0 } + - { stype: char, src: "c'\\uffff'", dtype: Short, dst: (-1) } - - { stype: int, src: Int.MIN_VALUE, dtype: byte, dst: 0 as byte } - - { stype: int, src: Int.MAX_VALUE, dtype: byte, dst: (-1) as byte } - - { stype: int, src: Int.MIN_VALUE, dtype: short, dst: 0 as short } - - { stype: int, src: Int.MAX_VALUE, dtype: short, dst: (-1) as short } - - { stype: int, src: Int.MIN_VALUE, dtype: char, dst: "c'\\u0000'" } - - { stype: int, src: Int.MAX_VALUE, dtype: char, dst: "c'\\uffff'" } + - { stype: int, src: Int.MIN_VALUE, dtype: Byte, dst: 0 } + - { stype: int, src: Int.MAX_VALUE, dtype: Byte, dst: (-1) } + - { stype: int, src: Int.MIN_VALUE, dtype: Short, dst: 0 } + - { stype: int, src: Int.MAX_VALUE, dtype: Short, dst: (-1) } + - { stype: int, src: Int.MIN_VALUE, dtype: Char, dst: "c'\\u0000'" } + - { stype: int, src: Int.MAX_VALUE, dtype: Char, dst: "c'\\uffff'" } - - { stype: long, src: Long.MIN_VALUE, dtype: byte, dst: 0 as byte } - - { stype: long, src: Long.MAX_VALUE, dtype: byte, dst: (-1) as byte } - - { stype: long, src: Long.MIN_VALUE, dtype: short, dst: 0 as short } - - { stype: long, src: Long.MAX_VALUE, dtype: short, dst: (-1) as short } - - { stype: long, src: Long.MIN_VALUE, dtype: char, dst: "c'\\u0000'" } - - { stype: long, src: Long.MAX_VALUE, dtype: char, dst: "c'\\uffff'" } - - { stype: long, src: Long.MIN_VALUE, dtype: int, dst: 0 as int } - - { stype: long, src: Long.MAX_VALUE, dtype: int, dst: (-1) as int } + - { stype: long, src: Long.MIN_VALUE, dtype: Byte, dst: 0 } + - { stype: long, src: Long.MAX_VALUE, dtype: Byte, dst: (-1) } + - { stype: long, src: Long.MIN_VALUE, dtype: Short, dst: 0 } + - { stype: long, src: Long.MAX_VALUE, dtype: Short, dst: (-1) } + - { stype: long, src: Long.MIN_VALUE, dtype: Char, dst: "c'\\u0000'" } + - { stype: long, src: Long.MAX_VALUE, dtype: Char, dst: "c'\\uffff'" } + - { stype: long, src: Long.MIN_VALUE, dtype: Int, dst: 0 } + - { stype: long, src: Long.MAX_VALUE, dtype: Int, dst: (-1) } - - { stype: float, src: Float.MIN_VALUE, dtype: byte, dst: 0 as byte } - - { stype: float, src: Float.MAX_VALUE, dtype: byte, dst: (-1) as byte } - - { stype: float, src: Float.MIN_VALUE, dtype: short, dst: 0 as short } - - { stype: float, src: Float.MAX_VALUE, dtype: short, dst: (-1) as short } - - { stype: float, src: Float.MIN_VALUE, dtype: char, dst: "c'\\u0000'" } - - { stype: float, src: Float.MAX_VALUE, dtype: char, dst: "c'\\uffff'" } - - { stype: float, src: Float.MIN_VALUE, dtype: int, dst: 0 } - - { stype: float, src: Float.MAX_VALUE, dtype: int, dst: 2147483647 } - - { stype: float, src: Float.MIN_VALUE, dtype: long, dst: 0 as long } - - { stype: float, src: Float.MAX_VALUE, dtype: long, dst: 9223372036854775807 as long } + - { stype: float, src: Float.MIN_VALUE, dtype: Byte, dst: 0 } + - { stype: float, src: Float.MAX_VALUE, dtype: Byte, dst: (-1) } + - { stype: float, src: Float.MIN_VALUE, dtype: Short, dst: 0 } + - { stype: float, src: Float.MAX_VALUE, dtype: Short, dst: (-1) } + - { stype: float, src: Float.MIN_VALUE, dtype: Char, dst: "c'\\u0000'" } + - { stype: float, src: Float.MAX_VALUE, dtype: Char, dst: "c'\\uffff'" } + - { stype: float, src: Float.MIN_VALUE, dtype: Int, dst: 0 } + - { stype: float, src: Float.MAX_VALUE, dtype: Int, dst: 2147483647 } + - { stype: float, src: Float.MIN_VALUE, dtype: Long, dst: 0 } + - { stype: float, src: Float.MAX_VALUE, dtype: Long, dst: 9223372036854775807 } - - { stype: double, src: Double.MIN_VALUE, dtype: byte, dst: 0 as byte } - - { stype: double, src: Double.MAX_VALUE, dtype: byte, dst: (-1) as byte } - - { stype: double, src: Double.MIN_VALUE, dtype: short, dst: 0 as short } - - { stype: double, src: Double.MAX_VALUE, dtype: short, dst: (-1) as short } - - { stype: double, src: Double.MIN_VALUE, dtype: char, dst: "c'\\u0000'" } - - { stype: double, src: Double.MAX_VALUE, dtype: char, dst: "c'\\uffff'" } - - { stype: double, src: Double.MIN_VALUE, dtype: int, dst: 0 } - - { stype: double, src: Double.MAX_VALUE, dtype: int, dst: 2147483647 } - - { stype: double, src: Double.MIN_VALUE, dtype: long, dst: 0 as long } - - { stype: double, src: Double.MAX_VALUE, dtype: long, dst: 9223372036854775807 as long } - - { stype: double, src: Double.MIN_VALUE, dtype: float, dst: 0.0 as float } - - { stype: double, src: Double.MAX_VALUE, dtype: float, dst: Float.POSITIVE_INFINITY } + - { stype: double, src: Double.MIN_VALUE, dtype: Byte, dst: 0 } + - { stype: double, src: Double.MAX_VALUE, dtype: Byte, dst: (-1) } + - { stype: double, src: Double.MIN_VALUE, dtype: Short, dst: 0 } + - { stype: double, src: Double.MAX_VALUE, dtype: Short, dst: (-1) } + - { stype: double, src: Double.MIN_VALUE, dtype: Char, dst: "c'\\u0000'" } + - { stype: double, src: Double.MAX_VALUE, dtype: Char, dst: "c'\\uffff'" } + - { stype: double, src: Double.MIN_VALUE, dtype: Int, dst: 0 } + - { stype: double, src: Double.MAX_VALUE, dtype: Int, dst: 2147483647 } + - { stype: double, src: Double.MIN_VALUE, dtype: Long, dst: 0 } + - { stype: double, src: Double.MAX_VALUE, dtype: Long, dst: 9223372036854775807 } + - { stype: double, src: Double.MIN_VALUE, dtype: Float, dst: 0.0 } + - { stype: double, src: Double.MAX_VALUE, dtype: Float, dst: Float.POSITIVE_INFINITY } - - { stype: float, src: Float.NaN, dtype: byte, dst: 0 as byte } - - { stype: float, src: Float.NaN, dtype: short, dst: 0 as short } - - { stype: float, src: Float.NaN, dtype: char, dst: "c'\\u0000'" } - - { stype: float, src: Float.NaN, dtype: int, dst: 0 } - - { stype: float, src: Float.NaN, dtype: long, dst: 0 as long } + - { stype: float, src: Float.NaN, dtype: Byte, dst: 0 } + - { stype: float, src: Float.NaN, dtype: Short, dst: 0 } + - { stype: float, src: Float.NaN, dtype: Char, dst: "c'\\u0000'" } + - { stype: float, src: Float.NaN, dtype: Int, dst: 0 } + - { stype: float, src: Float.NaN, dtype: Long, dst: 0 } - - { stype: float, src: Float.POSITIVE_INFINITY, dtype: byte, dst: (-1) as byte } - - { stype: float, src: Float.POSITIVE_INFINITY, dtype: short, dst: (-1) as short } - - { stype: float, src: Float.POSITIVE_INFINITY, dtype: char, dst: "c'\\uffff'" } - - { stype: float, src: Float.POSITIVE_INFINITY, dtype: int, dst: 2147483647 } - - { stype: float, src: Float.POSITIVE_INFINITY, dtype: long, dst: 9223372036854775807 as long } + - { stype: float, src: Float.POSITIVE_INFINITY, dtype: Byte, dst: (-1) } + - { stype: float, src: Float.POSITIVE_INFINITY, dtype: Short, dst: (-1) } + - { stype: float, src: Float.POSITIVE_INFINITY, dtype: Char, dst: "c'\\uffff'" } + - { stype: float, src: Float.POSITIVE_INFINITY, dtype: Int, dst: 2147483647 } + - { stype: float, src: Float.POSITIVE_INFINITY, dtype: Long, dst: 9223372036854775807 } - - { stype: float, src: Float.NEGATIVE_INFINITY, dtype: byte, dst: 0 as byte } - - { stype: float, src: Float.NEGATIVE_INFINITY, dtype: short, dst: 0 as short } - - { stype: float, src: Float.NEGATIVE_INFINITY, dtype: char, dst: "c'\\u0000'" } - - { stype: float, src: Float.NEGATIVE_INFINITY, dtype: int, dst: -2147483648 } - - { stype: float, src: Float.NEGATIVE_INFINITY, dtype: long, dst: (-9223372036854775808) as long } + - { stype: float, src: Float.NEGATIVE_INFINITY, dtype: Byte, dst: 0 } + - { stype: float, src: Float.NEGATIVE_INFINITY, dtype: Short, dst: 0 } + - { stype: float, src: Float.NEGATIVE_INFINITY, dtype: Char, dst: "c'\\u0000'" } + - { stype: float, src: Float.NEGATIVE_INFINITY, dtype: Int, dst: -2147483648 } + - { stype: float, src: Float.NEGATIVE_INFINITY, dtype: Long, dst: (-9223372036854775808) } - - { stype: double, src: Double.NaN, dtype: byte, dst: 0 as byte } - - { stype: double, src: Double.NaN, dtype: short, dst: 0 as short } - - { stype: double, src: Double.NaN, dtype: char, dst: "c'\\u0000'" } - - { stype: double, src: Double.NaN, dtype: int, dst: 0 } - - { stype: double, src: Double.NaN, dtype: long, dst: 0 as long } + - { stype: double, src: Double.NaN, dtype: Byte, dst: 0 } + - { stype: double, src: Double.NaN, dtype: Short, dst: 0 } + - { stype: double, src: Double.NaN, dtype: Char, dst: "c'\\u0000'" } + - { stype: double, src: Double.NaN, dtype: Int, dst: 0 } + - { stype: double, src: Double.NaN, dtype: Long, dst: 0 } - - { stype: double, src: Double.POSITIVE_INFINITY, dtype: byte, dst: (-1) as byte } - - { stype: double, src: Double.POSITIVE_INFINITY, dtype: short, dst: (-1) as short } - - { stype: double, src: Double.POSITIVE_INFINITY, dtype: char, dst: "c'\\uffff'" } - - { stype: double, src: Double.POSITIVE_INFINITY, dtype: int, dst: 2147483647 } - - { stype: double, src: Double.POSITIVE_INFINITY, dtype: long, dst: 9223372036854775807 as long } - - { stype: double, src: Double.POSITIVE_INFINITY, dtype: float, dst: Float.POSITIVE_INFINITY } + - { stype: double, src: Double.POSITIVE_INFINITY, dtype: Byte, dst: (-1) } + - { stype: double, src: Double.POSITIVE_INFINITY, dtype: Short, dst: (-1) } + - { stype: double, src: Double.POSITIVE_INFINITY, dtype: Char, dst: "c'\\uffff'" } + - { stype: double, src: Double.POSITIVE_INFINITY, dtype: Int, dst: 2147483647 } + - { stype: double, src: Double.POSITIVE_INFINITY, dtype: Long, dst: 9223372036854775807 } + - { stype: double, src: Double.POSITIVE_INFINITY, dtype: Float, dst: Float.POSITIVE_INFINITY } - - { stype: double, src: Double.NEGATIVE_INFINITY, dtype: byte, dst: 0 as byte } - - { stype: double, src: Double.NEGATIVE_INFINITY, dtype: short, dst: 0 as short } - - { stype: double, src: Double.NEGATIVE_INFINITY, dtype: char, dst: "c'\\u0000'" } - - { stype: double, src: Double.NEGATIVE_INFINITY, dtype: int, dst: -2147483648 } - - { stype: double, src: Double.NEGATIVE_INFINITY, dtype: long, dst: (-9223372036854775808) as long } - - { stype: double, src: Double.NEGATIVE_INFINITY, dtype: float, dst: Float.NEGATIVE_INFINITY } + - { stype: double, src: Double.NEGATIVE_INFINITY, dtype: Byte, dst: 0 } + - { stype: double, src: Double.NEGATIVE_INFINITY, dtype: Short, dst: 0 } + - { stype: double, src: Double.NEGATIVE_INFINITY, dtype: Char, dst: "c'\\u0000'" } + - { stype: double, src: Double.NEGATIVE_INFINITY, dtype: Int, dst: -2147483648 } + - { stype: double, src: Double.NEGATIVE_INFINITY, dtype: Long, dst: (-9223372036854775808) } + - { stype: double, src: Double.NEGATIVE_INFINITY, dtype: Float, dst: Float.NEGATIVE_INFINITY } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/prim_wide_narrow.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/prim_wide_narrow.ets index 8c458db4925fc24ba876e30730d415bf3051bcb4..78834347df8be1df30d000129a3a4eed53fce74a 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/prim_wide_narrow.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/prim_wide_narrow.ets @@ -23,7 +23,7 @@ desc: |- function main(): int { {%- for t in case['types'] %} let src_{{loop.index}}: {{t.stype}} = {{t.src|safe}}; - if ((src_{{loop.index}} as {{t.dtype}}) != ({{t.dst|safe}}) ) { + if (src_{{loop.index}}.toChar() != ({{t.dst|safe}}) ) { return 1; } {% endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/prim_wide_narrow.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/prim_wide_narrow.params.yaml index 36d7636de84642c109b5808cc9cef6b4127d40a9..bbc641876bc04267e0645c6b359ce4a27fce1415 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/prim_wide_narrow.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/prim_wide_narrow.params.yaml @@ -14,8 +14,8 @@ --- cases: - types: - - { stype: byte, src: Byte.MIN_VALUE, dtype: char, dst: "c'\\uff80'" } - - { stype: byte, src: Byte.MAX_VALUE, dtype: char, dst: "c'\\u007f'" } - - { stype: byte, src: 0 as byte, dtype: char, dst: "c'\\u0000'" } - - { stype: byte, src: 1 as byte, dtype: char, dst: "c'\\u0001'" } - - { stype: byte, src: (-1) as byte, dtype: char, dst: "c'\\uffff'" } + - { stype: byte, src: Byte.MIN_VALUE, dst: "c'\\uff80'" } + - { stype: byte, src: Byte.MAX_VALUE, dst: "c'\\u007f'" } + - { stype: byte, src: 0, dst: "c'\\u0000'" } + - { stype: byte, src: 1, dst: "c'\\u0001'" } + - { stype: byte, src: -1, dst: "c'\\uffff'" } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/ref_widening.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/ref_widening.ets index b4d2d6cab9ee532d0571ac7555d2e8394c7df83b..77779dd6d795997def9ef6bc789e393aad1871a8 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/ref_widening.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/ref_widening.ets @@ -23,12 +23,9 @@ tags: [{{t.tags}}] {{t.defs}} -function main(): int { +function main() { let src: {{t.stype}} = {{t.src|safe}}; let dst: {{t.dtype}} = src as {{t.dtype}}; - if (src !== dst ) { // reference equality - return 1; - } - return 0; + assertEQ( src, dst ) // reference equality } {% endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/unboxing2.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/unboxing2.ets index 0d5611d795dd32356ed98d54734871757f98b7d6..53d4dd6544c285b5f2bfdbd4f4de00870f122677 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/unboxing2.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/unboxing2.ets @@ -23,7 +23,7 @@ function main(): int { {% for v in case['values'] %} let src_{{loop.index}}: {{case.src_type}} = new {{case.src_type}}({{v|safe}}); let dst_{{loop.index}}: {{case.dst_type}} = src_{{loop.index}}; // unboxing in this assignment - if (dst_{{loop.index}} != (src_{{loop.index}}.unboxed() as {{case.dst_type}})) { + if (dst_{{loop.index}} != (src_{{loop.index}}.unboxed().to{{case.dst_type}}())) { return 1; } {% endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/unboxing2.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/unboxing2.params.yaml index e86a4823470ed1dea31b0afda65016d8220f4284..3430def954322a49e0046c76b0b069f7e656b8fe 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/unboxing2.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/unboxing2.params.yaml @@ -15,80 +15,80 @@ cases: - src_type: Byte - dst_type: short + dst_type: Short values: [-128 as byte, 0 as byte, 127 as byte] - src_type: Byte - dst_type: int + dst_type: Int values: [-128 as byte, 0 as byte, 127 as byte] - src_type: Byte - dst_type: long + dst_type: Long values: [-128 as byte, 0 as byte, 127 as byte] - src_type: Byte - dst_type: float + dst_type: Float values: [-128 as byte, 0 as byte, 127 as byte] - src_type: Byte - dst_type: double + dst_type: Double values: [-128 as byte, 0 as byte, 127 as byte] - src_type: Char - dst_type: int + dst_type: Int values: ["c'\\u0000'", "c'X'", "c'\\uffff'"] - src_type: Char - dst_type: long + dst_type: Long values: ["c'\\u0000'", "c'X'", "c'\\uffff'"] - src_type: Char - dst_type: float + dst_type: Float values: ["c'\\u0000'", "c'X'", "c'\\uffff'"] - src_type: Char - dst_type: double + dst_type: Double values: ["c'\\u0000'", "c'X'", "c'\\uffff'"] - src_type: Short - dst_type: int + dst_type: Int values: [-32768 as short, -128 as short, 0 as short] - src_type: Short - dst_type: long + dst_type: Long values: [-32768 as short, -128 as short, 0 as short] - src_type: Short - dst_type: float + dst_type: Float values: [-32768 as short, -128 as short, 0 as short] - src_type: Short - dst_type: double + dst_type: Double values: [-32768 as short, -128 as short, 0 as short] - src_type: Int - dst_type: long + dst_type: Long values: [127, 32767, 2147483647] - src_type: Int - dst_type: float + dst_type: Float values: [127, 32767] - src_type: Int - dst_type: double + dst_type: Double values: [127, 32768] - src_type: Long - dst_type: float + dst_type: Float values: [-1 as long, 0 as long, 1 as long] - src_type: Long - dst_type: double + dst_type: Double values: [-128 as long, 127 as long] - src_type: Float - dst_type: double + dst_type: Double values: [1.4e-10 as float, 0.0000001 as float] diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/widening_prim.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/widening_prim.params.yaml index 4a43c6ce04fe536ad8f5d15d3be442a1f92305e6..516d2842d759886564ef27d6cdb9f3958ff6317d 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/widening_prim.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/widening_prim.params.yaml @@ -68,13 +68,13 @@ cases: - { src_type: long, src_val: 9223372036854775807, dst_type: double, dst_val: 9.223372036854776e18 } - { src_type: long, src_val: -9223372036854775808, dst_type: double, dst_val: -9.223372036854776e18 } - - { src_type: float, src_val: -0.0, dst_type: double, dst_val: -0.0 } - - { src_type: float, src_val: +0.0, dst_type: double, dst_val: +0.0 } + - { src_type: float, src_val: -0.0f, dst_type: double, dst_val: -0.0 } + - { src_type: float, src_val: +0.0f, dst_type: double, dst_val: +0.0 } # +max - - { src_type: float, src_val: 3.4028234663852886e38, dst_type: double, dst_val: 3.4028234663852886e38 } + - { src_type: float, src_val: 3.4028234663852886e38f, dst_type: double, dst_val: 3.4028234663852886e38 } # +min - - { src_type: float, src_val: 1.401298464324817e-45, dst_type: double, dst_val: 1.401298464324817e-45 } + - { src_type: float, src_val: 1.401298464324817e-45f, dst_type: double, dst_val: 1.401298464324817e-45 } # -max - - { src_type: float, src_val: -3.4028234663852886e38, dst_type: double, dst_val: -3.4028234663852886e38 } + - { src_type: float, src_val: -3.4028234663852886e38f, dst_type: double, dst_val: -3.4028234663852886e38 } # -min - - { src_type: float, src_val: -1.401298464324817e-45, dst_type: double, dst_val: -1.401298464324817e-45 } + - { src_type: float, src_val: -1.401298464324817e-45f, dst_type: double, dst_val: -1.401298464324817e-45 } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/widening_prim_call.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/widening_prim_call.params.yaml index 5f3b144cef7c98f1dfdd71954e8939a4033837d2..f4f035dceb93447b8171bd9d6a092d65a2951653 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/widening_prim_call.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/01.assignment-like_contexts/widening_prim_call.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 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 @@ -46,20 +46,20 @@ cases: - ctype: float values: - - { type: byte, val: 0, val2: (0.0 as float) } - - { type: byte, val: 127, val2: (127.0 as float) } - - { type: byte, val: -128, val2: (-128.0 as float) } - - { type: char, val: 0, val2: (0.0 as float) } - - { type: char, val: "c'\\uFFFF'", val2: (65535.0 as float)} - - { type: short, val: 0, val2: (0.0 as float) } - - { type: short, val: 32_767, val2: (32_767.0 as float) } - - { type: short, val: -32_768, val2: (-32_768.0 as float) } - - { type: int, val: 0, val2: (0.0 as float) } - - { type: int, val: 2147483647, val2: (2.147483648e9 as float)} - - { type: int, val: -2147483648, val2: (-2.147483648e9 as float) } - - { type: long, val: 0, val2: (0.0 as float)} - - { type: long, val: 9223372036854775807, val2: (9.223372036854776e18 as float)} - - { type: long, val: -9223372036854775808, val2: (-9.223372036854776e18 as float)} + - { type: byte, val: 0, val2: (0.0f as float) } + - { type: byte, val: 127, val2: (127.0f as float) } + - { type: byte, val: -128, val2: (-128.0f as float) } + - { type: char, val: 0, val2: (0.0f as float) } + - { type: char, val: "c'\\uFFFF'", val2: (65535.0f as float)} + - { type: short, val: 0, val2: (0.0f as float) } + - { type: short, val: 32_767, val2: (32_767.0f as float) } + - { type: short, val: -32_768, val2: (-32_768.0f as float) } + - { type: int, val: 0, val2: (0.0f as float) } + - { type: int, val: 2147483647, val2: (2.147483648e9f as float)} + - { type: int, val: -2147483648, val2: (-2.147483648e9f as float) } + - { type: long, val: 0, val2: (0.0f as float)} + - { type: long, val: 9223372036854775807, val2: (9.223372036854776e18f as float)} + - { type: long, val: -9223372036854775808, val2: (-9.223372036854776e18f as float)} - ctype: double values: @@ -77,12 +77,12 @@ cases: - { type: long, val: 0, val2: 0.0 } - { type: long, val: 9223372036854775807, val2: 9.223372036854776e18 } - { type: long, val: -9223372036854775808, val2: -9.223372036854776e18 } - - { type: float, val: 0.0, val2: 0.0 } + - { type: float, val: 0.0f, val2: 0.0f } # +max - - { type: float, val: 3.4028234663852886e38, val2: 3.4028234663852886e38 } + - { type: float, val: 3.4028234663852886e38f, val2: 3.4028234663852886e38f } # +min - - { type: float, val: 1.401298464324817e-45, val2: 1.401298464324817e-45 } + - { type: float, val: 1.401298464324817e-45f, val2: 1.401298464324817e-45f } # -max - - { type: float, val: -3.4028234663852886e38, val2: -3.4028234663852886e38 } + - { type: float, val: -3.4028234663852886e38f, val2: -3.4028234663852886e38f } # -min - - { type: float, val: -1.401298464324817e-45, val2: -1.401298464324817e-45 } + - { type: float, val: -1.401298464324817e-45f, val2: -1.401298464324817e-45f } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/02.string_operator_contexts/conversion.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/02.string_operator_contexts/conversion.params.yaml index d0355ff1411e7b0e9a2ffbbcbd6cb7c6ef050bce..d88db6b59127c8c1ed2a32d77cc7d6ce7ee4696e 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/02.string_operator_contexts/conversion.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/02.string_operator_contexts/conversion.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 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 @@ -37,27 +37,27 @@ cases: - [Integral, new Long(42 as long), "\"42\""] - val: - - [float, 3.14, new Float(3.14 as float).toString()] + - [float, 3.14f, new Float(3.14f as float).toString()] - [double, 3.14, new Double(3.14 as double).toString()] - - [float, 0.0/0.0, "\"NaN\""] + - [float, 0.0f/0.0f, "\"NaN\""] - [double, 0.0/0.0, "\"NaN\""] - - [float, 1.0/0.0, "\"Infinity\""] + - [float, 1.0f/0.0f, "\"Infinity\""] - [double, 1.0/0.0, "\"Infinity\""] - - [float, -1.0/0.0, "\"-Infinity\""] + - [float, -1.0f/0.0f, "\"-Infinity\""] - [double, -1.0/0.0, "\"-Infinity\""] - val: - - [Float, new Float(3.14 as float), p1.toString()] + - [Float, new Float(3.14f as float), p1.toString()] - [Double, new Double(3.14 as double), p2.toString()] - - [Float, new Float((0.0/0.0) as float), "\"NaN\""] + - [Float, new Float((0.0f/0.0f) as float), "\"NaN\""] - [Double, new Double(0.0/0.0), "\"NaN\""] - - [Float, new Float((1.0/0.0) as float), "\"Infinity\""] + - [Float, new Float((1.0f/0.0f) as float), "\"Infinity\""] - [Double, new Double(1.0/0.0), "\"Infinity\""] - - [Float, new Float((-1.0/0.0) as float), "\"-Infinity\""] + - [Float, new Float((-1.0f/0.0f) as float), "\"-Infinity\""] - [Double, new Double(-1.0/0.0), "\"-Infinity\""] - val: - - [Floating, new Float(3.14 as float), p1.toString()] + - [Floating, new Float(3.14f as float), p1.toString()] - [Floating, new Double(3.14 as double), p2.toString()] - val: @@ -80,7 +80,7 @@ cases: - ["short[]", "[5, 6]", p4.toString()] - ["int[]", "[1431655765]", p5.toString()] - ["long[]", "[6148914691236517]", p6.toString()] - - ["float[]", "[0.1, 0.2, 0.3]", p7.toString()] + - ["float[]", "[0.1f, 0.2f, 0.3f]", p7.toString()] - ["double[]", "[1.0, 2.0, 3.0]", p8.toString()] - val: diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/binary_numeric_promotion/result_type_arith.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/binary_numeric_promotion/result_type_arith.ets index 0eda37e7466a575fbaa53a15689f789f4eecb0be..b380ca8d07a4d26c040441508086fb248e9f2977 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/binary_numeric_promotion/result_type_arith.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/binary_numeric_promotion/result_type_arith.ets @@ -60,49 +60,14 @@ function foo(p: double): int { return 8; } -function foo(p: Byte): int { - return 21; -} - -function foo(p: Short): int { - return 22; -} - -function foo(p: Int): int { - return 23; -} - -function foo(p: Long): int { - return 24; -} - -function foo(p: Char): int { - return 25; -} - -function foo(p: Boolean): int { - return 26; -} - -function foo(p: Float): int { - return 27; -} - -function foo(p: Double): int { - return 28; -} - function foo(p: Object): int { return 40; } -function main(): int { +function main(): void { let v: {{c.type}} = {{c.val}}; let r: {{c.rt}} = {{c.rv}}; let result: int = foo(v {{c.op}} r); - if (result != {{c.res}}) { - return 1; - } - return 0; + assertEQ(result, {{c.res}}) } {% endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/binary_numeric_promotion/result_type_arith_n.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/binary_numeric_promotion/result_type_arith_n.ets index 92cea8a492b55d7130a361a9dc2289c68622576d..0494b0ac8c1e9dbaa4e9156241c4ee104e52e042 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/binary_numeric_promotion/result_type_arith_n.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/binary_numeric_promotion/result_type_arith_n.ets @@ -61,38 +61,6 @@ function foo(p: double): int { return 8; } -function foo(p: Byte): int { - return 21; -} - -function foo(p: Short): int { - return 22; -} - -function foo(p: Int): int { - return 23; -} - -function foo(p: Long): int { - return 24; -} - -function foo(p: Char): int { - return 25; -} - -function foo(p: Boolean): int { - return 26; -} - -function foo(p: Float): int { - return 27; -} - -function foo(p: Double): int { - return 28; -} - function foo(p: Object): int { return 40; } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/binary_numeric_promotion/result_type_bitwise.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/binary_numeric_promotion/result_type_bitwise.ets index 5a0abf58e5a61c2c6f81acd6742ce9c9ae6743bf..5cf197df2f8c97a05876d36e2d6172bb58649823 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/binary_numeric_promotion/result_type_bitwise.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/binary_numeric_promotion/result_type_bitwise.ets @@ -60,38 +60,6 @@ function foo(p: double): int { return 8; } -function foo(p: Byte): int { - return 21; -} - -function foo(p: Short): int { - return 22; -} - -function foo(p: Int): int { - return 23; -} - -function foo(p: Long): int { - return 24; -} - -function foo(p: Char): int { - return 25; -} - -function foo(p: Boolean): int { - return 26; -} - -function foo(p: Float): int { - return 27; -} - -function foo(p: Double): int { - return 28; -} - function foo(p: Object): int { return 40; } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/binary_numeric_promotion/result_type_bool.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/binary_numeric_promotion/result_type_bool.ets index a77303a018caf381d877dd512a7eca2a4e0ba168..1c934f5a53f8c5ffda307b7f78bb1016e3489af2 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/binary_numeric_promotion/result_type_bool.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/binary_numeric_promotion/result_type_bool.ets @@ -60,38 +60,6 @@ function foo(p: double): int { return 8; } -function foo(p: Byte): int { - return 21; -} - -function foo(p: Short): int { - return 22; -} - -function foo(p: Int): int { - return 23; -} - -function foo(p: Long): int { - return 24; -} - -function foo(p: Char): int { - return 25; -} - -function foo(p: Boolean): int { - return 26; -} - -function foo(p: Float): int { - return 27; -} - -function foo(p: Double): int { - return 28; -} - function foo(p: Object): int { return 40; } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/binary_numeric_promotion/result_type_cond.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/binary_numeric_promotion/result_type_cond.ets index 34c8478017f1ae6aa133d941d3da79e3f6e11c1d..aa7d0cc0c7ff340267209e75bd2648c7712fbb9c 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/binary_numeric_promotion/result_type_cond.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/binary_numeric_promotion/result_type_cond.ets @@ -60,38 +60,6 @@ function foo(p: double): int { return 8; } -function foo(p: Byte): int { - return 21; -} - -function foo(p: Short): int { - return 22; -} - -function foo(p: Int): int { - return 23; -} - -function foo(p: Long): int { - return 24; -} - -function foo(p: Char): int { - return 25; -} - -function foo(p: Boolean): int { - return 26; -} - -function foo(p: Float): int { - return 27; -} - -function foo(p: Double): int { - return 28; -} - function foo(p: Object): int { return 40; } @@ -101,9 +69,7 @@ function main(): int { let v: {{c.type}} = {{c.val}}; let r: {{c.rt}} = {{c.rv}}; let result: int = foo(b ? v : r); - if (result != {{c.res}}) { - return 1; - } + assertEQ(result, {{c.res}}) return 0; } {% endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/binary_numeric_promotion/result_type_cond.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/binary_numeric_promotion/result_type_cond.params.yaml index 320a9f20d277eaa6e70228abef4f6c6ff96f147f..c148357030ad2d5a6f827ed2f0a6bd05be6c346a 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/binary_numeric_promotion/result_type_cond.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/binary_numeric_promotion/result_type_cond.params.yaml @@ -21,13 +21,13 @@ cases: - { type: byte, val: 1 as byte, rt: float, rv: 1.0 as float, res: 7 } - { type: byte, val: 1 as byte, rt: double, rv: 1.0, res: 8 } - - { type: byte, val: 1 as byte, rt: Byte, rv: new Byte(1 as byte), res: 21 } - - { type: byte, val: 1 as byte, rt: Short, rv: new Short(1 as short), res: 40 } + - { type: byte, val: 1 as byte, rt: Byte, rv: new Byte(1 as byte), res: 1 } + - { type: byte, val: 1 as byte, rt: Short, rv: new Short(1 as short), res: 2 } - { type: byte, val: 1 as byte, rt: Char, rv: new Char(c'0'), res: 40 } - - { type: byte, val: 1 as byte, rt: Int, rv: new Int(1), res: 40 } - - { type: byte, val: 1 as byte, rt: Long, rv: new Long(1 as long), res: 40 } - - { type: byte, val: 1 as byte, rt: Float, rv: new Float(1.0 as float), res: 40 } - - { type: byte, val: 1 as byte, rt: Double, rv: new Double(1.0), res: 40 } + - { type: byte, val: 1 as byte, rt: Int, rv: new Int(1), res: 3 } + - { type: byte, val: 1 as byte, rt: Long, rv: new Long(1 as long), res: 4 } + - { type: byte, val: 1 as byte, rt: Float, rv: new Float(1.0 as float), res: 7 } + - { type: byte, val: 1 as byte, rt: Double, rv: new Double(1.0), res: 8 } - { type: short, val: 1 as short, rt: byte, rv: 1 as byte, res: 2 } - { type: short, val: 1 as short, rt: short, rv: 1 as short, res: 2 } @@ -37,13 +37,13 @@ cases: - { type: short, val: 1 as short, rt: float, rv: 1.0 as float, res: 7 } - { type: short, val: 1 as short, rt: double, rv: 1.0, res: 8 } - - { type: short, val: 1 as short, rt: Byte, rv: new Byte(1 as byte), res: 40 } - - { type: short, val: 1 as short, rt: Short, rv: new Short(1 as short), res: 22 } + - { type: short, val: 1 as short, rt: Byte, rv: new Byte(1 as byte), res: 2 } + - { type: short, val: 1 as short, rt: Short, rv: new Short(1 as short), res: 2 } - { type: short, val: 1 as short, rt: Char, rv: new Char(c'0'), res: 40 } - - { type: short, val: 1 as short, rt: Int, rv: new Int(1), res: 40 } - - { type: short, val: 1 as short, rt: Long, rv: new Long(1 as long), res: 40 } - - { type: short, val: 1 as short, rt: Float, rv: new Float(1.0 as float), res: 40 } - - { type: short, val: 1 as short, rt: Double, rv: new Double(1.0), res: 40 } + - { type: short, val: 1 as short, rt: Int, rv: new Int(1), res: 3 } + - { type: short, val: 1 as short, rt: Long, rv: new Long(1 as long), res: 4 } + - { type: short, val: 1 as short, rt: Float, rv: new Float(1.0 as float), res: 7 } + - { type: short, val: 1 as short, rt: Double, rv: new Double(1.0), res: 8 } - { type: char, val: "c'2'", rt: byte, rv: 1 as byte, res: 40 } - { type: char, val: "c'2'", rt: short, rv: 1 as short, res: 40 } @@ -55,7 +55,7 @@ cases: - { type: char, val: "c'2'", rt: Byte, rv: new Byte(1 as byte), res: 40 } - { type: char, val: "c'2'", rt: Short, rv: new Short(1 as short), res: 40 } - - { type: char, val: "c'2'", rt: Char, rv: new Char(c'0'), res: 25 } + - { type: char, val: "c'2'", rt: Char, rv: new Char(c'0'), res: 5 } - { type: char, val: "c'2'", rt: Int, rv: new Int(1), res: 40 } - { type: char, val: "c'2'", rt: Long, rv: new Long(1 as long), res: 40 } - { type: char, val: "c'2'", rt: Float, rv: new Float(1.0 as float), res: 40 } @@ -69,13 +69,13 @@ cases: - { type: int, val: 1, rt: float, rv: 1.0 as float, res: 7 } - { type: int, val: 1, rt: double, rv: 1.0, res: 8 } - - { type: int, val: 1, rt: Byte, rv: new Byte(1 as byte), res: 40 } - - { type: int, val: 1, rt: Short, rv: new Short(1 as short), res: 40 } + - { type: int, val: 1, rt: Byte, rv: new Byte(1 as byte), res: 3 } + - { type: int, val: 1, rt: Short, rv: new Short(1 as short), res: 3 } - { type: int, val: 1, rt: Char, rv: new Char(c'0'), res: 40 } - - { type: int, val: 1, rt: Int, rv: new Int(1), res: 23 } - - { type: int, val: 1, rt: Long, rv: new Long(1 as long), res: 40 } - - { type: int, val: 1, rt: Float, rv: new Float(1.0 as float), res: 40 } - - { type: int, val: 1, rt: Double, rv: new Double(1.0), res: 40 } + - { type: int, val: 1, rt: Int, rv: new Int(1), res: 3 } + - { type: int, val: 1, rt: Long, rv: new Long(1 as long), res: 4 } + - { type: int, val: 1, rt: Float, rv: new Float(1.0 as float), res: 7 } + - { type: int, val: 1, rt: Double, rv: new Double(1.0), res: 8 } - { type: long, val: 1 as long, rt: byte, rv: 1 as byte, res: 4 } - { type: long, val: 1 as long, rt: short, rv: 1 as short, res: 4 } @@ -85,13 +85,13 @@ cases: - { type: long, val: 1 as long, rt: float, rv: 1.0 as float, res: 7 } - { type: long, val: 1 as long, rt: double, rv: 1.0, res: 8 } - - { type: long, val: 1 as long, rt: Byte, rv: new Byte(1 as byte), res: 40 } - - { type: long, val: 1 as long, rt: Short, rv: new Short(1 as short), res: 40 } + - { type: long, val: 1 as long, rt: Byte, rv: new Byte(1 as byte), res: 4 } + - { type: long, val: 1 as long, rt: Short, rv: new Short(1 as short), res: 4 } - { type: long, val: 1 as long, rt: Char, rv: new Char(c'0'), res: 40 } - - { type: long, val: 1 as long, rt: Int, rv: new Int(1), res: 40 } - - { type: long, val: 1 as long, rt: Long, rv: new Long(1 as long), res: 24 } - - { type: long, val: 1 as long, rt: Float, rv: new Float(1.0 as float), res: 40 } - - { type: long, val: 1 as long, rt: Double, rv: new Double(1.0), res: 40 } + - { type: long, val: 1 as long, rt: Int, rv: new Int(1), res: 4 } + - { type: long, val: 1 as long, rt: Long, rv: new Long(1 as long), res: 4 } + - { type: long, val: 1 as long, rt: Float, rv: new Float(1.0 as float), res: 7 } + - { type: long, val: 1 as long, rt: Double, rv: new Double(1.0), res: 8 } - { type: float, val: 1 as float, rt: byte, rv: 1 as byte, res: 7 } - { type: float, val: 1 as float, rt: short, rv: 1 as short, res: 7 } @@ -101,13 +101,13 @@ cases: - { type: float, val: 1 as float, rt: float, rv: 1.0 as float, res: 7 } - { type: float, val: 1 as float, rt: double, rv: 1.0, res: 8 } - - { type: float, val: 1 as float, rt: Byte, rv: new Byte(1 as byte), res: 40 } - - { type: float, val: 1 as float, rt: Short, rv: new Short(1 as short), res: 40 } + - { type: float, val: 1 as float, rt: Byte, rv: new Byte(1 as byte), res: 7 } + - { type: float, val: 1 as float, rt: Short, rv: new Short(1 as short), res: 7 } - { type: float, val: 1 as float, rt: Char, rv: new Char(c'0'), res: 40 } - - { type: float, val: 1 as float, rt: Int, rv: new Int(1), res: 40 } - - { type: float, val: 1 as float, rt: Long, rv: new Long(1 as long), res: 40 } - - { type: float, val: 1 as float, rt: Float, rv: new Float(1.0 as float), res: 27 } - - { type: float, val: 1 as float, rt: Double, rv: new Double(1.0), res: 40 } + - { type: float, val: 1 as float, rt: Int, rv: new Int(1), res: 7 } + - { type: float, val: 1 as float, rt: Long, rv: new Long(1 as long), res: 7 } + - { type: float, val: 1 as float, rt: Float, rv: new Float(1.0 as float), res: 7 } + - { type: float, val: 1 as float, rt: Double, rv: new Double(1.0), res: 8 } - { type: double, val: 1 as double, rt: byte, rv: 1 as byte, res: 8 } - { type: double, val: 1 as double, rt: short, rv: 1 as short, res: 8 } @@ -117,10 +117,10 @@ cases: - { type: double, val: 1 as double, rt: float, rv: 1.0 as float, res: 8 } - { type: double, val: 1 as double, rt: double, rv: 1.0, res: 8 } - - { type: double, val: 1 as double, rt: Byte, rv: new Byte(1 as byte), res: 40 } - - { type: double, val: 1 as double, rt: Short, rv: new Short(1 as short), res: 40 } + - { type: double, val: 1 as double, rt: Byte, rv: new Byte(1 as byte), res: 8 } + - { type: double, val: 1 as double, rt: Short, rv: new Short(1 as short), res: 8 } - { type: double, val: 1 as double, rt: Char, rv: new Char(c'0'), res: 40 } - - { type: double, val: 1 as double, rt: Int, rv: new Int(1), res: 40 } - - { type: double, val: 1 as double, rt: Long, rv: new Long(1 as long), res: 40 } - - { type: double, val: 1 as double, rt: Float, rv: new Float(1.0 as float), res: 40 } - - { type: double, val: 1 as double, rt: Double, rv: new Double(1.0), res: 28 } + - { type: double, val: 1 as double, rt: Int, rv: new Int(1), res: 8 } + - { type: double, val: 1 as double, rt: Long, rv: new Long(1 as long), res: 8 } + - { type: double, val: 1 as double, rt: Float, rv: new Float(1.0 as float), res: 8 } + - { type: double, val: 1 as double, rt: Double, rv: new Double(1.0), res: 8 } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/array_creation.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/array_creation.params.yaml index 9d108fac87efe2f96c18f8d9f50b6d2af3f11d06..7b52a5787ed31c1cb1fc480f655875864d24031e 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/array_creation.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/array_creation.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 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,12 +15,10 @@ cases: - { type: byte, val: 42, len: 42 } - { type: short, val: '0xff', len: 255 } - - { type: char, val: "c'A'", len: 65 } - { type: Byte, val: new Byte(3 as byte), len: 3 } - { type: Short, val: new Short(0x1ff as short), len: 511 } - - { type: Char, val: new Char(c' '), len: 32 } - { type: Int, val: new Int(128), len: 128 } - - { type: float, val: 10.0, len: 10 } + - { type: float, val: 10.0f, len: 10 } - { type: double, val: 20.0, len: 20 } - - { type: Float, val: new Float(1.0 as float), len: 1 } + - { type: Float, val: new Float(1.0f as float), len: 1 } - { type: Double, val: new Double(2.0 as double), len: 2 } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/array_creation_n.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/array_creation_n.ets index b84ba316286f4756eb392d5bf8a5c7ac74131a24..52512e63ad08dd68e13346c934ce919c49ff7ed6 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/array_creation_n.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/array_creation_n.ets @@ -24,7 +24,7 @@ tags: [compile-only, negative] function main(): int { let v: {{c.type}} = {{c.val}}; - let arr: {{c.type}}[][] = new {{c.type}}[v][v]; + let arr: FixedArray> = new {{c.type}}[v][v]; if (arr.length != {{c.len}}) { return 1; } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/array_creation_n.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/array_creation_n.params.yaml index 7a1944a8f9e2173e05bd53a2efbef4d3bdd025a6..465f5bad33cd2d6f34d46ab80dfe8382df6e63e7 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/array_creation_n.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/array_creation_n.params.yaml @@ -15,3 +15,5 @@ cases: - { type: long, val: 10, len: 10 } - { type: Long, val: new Long(1 as long), len: 1 } + - { type: char, val: "c'A'", len: 65 } + - { type: Char, val: new Char(c' '), len: 32 } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/bitwise_complement_n.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/bitwise_complement_n.ets index d8efd70c81137a657d2fbf9e3da9cbd46707c66a..d7e8728377546b033ac7d004e51e8b0133ebbbbd 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/bitwise_complement_n.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/bitwise_complement_n.ets @@ -30,22 +30,6 @@ function foo(a: String): int { return 0; } -function foo(a: Integral): int { - return 0; -} - -function foo(a: Floating): int { - return 0; -} - -function foo(a: Double): int { - return 0; -} - -function foo(a: Float): int { - return 0; -} - function foo(a: boolean): int { return 0; } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/shift.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/shift.ets index bfe7eb005db3239f0bcf94241e0c54c6784e8117..c01292939c2d523ba7e47731c374409d265f410a 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/shift.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/shift.ets @@ -53,38 +53,6 @@ function foo(p: double): int { return 8; } -function foo(p: Byte): int { - return 21; -} - -function foo(p: Short): int { - return 22; -} - -function foo(p: Int): int { - return 23; -} - -function foo(p: Long): int { - return 24; -} - -function foo(p: Char): int { - return 25; -} - -function foo(p: Boolean): int { - return 26; -} - -function foo(p: Float): int { - return 27; -} - -function foo(p: Double): int { - return 28; -} - function foo(p: Object): int { return 40; } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/unary_minus.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/unary_minus.params.yaml index cfc5bab441583e991d18ac438f60c3b315a68a6c..c76ae8938f9b8a88f2a99e4608897da45cdcfeaa 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/unary_minus.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/unary_minus.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 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 @@ -21,12 +21,12 @@ cases: - { type: char, val: "c'\\uFFFF'", r: [5, 5, 5, -65535, 65535, -65535] } - { type: int, val: '0xFFFFFFFF', r: [5, 5, 5, 1, -1, 1] } - { type: long, val: '0xFFFFFFFFFFFFFFFF', r: [6, 6, 6, 1, -1, 1] } - - { type: float, val: 1.0, r: [7, 7, 7, -1.0, 1.0, -1.0] } + - { type: float, val: 1.0f, r: [7f, 7f, 7f, -1.0f, 1.0f, -1.0f] } - { type: double, val: 1.00, r: [8, 8, 8, -1.0, 1.0, -1.0] } - { type: Byte, val: new Byte(3 as byte), r: [5, 5, 5, -3, 3, -3] } - { type: Short, val: new Short(0x1ff as short), r: [5, 5, 5, -511, 511, -511] } - { type: Char, val: new Char(c' '), r: [5, 5, 5, -32, 32, -32] } - { type: Int, val: new Int(128), r: [5, 5, 5, -128, 128, -128] } - { type: Long, val: new Long(1 as long), r: [6, 6, 6, -1, 1, -1] } - - { type: Float, val: new Float(1.0 as float), r: [7, 7, 7, -1.0, 1.0, -1.0] } + - { type: Float, val: new Float(1.0f as float), r: [7f, 7f, 7f, -1.0f, 1.0f, -1.0f] } - { type: Double, val: new Double(1.00 as double), r: [8, 8, 8, -1.0, 1.0, -1.0] } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/unary_plus.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/unary_plus.params.yaml index 7a97b1a2108113c291aa517443fb8b547f3b9fa1..6963f6544627be403dfb7dd50b7dc3f0d74496ec 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/unary_plus.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/unary_plus.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 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 @@ -21,12 +21,12 @@ cases: - { type: char, val: "c'\\uFFFF'", r: [5, 5, 5, 65535, 65535, 65535] } - { type: int, val: '0xFFFFFFFF', r: [5, 5, 5, -1, -1, -1] } - { type: long, val: '0xFFFFFFFFFFFFFFFF', r: [6, 6, 6, -1, -1, -1] } - - { type: float, val: 1.0, r: [7, 7, 7, 1.0, 1.0, 1.0] } + - { type: float, val: 1.0f, r: [7f, 7f, 7f, 1.0f, 1.0f, 1.0f] } - { type: double, val: 1.00, r: [8, 8, 8, 1.0, 1.0, 1.0] } - { type: Byte, val: new Byte(3 as byte), r: [5, 5, 5, 3, 3, 3] } - { type: Short, val: new Short(0x1ff as short), r: [5, 5, 5, 511, 511, 511] } - { type: Char, val: new Char(c' '), r: [5, 5, 5, 32, 32, 32] } - { type: Int, val: new Int(128), r: [5, 5, 5, 128, 128, 128] } - { type: Long, val: new Long(1 as long), r: [6, 6, 6, 1, 1, 1] } - - { type: Float, val: new Float(1.0 as float), r: [7, 7, 7, 1.0, 1.0, 1.0] } + - { type: Float, val: new Float(1.0f as float), r: [7f, 7f, 7f, 1.0f, 1.0f, 1.0f] } - { type: Double, val: new Double(1.00 as double), r: [8, 8, 8, 1.0, 1.0, 1.0] } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/01.numeric_casting_conversions/num_cc.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/01.numeric_casting_conversions/num_cc.ets index 28b7e8df312641d7a813a155a2dc4dffe217cf59..269f0eb5207543358ef1a69c2224b72715110e41 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/01.numeric_casting_conversions/num_cc.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/01.numeric_casting_conversions/num_cc.ets @@ -24,7 +24,7 @@ let d{{loop.index}}: {{c.to_type}} = {{v.dval}} function main(): int { let d: {{c.to_type}} - d = s{{loop.index}} as {{c.to_type}} + d = {{c.from_type}}.to{{c.to_type}}(s{{loop.index}}) if (d != d{{loop.index}}) { return 1 } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/01.numeric_casting_conversions/num_cc.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/01.numeric_casting_conversions/num_cc.params.yaml index 0aeb8d86816c990bc6cbdc223e1d63798ba8b771..260821279b94eb74b3b474eff5ed1f0ae4132a97 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/01.numeric_casting_conversions/num_cc.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/01.numeric_casting_conversions/num_cc.params.yaml @@ -13,8 +13,8 @@ --- cases: - - from_type: double - to_type: byte + - from_type: Double + to_type: Byte values: - { sval: 'Double.NaN', dval: '0' } - { sval: 'Double.NEGATIVE_INFINITY', dval: '0' } @@ -56,18 +56,18 @@ cases: - { sval: '1.7976931348623157E308', dval: '-1' } - { sval: 'Double.POSITIVE_INFINITY', dval: '-1' } - - from_type: double - to_type: byte + - from_type: Double + to_type: Byte values: - { sval: '-4.9E-308', dval: '0' } - - from_type: double - to_type: byte + - from_type: Double + to_type: Byte values: - { sval: '4.9E-308', dval: '0' } - - from_type: double - to_type: short + - from_type: Double + to_type: Short values: - { sval: 'Double.NaN', dval: '0' } - { sval: 'Double.NEGATIVE_INFINITY', dval: '0' } @@ -109,18 +109,18 @@ cases: - { sval: '1.7976931348623157E308', dval: '-1' } - { sval: 'Double.POSITIVE_INFINITY', dval: '-1' } - - from_type: double - to_type: short + - from_type: Double + to_type: Short values: - { sval: '-4.9E-308', dval: '0' } - - from_type: double - to_type: short + - from_type: Double + to_type: Short values: - { sval: '4.9E-308', dval: '0' } - - from_type: double - to_type: int + - from_type: Double + to_type: Int values: - { sval: 'Double.NaN', dval: '0' } - { sval: 'Double.NEGATIVE_INFINITY', dval: '-2147483648' } @@ -162,18 +162,18 @@ cases: - { sval: '1.7976931348623157E308', dval: '2147483647' } - { sval: 'Double.POSITIVE_INFINITY', dval: '2147483647' } - - from_type: double - to_type: int + - from_type: Double + to_type: Int values: - { sval: '-4.9E-308', dval: '0' } - - from_type: double - to_type: int + - from_type: Double + to_type: Int values: - { sval: '4.9E-308', dval: '0' } - - from_type: double - to_type: long + - from_type: Double + to_type: Long values: - { sval: 'Double.NaN', dval: '0' } - { sval: 'Double.NEGATIVE_INFINITY', dval: '-9223372036854775808' } @@ -215,18 +215,18 @@ cases: - { sval: '1.7976931348623157E308', dval: '9223372036854775807' } - { sval: 'Double.POSITIVE_INFINITY', dval: '9223372036854775807' } - - from_type: double - to_type: long + - from_type: Double + to_type: Long values: - { sval: '-4.9E-308', dval: '0' } - - from_type: double - to_type: long + - from_type: Double + to_type: Long values: - { sval: '4.9E-308', dval: '0' } - - from_type: double - to_type: float + - from_type: Double + to_type: Float values: - { sval: 'Double.NEGATIVE_INFINITY', dval: 'Float.NEGATIVE_INFINITY' } - { sval: '-1.7976931348623157E308', dval: 'Float.NEGATIVE_INFINITY' } @@ -267,18 +267,18 @@ cases: - { sval: '1.7976931348623157E308', dval: 'Float.POSITIVE_INFINITY' } - { sval: 'Double.POSITIVE_INFINITY', dval: 'Float.POSITIVE_INFINITY' } - - from_type: double - to_type: float + - from_type: Double + to_type: Float values: - { sval: '-4.9E-308', dval: '-0.0f' } - - from_type: double - to_type: float + - from_type: Double + to_type: Float values: - { sval: '4.9E-308', dval: '0.0f' } - - from_type: double - to_type: double + - from_type: Double + to_type: Double values: - { sval: 'Double.NEGATIVE_INFINITY', dval: 'Double.NEGATIVE_INFINITY' } - { sval: '-1.7976931348623157E308', dval: '-1.7976931348623157E308' } @@ -321,8 +321,8 @@ cases: - { sval: '1.7976931348623157E308', dval: '1.7976931348623157E308' } - { sval: 'Double.POSITIVE_INFINITY', dval: 'Double.POSITIVE_INFINITY' } - - from_type: double - to_type: char + - from_type: Double + to_type: Char values: - { sval: 'Double.NaN', dval: "c'\\u0000'" } - { sval: 'Double.NEGATIVE_INFINITY', dval: "c'\\u0000'" } @@ -364,18 +364,18 @@ cases: - { sval: '1.7976931348623157E308', dval: "c'\\uffff'" } - { sval: 'Double.POSITIVE_INFINITY', dval: "c'\\uffff'" } - - from_type: double - to_type: char + - from_type: Double + to_type: Char values: - { sval: '-4.9E-308', dval: "c'\\u0000'" } - - from_type: double - to_type: char + - from_type: Double + to_type: Char values: - { sval: '4.9E-308', dval: "c'\\u0000'" } - - from_type: float - to_type: byte + - from_type: Float + to_type: Byte values: - { sval: 'Float.NaN', dval: '0' } - { sval: 'Float.NEGATIVE_INFINITY', dval: '0' } @@ -415,8 +415,8 @@ cases: - { sval: '3.4028235E38f', dval: '-1' } - { sval: 'Float.POSITIVE_INFINITY', dval: '-1' } - - from_type: float - to_type: short + - from_type: Float + to_type: Short values: - { sval: 'Float.NaN', dval: '0' } - { sval: 'Float.NEGATIVE_INFINITY', dval: '0' } @@ -456,8 +456,8 @@ cases: - { sval: '3.4028235E38f', dval: '-1' } - { sval: 'Float.POSITIVE_INFINITY', dval: '-1' } - - from_type: float - to_type: int + - from_type: Float + to_type: Int values: - { sval: 'Float.NaN', dval: '0' } - { sval: 'Float.NEGATIVE_INFINITY', dval: '-2147483648' } @@ -497,8 +497,8 @@ cases: - { sval: '3.4028235E38f', dval: '2147483647' } - { sval: 'Float.POSITIVE_INFINITY', dval: '2147483647' } - - from_type: float - to_type: long + - from_type: Float + to_type: Long values: - { sval: 'Float.NaN', dval: '0' } - { sval: 'Float.NEGATIVE_INFINITY', dval: '-9223372036854775808' } @@ -538,8 +538,8 @@ cases: - { sval: '3.4028235E38f', dval: '9223372036854775807' } - { sval: 'Float.POSITIVE_INFINITY', dval: '9223372036854775807' } - - from_type: float - to_type: float + - from_type: Float + to_type: Float values: - { sval: 'Float.NEGATIVE_INFINITY', dval: 'Float.NEGATIVE_INFINITY' } - { sval: '-3.4028235E38f', dval: '-3.4028235E38f' } @@ -578,8 +578,8 @@ cases: - { sval: '3.4028235E38f', dval: '3.4028235E38f' } - { sval: 'Float.POSITIVE_INFINITY', dval: 'Float.POSITIVE_INFINITY' } - - from_type: float - to_type: double + - from_type: Float + to_type: Double values: - { sval: 'Float.NEGATIVE_INFINITY', dval: 'Double.NEGATIVE_INFINITY' } - { sval: '-3.4028235E38f', dval: '-3.4028234663852886E38' } @@ -618,8 +618,8 @@ cases: - { sval: '3.4028235E38f', dval: '3.4028234663852886E38' } - { sval: 'Float.POSITIVE_INFINITY', dval: 'Double.POSITIVE_INFINITY' } - - from_type: float - to_type: char + - from_type: Float + to_type: Char values: - { sval: 'Float.NaN', dval: "c'\\u0000'" } - { sval: 'Float.NEGATIVE_INFINITY', dval: "c'\\u0000'" } @@ -659,8 +659,8 @@ cases: - { sval: '3.4028235E38f', dval: "c'\\uffff'" } - { sval: 'Float.POSITIVE_INFINITY', dval: "c'\\uffff'" } - - from_type: long - to_type: byte + - from_type: Long + to_type: Byte values: - { sval: '-9223372036854775808', dval: '0' } - { sval: '-9223372036854775807', dval: '1' } @@ -688,8 +688,8 @@ cases: - { sval: '9223372036854775806', dval: '-2' } - { sval: '9223372036854775807', dval: '-1' } - - from_type: long - to_type: short + - from_type: Long + to_type: Short values: - { sval: '-9223372036854775808', dval: '0' } - { sval: '-9223372036854775807', dval: '1' } @@ -717,8 +717,8 @@ cases: - { sval: '9223372036854775806', dval: '-2' } - { sval: '9223372036854775807', dval: '-1' } - - from_type: long - to_type: int + - from_type: Long + to_type: Int values: - { sval: '-9223372036854775808', dval: '0' } - { sval: '-9223372036854775807', dval: '1' } @@ -746,8 +746,8 @@ cases: - { sval: '9223372036854775806', dval: '-2' } - { sval: '9223372036854775807', dval: '-1' } - - from_type: long - to_type: long + - from_type: Long + to_type: Long values: - { sval: '-9223372036854775808', dval: '-9223372036854775808' } - { sval: '-9223372036854775807', dval: '-9223372036854775807' } @@ -775,8 +775,8 @@ cases: - { sval: '9223372036854775806', dval: '9223372036854775806' } - { sval: '9223372036854775807', dval: '9223372036854775807' } - - from_type: long - to_type: float + - from_type: Long + to_type: Float values: - { sval: '-9223372036854775808', dval: '-9.223372E18f' } - { sval: '-9223372036854775807', dval: '-9.223372E18f' } @@ -804,8 +804,8 @@ cases: - { sval: '9223372036854775806', dval: '9.223372E18f' } - { sval: '9223372036854775807', dval: '9.223372E18f' } - - from_type: long - to_type: double + - from_type: Long + to_type: Double values: - { sval: '-9223372036854775808', dval: '-9.223372036854776E18' } - { sval: '-9223372036854775807', dval: '-9.223372036854776E18' } @@ -833,8 +833,8 @@ cases: - { sval: '9223372036854775806', dval: '9.223372036854776E18' } - { sval: '9223372036854775807', dval: '9.223372036854776E18' } - - from_type: long - to_type: char + - from_type: Long + to_type: Char values: - { sval: '-9223372036854775808', dval: "c'\\u0000'" } - { sval: '-9223372036854775807', dval: "c'\\u0001'" } @@ -862,8 +862,8 @@ cases: - { sval: '9223372036854775806', dval: "c'\\ufffe'" } - { sval: '9223372036854775807', dval: "c'\\uffff'" } - - from_type: int - to_type: byte + - from_type: Int + to_type: Byte values: - { sval: '-2147483648', dval: '0' } - { sval: '-2147483647', dval: '1' } @@ -885,8 +885,8 @@ cases: - { sval: '2147483646', dval: '-2' } - { sval: '2147483647', dval: '-1' } - - from_type: int - to_type: short + - from_type: Int + to_type: Short values: - { sval: '-2147483648', dval: '0' } - { sval: '-2147483647', dval: '1' } @@ -908,8 +908,8 @@ cases: - { sval: '2147483646', dval: '-2' } - { sval: '2147483647', dval: '-1' } - - from_type: int - to_type: int + - from_type: Int + to_type: Int values: - { sval: '-2147483648', dval: '-2147483648' } - { sval: '-2147483647', dval: '-2147483647' } @@ -931,8 +931,8 @@ cases: - { sval: '2147483646', dval: '2147483646' } - { sval: '2147483647', dval: '2147483647' } - - from_type: int - to_type: long + - from_type: Int + to_type: Long values: - { sval: '-2147483648', dval: '-2147483648' } - { sval: '-2147483647', dval: '-2147483647' } @@ -954,8 +954,8 @@ cases: - { sval: '2147483646', dval: '2147483646' } - { sval: '2147483647', dval: '2147483647' } - - from_type: int - to_type: float + - from_type: Int + to_type: Float values: - { sval: '-2147483648', dval: '-2.14748365E9f' } - { sval: '-2147483647', dval: '-2.14748365E9f' } @@ -977,8 +977,8 @@ cases: - { sval: '2147483646', dval: '2.14748365E9f' } - { sval: '2147483647', dval: '2.14748365E9f' } - - from_type: int - to_type: double + - from_type: Int + to_type: Double values: - { sval: '-2147483648', dval: '-2.147483648E9' } - { sval: '-2147483647', dval: '-2.147483647E9' } @@ -1000,8 +1000,8 @@ cases: - { sval: '2147483646', dval: '2.147483646E9' } - { sval: '2147483647', dval: '2.147483647E9' } - - from_type: int - to_type: char + - from_type: Int + to_type: Char values: - { sval: '-2147483648', dval: "c'\\u0000'" } - { sval: '-2147483647', dval: "c'\\u0001'" } @@ -1023,8 +1023,8 @@ cases: - { sval: '2147483646', dval: "c'\\ufffe'" } - { sval: '2147483647', dval: "c'\\uffff'" } - - from_type: short - to_type: byte + - from_type: Short + to_type: Byte values: - { sval: '-32768', dval: '0' } - { sval: '-32767', dval: '1' } @@ -1040,8 +1040,8 @@ cases: - { sval: '32766', dval: '-2' } - { sval: '32767', dval: '-1' } - - from_type: short - to_type: short + - from_type: Short + to_type: Short values: - { sval: '-32768', dval: '-32768' } - { sval: '-32767', dval: '-32767' } @@ -1057,8 +1057,8 @@ cases: - { sval: '32766', dval: '32766' } - { sval: '32767', dval: '32767' } - - from_type: short - to_type: int + - from_type: Short + to_type: Int values: - { sval: '-32768', dval: '-32768' } - { sval: '-32767', dval: '-32767' } @@ -1074,8 +1074,8 @@ cases: - { sval: '32766', dval: '32766' } - { sval: '32767', dval: '32767' } - - from_type: short - to_type: long + - from_type: Short + to_type: Long values: - { sval: '-32768', dval: '-32768' } - { sval: '-32767', dval: '-32767' } @@ -1091,8 +1091,8 @@ cases: - { sval: '32766', dval: '32766' } - { sval: '32767', dval: '32767' } - - from_type: short - to_type: float + - from_type: Short + to_type: Float values: - { sval: '-32768', dval: '-32768.0f' } - { sval: '-32767', dval: '-32767.0f' } @@ -1108,8 +1108,8 @@ cases: - { sval: '32766', dval: '32766.0f' } - { sval: '32767', dval: '32767.0f' } - - from_type: short - to_type: double + - from_type: Short + to_type: Double values: - { sval: '-32768', dval: '-32768.0' } - { sval: '-32767', dval: '-32767.0' } @@ -1125,8 +1125,8 @@ cases: - { sval: '32766', dval: '32766.0' } - { sval: '32767', dval: '32767.0' } - - from_type: short - to_type: char + - from_type: Short + to_type: Char values: - { sval: '-32768', dval: "c'\\u8000'" } - { sval: '-32767', dval: "c'\\u8001'" } @@ -1142,8 +1142,8 @@ cases: - { sval: '32766', dval: "c'\\u7ffe'" } - { sval: '32767', dval: "c'\\u7fff'" } - - from_type: byte - to_type: byte + - from_type: Byte + to_type: Byte values: - { sval: '-128', dval: '-128' } - { sval: '-127', dval: '-127' } @@ -1153,8 +1153,8 @@ cases: - { sval: '126', dval: '126' } - { sval: '127', dval: '127' } - - from_type: byte - to_type: short + - from_type: Byte + to_type: Short values: - { sval: '-128', dval: '-128' } - { sval: '-127', dval: '-127' } @@ -1164,8 +1164,8 @@ cases: - { sval: '126', dval: '126' } - { sval: '127', dval: '127' } - - from_type: byte - to_type: int + - from_type: Byte + to_type: Int values: - { sval: '-128', dval: '-128' } - { sval: '-127', dval: '-127' } @@ -1175,8 +1175,8 @@ cases: - { sval: '126', dval: '126' } - { sval: '127', dval: '127' } - - from_type: byte - to_type: long + - from_type: Byte + to_type: Long values: - { sval: '-128', dval: '-128' } - { sval: '-127', dval: '-127' } @@ -1186,8 +1186,8 @@ cases: - { sval: '126', dval: '126' } - { sval: '127', dval: '127' } - - from_type: byte - to_type: float + - from_type: Byte + to_type: Float values: - { sval: '-128', dval: '-128.0f' } - { sval: '-127', dval: '-127.0f' } @@ -1197,8 +1197,8 @@ cases: - { sval: '126', dval: '126.0f' } - { sval: '127', dval: '127.0f' } - - from_type: byte - to_type: double + - from_type: Byte + to_type: Double values: - { sval: '-128', dval: '-128.0' } - { sval: '-127', dval: '-127.0' } @@ -1208,8 +1208,8 @@ cases: - { sval: '126', dval: '126.0' } - { sval: '127', dval: '127.0' } - - from_type: byte - to_type: char + - from_type: Byte + to_type: Char values: - { sval: '-128', dval: "c'\\uff80'" } - { sval: '-127', dval: "c'\\uff81'" } @@ -1219,8 +1219,8 @@ cases: - { sval: '126', dval: "c'\\u007e'" } - { sval: '127', dval: "c'\\u007f'" } - - from_type: char - to_type: byte + - from_type: Char + to_type: Byte values: - { sval: "c'\\u0000'", dval: '0' } - { sval: "c'\\u0001'", dval: '1' } @@ -1234,8 +1234,8 @@ cases: - { sval: "c'\\ufffe'", dval: '-2' } - { sval: "c'\\uffff'", dval: '-1' } - - from_type: char - to_type: short + - from_type: Char + to_type: Short values: - { sval: "c'\\u0000'", dval: '0' } - { sval: "c'\\u0001'", dval: '1' } @@ -1249,8 +1249,8 @@ cases: - { sval: "c'\\ufffe'", dval: '-2' } - { sval: "c'\\uffff'", dval: '-1' } - - from_type: char - to_type: int + - from_type: Char + to_type: Int values: - { sval: "c'\\u0000'", dval: '0' } - { sval: "c'\\u0001'", dval: '1' } @@ -1264,8 +1264,8 @@ cases: - { sval: "c'\\ufffe'", dval: '65534' } - { sval: "c'\\uffff'", dval: '65535' } - - from_type: char - to_type: long + - from_type: Char + to_type: Long values: - { sval: "c'\\u0000'", dval: '0' } - { sval: "c'\\u0001'", dval: '1' } @@ -1279,8 +1279,8 @@ cases: - { sval: "c'\\ufffe'", dval: '65534' } - { sval: "c'\\uffff'", dval: '65535' } - - from_type: char - to_type: float + - from_type: Char + to_type: Float values: - { sval: "c'\\u0000'", dval: '0.0f' } - { sval: "c'\\u0001'", dval: '1.0f' } @@ -1294,8 +1294,8 @@ cases: - { sval: "c'\\ufffe'", dval: '65534.0f' } - { sval: "c'\\uffff'", dval: '65535.0f' } - - from_type: char - to_type: double + - from_type: Char + to_type: Double values: - { sval: "c'\\u0000'", dval: '0.0' } - { sval: "c'\\u0001'", dval: '1.0' } @@ -1309,8 +1309,8 @@ cases: - { sval: "c'\\ufffe'", dval: '65534.0' } - { sval: "c'\\uffff'", dval: '65535.0' } - - from_type: char - to_type: char + - from_type: Char + to_type: Char values: - { sval: "c'\\u0000'", dval: "c'\\u0000'" } - { sval: "c'\\u0001'", dval: "c'\\u0001'" } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/01.numeric_casting_conversions/num_cc_nan.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/01.numeric_casting_conversions/num_cc_nan.ets index da4ffeae3d21db728a979e70cc5dc5f1840c7c55..19ea76c6e44e66e7454644512bb15a7d9593f13e 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/01.numeric_casting_conversions/num_cc_nan.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/01.numeric_casting_conversions/num_cc_nan.ets @@ -26,7 +26,7 @@ function main(): int { } let s2: float = Float.NaN - let d2: double = s2 as double + let d2: double = s2.toDouble() if (!Double.isNaN(d2)) { return 1 } @@ -38,7 +38,7 @@ function main(): int { } let s4: double = Double.NaN - let d4: float = s4 as float + let d4: float = s4.toFloat() if (!Float.isNaN(d4)) { return 1 } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/01.numeric_casting_conversions/unboxing2.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/01.numeric_casting_conversions/unboxing2.ets index f93f0c00a9212016e0d395057c5f33e77e95d511..bb186ec16aed886506e394889fbeed2952141105 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/01.numeric_casting_conversions/unboxing2.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/01.numeric_casting_conversions/unboxing2.ets @@ -21,7 +21,7 @@ desc: Casting contexts allow the use of an unboxing conversion followed by a wid function main(): int { {%- for t in c['types'] %} let s{{loop.index}}: {{t.type}} = new {{t.type}}({{t.val}}); - let d{{loop.index}}: {{t.dtype}} = s{{loop.index}} as {{t.dtype}}; + let d{{loop.index}}: {{t.dtype}} = s{{loop.index}}.to{{t.dtype}}(); if (d{{loop.index}} != {{t.dval}}) { return 1; } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/01.numeric_casting_conversions/unboxing2.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/01.numeric_casting_conversions/unboxing2.params.yaml index c6b3f98fbaee58363e5f9863112278299e17ffa1..4a97dc101274815807d38b7c8681871144ddb971 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/01.numeric_casting_conversions/unboxing2.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/01.numeric_casting_conversions/unboxing2.params.yaml @@ -14,27 +14,27 @@ --- cases: - types: - - { dtype: short, dval: 119 as short, type: Byte, val: 0x77 as byte } - - { dtype: int, dval: 119, type: Byte, val: 0x77 as byte } - - { dtype: long, dval: 119 as long, type: Byte, val: 0x77 as byte } - - { dtype: float, dval: 16.0 as float, type: Byte, val: 16 as byte } - - { dtype: double, dval: 16.0 as double, type: Byte, val: 16 as byte } + - { dtype: Short, dval: 119 as short, type: Byte, val: 0x77 as byte } + - { dtype: Int, dval: 119, type: Byte, val: 0x77 as byte } + - { dtype: Long, dval: 119 as long, type: Byte, val: 0x77 as byte } + - { dtype: Float, dval: 16.0 as float, type: Byte, val: 16 as byte } + - { dtype: Double, dval: 16.0 as double, type: Byte, val: 16 as byte } - - { dtype: int, dval: 13, type: Char, val: "c'\\r'" } - - { dtype: long, dval: 13 as long, type: Char, val: "c'\\r'" } - - { dtype: float, dval: 32.0 as float, type: Char, val: "c'\\u0020'" } - - { dtype: double, dval: 2.0 as double, type: Char, val: "c'\\u0002'" } + - { dtype: Int, dval: 13, type: Char, val: "c'\\r'" } + - { dtype: Long, dval: 13 as long, type: Char, val: "c'\\r'" } + - { dtype: Float, dval: 32.0 as float, type: Char, val: "c'\\u0020'" } + - { dtype: Double, dval: 2.0 as double, type: Char, val: "c'\\u0002'" } - - { dtype: int, dval: 21845, type: Short, val: 0x5555 as short } - - { dtype: long, dval: 21845 as long, type: Short, val: 0x5555 as short } - - { dtype: float, dval: 32 as float, type: Short, val: 0x20 as short } - - { dtype: double, dval: 32.0, type: Short, val: 0x20 as short } + - { dtype: Int, dval: 21845, type: Short, val: 0x5555 as short } + - { dtype: Long, dval: 21845 as long, type: Short, val: 0x5555 as short } + - { dtype: Float, dval: 32 as float, type: Short, val: 0x20 as short } + - { dtype: Double, dval: 32.0, type: Short, val: 0x20 as short } - - { dtype: long, dval: 18 as long, type: Int, val: 0x12 as int } - - { dtype: float, dval: 2 as float, type: Int, val: 0x2 as int } - - { dtype: double, dval: 2 as double, type: Int, val: 0x2 as int } + - { dtype: Long, dval: 18 as long, type: Int, val: 0x12 as int } + - { dtype: Float, dval: 2 as float, type: Int, val: 0x2 as int } + - { dtype: Double, dval: 2 as double, type: Int, val: 0x2 as int } - - { dtype: float, dval: 4 as float, type: Long, val: 4 as long } - - { dtype: double, dval: 4 as double, type: Long, val: 4 as long } + - { dtype: Float, dval: 4 as float, type: Long, val: 4 as long } + - { dtype: Double, dval: 4 as double, type: Long, val: 4 as long } - - { dtype: double, dval: 0.5, type: Float, val: 0.5 as float } + - { dtype: Double, dval: 0.5, type: Float, val: 0.5 as float } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/04.casting_conversions_from_type_parameter/sample_neg.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/04.casting_conversions_from_type_parameter/sample_p.ets similarity index 90% rename from static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/04.casting_conversions_from_type_parameter/sample_neg.ets rename to static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/04.casting_conversions_from_type_parameter/sample_p.ets index cfbf40384505f38e8918a43ba2bbed0558d50426..17852efaaa0b1a005fb26b828355a3413597e1ce 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/04.casting_conversions_from_type_parameter/sample_neg.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/04.casting_conversions_from_type_parameter/sample_p.ets @@ -18,12 +18,12 @@ desc: >- Casting conversion from a type parameter attempts to convert an expression of the type parameter to any reference type (see Reference Types) which is to be specified as a target type -tags: [compile-only, negative] +tags: [compile-only] ---*/ class X { method (p: T) { - p as number // compile-time error, cast to value type + p as number // NO compile-time error } } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/04.casting_conversions_from_type_parameter/value.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/04.casting_conversions_from_type_parameter/value.ets index 8b83633eee59b64f553b56138f1117666ace4fa7..3bf2532288e9af3892a7f93d823cca6e7069f215 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/04.casting_conversions_from_type_parameter/value.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/04.casting_conversions_from_type_parameter/value.ets @@ -19,7 +19,6 @@ desc: Casting conversions from type parameter tags: - compile-only -- negative ---*/ {{c.decl}} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/04.casting_conversions_from_type_parameter/value.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/04.casting_conversions_from_type_parameter/value.params.yaml index 79f803fe70170e97ad5ab16a16db4a534e2cd95f..52f33d9318df246d2946d17202df634146279484 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/04.casting_conversions_from_type_parameter/value.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/04.casting_conversions_from_type_parameter/value.params.yaml @@ -13,14 +13,6 @@ --- # Tyoes for negative cases for casting conversions from type parameter cases: - - decl: |- - class X { - method (p: T): number { - let n = p as number // compile-time error, cast to value type - return n - } - } - - decl: |- function f(p: T): number { let n = p as number // compile-time error, cast to value type diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/04.casting_conversions_from_type_parameter/value_p.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/04.casting_conversions_from_type_parameter/value_p.ets new file mode 100755 index 0000000000000000000000000000000000000000..043c032fecd49cd6a0cc0db6b9ce9f8974db2e15 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/04.casting_conversions_from_type_parameter/value_p.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 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. + */ + +/*--- +desc: Casting conversions from type parameter +tags: +- compile-only +---*/ + +class X { + method (p: T): number { + let n = p as number // compile-time error, cast to value type + return n + } +} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/06.casting_conversions_from_union/un1.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/06.casting_conversions_from_union/un1.params.yaml index 2785695917f9082bf765449318ec8a3905a12198..6ac96505b5775a3144d945e2f5388a224c9016c9 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/06.casting_conversions_from_union/un1.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/06.casting_conversions_from_union/un1.params.yaml @@ -48,7 +48,7 @@ cases: type N2 = string|undefined type N3 = Error|Boolean[]|number[] type UT = N1|N2|N3 - let la: long[] = [42.0 as long] as long[] + let la: long[] = [42 as long] as long[] let nab: Number[] = [new Number()] as Number[] let s: string = "abc" let e: Error = new Error() diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/06.casting_conversions_from_union/un2.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/06.casting_conversions_from_union/un2.params.yaml index 2785695917f9082bf765449318ec8a3905a12198..6ac96505b5775a3144d945e2f5388a224c9016c9 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/06.casting_conversions_from_union/un2.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/06.casting_conversions_from_union/un2.params.yaml @@ -48,7 +48,7 @@ cases: type N2 = string|undefined type N3 = Error|Boolean[]|number[] type UT = N1|N2|N3 - let la: long[] = [42.0 as long] as long[] + let la: long[] = [42 as long] as long[] let nab: Number[] = [new Number()] as Number[] let s: string = "abc" let e: Error = new Error() diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/07.casting_conversions_to_enumeration/cte_int_enum.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/07.casting_conversions_to_enumeration/cte_int_enum.ets index 8ba39fe4f9c3012e50f7bb37c3231b44dd89f734..7bfd9f70632942306d942b2eaddf7cbabf9925e6 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/07.casting_conversions_to_enumeration/cte_int_enum.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/07.casting_conversions_to_enumeration/cte_int_enum.ets @@ -15,6 +15,9 @@ /*--- desc: Casting conversions to enumeration int. +tags: +- compile-only +- negative ---*/ enum Status { @@ -26,4 +29,4 @@ enum Status { function main(): void { let numericValue: number = 1; assertTrue(numericValue == Status.Approved); -} \ No newline at end of file +} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/sequenced.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/sequenced.ets index a55bcedef0b067a16cfb7d8c135c776b0f025550..059fd5de4114243726ccf0800c58ed557ffb9966 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/sequenced.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/sequenced.ets @@ -21,7 +21,7 @@ tags: [{{c.tags}}] function main(): int { let s: {{c.stype}} = {{c.sval|safe}}; - let d: {{c.dtype}} = s as {{c.dtype}}; + let d: {{c.dtype}} = s.to{{c.dtype}}(); return 0; } {% endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/sequenced.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/sequenced.params.yaml index 8cb2a8947790d30f861df6a2a4a6ec156d95ec28..19eb599713942f4f8a2792ef6bafe1e62129854c 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/sequenced.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.casting_contexts_and_conversions/sequenced.params.yaml @@ -62,12 +62,12 @@ cases: - { stype: double, sval: '0.0', dtype: Long } - { stype: double, sval: '0.0', dtype: Float } - - { stype: Byte, sval: 'new Byte()', dtype: char } - - { stype: Byte, sval: 'new Byte()', dtype: short } - - { stype: Byte, sval: 'new Byte()', dtype: int } - - { stype: Byte, sval: 'new Byte()', dtype: long } - - { stype: Byte, sval: 'new Byte()', dtype: float } - - { stype: Byte, sval: 'new Byte()', dtype: double } + - { stype: Byte, sval: 'new Byte()', dtype: Char } + - { stype: Byte, sval: 'new Byte()', dtype: Short } + - { stype: Byte, sval: 'new Byte()', dtype: Int } + - { stype: Byte, sval: 'new Byte()', dtype: Long } + - { stype: Byte, sval: 'new Byte()', dtype: Float } + - { stype: Byte, sval: 'new Byte()', dtype: Double } - { stype: Byte, sval: 'new Byte()', dtype: Short } - { stype: Byte, sval: 'new Byte()', dtype: Char } - { stype: Byte, sval: 'new Byte()', dtype: Int } @@ -75,12 +75,12 @@ cases: - { stype: Byte, sval: 'new Byte()', dtype: Float } - { stype: Byte, sval: 'new Byte()', dtype: Double } - - { stype: Char, sval: "new Char(c'X')", dtype: byte } - - { stype: Char, sval: "new Char(c'X')", dtype: short } - - { stype: Char, sval: "new Char(c'X')", dtype: int } - - { stype: Char, sval: "new Char(c'X')", dtype: long } - - { stype: Char, sval: "new Char(c'X')", dtype: float } - - { stype: Char, sval: "new Char(c'X')", dtype: double } + - { stype: Char, sval: "new Char(c'X')", dtype: Byte } + - { stype: Char, sval: "new Char(c'X')", dtype: Short } + - { stype: Char, sval: "new Char(c'X')", dtype: Int } + - { stype: Char, sval: "new Char(c'X')", dtype: Long } + - { stype: Char, sval: "new Char(c'X')", dtype: Float } + - { stype: Char, sval: "new Char(c'X')", dtype: Double } - { stype: Char, sval: "new Char(c'X')", dtype: Byte } - { stype: Char, sval: "new Char(c'X')", dtype: Short } - { stype: Char, sval: "new Char(c'X')", dtype: Int } @@ -88,12 +88,12 @@ cases: - { stype: Char, sval: "new Char(c'X')", dtype: Float } - { stype: Char, sval: "new Char(c'X')", dtype: Double } - - { stype: Short, sval: 'new Short()', dtype: byte } - - { stype: Short, sval: 'new Short()', dtype: char } - - { stype: Short, sval: 'new Short()', dtype: int } - - { stype: Short, sval: 'new Short()', dtype: long } - - { stype: Short, sval: 'new Short()', dtype: float } - - { stype: Short, sval: 'new Short()', dtype: double } + - { stype: Short, sval: 'new Short()', dtype: Byte } + - { stype: Short, sval: 'new Short()', dtype: Char } + - { stype: Short, sval: 'new Short()', dtype: Int } + - { stype: Short, sval: 'new Short()', dtype: Long } + - { stype: Short, sval: 'new Short()', dtype: Float } + - { stype: Short, sval: 'new Short()', dtype: Double } - { stype: Short, sval: 'new Short()', dtype: Byte } - { stype: Short, sval: 'new Short()', dtype: Char } - { stype: Short, sval: 'new Short()', dtype: Int } @@ -101,12 +101,12 @@ cases: - { stype: Short, sval: 'new Short()', dtype: Float } - { stype: Short, sval: 'new Short()', dtype: Double } - - { stype: Int, sval: 'new Int()', dtype: byte } - - { stype: Int, sval: 'new Int()', dtype: short } - - { stype: Int, sval: 'new Int()', dtype: char } - - { stype: Int, sval: 'new Int()', dtype: long } - - { stype: Int, sval: 'new Int()', dtype: float } - - { stype: Int, sval: 'new Int()', dtype: double } + - { stype: Int, sval: 'new Int()', dtype: Byte } + - { stype: Int, sval: 'new Int()', dtype: Short } + - { stype: Int, sval: 'new Int()', dtype: Char } + - { stype: Int, sval: 'new Int()', dtype: Long } + - { stype: Int, sval: 'new Int()', dtype: Float } + - { stype: Int, sval: 'new Int()', dtype: Double } - { stype: Int, sval: 'new Int()', dtype: Byte } - { stype: Int, sval: 'new Int()', dtype: Short } - { stype: Int, sval: 'new Int()', dtype: Char } @@ -114,12 +114,12 @@ cases: - { stype: Int, sval: 'new Int()', dtype: Float } - { stype: Int, sval: 'new Int()', dtype: Double } - - { stype: Long, sval: 'new Long()', dtype: byte } - - { stype: Long, sval: 'new Long()', dtype: short } - - { stype: Long, sval: 'new Long()', dtype: char } - - { stype: Long, sval: 'new Long()', dtype: int } - - { stype: Long, sval: 'new Long()', dtype: float } - - { stype: Long, sval: 'new Long()', dtype: double } + - { stype: Long, sval: 'new Long()', dtype: Byte } + - { stype: Long, sval: 'new Long()', dtype: Short } + - { stype: Long, sval: 'new Long()', dtype: Char } + - { stype: Long, sval: 'new Long()', dtype: Int } + - { stype: Long, sval: 'new Long()', dtype: Float } + - { stype: Long, sval: 'new Long()', dtype: Double } - { stype: Long, sval: 'new Long()', dtype: Byte } - { stype: Long, sval: 'new Long()', dtype: Short } - { stype: Long, sval: 'new Long()', dtype: Char } @@ -127,12 +127,12 @@ cases: - { stype: Long, sval: 'new Long()', dtype: Float } - { stype: Long, sval: 'new Long()', dtype: Double } - - { stype: Float, sval: 'new Float()', dtype: byte } - - { stype: Float, sval: 'new Float()', dtype: short } - - { stype: Float, sval: 'new Float()', dtype: char } - - { stype: Float, sval: 'new Float()', dtype: int } - - { stype: Float, sval: 'new Float()', dtype: long } - - { stype: Float, sval: 'new Float()', dtype: double } + - { stype: Float, sval: 'new Float()', dtype: Byte } + - { stype: Float, sval: 'new Float()', dtype: Short } + - { stype: Float, sval: 'new Float()', dtype: Char } + - { stype: Float, sval: 'new Float()', dtype: Int } + - { stype: Float, sval: 'new Float()', dtype: Long } + - { stype: Float, sval: 'new Float()', dtype: Double } - { stype: Float, sval: 'new Float()', dtype: Byte } - { stype: Float, sval: 'new Float()', dtype: Short } - { stype: Float, sval: 'new Float()', dtype: Char } @@ -140,12 +140,12 @@ cases: - { stype: Float, sval: 'new Float()', dtype: Long } - { stype: Float, sval: 'new Float()', dtype: Double } - - { stype: Double, sval: 'new Double()', dtype: byte } - - { stype: Double, sval: 'new Double()', dtype: short } - - { stype: Double, sval: 'new Double()', dtype: char } - - { stype: Double, sval: 'new Double()', dtype: int } - - { stype: Double, sval: 'new Double()', dtype: long } - - { stype: Double, sval: 'new Double()', dtype: float } + - { stype: Double, sval: 'new Double()', dtype: Byte } + - { stype: Double, sval: 'new Double()', dtype: Short } + - { stype: Double, sval: 'new Double()', dtype: Char } + - { stype: Double, sval: 'new Double()', dtype: Int } + - { stype: Double, sval: 'new Double()', dtype: Long } + - { stype: Double, sval: 'new Double()', dtype: Float } - { stype: Double, sval: 'new Double()', dtype: Byte } - { stype: Double, sval: 'new Double()', dtype: Short } - { stype: Double, sval: 'new Double()', dtype: Char } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/02.widening_primitive_conversions/decl_const/decl-const.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/02.widening_primitive_conversions/decl_const/decl-const.ets index e726dc0bb9d56adb06fbeaea633c91f10bf250bc..47a1ace1b038c21a9f7f243cb9431a8fc9469971 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/02.widening_primitive_conversions/decl_const/decl-const.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/02.widening_primitive_conversions/decl_const/decl-const.ets @@ -23,7 +23,7 @@ params: from {{c.from_type}} to {{c.to_type}} function main(): int { {%- for v in c['values'] %} let s{{loop.index}}: {{c.from_type}} = {{v.expr|safe}} - const d{{loop.index}}: {{c.to_type}} = s{{loop.index}} // this const declaration is tested + const d{{loop.index}}: {{c.to_type}} = s{{loop.index}}.to{{c.to_type}}() // this const declaration is tested if (d{{loop.index}} != {{v.val}}) { return 1 } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/02.widening_primitive_conversions/decl_const/decl-const.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/02.widening_primitive_conversions/decl_const/decl-const.params.yaml index f4640026081f443cfd76b5a8943648987f5fa8eb..43e05b8259b18a86e032bef24c8ebbad5fac4794 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/02.widening_primitive_conversions/decl_const/decl-const.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/02.widening_primitive_conversions/decl_const/decl-const.params.yaml @@ -14,140 +14,112 @@ --- cases: - from_type: byte - to_type: short + to_type: Short values: - { expr: 0b0 as byte, val: 0 as short } - { expr: Byte.MIN_VALUE, val: -128 as short } - { expr: Byte.MAX_VALUE, val: 127 as short } - from_type: byte - to_type: int + to_type: Int values: - { expr: 0b0 as byte, val: 0 } - { expr: Byte.MIN_VALUE, val: -128 } - { expr: Byte.MAX_VALUE, val: 127 } - from_type: byte - to_type: long + to_type: Long values: - { expr: 0b0 as byte, val: 0 as long } - { expr: Byte.MIN_VALUE, val: -128 as long } - { expr: Byte.MAX_VALUE, val: 127 as long } - from_type: byte - to_type: float + to_type: Float values: - { expr: 0b0 as byte, val: 0.0 as float } - { expr: Byte.MIN_VALUE, val: -128.0 as float } - { expr: Byte.MAX_VALUE, val: 127.0 as float } - from_type: byte - to_type: double + to_type: Double values: - { expr: 0b0 as byte, val: 0.0 } - { expr: Byte.MIN_VALUE, val: -128.0 as double } - { expr: Byte.MAX_VALUE, val: 127.0 as double } - from_type: byte - to_type: number - values: - - { expr: 0b0 as byte, val: 0.0 } - - { expr: Byte.MIN_VALUE, val: -128.0 as number } - - { expr: Byte.MAX_VALUE, val: 127.0 as number } - - - from_type: byte - to_type: char + to_type: Char values: - { expr: 0b0 as byte, val: "c'\\u0000'" } - { expr: Byte.MIN_VALUE, val: "c'\\uFF80'" } - { expr: Byte.MAX_VALUE, val: "c'\\u007F'" } - from_type: short - to_type: int + to_type: Int values: - { expr: 0b0 as short, val: 0 } - { expr: Short.MIN_VALUE, val: -32_768 } - { expr: Short.MAX_VALUE, val: 32_767 } - from_type: short - to_type: long + to_type: Long values: - { expr: 0b0 as short, val: 0 as long } - { expr: Short.MIN_VALUE, val: -32_768 as long } - { expr: Short.MAX_VALUE, val: 32_767 as long } - from_type: short - to_type: float + to_type: Float values: - { expr: 0b0 as short, val: 0.0 as float } - { expr: Short.MIN_VALUE, val: -32_768.0 as float } - { expr: Short.MAX_VALUE, val: 32_767.0 as float } - from_type: short - to_type: double + to_type: Double values: - { expr: 0b0 as short, val: 0.0 } - { expr: Short.MIN_VALUE, val: -32_768.0 as double} - { expr: Short.MAX_VALUE, val: 32_767.0 as double } - - from_type: short - to_type: number - values: - - { expr: 0b0 as short, val: 0.0 } - - { expr: Short.MIN_VALUE, val: -32_768.0 as number } - - { expr: Short.MAX_VALUE, val: 32_767.0 as number } - - from_type: int - to_type: long + to_type: Long values: - { expr: 0, val: 0 as long } - { expr: Int.MIN_VALUE, val: -2147483648 as long } - { expr: Int.MAX_VALUE, val: 2147483647 as long } - from_type: int - to_type: float + to_type: Float values: - { expr: 0, val: 0.0 as float } - { expr: Int.MIN_VALUE, val: -2147483600.0 as float } # expected loss of precision - { expr: Int.MAX_VALUE, val: 2147483600 as float } # expected loss of precision - from_type: int - to_type: double + to_type: Double values: - { expr: 0, val: 0.0 } - { expr: Int.MIN_VALUE, val: -2147483648.0 as double } - { expr: Int.MAX_VALUE, val: 2147483647.0 as double } - - from_type: int - to_type: number - values: - - { expr: 0, val: 0.0 } - - { expr: Int.MIN_VALUE, val: -2147483648.0 as number } - - { expr: Int.MAX_VALUE, val: 2147483647.0 as number } - - from_type: long - to_type: float + to_type: Float values: - { expr: 0 as long, val: 0.0 as float } - { expr: Long.MIN_VALUE, val: -9223372000000000000 as float } # expected loss of precision - { expr: Long.MAX_VALUE, val: 9223372000000000000 as float } # expected loss of precision - from_type: long - to_type: double + to_type: Double values: - { expr: 0 as long, val: 0.0 } - { expr: Long.MIN_VALUE, val: -9223372036854775808.0 as double } - { expr: Long.MAX_VALUE, val: 9223372036854775807.0 as double } - - from_type: long - to_type: number - values: - - { expr: 0 as long, val: 0.0 } - - { expr: Long.MIN_VALUE, val: -9223372036854775808.0 as number } - - { expr: Long.MAX_VALUE, val: 9223372036854775807.0 as number } - - from_type: float - to_type: double + to_type: Double values: - { expr: +0.0 as float, val: +0.0 } - { expr: -0.0 as float, val: -0.0 } @@ -157,74 +129,29 @@ cases: - { expr: -1.401298464324817e-45 as float, val: -1.401298464324817e-45 as double } - from_type: char - to_type: int + to_type: Int values: - { expr: "c'\\u0000'", val: 0 } - { expr: "c'\\u0FFF'", val: 4095 } - { expr: "c'\\uFFFF'", val: 65535 } - from_type: char - to_type: long + to_type: Long values: - { expr: "c'\\u0000'", val: 0 as long } - { expr: "c'\\u0FFF'", val: 4095 as long } - { expr: "c'\\uFFFF'", val: 65535 as long } - from_type: char - to_type: float + to_type: Float values: - { expr: "c'\\u0000'", val: 0.0 as float } - { expr: "c'\\u0FFF'", val: 4095.0 as float } - { expr: "c'\\uFFFF'", val: 65535.0 as float } - from_type: char - to_type: double + to_type: Double values: - { expr: "c'\\u0000'", val: 0.0 as double } - { expr: "c'\\u0FFF'", val: 4095.0 as double } - { expr: "c'\\uFFFF'", val: 65535.0 as double } - - - from_type: Color - to_type: int - defs: |- - enum Color { Red, Green, Blue } - values: - - { expr: Color.Red, val: 0 } - - { expr: Color.Green, val: 1 } - - { expr: Color.Blue, val: 2 } - - - from_type: Color - to_type: long - defs: |- - enum Color { Red=100, Green=200, Blue=300 } - values: - - { expr: Color.Red, val: 100 as long } - - { expr: Color.Green, val: 200 as long } - - { expr: Color.Blue, val: 300 as long } - - - from_type: Color - to_type: float - defs: |- - enum Color { Red=10, Green=20, Blue=30 } - values: - - { expr: Color.Red, val: 10.0 as float } - - { expr: Color.Green, val: 20.0 as float } - - { expr: Color.Blue, val: 30.0 as float } - - - from_type: Color - to_type: double - defs: |- - enum Color { Red=10001, Green=10002, Blue=10003 } - values: - - { expr: Color.Red, val: 10001.0 as double } - - { expr: Color.Green, val: 10002.0 as double } - - { expr: Color.Blue, val: 10003.0 as double } - - - from_type: Color - to_type: number - defs: |- - enum Color { Red=20001, Green=20002, Blue=20003 } - values: - - { expr: Color.Red, val: 20001.0 as number } - - { expr: Color.Green, val: 20002.0 as number } - - { expr: Color.Blue, val: 20003.0 as number } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var-n.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var-n.ets index d0d72485918afa52f46e709426ed8d95721315ab..bea03275e1eaae98544c211da043635be2456077 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var-n.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var-n.ets @@ -19,8 +19,9 @@ desc: Assignment context, variable, constant narrowing integer conversion, impli tags: [compile-only, negative] ---*/ let d: {{c.to_type}} +const s: {{c.from_type}} = {{c.expr}} function main() { - d = {{c.expr|safe}} // constant expression value doesn't fit in the variable type range + d = s // constant expression value doesn't fit in the variable type range } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var-n.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var-n.params.yaml index 54ceeaa5835bc6d33e4a1b37dd12791f3c3a46a8..362eb217bada00cdd43819f36810241304147392 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var-n.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var-n.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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 @@ -14,31 +14,31 @@ --- cases: # from short - - { expr: -129 as short, to_type: byte } - - { expr: 128 as short, to_type: byte } + - { expr: -129, from_type: short, to_type: byte } + - { expr: 128, from_type: short, to_type: byte } # from int - - { expr: -129 as int, to_type: byte } - - { expr: 128 as int, to_type: byte } + - { expr: -129, from_type: int, to_type: byte } + - { expr: 128, from_type: int, to_type: byte } - - { expr: -32769 as int, to_type: short } - - { expr: 32768 as int, to_type: short } + - { expr: -32769, from_type: int, to_type: short } + - { expr: 32768, from_type: int, to_type: short } - - { expr: -1 as int, to_type: char } - - { expr: 65536 as int, to_type: char } + - { expr: -1, from_type: int, to_type: char } + - { expr: 65536, from_type: int, to_type: char } # from long - - { expr: -129 as long, to_type: byte } - - { expr: 128 as long, to_type: byte } + - { expr: -129, from_type: long, to_type: byte } + - { expr: 128, from_type: long, to_type: byte } - - { expr: -32769 as long, to_type: short } - - { expr: 32768 as long, to_type: short } + - { expr: -32769, from_type: long, to_type: short } + - { expr: 32768, from_type: long, to_type: short } - - { expr: -2147483649 as long, to_type: int } - - { expr: 2147483648 as long, to_type: int } + - { expr: -2147483649, from_type: long, to_type: int } + - { expr: 2147483648, from_type: long, to_type: int } - - { expr: -1 as long, to_type: char } - - { expr: 65536 as long, to_type: char } + - { expr: -1, from_type: long, to_type: char } + - { expr: 65536, from_type: long, to_type: char } # from char - - { expr: "c'\\u0100'", to_type: byte } + - { expr: "c'\\u0100'", from_type: char, to_type: byte } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var-n3.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var-n3.ets index 9d8c36a2dea9aed4fd1365111ba6d2c1a1c9529f..d4bd443673eb83baf8d8a25dd2c8b27ac8b4af9b 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var-n3.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var-n3.ets @@ -16,7 +16,6 @@ /*--- desc: Assignment context, variable, constant narrowing integer conversion, implicit -tags: [compile-only, negative] params: from {{c.from_type}} to {{c.to_type}} ---*/ {%- for v in c['values'] %} @@ -25,17 +24,10 @@ const c{{loop.index}}: {{c.from_type}} = {{v.expr|safe}} let d: {{c.to_type}} -function main(): int { +function main() { {%- for v in c['values'] %} - d = {{v.expr|safe}} // literal constant value - if (d != {{v.val}}) { - return 1 - } - d = c{{loop.index}} // constant - if (d != {{v.val}}) { - return 1 - } + d = c{{loop.index}}.to{{c.to_type}}() + assertEQ(d, {{v.val}}) {%- endfor %} - return 0 } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var-n3.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var-n3.params.yaml index 1dc5daf8a6ffd1934f67ac59777ecb2ca6d0d7ca..60ef4dad5edcacc3bc39d0e3c5501a20a21b3a16 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var-n3.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var-n3.params.yaml @@ -14,50 +14,50 @@ --- cases: - from_type: short - to_type: byte + to_type: Byte values: - - { expr: 0 as short, val: 0 as byte } - - { expr: -128 as short, val: -128 as byte } - - { expr: 0x7F as short, val: 0x7F as byte } + - { expr: 0, val: 0 } + - { expr: -128, val: -128 } + - { expr: 0x7F, val: 0x7F } - from_type: int - to_type: byte + to_type: Byte values: - - { expr: 0 as int, val: 0 as byte } - - { expr: -128 as int, val: -128 as byte } - - { expr: 0x7F as int, val: 0x7F as byte } + - { expr: 0, val: 0 } + - { expr: -128, val: -128 } + - { expr: 0x7F, val: 0x7F } - from_type: int - to_type: short + to_type: Short values: - - { expr: 0 as int, val: 0 as short } - - { expr: -32768 as int, val: -32768 as short } - - { expr: 32767 as int, val: 32767 as short } + - { expr: 0, val: 0 } + - { expr: -32768, val: -32768 } + - { expr: 32767, val: 32767 } - from_type: long - to_type: byte + to_type: Byte values: - - { expr: 0 as long, val: 0 as byte } - - { expr: -128 as long, val: -128 as byte } - - { expr: 0x7F as long, val: 0x7F as byte } + - { expr: 0, val: 0 } + - { expr: -128, val: -128 } + - { expr: 0x7F, val: 0x7F } - from_type: long - to_type: short + to_type: Short values: - - { expr: 0 as long, val: 0 as short } - - { expr: -32768 as long, val: -32768 as short } - - { expr: 32767 as long, val: 32767 as short } + - { expr: 0, val: 0 } + - { expr: -32768, val: -32768 } + - { expr: 32767, val: 32767 } - from_type: long - to_type: int + to_type: Int values: - - { expr: 0 as long, val: 0 as int } - - { expr: -2147483648 as long, val: -2147483648 as int } - - { expr: 2147483647 as long, val: 2147483647 as int } + - { expr: 0, val: 0 } + - { expr: -2147483648, val: -2147483648 } + - { expr: 2147483647, val: 2147483647 } - from_type: long - to_type: char + to_type: Char values: - - { expr: 0 as long, val: "c'\\u0000'" } - - { expr: 32767 as long, val: "c'\\u7fff'" } - - { expr: 65535 as long, val: "c'\\uFFFF'" } + - { expr: 0, val: "c'\\u0000'" } + - { expr: 32767, val: "c'\\u7fff'" } + - { expr: 65535, val: "c'\\uFFFF'" } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var.ets index 53e29571077bc95a1abd2dfc123ec76a2fd05b79..5053a6a61370dc44b32c5586c2f727b6fdd70ee7 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var.ets @@ -24,17 +24,13 @@ const c{{loop.index}}: {{c.from_type}} = {{v.expr|safe}} let d: {{c.to_type}} -function main(): int { +function main() { {%- for v in c['values'] %} - d = {{v.expr|safe}} // literal constant value - if (d != {{v.val}}) { - return 1 - } - d = c{{loop.index}} // constant - if (d != {{v.val}}) { - return 1 - } + d = {{v.expr|safe}}.to{{c.to_type}}() // literal constant value + assertEQ(d, {{v.val}}) + + d = c{{loop.index}}.to{{c.to_type}}() // constant + assertEQ(d, {{v.val}}) {%- endfor %} - return 0 } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var.params.yaml index 67bc329b37f992cd8331a6c0990c4e068a78f8b0..efce17625af919e67b57b469198f119927e55d7b 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var.params.yaml @@ -14,14 +14,14 @@ --- cases: - from_type: char - to_type: byte + to_type: Byte values: - - { expr: "c'\\u007F'", val: 127 as byte } - - { expr: "c'\\u0000'", val: 0 as byte } - - { expr: c' ', val: 32 as byte } + - { expr: "c'\\u007F'", val: 127 } + - { expr: "c'\\u0000'", val: 0 } + - { expr: c' ', val: 32 } - - from_type: int - to_type: char + - from_type: Int + to_type: Char values: - { expr: 0, val: "c'\\u0000'" } - { expr: 32767, val: "c'\\u7fff'" } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr-n.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr-n.ets index 07e4d1a8dd0f7032847597ae7a2c645c8be32ca0..64975b1bc4a8025eb8f4e007429ccc71a28e79d3 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr-n.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr-n.ets @@ -18,9 +18,11 @@ desc: Composite context, array element, constant narrowing integer conversion, implicit tags: [compile-only, negative] ---*/ +const s: {{c.from_type}} = {{c.expr|safe}} + function main() { // constant expression doesn't fit in array type range - let d: {{c.to_type}}[] = [{{c.expr|safe}}] + let d: {{c.to_type}}[] = [s] let x = d[0] } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr-n.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr-n.params.yaml index 54ceeaa5835bc6d33e4a1b37dd12791f3c3a46a8..362eb217bada00cdd43819f36810241304147392 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr-n.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr-n.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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 @@ -14,31 +14,31 @@ --- cases: # from short - - { expr: -129 as short, to_type: byte } - - { expr: 128 as short, to_type: byte } + - { expr: -129, from_type: short, to_type: byte } + - { expr: 128, from_type: short, to_type: byte } # from int - - { expr: -129 as int, to_type: byte } - - { expr: 128 as int, to_type: byte } + - { expr: -129, from_type: int, to_type: byte } + - { expr: 128, from_type: int, to_type: byte } - - { expr: -32769 as int, to_type: short } - - { expr: 32768 as int, to_type: short } + - { expr: -32769, from_type: int, to_type: short } + - { expr: 32768, from_type: int, to_type: short } - - { expr: -1 as int, to_type: char } - - { expr: 65536 as int, to_type: char } + - { expr: -1, from_type: int, to_type: char } + - { expr: 65536, from_type: int, to_type: char } # from long - - { expr: -129 as long, to_type: byte } - - { expr: 128 as long, to_type: byte } + - { expr: -129, from_type: long, to_type: byte } + - { expr: 128, from_type: long, to_type: byte } - - { expr: -32769 as long, to_type: short } - - { expr: 32768 as long, to_type: short } + - { expr: -32769, from_type: long, to_type: short } + - { expr: 32768, from_type: long, to_type: short } - - { expr: -2147483649 as long, to_type: int } - - { expr: 2147483648 as long, to_type: int } + - { expr: -2147483649, from_type: long, to_type: int } + - { expr: 2147483648, from_type: long, to_type: int } - - { expr: -1 as long, to_type: char } - - { expr: 65536 as long, to_type: char } + - { expr: -1, from_type: long, to_type: char } + - { expr: 65536, from_type: long, to_type: char } # from char - - { expr: "c'\\u0100'", to_type: byte } + - { expr: "c'\\u0100'", from_type: char, to_type: byte } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr-n3.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr-n3.ets index 7a0ebc02734b5426624f70a1a642b10fab6b4726..9d5c023fb76b578e5f0aa70031bf4aea57c72b45 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr-n3.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr-n3.ets @@ -16,24 +16,16 @@ /*--- desc: Composite context, array element, constant narrowing integer conversion, implicit -tags: [compile-only, negative] params: from {{c.from_type}} to {{c.to_type}} ---*/ {%- for v in c['values'] %} const c{{loop.index}}: {{c.from_type}} = {{v.expr|safe}} {%- endfor %} -function main(): int { +function main() { {%- for v in c['values'] %} - let d{{loop.index}}: {{c.to_type}}[] = [{{v.expr|safe}}, {{v.expr|safe}}] // expression - if (d{{loop.index}}[1] != {{v.val}}) { - return 1 - } - d{{loop.index}} = [c{{loop.index}}] // constant - if (d{{loop.index}}[0] != {{v.val}}) { - return 1 - } -{%- endfor %} - return 0 + let d{{loop.index}}: {{c.to_type}}[] = [c{{loop.index}}.to{{c.to_type}}()] + assertEQ(d{{loop.index}}[0], {{v.val}}) +{% endfor %} } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr-n3.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr-n3.params.yaml index 1dc5daf8a6ffd1934f67ac59777ecb2ca6d0d7ca..60ef4dad5edcacc3bc39d0e3c5501a20a21b3a16 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr-n3.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr-n3.params.yaml @@ -14,50 +14,50 @@ --- cases: - from_type: short - to_type: byte + to_type: Byte values: - - { expr: 0 as short, val: 0 as byte } - - { expr: -128 as short, val: -128 as byte } - - { expr: 0x7F as short, val: 0x7F as byte } + - { expr: 0, val: 0 } + - { expr: -128, val: -128 } + - { expr: 0x7F, val: 0x7F } - from_type: int - to_type: byte + to_type: Byte values: - - { expr: 0 as int, val: 0 as byte } - - { expr: -128 as int, val: -128 as byte } - - { expr: 0x7F as int, val: 0x7F as byte } + - { expr: 0, val: 0 } + - { expr: -128, val: -128 } + - { expr: 0x7F, val: 0x7F } - from_type: int - to_type: short + to_type: Short values: - - { expr: 0 as int, val: 0 as short } - - { expr: -32768 as int, val: -32768 as short } - - { expr: 32767 as int, val: 32767 as short } + - { expr: 0, val: 0 } + - { expr: -32768, val: -32768 } + - { expr: 32767, val: 32767 } - from_type: long - to_type: byte + to_type: Byte values: - - { expr: 0 as long, val: 0 as byte } - - { expr: -128 as long, val: -128 as byte } - - { expr: 0x7F as long, val: 0x7F as byte } + - { expr: 0, val: 0 } + - { expr: -128, val: -128 } + - { expr: 0x7F, val: 0x7F } - from_type: long - to_type: short + to_type: Short values: - - { expr: 0 as long, val: 0 as short } - - { expr: -32768 as long, val: -32768 as short } - - { expr: 32767 as long, val: 32767 as short } + - { expr: 0, val: 0 } + - { expr: -32768, val: -32768 } + - { expr: 32767, val: 32767 } - from_type: long - to_type: int + to_type: Int values: - - { expr: 0 as long, val: 0 as int } - - { expr: -2147483648 as long, val: -2147483648 as int } - - { expr: 2147483647 as long, val: 2147483647 as int } + - { expr: 0, val: 0 } + - { expr: -2147483648, val: -2147483648 } + - { expr: 2147483647, val: 2147483647 } - from_type: long - to_type: char + to_type: Char values: - - { expr: 0 as long, val: "c'\\u0000'" } - - { expr: 32767 as long, val: "c'\\u7fff'" } - - { expr: 65535 as long, val: "c'\\uFFFF'" } + - { expr: 0, val: "c'\\u0000'" } + - { expr: 32767, val: "c'\\u7fff'" } + - { expr: 65535, val: "c'\\uFFFF'" } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr.ets index 07ada6d2e798875ea6f212ea0eb8732751fdfd40..74fa239dfac13123d3a0ac3ddde0169d216d1b50 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr.ets @@ -22,17 +22,13 @@ params: from {{c.from_type}} to {{c.to_type}} const c{{loop.index}}: {{c.from_type}} = {{v.expr|safe}} {%- endfor %} -function main(): int { +function main() { {%- for v in c['values'] %} - let d{{loop.index}}: {{c.to_type}}[] = [{{v.expr|safe}}, {{v.expr|safe}}] // expression - if (d{{loop.index}}[1] != {{v.val}}) { - return 1 - } - d{{loop.index}} = [c{{loop.index}}] // constant - if (d{{loop.index}}[0] != {{v.val}}) { - return 1 - } + let d{{loop.index}}: {{c.to_type}}[] = [({{v.expr|safe}}).to{{c.to_type}}(), ({{v.expr|safe}}).to{{c.to_type}}()] // expression + assertEQ(d{{loop.index}}[1], ({{v.val}}).to{{c.to_type}}()) + + d{{loop.index}} = [c{{loop.index}}.to{{c.to_type}}()] // constant + assertEQ(d{{loop.index}}[0], ({{v.val}}).to{{c.to_type}}()) {%- endfor %} - return 0 } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr.params.yaml index fb8ca571be2c2c9cd4421e044e5b22895cfa7ec1..dad04915eeb2510c2e4bc7c36fd126dd13223f45 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr.params.yaml @@ -14,14 +14,14 @@ --- cases: - from_type: char - to_type: byte + to_type: Byte values: - - { expr: "c'\\u007F'", val: 127 as byte } - - { expr: "c'\\u0000'", val: 0 as byte } - - { expr: c' ', val: 32 as byte } + - { expr: "c'\\u007F'", val: 127 } + - { expr: "c'\\u0000'", val: 0 } + - { expr: c' ', val: 32 } - - from_type: int - to_type: char + - from_type: Int + to_type: Char values: - { expr: 0, val: "c'\\u0000'" } - { expr: 32767, val: "c'\\u7fff'" } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-class-n3.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-class-n3.ets index 46be20a7ab451d4d0d16d95094669e3d8d508535..951b56e902e784d322f1356e9270552d64adc8a4 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-class-n3.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-class-n3.ets @@ -16,7 +16,6 @@ /*--- desc: Composite context, class field, constant narrowing integer conversion, implicit -tags: [compile-only, negative] params: from {{c.from_type}} to {{c.to_type}} ---*/ {%- for v in c['values'] %} @@ -25,17 +24,10 @@ const c{{loop.index}}: {{c.from_type}} = {{v.expr|safe}} class A { fld: {{c.to_type}} } -function main(): int { +function main() { {%- for v in c['values'] %} - let d{{loop.index}}: A = { fld: {{v.expr|safe}} } - if (d{{loop.index}}.fld != {{v.val}}) { - return 1 - } - d{{loop.index}} = { fld: c{{loop.index}} } - if (d{{loop.index}}.fld != {{v.val}}) { - return 1 - } -{%- endfor %} - return 0 + let d{{loop.index}}: A = { fld: c{{loop.index}}.to{{c.to_type}}() } + assertEQ(d{{loop.index}}.fld, {{v.val}}) +{% endfor %} } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-class-n3.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-class-n3.params.yaml index 1dc5daf8a6ffd1934f67ac59777ecb2ca6d0d7ca..60ef4dad5edcacc3bc39d0e3c5501a20a21b3a16 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-class-n3.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-class-n3.params.yaml @@ -14,50 +14,50 @@ --- cases: - from_type: short - to_type: byte + to_type: Byte values: - - { expr: 0 as short, val: 0 as byte } - - { expr: -128 as short, val: -128 as byte } - - { expr: 0x7F as short, val: 0x7F as byte } + - { expr: 0, val: 0 } + - { expr: -128, val: -128 } + - { expr: 0x7F, val: 0x7F } - from_type: int - to_type: byte + to_type: Byte values: - - { expr: 0 as int, val: 0 as byte } - - { expr: -128 as int, val: -128 as byte } - - { expr: 0x7F as int, val: 0x7F as byte } + - { expr: 0, val: 0 } + - { expr: -128, val: -128 } + - { expr: 0x7F, val: 0x7F } - from_type: int - to_type: short + to_type: Short values: - - { expr: 0 as int, val: 0 as short } - - { expr: -32768 as int, val: -32768 as short } - - { expr: 32767 as int, val: 32767 as short } + - { expr: 0, val: 0 } + - { expr: -32768, val: -32768 } + - { expr: 32767, val: 32767 } - from_type: long - to_type: byte + to_type: Byte values: - - { expr: 0 as long, val: 0 as byte } - - { expr: -128 as long, val: -128 as byte } - - { expr: 0x7F as long, val: 0x7F as byte } + - { expr: 0, val: 0 } + - { expr: -128, val: -128 } + - { expr: 0x7F, val: 0x7F } - from_type: long - to_type: short + to_type: Short values: - - { expr: 0 as long, val: 0 as short } - - { expr: -32768 as long, val: -32768 as short } - - { expr: 32767 as long, val: 32767 as short } + - { expr: 0, val: 0 } + - { expr: -32768, val: -32768 } + - { expr: 32767, val: 32767 } - from_type: long - to_type: int + to_type: Int values: - - { expr: 0 as long, val: 0 as int } - - { expr: -2147483648 as long, val: -2147483648 as int } - - { expr: 2147483647 as long, val: 2147483647 as int } + - { expr: 0, val: 0 } + - { expr: -2147483648, val: -2147483648 } + - { expr: 2147483647, val: 2147483647 } - from_type: long - to_type: char + to_type: Char values: - - { expr: 0 as long, val: "c'\\u0000'" } - - { expr: 32767 as long, val: "c'\\u7fff'" } - - { expr: 65535 as long, val: "c'\\uFFFF'" } + - { expr: 0, val: "c'\\u0000'" } + - { expr: 32767, val: "c'\\u7fff'" } + - { expr: 65535, val: "c'\\uFFFF'" } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-clss-n.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-clss-n.ets index 91c50d8bcce4bf5c25570184e74c20c00987d226..ed259544637c6896ca9061b4a9d10d6711b4f02a 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-clss-n.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-clss-n.ets @@ -20,9 +20,11 @@ tags: [compile-only, negative] ---*/ class A { fld: {{c.to_type}} } +const s: {{c.from_type}} = {{c.expr|safe}} + function main() { // constant expression doesn't fit in the field type range - let d: A = { fld: {{c.expr|safe}} } + let d: A = { fld: s } let x = d.fld } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-clss-n.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-clss-n.params.yaml index 54ceeaa5835bc6d33e4a1b37dd12791f3c3a46a8..362eb217bada00cdd43819f36810241304147392 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-clss-n.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-clss-n.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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 @@ -14,31 +14,31 @@ --- cases: # from short - - { expr: -129 as short, to_type: byte } - - { expr: 128 as short, to_type: byte } + - { expr: -129, from_type: short, to_type: byte } + - { expr: 128, from_type: short, to_type: byte } # from int - - { expr: -129 as int, to_type: byte } - - { expr: 128 as int, to_type: byte } + - { expr: -129, from_type: int, to_type: byte } + - { expr: 128, from_type: int, to_type: byte } - - { expr: -32769 as int, to_type: short } - - { expr: 32768 as int, to_type: short } + - { expr: -32769, from_type: int, to_type: short } + - { expr: 32768, from_type: int, to_type: short } - - { expr: -1 as int, to_type: char } - - { expr: 65536 as int, to_type: char } + - { expr: -1, from_type: int, to_type: char } + - { expr: 65536, from_type: int, to_type: char } # from long - - { expr: -129 as long, to_type: byte } - - { expr: 128 as long, to_type: byte } + - { expr: -129, from_type: long, to_type: byte } + - { expr: 128, from_type: long, to_type: byte } - - { expr: -32769 as long, to_type: short } - - { expr: 32768 as long, to_type: short } + - { expr: -32769, from_type: long, to_type: short } + - { expr: 32768, from_type: long, to_type: short } - - { expr: -2147483649 as long, to_type: int } - - { expr: 2147483648 as long, to_type: int } + - { expr: -2147483649, from_type: long, to_type: int } + - { expr: 2147483648, from_type: long, to_type: int } - - { expr: -1 as long, to_type: char } - - { expr: 65536 as long, to_type: char } + - { expr: -1, from_type: long, to_type: char } + - { expr: 65536, from_type: long, to_type: char } # from char - - { expr: "c'\\u0100'", to_type: byte } + - { expr: "c'\\u0100'", from_type: char, to_type: byte } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-clss.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-clss.ets index 8c93ace2343fa82de90038ef7e7933be098f3ffe..38223873afb8108aecb1110717eacdb6e5a02889 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-clss.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-clss.ets @@ -24,17 +24,13 @@ const c{{loop.index}}: {{c.from_type}} = {{v.expr|safe}} class A { fld: {{c.to_type}} } -function main(): int { +function main() { {%- for v in c['values'] %} - let d{{loop.index}}: A = { fld: {{v.expr|safe}} } - if (d{{loop.index}}.fld != {{v.val}}) { - return 1 - } - d{{loop.index}} = { fld: c{{loop.index}} } - if (d{{loop.index}}.fld != {{v.val}}) { - return 1 - } + let d{{loop.index}}: A = { fld: ({{v.expr|safe}}).to{{c.to_type}}() } + assertEQ(d{{loop.index}}.fld, {{v.val}}) + + d{{loop.index}} = { fld: c{{loop.index}}.to{{c.to_type}}() } + assertEQ(d{{loop.index}}.fld, {{v.val}}) {%- endfor %} - return 0 } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-clss.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-clss.params.yaml index fb8ca571be2c2c9cd4421e044e5b22895cfa7ec1..dad04915eeb2510c2e4bc7c36fd126dd13223f45 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-clss.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-clss.params.yaml @@ -14,14 +14,14 @@ --- cases: - from_type: char - to_type: byte + to_type: Byte values: - - { expr: "c'\\u007F'", val: 127 as byte } - - { expr: "c'\\u0000'", val: 0 as byte } - - { expr: c' ', val: 32 as byte } + - { expr: "c'\\u007F'", val: 127 } + - { expr: "c'\\u0000'", val: 0 } + - { expr: c' ', val: 32 } - - from_type: int - to_type: char + - from_type: Int + to_type: Char values: - { expr: 0, val: "c'\\u0000'" } - { expr: 32767, val: "c'\\u7fff'" } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-intf-n.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-intf-n.ets index 69b6c3d2d61544f8f698c8b197fecab43bf0d465..4488e75bf9bde0c40d28912f00a9d7564155ebad 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-intf-n.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-intf-n.ets @@ -20,9 +20,11 @@ tags: [compile-only, negative] ---*/ interface J { fld: {{c.to_type}} } +const s: {{c.from_type}} = {{c.expr|safe}} + function main() { // constant expression value doesn't fit in the field type range - let d: J = { fld: {{c.expr|safe}} } + let d: J = { fld: c } let x = d.fld } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-intf-n.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-intf-n.params.yaml index 54ceeaa5835bc6d33e4a1b37dd12791f3c3a46a8..362eb217bada00cdd43819f36810241304147392 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-intf-n.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-intf-n.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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 @@ -14,31 +14,31 @@ --- cases: # from short - - { expr: -129 as short, to_type: byte } - - { expr: 128 as short, to_type: byte } + - { expr: -129, from_type: short, to_type: byte } + - { expr: 128, from_type: short, to_type: byte } # from int - - { expr: -129 as int, to_type: byte } - - { expr: 128 as int, to_type: byte } + - { expr: -129, from_type: int, to_type: byte } + - { expr: 128, from_type: int, to_type: byte } - - { expr: -32769 as int, to_type: short } - - { expr: 32768 as int, to_type: short } + - { expr: -32769, from_type: int, to_type: short } + - { expr: 32768, from_type: int, to_type: short } - - { expr: -1 as int, to_type: char } - - { expr: 65536 as int, to_type: char } + - { expr: -1, from_type: int, to_type: char } + - { expr: 65536, from_type: int, to_type: char } # from long - - { expr: -129 as long, to_type: byte } - - { expr: 128 as long, to_type: byte } + - { expr: -129, from_type: long, to_type: byte } + - { expr: 128, from_type: long, to_type: byte } - - { expr: -32769 as long, to_type: short } - - { expr: 32768 as long, to_type: short } + - { expr: -32769, from_type: long, to_type: short } + - { expr: 32768, from_type: long, to_type: short } - - { expr: -2147483649 as long, to_type: int } - - { expr: 2147483648 as long, to_type: int } + - { expr: -2147483649, from_type: long, to_type: int } + - { expr: 2147483648, from_type: long, to_type: int } - - { expr: -1 as long, to_type: char } - - { expr: 65536 as long, to_type: char } + - { expr: -1, from_type: long, to_type: char } + - { expr: 65536, from_type: long, to_type: char } # from char - - { expr: "c'\\u0100'", to_type: byte } + - { expr: "c'\\u0100'", from_type: char, to_type: byte } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-intf-n3.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-intf-n3.ets index 58d69e5a0a0cf766b214d6447156cad687c4bad5..03d97f2ee0c401d4f844afea9b82795dead3b809 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-intf-n3.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-intf-n3.ets @@ -16,7 +16,6 @@ /*--- desc: Composite context, interface field, constant narrowing integer conversion, implicit -tags: [compile-only, negative] params: from {{c.from_type}} to {{c.to_type}} ---*/ {%- for v in c['values'] %} @@ -25,17 +24,10 @@ const c{{loop.index}}: {{c.from_type}} = {{v.expr|safe}} interface J { fld: {{c.to_type}} } -function main(): int { +function main() { {%- for v in c['values'] %} - let d{{loop.index}}: J = { fld: {{v.expr|safe}} } // expression - if (d{{loop.index}}.fld != {{v.val}}) { - return 1 - } - d{{loop.index}} = { fld: c{{loop.index}} } // constant - if (d{{loop.index}}.fld != {{v.val}}) { - return 1 - } -{%- endfor %} - return 0 + let d{{loop.index}}: J = { fld: c{{loop.index}}.to{{c.to_type}}() } + assertEQ(d{{loop.index}}.fld, {{v.val}}) +{% endfor %} } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-intf-n3.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-intf-n3.params.yaml index 1dc5daf8a6ffd1934f67ac59777ecb2ca6d0d7ca..60ef4dad5edcacc3bc39d0e3c5501a20a21b3a16 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-intf-n3.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-intf-n3.params.yaml @@ -14,50 +14,50 @@ --- cases: - from_type: short - to_type: byte + to_type: Byte values: - - { expr: 0 as short, val: 0 as byte } - - { expr: -128 as short, val: -128 as byte } - - { expr: 0x7F as short, val: 0x7F as byte } + - { expr: 0, val: 0 } + - { expr: -128, val: -128 } + - { expr: 0x7F, val: 0x7F } - from_type: int - to_type: byte + to_type: Byte values: - - { expr: 0 as int, val: 0 as byte } - - { expr: -128 as int, val: -128 as byte } - - { expr: 0x7F as int, val: 0x7F as byte } + - { expr: 0, val: 0 } + - { expr: -128, val: -128 } + - { expr: 0x7F, val: 0x7F } - from_type: int - to_type: short + to_type: Short values: - - { expr: 0 as int, val: 0 as short } - - { expr: -32768 as int, val: -32768 as short } - - { expr: 32767 as int, val: 32767 as short } + - { expr: 0, val: 0 } + - { expr: -32768, val: -32768 } + - { expr: 32767, val: 32767 } - from_type: long - to_type: byte + to_type: Byte values: - - { expr: 0 as long, val: 0 as byte } - - { expr: -128 as long, val: -128 as byte } - - { expr: 0x7F as long, val: 0x7F as byte } + - { expr: 0, val: 0 } + - { expr: -128, val: -128 } + - { expr: 0x7F, val: 0x7F } - from_type: long - to_type: short + to_type: Short values: - - { expr: 0 as long, val: 0 as short } - - { expr: -32768 as long, val: -32768 as short } - - { expr: 32767 as long, val: 32767 as short } + - { expr: 0, val: 0 } + - { expr: -32768, val: -32768 } + - { expr: 32767, val: 32767 } - from_type: long - to_type: int + to_type: Int values: - - { expr: 0 as long, val: 0 as int } - - { expr: -2147483648 as long, val: -2147483648 as int } - - { expr: 2147483647 as long, val: 2147483647 as int } + - { expr: 0, val: 0 } + - { expr: -2147483648, val: -2147483648 } + - { expr: 2147483647, val: 2147483647 } - from_type: long - to_type: char + to_type: Char values: - - { expr: 0 as long, val: "c'\\u0000'" } - - { expr: 32767 as long, val: "c'\\u7fff'" } - - { expr: 65535 as long, val: "c'\\uFFFF'" } + - { expr: 0, val: "c'\\u0000'" } + - { expr: 32767, val: "c'\\u7fff'" } + - { expr: 65535, val: "c'\\uFFFF'" } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-intf.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-intf.ets index d22d86d454c08185d73e53490e0ad76642346c43..afa3716377129987ea1ff82875f483d54c4f221a 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-intf.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-intf.ets @@ -24,17 +24,13 @@ const c{{loop.index}}: {{c.from_type}} = {{v.expr|safe}} interface J { fld: {{c.to_type}} } -function main(): int { +function main() { {%- for v in c['values'] %} - let d{{loop.index}}: J = { fld: {{v.expr|safe}} } // expression - if (d{{loop.index}}.fld != {{v.val}}) { - return 1 - } - d{{loop.index}} = { fld: c{{loop.index}} } // constant - if (d{{loop.index}}.fld != {{v.val}}) { - return 1 - } + let d{{loop.index}}: J = { fld: ({{v.expr|safe}}).to{{c.to_type}}() } // expression + assertEQ(d{{loop.index}}.fld, {{v.val}}) + + d{{loop.index}} = { fld: c{{loop.index}}.to{{c.to_type}}() } // constant + assertEQ(d{{loop.index}}.fld, {{v.val}}) {%- endfor %} - return 0 } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-intf.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-intf.params.yaml index 688973f6910d4ae124847915702ad71ce40c8b10..762a363bb8b845543804b5549b0ee6d0eaded28b 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-intf.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-intf.params.yaml @@ -14,14 +14,14 @@ --- cases: - from_type: char - to_type: byte + to_type: Byte values: - - { expr: "c'\\u007F'", val: 127 as byte } - - { expr: "c'\\u0000'", val: 0 as byte } - - { expr: c' ', val: 32 as byte } + - { expr: "c'\\u007F'", val: 127 } + - { expr: "c'\\u0000'", val: 0 } + - { expr: c' ', val: 32 } - - from_type: int - to_type: char + - from_type: Int + to_type: Char values: - { expr: 0, val: "c'\\u0000'" } - { expr: 32767, val: "c'\\u7fff'" } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_const/decl-const-n.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_const/decl-const-n.ets index 358d9782f7e8ab536fe626afd2d9d122069f6a6d..ff38c6c54bb3e84c36607afeb3e4167a5cc83492 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_const/decl-const-n.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_const/decl-const-n.ets @@ -18,7 +18,10 @@ desc: Declaration context, constant declaration, constant narrowing integer conversion, implicit tags: [compile-only, negative] ---*/ + +const s: {{c.from_type}} = {{c.expr|safe}} + function main() { - const d: {{c.to_type}} = {{c.expr|safe}} // constant expression value doesn't fit in the constant type range + const d: {{c.to_type}} = s // constant expression value doesn't fit in the constant type range } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_const/decl-const-n.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_const/decl-const-n.params.yaml index 54ceeaa5835bc6d33e4a1b37dd12791f3c3a46a8..362eb217bada00cdd43819f36810241304147392 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_const/decl-const-n.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_const/decl-const-n.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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 @@ -14,31 +14,31 @@ --- cases: # from short - - { expr: -129 as short, to_type: byte } - - { expr: 128 as short, to_type: byte } + - { expr: -129, from_type: short, to_type: byte } + - { expr: 128, from_type: short, to_type: byte } # from int - - { expr: -129 as int, to_type: byte } - - { expr: 128 as int, to_type: byte } + - { expr: -129, from_type: int, to_type: byte } + - { expr: 128, from_type: int, to_type: byte } - - { expr: -32769 as int, to_type: short } - - { expr: 32768 as int, to_type: short } + - { expr: -32769, from_type: int, to_type: short } + - { expr: 32768, from_type: int, to_type: short } - - { expr: -1 as int, to_type: char } - - { expr: 65536 as int, to_type: char } + - { expr: -1, from_type: int, to_type: char } + - { expr: 65536, from_type: int, to_type: char } # from long - - { expr: -129 as long, to_type: byte } - - { expr: 128 as long, to_type: byte } + - { expr: -129, from_type: long, to_type: byte } + - { expr: 128, from_type: long, to_type: byte } - - { expr: -32769 as long, to_type: short } - - { expr: 32768 as long, to_type: short } + - { expr: -32769, from_type: long, to_type: short } + - { expr: 32768, from_type: long, to_type: short } - - { expr: -2147483649 as long, to_type: int } - - { expr: 2147483648 as long, to_type: int } + - { expr: -2147483649, from_type: long, to_type: int } + - { expr: 2147483648, from_type: long, to_type: int } - - { expr: -1 as long, to_type: char } - - { expr: 65536 as long, to_type: char } + - { expr: -1, from_type: long, to_type: char } + - { expr: 65536, from_type: long, to_type: char } # from char - - { expr: "c'\\u0100'", to_type: byte } + - { expr: "c'\\u0100'", from_type: char, to_type: byte } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_const/decl-const-n3.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_const/decl-const-n3.ets index 3ff88a83e2d934587cf35b68af011c12587a4da7..f15f4ae2b8b5ec554248081470560b09515845c1 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_const/decl-const-n3.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_const/decl-const-n3.ets @@ -16,24 +16,16 @@ /*--- desc: Declaration context, constant declaration, constant narrowing integer conversion, implicit -tags: [compile-only, negative] params: from {{c.from_type}} to {{c.to_type}} ---*/ {%- for v in c['values'] %} const c{{loop.index}}: {{c.from_type}} = {{v.expr|safe}} {%- endfor %} -function main(): int { +function main() { {%- for v in c['values'] %} - const d{{loop.index}}: {{c.to_type}} = {{v.expr|safe}} // expression - if (d{{loop.index}} != {{v.val}}) { - return 1 - } - const e{{loop.index}}: {{c.to_type}} = c{{loop.index}} // constant - if (e{{loop.index}} != {{v.val}}) { - return 1 - } -{%- endfor %} - return 0 + const e{{loop.index}}: {{c.to_type}} = c{{loop.index}} + assertEQ(e{{loop.index}}, {{v.val}}) +{% endfor %} } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_const/decl-const-n3.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_const/decl-const-n3.params.yaml index 1dc5daf8a6ffd1934f67ac59777ecb2ca6d0d7ca..2f2dc41e29fed3d51bfb964fcbbd93b7b912cc1f 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_const/decl-const-n3.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_const/decl-const-n3.params.yaml @@ -16,48 +16,48 @@ cases: - from_type: short to_type: byte values: - - { expr: 0 as short, val: 0 as byte } - - { expr: -128 as short, val: -128 as byte } - - { expr: 0x7F as short, val: 0x7F as byte } + - { expr: 0, val: 0 } + - { expr: -128, val: -128 } + - { expr: 0x7F, val: 0x7F } - from_type: int to_type: byte values: - - { expr: 0 as int, val: 0 as byte } - - { expr: -128 as int, val: -128 as byte } - - { expr: 0x7F as int, val: 0x7F as byte } + - { expr: 0, val: 0 } + - { expr: -128, val: -128 } + - { expr: 0x7F, val: 0x7F } - from_type: int to_type: short values: - - { expr: 0 as int, val: 0 as short } - - { expr: -32768 as int, val: -32768 as short } - - { expr: 32767 as int, val: 32767 as short } + - { expr: 0, val: 0 } + - { expr: -32768, val: -32768 } + - { expr: 32767, val: 32767 } - from_type: long to_type: byte values: - - { expr: 0 as long, val: 0 as byte } - - { expr: -128 as long, val: -128 as byte } - - { expr: 0x7F as long, val: 0x7F as byte } + - { expr: 0, val: 0 } + - { expr: -128, val: -128 } + - { expr: 0x7F, val: 0x7F } - from_type: long to_type: short values: - - { expr: 0 as long, val: 0 as short } - - { expr: -32768 as long, val: -32768 as short } - - { expr: 32767 as long, val: 32767 as short } + - { expr: 0, val: 0 } + - { expr: -32768, val: -32768 } + - { expr: 32767, val: 32767 } - from_type: long to_type: int values: - - { expr: 0 as long, val: 0 as int } - - { expr: -2147483648 as long, val: -2147483648 as int } - - { expr: 2147483647 as long, val: 2147483647 as int } + - { expr: 0, val: 0 } + - { expr: -2147483648, val: -2147483648 } + - { expr: 2147483647, val: 2147483647 } - from_type: long to_type: char values: - - { expr: 0 as long, val: "c'\\u0000'" } - - { expr: 32767 as long, val: "c'\\u7fff'" } - - { expr: 65535 as long, val: "c'\\uFFFF'" } + - { expr: 0, val: "c'\\u0000'" } + - { expr: 32767, val: "c'\\u7fff'" } + - { expr: 65535, val: "c'\\uFFFF'" } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-field-n.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-field-n.ets index 04c6546e14ed9f2618932b9a761604e9ef20316d..097f65dca193ad55eefd4f23e53eeedcada487e5 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-field-n.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-field-n.ets @@ -18,8 +18,11 @@ desc: Declaration context, instance field declaration, constant narrowing integer conversion, implicit tags: [compile-only, negative] ---*/ + +const s: {{c.from_type}} = {{c.expr|safe}} + class A { - public d: {{c.to_type}} = {{c.expr|safe}} // constant expression value doesn't fit in the field type range + public d: {{c.to_type}} = s // constant expression value doesn't fit in the field type range } function main() { diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-field-n.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-field-n.params.yaml index 54ceeaa5835bc6d33e4a1b37dd12791f3c3a46a8..362eb217bada00cdd43819f36810241304147392 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-field-n.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-field-n.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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 @@ -14,31 +14,31 @@ --- cases: # from short - - { expr: -129 as short, to_type: byte } - - { expr: 128 as short, to_type: byte } + - { expr: -129, from_type: short, to_type: byte } + - { expr: 128, from_type: short, to_type: byte } # from int - - { expr: -129 as int, to_type: byte } - - { expr: 128 as int, to_type: byte } + - { expr: -129, from_type: int, to_type: byte } + - { expr: 128, from_type: int, to_type: byte } - - { expr: -32769 as int, to_type: short } - - { expr: 32768 as int, to_type: short } + - { expr: -32769, from_type: int, to_type: short } + - { expr: 32768, from_type: int, to_type: short } - - { expr: -1 as int, to_type: char } - - { expr: 65536 as int, to_type: char } + - { expr: -1, from_type: int, to_type: char } + - { expr: 65536, from_type: int, to_type: char } # from long - - { expr: -129 as long, to_type: byte } - - { expr: 128 as long, to_type: byte } + - { expr: -129, from_type: long, to_type: byte } + - { expr: 128, from_type: long, to_type: byte } - - { expr: -32769 as long, to_type: short } - - { expr: 32768 as long, to_type: short } + - { expr: -32769, from_type: long, to_type: short } + - { expr: 32768, from_type: long, to_type: short } - - { expr: -2147483649 as long, to_type: int } - - { expr: 2147483648 as long, to_type: int } + - { expr: -2147483649, from_type: long, to_type: int } + - { expr: 2147483648, from_type: long, to_type: int } - - { expr: -1 as long, to_type: char } - - { expr: 65536 as long, to_type: char } + - { expr: -1, from_type: long, to_type: char } + - { expr: 65536, from_type: long, to_type: char } # from char - - { expr: "c'\\u0100'", to_type: byte } + - { expr: "c'\\u0100'", from_type: char, to_type: byte } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-field-n3.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-field-n3.ets index a2d938a6eb16037b14b315a4a4fd70cf23ccf91a..223c5299f62ca94a70353dfffd76f62d91c8d8ae 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-field-n3.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-field-n3.ets @@ -15,7 +15,6 @@ {%- for c in cases %} /*--- desc: Declaration context, instance field declaration, constant narrowing integer conversion, implicit -tags: [compile-only, negative] params: from {{c.from_type}} to {{c.to_type}} ---*/ {%- for v in c['values'] %} @@ -24,21 +23,14 @@ const c{{loop.index}}: {{c.from_type}} = {{v.expr|safe}} {%- for v in c['values'] %} class A{{loop.index}} { - public d: {{c.to_type}} = {{v.expr|safe}} public e: {{c.to_type}} = c{{loop.index}} } {%- endfor %} -function main(): int { +function main() { {%- for v in c['values'] %} let a{{loop.index}}: A{{loop.index}} = new A{{loop.index}}() - if (a{{loop.index}}.d != {{v.val}}) { - return 1 - } - if (a{{loop.index}}.e != {{v.val}}) { - return 1 - } -{%- endfor %} - return 0 + assertEQ(a{{loop.index}}.e, {{v.val}}) +{% endfor %} } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-field-n3.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-field-n3.params.yaml index 1dc5daf8a6ffd1934f67ac59777ecb2ca6d0d7ca..2f2dc41e29fed3d51bfb964fcbbd93b7b912cc1f 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-field-n3.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-field-n3.params.yaml @@ -16,48 +16,48 @@ cases: - from_type: short to_type: byte values: - - { expr: 0 as short, val: 0 as byte } - - { expr: -128 as short, val: -128 as byte } - - { expr: 0x7F as short, val: 0x7F as byte } + - { expr: 0, val: 0 } + - { expr: -128, val: -128 } + - { expr: 0x7F, val: 0x7F } - from_type: int to_type: byte values: - - { expr: 0 as int, val: 0 as byte } - - { expr: -128 as int, val: -128 as byte } - - { expr: 0x7F as int, val: 0x7F as byte } + - { expr: 0, val: 0 } + - { expr: -128, val: -128 } + - { expr: 0x7F, val: 0x7F } - from_type: int to_type: short values: - - { expr: 0 as int, val: 0 as short } - - { expr: -32768 as int, val: -32768 as short } - - { expr: 32767 as int, val: 32767 as short } + - { expr: 0, val: 0 } + - { expr: -32768, val: -32768 } + - { expr: 32767, val: 32767 } - from_type: long to_type: byte values: - - { expr: 0 as long, val: 0 as byte } - - { expr: -128 as long, val: -128 as byte } - - { expr: 0x7F as long, val: 0x7F as byte } + - { expr: 0, val: 0 } + - { expr: -128, val: -128 } + - { expr: 0x7F, val: 0x7F } - from_type: long to_type: short values: - - { expr: 0 as long, val: 0 as short } - - { expr: -32768 as long, val: -32768 as short } - - { expr: 32767 as long, val: 32767 as short } + - { expr: 0, val: 0 } + - { expr: -32768, val: -32768 } + - { expr: 32767, val: 32767 } - from_type: long to_type: int values: - - { expr: 0 as long, val: 0 as int } - - { expr: -2147483648 as long, val: -2147483648 as int } - - { expr: 2147483647 as long, val: 2147483647 as int } + - { expr: 0, val: 0 } + - { expr: -2147483648, val: -2147483648 } + - { expr: 2147483647, val: 2147483647 } - from_type: long to_type: char values: - - { expr: 0 as long, val: "c'\\u0000'" } - - { expr: 32767 as long, val: "c'\\u7fff'" } - - { expr: 65535 as long, val: "c'\\uFFFF'" } + - { expr: 0, val: "c'\\u0000'" } + - { expr: 32767, val: "c'\\u7fff'" } + - { expr: 65535, val: "c'\\uFFFF'" } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-st-field-n.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-st-field-n.ets index 864db868a84c6aad54853fa4528381d460071f60..593683f4bc71d2a8df6abacdd0ebed056d1ddff6 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-st-field-n.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-st-field-n.ets @@ -18,8 +18,11 @@ desc: Declaration context, static field declaration, constant narrowing integer conversion, implicit tags: [compile-only, negative] ---*/ + +const s: {{c.from_type}} = {{c.expr|safe}} + class A { - public static d: {{c.to_type}} = {{c.expr|safe}} // constant expression value doesn't fit in the field type range + public static d: {{c.to_type}} = s // constant expression value doesn't fit in the field type range } function main() {} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-st-field-n.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-st-field-n.params.yaml index 54ceeaa5835bc6d33e4a1b37dd12791f3c3a46a8..362eb217bada00cdd43819f36810241304147392 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-st-field-n.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-st-field-n.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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 @@ -14,31 +14,31 @@ --- cases: # from short - - { expr: -129 as short, to_type: byte } - - { expr: 128 as short, to_type: byte } + - { expr: -129, from_type: short, to_type: byte } + - { expr: 128, from_type: short, to_type: byte } # from int - - { expr: -129 as int, to_type: byte } - - { expr: 128 as int, to_type: byte } + - { expr: -129, from_type: int, to_type: byte } + - { expr: 128, from_type: int, to_type: byte } - - { expr: -32769 as int, to_type: short } - - { expr: 32768 as int, to_type: short } + - { expr: -32769, from_type: int, to_type: short } + - { expr: 32768, from_type: int, to_type: short } - - { expr: -1 as int, to_type: char } - - { expr: 65536 as int, to_type: char } + - { expr: -1, from_type: int, to_type: char } + - { expr: 65536, from_type: int, to_type: char } # from long - - { expr: -129 as long, to_type: byte } - - { expr: 128 as long, to_type: byte } + - { expr: -129, from_type: long, to_type: byte } + - { expr: 128, from_type: long, to_type: byte } - - { expr: -32769 as long, to_type: short } - - { expr: 32768 as long, to_type: short } + - { expr: -32769, from_type: long, to_type: short } + - { expr: 32768, from_type: long, to_type: short } - - { expr: -2147483649 as long, to_type: int } - - { expr: 2147483648 as long, to_type: int } + - { expr: -2147483649, from_type: long, to_type: int } + - { expr: 2147483648, from_type: long, to_type: int } - - { expr: -1 as long, to_type: char } - - { expr: 65536 as long, to_type: char } + - { expr: -1, from_type: long, to_type: char } + - { expr: 65536, from_type: long, to_type: char } # from char - - { expr: "c'\\u0100'", to_type: byte } + - { expr: "c'\\u0100'", from_type: char, to_type: byte } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-st-field-n3.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-st-field-n3.ets index de2dbf0833916bb3f5582da88b8914ed26198edf..4607048b2f010d058d3f812803d140014792fdfa 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-st-field-n3.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-st-field-n3.ets @@ -16,7 +16,6 @@ /*--- desc: Declaration context, static field declaration, constant narrowing integer conversion, implicit -tags: [compile-only, negative] params: from {{c.from_type}} to {{c.to_type}} ---*/ {%- for v in c['values'] %} @@ -25,20 +24,13 @@ const c{{loop.index}}: {{c.from_type}} = {{v.expr|safe}} {%- for v in c['values'] %} class A{{loop.index}} { - public static d: {{c.to_type}} = {{v.expr|safe}} public static e: {{c.to_type}} = c{{loop.index}} } {%- endfor %} -function main(): int { +function main() { {%- for v in c['values'] %} - if (A{{loop.index}}.d != {{v.val}}) { - return 1 - } - if (A{{loop.index}}.e != {{v.val}}) { - return 1 - } -{%- endfor %} - return 0 + assertEQ(A{{loop.index}}.e, {{v.val}}) +{% endfor %} } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-st-field-n3.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-st-field-n3.params.yaml index 1dc5daf8a6ffd1934f67ac59777ecb2ca6d0d7ca..2f2dc41e29fed3d51bfb964fcbbd93b7b912cc1f 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-st-field-n3.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_field/decl-st-field-n3.params.yaml @@ -16,48 +16,48 @@ cases: - from_type: short to_type: byte values: - - { expr: 0 as short, val: 0 as byte } - - { expr: -128 as short, val: -128 as byte } - - { expr: 0x7F as short, val: 0x7F as byte } + - { expr: 0, val: 0 } + - { expr: -128, val: -128 } + - { expr: 0x7F, val: 0x7F } - from_type: int to_type: byte values: - - { expr: 0 as int, val: 0 as byte } - - { expr: -128 as int, val: -128 as byte } - - { expr: 0x7F as int, val: 0x7F as byte } + - { expr: 0, val: 0 } + - { expr: -128, val: -128 } + - { expr: 0x7F, val: 0x7F } - from_type: int to_type: short values: - - { expr: 0 as int, val: 0 as short } - - { expr: -32768 as int, val: -32768 as short } - - { expr: 32767 as int, val: 32767 as short } + - { expr: 0, val: 0 } + - { expr: -32768, val: -32768 } + - { expr: 32767, val: 32767 } - from_type: long to_type: byte values: - - { expr: 0 as long, val: 0 as byte } - - { expr: -128 as long, val: -128 as byte } - - { expr: 0x7F as long, val: 0x7F as byte } + - { expr: 0, val: 0 } + - { expr: -128, val: -128 } + - { expr: 0x7F, val: 0x7F } - from_type: long to_type: short values: - - { expr: 0 as long, val: 0 as short } - - { expr: -32768 as long, val: -32768 as short } - - { expr: 32767 as long, val: 32767 as short } + - { expr: 0, val: 0 } + - { expr: -32768, val: -32768 } + - { expr: 32767, val: 32767 } - from_type: long to_type: int values: - - { expr: 0 as long, val: 0 as int } - - { expr: -2147483648 as long, val: -2147483648 as int } - - { expr: 2147483647 as long, val: 2147483647 as int } + - { expr: 0, val: 0 } + - { expr: -2147483648, val: -2147483648 } + - { expr: 2147483647, val: 2147483647 } - from_type: long to_type: char values: - - { expr: 0 as long, val: "c'\\u0000'" } - - { expr: 32767 as long, val: "c'\\u7fff'" } - - { expr: 65535 as long, val: "c'\\uFFFF'" } + - { expr: 0, val: "c'\\u0000'" } + - { expr: 32767, val: "c'\\u7fff'" } + - { expr: 65535, val: "c'\\uFFFF'" } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_var/decl-var-n.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_var/decl-var-n.ets index dcbe62da1836430030e51099d3fc052dd6785daa..79a33470d757151bcdcd8852ca846e3c4070a337 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_var/decl-var-n.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_var/decl-var-n.ets @@ -18,7 +18,10 @@ desc: Declaration context, variable declaration, constant narrowing integer conversion, implicit tags: [compile-only, negative] ---*/ + +const s: {{c.from_type}} = {{c.expr|safe}} + function main() { - let d: {{c.to_type}} = {{c.expr|safe}} // constant expression value doesn't fit in the variable type range + let d: {{c.to_type}} = s // constant expression value doesn't fit in the variable type range } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_var/decl-var-n.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_var/decl-var-n.params.yaml index 54ceeaa5835bc6d33e4a1b37dd12791f3c3a46a8..362eb217bada00cdd43819f36810241304147392 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_var/decl-var-n.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_var/decl-var-n.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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 @@ -14,31 +14,31 @@ --- cases: # from short - - { expr: -129 as short, to_type: byte } - - { expr: 128 as short, to_type: byte } + - { expr: -129, from_type: short, to_type: byte } + - { expr: 128, from_type: short, to_type: byte } # from int - - { expr: -129 as int, to_type: byte } - - { expr: 128 as int, to_type: byte } + - { expr: -129, from_type: int, to_type: byte } + - { expr: 128, from_type: int, to_type: byte } - - { expr: -32769 as int, to_type: short } - - { expr: 32768 as int, to_type: short } + - { expr: -32769, from_type: int, to_type: short } + - { expr: 32768, from_type: int, to_type: short } - - { expr: -1 as int, to_type: char } - - { expr: 65536 as int, to_type: char } + - { expr: -1, from_type: int, to_type: char } + - { expr: 65536, from_type: int, to_type: char } # from long - - { expr: -129 as long, to_type: byte } - - { expr: 128 as long, to_type: byte } + - { expr: -129, from_type: long, to_type: byte } + - { expr: 128, from_type: long, to_type: byte } - - { expr: -32769 as long, to_type: short } - - { expr: 32768 as long, to_type: short } + - { expr: -32769, from_type: long, to_type: short } + - { expr: 32768, from_type: long, to_type: short } - - { expr: -2147483649 as long, to_type: int } - - { expr: 2147483648 as long, to_type: int } + - { expr: -2147483649, from_type: long, to_type: int } + - { expr: 2147483648, from_type: long, to_type: int } - - { expr: -1 as long, to_type: char } - - { expr: 65536 as long, to_type: char } + - { expr: -1, from_type: long, to_type: char } + - { expr: 65536, from_type: long, to_type: char } # from char - - { expr: "c'\\u0100'", to_type: byte } + - { expr: "c'\\u0100'", from_type: char, to_type: byte } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_var/decl-var-n3.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_var/decl-var-n3.ets index 9e2a56abd757768477df8da9f15d7b70181a451d..04c167dc3710a353fc5eff07623e9e3d0bb2da1b 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_var/decl-var-n3.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_var/decl-var-n3.ets @@ -16,24 +16,16 @@ /*--- desc: Declaration context, variable declaration, constant narrowing integer conversion, implicit -tags: [compile-only, negative] params: from {{c.from_type}} to {{c.to_type}} ---*/ {%- for v in c['values'] %} const c{{loop.index}}: {{c.from_type}} = {{v.expr|safe}} {%- endfor %} -function main(): int { +function main() { {%- for v in c['values'] %} - let d{{loop.index}}: {{c.to_type}} = {{v.expr|safe}} // expression - if (d{{loop.index}} != {{v.val}}) { - return 1 - } - let e{{loop.index}} = c{{loop.index}} // constant - if (e{{loop.index}} != {{v.val}}) { - return 1 - } -{%- endfor %} - return 0 + let e{{loop.index}}: {{c.to_type}} = c{{loop.index}} + assertEQ(e{{loop.index}}, {{v.val}}) +{% endfor %} } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_var/decl-var-n3.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_var/decl-var-n3.params.yaml index 1dc5daf8a6ffd1934f67ac59777ecb2ca6d0d7ca..2f2dc41e29fed3d51bfb964fcbbd93b7b912cc1f 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_var/decl-var-n3.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/decl_var/decl-var-n3.params.yaml @@ -16,48 +16,48 @@ cases: - from_type: short to_type: byte values: - - { expr: 0 as short, val: 0 as byte } - - { expr: -128 as short, val: -128 as byte } - - { expr: 0x7F as short, val: 0x7F as byte } + - { expr: 0, val: 0 } + - { expr: -128, val: -128 } + - { expr: 0x7F, val: 0x7F } - from_type: int to_type: byte values: - - { expr: 0 as int, val: 0 as byte } - - { expr: -128 as int, val: -128 as byte } - - { expr: 0x7F as int, val: 0x7F as byte } + - { expr: 0, val: 0 } + - { expr: -128, val: -128 } + - { expr: 0x7F, val: 0x7F } - from_type: int to_type: short values: - - { expr: 0 as int, val: 0 as short } - - { expr: -32768 as int, val: -32768 as short } - - { expr: 32767 as int, val: 32767 as short } + - { expr: 0, val: 0 } + - { expr: -32768, val: -32768 } + - { expr: 32767, val: 32767 } - from_type: long to_type: byte values: - - { expr: 0 as long, val: 0 as byte } - - { expr: -128 as long, val: -128 as byte } - - { expr: 0x7F as long, val: 0x7F as byte } + - { expr: 0, val: 0 } + - { expr: -128, val: -128 } + - { expr: 0x7F, val: 0x7F } - from_type: long to_type: short values: - - { expr: 0 as long, val: 0 as short } - - { expr: -32768 as long, val: -32768 as short } - - { expr: 32767 as long, val: 32767 as short } + - { expr: 0, val: 0 } + - { expr: -32768, val: -32768 } + - { expr: 32767, val: 32767 } - from_type: long to_type: int values: - - { expr: 0 as long, val: 0 as int } - - { expr: -2147483648 as long, val: -2147483648 as int } - - { expr: 2147483647 as long, val: 2147483647 as int } + - { expr: 0, val: 0 } + - { expr: -2147483648, val: -2147483648 } + - { expr: 2147483647, val: 2147483647 } - from_type: long to_type: char values: - - { expr: 0 as long, val: "c'\\u0000'" } - - { expr: 32767 as long, val: "c'\\u7fff'" } - - { expr: 65535 as long, val: "c'\\uFFFF'" } + - { expr: 0, val: "c'\\u0000'" } + - { expr: 32767, val: "c'\\u7fff'" } + - { expr: 65535, val: "c'\\uFFFF'" } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/assn_var/assn-var-un.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/assn_var/assn-var-un.ets index 31f8b3bbc0bb2469dbce3f9f624bdea1c99d78b5..223111cccb27902db1fa1b283934e0fe6ddf3046 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/assn_var/assn-var-un.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/assn_var/assn-var-un.ets @@ -31,7 +31,7 @@ let d: {{c.to_type}} function main() { {%- for t in c['values'] %} d = s{{loop.index}} - assertTrue( d as {{t.ref_type}} {{t.eq}} {{t.expr|safe}} ) + assertTrue( d {{'as ' + t.ref_type if t.ref_type}} {{t.eq}} {{t.expr|safe}} ) {%- endfor %} } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/assn_var/assn-var-un.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/assn_var/assn-var-un.params.yaml index 0ea7d29786487c3dd2a17b6b6e3bad2b1d90609b..f41c22137d511f90435385ecbf7c8ca96c9da3f7 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/assn_var/assn-var-un.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/assn_var/assn-var-un.params.yaml @@ -15,10 +15,10 @@ cases: - to_type: byte|short|int|long # normalized to Long values: - - { from_type: 'byte', ref_type: 'Long', expr: '127', eq: '==' } - - { from_type: 'short', ref_type: 'Long', expr: '-7', eq: '==' } - - { from_type: 'int', ref_type: 'Long', expr: '0xCAFE', eq: '==' } - - { from_type: 'long', ref_type: 'Long', expr: '0o777', eq: '==' } + - { from_type: 'byte', expr: '127', eq: '==' } + - { from_type: 'short', expr: '-7', eq: '==' } + - { from_type: 'int', expr: '0xCAFE', eq: '==' } + - { from_type: 'long', expr: '0o777', eq: '==' } - to_type: Byte|Short|Int|Long # normalized to Byte|Short|Int|Long values: @@ -29,9 +29,9 @@ cases: - to_type: float|double|number # normalized to double values: - - { from_type: 'float', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'float', expr: '3.5f', eq: '==' } + - { from_type: 'double', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number', expr: '1234567e8', eq: '==' } - to_type: Float|Double|Number # normalized to Float|Double values: @@ -41,13 +41,13 @@ cases: - to_type: byte|short|int|long|float|double # normalized to Double values: - - { from_type: 'byte', ref_type: 'Double', expr: '127', eq: '==' } - - { from_type: 'short', ref_type: 'Double', expr: '-7', eq: '==' } - - { from_type: 'int', ref_type: 'Double', expr: '0xCAFE', eq: '==' } - - { from_type: 'long', ref_type: 'Double', expr: '0o777', eq: '==' } - - { from_type: 'float', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'byte', expr: '127', eq: '==' } + - { from_type: 'short', expr: '-7', eq: '==' } + - { from_type: 'int', expr: '0xCAFE', eq: '==' } + - { from_type: 'long', expr: '0o777', eq: '==' } + - { from_type: 'float', expr: '3.5f', eq: '==' } + - { from_type: 'double', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number', expr: '1234567e8', eq: '==' } - to_type: Byte|Short|Int|Long|Float|Double # normalized to Byte|Short|Int|Long|Float|Double values: diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/assn_var/assn-var-wd.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/assn_var/assn-var-wd.params.yaml index d3b628d7df9a5f2319f3e64a92b82f8f1e638495..e15ee3523b41c881c23fbfe611abfdad46fc9f6c 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/assn_var/assn-var-wd.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/assn_var/assn-var-wd.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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,9 +15,9 @@ cases: - to_type: byte|short|int|long values: - - { from_type: 'byte|short', ref_type: 'Long', expr: '127', eq: '==' } - - { from_type: 'int|byte', ref_type: 'Long', expr: '-128', eq: '==' } - - { from_type: 'long|short|byte', ref_type: 'Long', expr: '0o777', eq: '==' } + - { from_type: 'byte|short', expr: '127 as byte', eq: '==' } + - { from_type: 'int|byte', expr: '-128', eq: '==' } + - { from_type: 'long|short|byte', expr: '0o777', eq: '==' } - to_type: Byte|Short|Int|Long decl: |- @@ -33,9 +33,9 @@ cases: - to_type: float|double|number values: - - { from_type: 'float|number', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double|float', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number|double', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'float|number', expr: '3.5f', eq: '==' } + - { from_type: 'double|float', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number|double', expr: '1234567e8', eq: '==' } - to_type: Float|Double|Number decl: |- @@ -49,13 +49,13 @@ cases: - to_type: byte|short|int|long|float|double values: - - { from_type: 'byte|float', ref_type: 'Double', expr: '127', eq: '==' } - - { from_type: 'short|int', ref_type: 'Double', expr: '-7', eq: '==' } - - { from_type: 'int|short|byte|double', ref_type: 'Double', expr: '0xCAFE', eq: '==' } - - { from_type: 'long|double', ref_type: 'Double', expr: '0o777', eq: '==' } - - { from_type: 'float|short|double|float', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double|int|long', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number|byte', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'byte|float', expr: '127 as byte', eq: '==' } + - { from_type: 'short|int', expr: '-7', eq: '==' } + - { from_type: 'int|short|byte|double', expr: '0xCAFE', eq: '==' } + - { from_type: 'long|double', expr: '0o777 as long', eq: '==' } + - { from_type: 'float|short|double|float', expr: '3.5f', eq: '==' } + - { from_type: 'double|int|long', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number|byte', expr: '1234567e8', eq: '==' } - to_type: Byte|Short|Int|Long|Float|Double decl: |- diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_cons/call-cons-un.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_cons/call-cons-un.ets index 56163f51f0677fa6ea032d90b2ba7a8b6f082e46..b7eec6567838d18f8ff55c061dbab6d04e1477c3 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_cons/call-cons-un.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_cons/call-cons-un.ets @@ -35,7 +35,7 @@ class Z { function main() { {%- for t in c['values'] %} - assertTrue( new Z(s{{loop.index}}).fld as {{t.ref_type}} {{t.eq}} {{t.expr|safe}} ) + assertTrue( new Z(s{{loop.index}}).fld {{'as ' + t.ref_type if t.ref_type}} {{t.eq}} {{t.expr|safe}} ) {%- endfor %} } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_cons/call-cons-un.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_cons/call-cons-un.params.yaml index 8ac559c94593727ecc7dadc240a6a13a3d25e60e..2f5dabbef49116a40b8acfcd7e983b9d6a8254b5 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_cons/call-cons-un.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_cons/call-cons-un.params.yaml @@ -15,10 +15,10 @@ cases: - to_type: byte|short|int|long # normalized to Long values: - - { from_type: 'byte', ref_type: 'Long', expr: '127', eq: '==' } - - { from_type: 'short', ref_type: 'Long', expr: '-7', eq: '==' } - - { from_type: 'int', ref_type: 'Long', expr: '0xCAFE', eq: '==' } - - { from_type: 'long', ref_type: 'Long', expr: '0o777', eq: '==' } + - { from_type: 'byte', expr: '127', eq: '==' } + - { from_type: 'short', expr: '-7', eq: '==' } + - { from_type: 'int', expr: '0xCAFE', eq: '==' } + - { from_type: 'long', expr: '0o777', eq: '==' } - to_type: Byte|Short|Int|Long # normalized to Byte|Short|Int|Long values: @@ -29,9 +29,9 @@ cases: - to_type: float|double|number # normalized to double values: - - { from_type: 'float', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'float', expr: '3.5f', eq: '==' } + - { from_type: 'double', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number', expr: '1234567e8', eq: '==' } - to_type: Float|Double|Number # normalized to Float|Double values: @@ -41,13 +41,13 @@ cases: - to_type: byte|short|int|long|float|double # normalized to Double values: - - { from_type: 'byte', ref_type: 'Double', expr: '127', eq: '==' } - - { from_type: 'short', ref_type: 'Double', expr: '-7', eq: '==' } - - { from_type: 'int', ref_type: 'Double', expr: '0xCAFE', eq: '==' } - - { from_type: 'long', ref_type: 'Double', expr: '0o777', eq: '==' } - - { from_type: 'float', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'byte', expr: '127', eq: '==' } + - { from_type: 'short', expr: '-7', eq: '==' } + - { from_type: 'int', expr: '0xCAFE', eq: '==' } + - { from_type: 'long', expr: '0o777', eq: '==' } + - { from_type: 'float', expr: '3.5f', eq: '==' } + - { from_type: 'double', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number', expr: '1234567e8', eq: '==' } - to_type: Byte|Short|Int|Long|Float|Double # normalized to Byte|Short|Int|Long|Float|Double values: diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_cons/call-cons-wd.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_cons/call-cons-wd.params.yaml index d3b628d7df9a5f2319f3e64a92b82f8f1e638495..e15ee3523b41c881c23fbfe611abfdad46fc9f6c 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_cons/call-cons-wd.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_cons/call-cons-wd.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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,9 +15,9 @@ cases: - to_type: byte|short|int|long values: - - { from_type: 'byte|short', ref_type: 'Long', expr: '127', eq: '==' } - - { from_type: 'int|byte', ref_type: 'Long', expr: '-128', eq: '==' } - - { from_type: 'long|short|byte', ref_type: 'Long', expr: '0o777', eq: '==' } + - { from_type: 'byte|short', expr: '127 as byte', eq: '==' } + - { from_type: 'int|byte', expr: '-128', eq: '==' } + - { from_type: 'long|short|byte', expr: '0o777', eq: '==' } - to_type: Byte|Short|Int|Long decl: |- @@ -33,9 +33,9 @@ cases: - to_type: float|double|number values: - - { from_type: 'float|number', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double|float', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number|double', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'float|number', expr: '3.5f', eq: '==' } + - { from_type: 'double|float', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number|double', expr: '1234567e8', eq: '==' } - to_type: Float|Double|Number decl: |- @@ -49,13 +49,13 @@ cases: - to_type: byte|short|int|long|float|double values: - - { from_type: 'byte|float', ref_type: 'Double', expr: '127', eq: '==' } - - { from_type: 'short|int', ref_type: 'Double', expr: '-7', eq: '==' } - - { from_type: 'int|short|byte|double', ref_type: 'Double', expr: '0xCAFE', eq: '==' } - - { from_type: 'long|double', ref_type: 'Double', expr: '0o777', eq: '==' } - - { from_type: 'float|short|double|float', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double|int|long', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number|byte', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'byte|float', expr: '127 as byte', eq: '==' } + - { from_type: 'short|int', expr: '-7', eq: '==' } + - { from_type: 'int|short|byte|double', expr: '0xCAFE', eq: '==' } + - { from_type: 'long|double', expr: '0o777 as long', eq: '==' } + - { from_type: 'float|short|double|float', expr: '3.5f', eq: '==' } + - { from_type: 'double|int|long', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number|byte', expr: '1234567e8', eq: '==' } - to_type: Byte|Short|Int|Long|Float|Double decl: |- diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_func/call-func-un.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_func/call-func-un.ets index 92edf4881e3241f71c85688e3b70024d936f6e6e..196282f9bae95e9138a68069d407528fcbd0f3b8 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_func/call-func-un.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_func/call-func-un.ets @@ -32,7 +32,7 @@ function foo(p: {{c.to_type}}): {{c.to_type}} { function main() { {%- for t in c['values'] %} - assertTrue( foo(s{{loop.index}}) as {{t.ref_type}} {{t.eq}} {{t.expr|safe}} ) + assertTrue( foo(s{{loop.index}}) {{'as ' + t.ref_type if t.ref_type}} {{t.eq}} {{t.expr|safe}} ) {%- endfor %} } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_func/call-func-un.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_func/call-func-un.params.yaml index 8ac559c94593727ecc7dadc240a6a13a3d25e60e..bade4e8fb11e0c7715154559902e76a7a446ed06 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_func/call-func-un.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_func/call-func-un.params.yaml @@ -15,9 +15,9 @@ cases: - to_type: byte|short|int|long # normalized to Long values: - - { from_type: 'byte', ref_type: 'Long', expr: '127', eq: '==' } - - { from_type: 'short', ref_type: 'Long', expr: '-7', eq: '==' } - - { from_type: 'int', ref_type: 'Long', expr: '0xCAFE', eq: '==' } + - { from_type: 'byte', expr: '127', eq: '==' } + - { from_type: 'short', expr: '-7', eq: '==' } + - { from_type: 'int', expr: '0xCAFE', eq: '==' } - { from_type: 'long', ref_type: 'Long', expr: '0o777', eq: '==' } - to_type: Byte|Short|Int|Long # normalized to Byte|Short|Int|Long @@ -29,7 +29,7 @@ cases: - to_type: float|double|number # normalized to double values: - - { from_type: 'float', ref_type: 'Double', expr: '3.5f', eq: '==' } + - { from_type: 'float', expr: '3.5f', eq: '==' } - { from_type: 'double', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - { from_type: 'number', ref_type: 'Double', expr: '1234567e8', eq: '==' } @@ -41,11 +41,11 @@ cases: - to_type: byte|short|int|long|float|double # normalized to Double values: - - { from_type: 'byte', ref_type: 'Double', expr: '127', eq: '==' } - - { from_type: 'short', ref_type: 'Double', expr: '-7', eq: '==' } - - { from_type: 'int', ref_type: 'Double', expr: '0xCAFE', eq: '==' } - - { from_type: 'long', ref_type: 'Double', expr: '0o777', eq: '==' } - - { from_type: 'float', ref_type: 'Double', expr: '3.5f', eq: '==' } + - { from_type: 'byte', expr: '127', eq: '==' } + - { from_type: 'short', expr: '-7', eq: '==' } + - { from_type: 'int', expr: '0xCAFE', eq: '==' } + - { from_type: 'long', expr: '0o777', eq: '==' } + - { from_type: 'float', expr: '3.5f', eq: '==' } - { from_type: 'double', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - { from_type: 'number', ref_type: 'Double', expr: '1234567e8', eq: '==' } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_func/call-func-wd.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_func/call-func-wd.params.yaml index d3b628d7df9a5f2319f3e64a92b82f8f1e638495..e15ee3523b41c881c23fbfe611abfdad46fc9f6c 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_func/call-func-wd.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_func/call-func-wd.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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,9 +15,9 @@ cases: - to_type: byte|short|int|long values: - - { from_type: 'byte|short', ref_type: 'Long', expr: '127', eq: '==' } - - { from_type: 'int|byte', ref_type: 'Long', expr: '-128', eq: '==' } - - { from_type: 'long|short|byte', ref_type: 'Long', expr: '0o777', eq: '==' } + - { from_type: 'byte|short', expr: '127 as byte', eq: '==' } + - { from_type: 'int|byte', expr: '-128', eq: '==' } + - { from_type: 'long|short|byte', expr: '0o777', eq: '==' } - to_type: Byte|Short|Int|Long decl: |- @@ -33,9 +33,9 @@ cases: - to_type: float|double|number values: - - { from_type: 'float|number', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double|float', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number|double', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'float|number', expr: '3.5f', eq: '==' } + - { from_type: 'double|float', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number|double', expr: '1234567e8', eq: '==' } - to_type: Float|Double|Number decl: |- @@ -49,13 +49,13 @@ cases: - to_type: byte|short|int|long|float|double values: - - { from_type: 'byte|float', ref_type: 'Double', expr: '127', eq: '==' } - - { from_type: 'short|int', ref_type: 'Double', expr: '-7', eq: '==' } - - { from_type: 'int|short|byte|double', ref_type: 'Double', expr: '0xCAFE', eq: '==' } - - { from_type: 'long|double', ref_type: 'Double', expr: '0o777', eq: '==' } - - { from_type: 'float|short|double|float', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double|int|long', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number|byte', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'byte|float', expr: '127 as byte', eq: '==' } + - { from_type: 'short|int', expr: '-7', eq: '==' } + - { from_type: 'int|short|byte|double', expr: '0xCAFE', eq: '==' } + - { from_type: 'long|double', expr: '0o777 as long', eq: '==' } + - { from_type: 'float|short|double|float', expr: '3.5f', eq: '==' } + - { from_type: 'double|int|long', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number|byte', expr: '1234567e8', eq: '==' } - to_type: Byte|Short|Int|Long|Float|Double decl: |- diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_lmbd/call-lmbd-un.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_lmbd/call-lmbd-un.ets index d1a7e1431c06e5e84da8ecc0ef14b89c15eac95b..21ed3788f0623f76883d005ce942b7ee6f78b8db 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_lmbd/call-lmbd-un.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_lmbd/call-lmbd-un.ets @@ -28,7 +28,7 @@ let s{{loop.index}}: {{t.from_type}} = {{t.expr|safe}}; function main() { {%- for t in c['values'] %} - assertTrue( ((p: {{c.to_type}}): {{c.to_type}} => { return p })(s{{loop.index}}) as {{t.ref_type}} {{t.eq}} {{t.expr|safe}} ) + assertTrue( ((p: {{c.to_type}}): {{c.to_type}} => { return p })(s{{loop.index}}) {{'as ' + t.ref_type if t.ref_type}} {{t.eq}} {{t.expr|safe}} ) {%- endfor %} } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_lmbd/call-lmbd-un.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_lmbd/call-lmbd-un.params.yaml index 8ac559c94593727ecc7dadc240a6a13a3d25e60e..30df95f7a86579e13e50d7b4ab60991d9e1f7687 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_lmbd/call-lmbd-un.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_lmbd/call-lmbd-un.params.yaml @@ -15,10 +15,10 @@ cases: - to_type: byte|short|int|long # normalized to Long values: - - { from_type: 'byte', ref_type: 'Long', expr: '127', eq: '==' } - - { from_type: 'short', ref_type: 'Long', expr: '-7', eq: '==' } - - { from_type: 'int', ref_type: 'Long', expr: '0xCAFE', eq: '==' } - - { from_type: 'long', ref_type: 'Long', expr: '0o777', eq: '==' } + - { from_type: 'byte', expr: '127', eq: '==' } + - { from_type: 'short', expr: '-7', eq: '==' } + - { from_type: 'int', expr: '0xCAFE', eq: '==' } + - { from_type: 'long', expr: '0o777', eq: '==' } - to_type: Byte|Short|Int|Long # normalized to Byte|Short|Int|Long values: @@ -29,9 +29,9 @@ cases: - to_type: float|double|number # normalized to double values: - - { from_type: 'float', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'float', expr: '3.5f', eq: '==' } + - { from_type: 'double', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number', expr: '1234567e8', eq: '==' } - to_type: Float|Double|Number # normalized to Float|Double values: @@ -41,13 +41,13 @@ cases: - to_type: byte|short|int|long|float|double # normalized to Double values: - - { from_type: 'byte', ref_type: 'Double', expr: '127', eq: '==' } - - { from_type: 'short', ref_type: 'Double', expr: '-7', eq: '==' } - - { from_type: 'int', ref_type: 'Double', expr: '0xCAFE', eq: '==' } - - { from_type: 'long', ref_type: 'Double', expr: '0o777', eq: '==' } - - { from_type: 'float', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'byte', expr: '127', eq: '==' } + - { from_type: 'short', expr: '-7', eq: '==' } + - { from_type: 'int', expr: '0xCAFE', eq: '==' } + - { from_type: 'long', expr: '0o777', eq: '==' } + - { from_type: 'float', expr: '3.5f', eq: '==' } + - { from_type: 'double', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number', expr: '1234567e8', eq: '==' } - to_type: Byte|Short|Int|Long|Float|Double # normalized to Byte|Short|Int|Long|Float|Double values: diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_lmbd/call-lmbd-wd.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_lmbd/call-lmbd-wd.params.yaml index d3b628d7df9a5f2319f3e64a92b82f8f1e638495..e15ee3523b41c881c23fbfe611abfdad46fc9f6c 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_lmbd/call-lmbd-wd.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_lmbd/call-lmbd-wd.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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,9 +15,9 @@ cases: - to_type: byte|short|int|long values: - - { from_type: 'byte|short', ref_type: 'Long', expr: '127', eq: '==' } - - { from_type: 'int|byte', ref_type: 'Long', expr: '-128', eq: '==' } - - { from_type: 'long|short|byte', ref_type: 'Long', expr: '0o777', eq: '==' } + - { from_type: 'byte|short', expr: '127 as byte', eq: '==' } + - { from_type: 'int|byte', expr: '-128', eq: '==' } + - { from_type: 'long|short|byte', expr: '0o777', eq: '==' } - to_type: Byte|Short|Int|Long decl: |- @@ -33,9 +33,9 @@ cases: - to_type: float|double|number values: - - { from_type: 'float|number', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double|float', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number|double', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'float|number', expr: '3.5f', eq: '==' } + - { from_type: 'double|float', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number|double', expr: '1234567e8', eq: '==' } - to_type: Float|Double|Number decl: |- @@ -49,13 +49,13 @@ cases: - to_type: byte|short|int|long|float|double values: - - { from_type: 'byte|float', ref_type: 'Double', expr: '127', eq: '==' } - - { from_type: 'short|int', ref_type: 'Double', expr: '-7', eq: '==' } - - { from_type: 'int|short|byte|double', ref_type: 'Double', expr: '0xCAFE', eq: '==' } - - { from_type: 'long|double', ref_type: 'Double', expr: '0o777', eq: '==' } - - { from_type: 'float|short|double|float', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double|int|long', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number|byte', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'byte|float', expr: '127 as byte', eq: '==' } + - { from_type: 'short|int', expr: '-7', eq: '==' } + - { from_type: 'int|short|byte|double', expr: '0xCAFE', eq: '==' } + - { from_type: 'long|double', expr: '0o777 as long', eq: '==' } + - { from_type: 'float|short|double|float', expr: '3.5f', eq: '==' } + - { from_type: 'double|int|long', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number|byte', expr: '1234567e8', eq: '==' } - to_type: Byte|Short|Int|Long|Float|Double decl: |- diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_meth/call-meth-un.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_meth/call-meth-un.ets index 83048d760e99e8f9c6addf5e9bcc21148361cc53..667f5fc28b962a45b3d1b88924478d87ac8547f4 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_meth/call-meth-un.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_meth/call-meth-un.ets @@ -35,7 +35,7 @@ class Z { function main() { let z: Z = new Z() {%- for t in c['values'] %} - assertTrue( z.meth(s{{loop.index}}) as {{t.ref_type}} {{t.eq}} {{t.expr|safe}} ) + assertTrue( z.meth(s{{loop.index}}) {{'as ' + t.ref_type if t.ref_type}} {{t.eq}} {{t.expr|safe}} ) {%- endfor %} } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_meth/call-meth-un.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_meth/call-meth-un.params.yaml index 8ac559c94593727ecc7dadc240a6a13a3d25e60e..238e2e53f3e803c1457a27bd2f0a495adeef6bb2 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_meth/call-meth-un.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_meth/call-meth-un.params.yaml @@ -15,9 +15,9 @@ cases: - to_type: byte|short|int|long # normalized to Long values: - - { from_type: 'byte', ref_type: 'Long', expr: '127', eq: '==' } - - { from_type: 'short', ref_type: 'Long', expr: '-7', eq: '==' } - - { from_type: 'int', ref_type: 'Long', expr: '0xCAFE', eq: '==' } + - { from_type: 'byte', expr: '127', eq: '==' } + - { from_type: 'short', expr: '-7', eq: '==' } + - { from_type: 'int', expr: '0xCAFE', eq: '==' } - { from_type: 'long', ref_type: 'Long', expr: '0o777', eq: '==' } - to_type: Byte|Short|Int|Long # normalized to Byte|Short|Int|Long @@ -29,7 +29,7 @@ cases: - to_type: float|double|number # normalized to double values: - - { from_type: 'float', ref_type: 'Double', expr: '3.5f', eq: '==' } + - { from_type: 'float', expr: '3.5f', eq: '==' } - { from_type: 'double', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - { from_type: 'number', ref_type: 'Double', expr: '1234567e8', eq: '==' } @@ -41,13 +41,13 @@ cases: - to_type: byte|short|int|long|float|double # normalized to Double values: - - { from_type: 'byte', ref_type: 'Double', expr: '127', eq: '==' } - - { from_type: 'short', ref_type: 'Double', expr: '-7', eq: '==' } - - { from_type: 'int', ref_type: 'Double', expr: '0xCAFE', eq: '==' } - - { from_type: 'long', ref_type: 'Double', expr: '0o777', eq: '==' } - - { from_type: 'float', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'byte', expr: '127', eq: '==' } + - { from_type: 'short', expr: '-7', eq: '==' } + - { from_type: 'int', expr: '0xCAFE', eq: '==' } + - { from_type: 'long', expr: '0o777', eq: '==' } + - { from_type: 'float', expr: '3.5f', eq: '==' } + - { from_type: 'double', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number', expr: '1234567e8', eq: '==' } - to_type: Byte|Short|Int|Long|Float|Double # normalized to Byte|Short|Int|Long|Float|Double values: diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_meth/call-meth-wd.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_meth/call-meth-wd.params.yaml index d3b628d7df9a5f2319f3e64a92b82f8f1e638495..e15ee3523b41c881c23fbfe611abfdad46fc9f6c 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_meth/call-meth-wd.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/call_meth/call-meth-wd.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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,9 +15,9 @@ cases: - to_type: byte|short|int|long values: - - { from_type: 'byte|short', ref_type: 'Long', expr: '127', eq: '==' } - - { from_type: 'int|byte', ref_type: 'Long', expr: '-128', eq: '==' } - - { from_type: 'long|short|byte', ref_type: 'Long', expr: '0o777', eq: '==' } + - { from_type: 'byte|short', expr: '127 as byte', eq: '==' } + - { from_type: 'int|byte', expr: '-128', eq: '==' } + - { from_type: 'long|short|byte', expr: '0o777', eq: '==' } - to_type: Byte|Short|Int|Long decl: |- @@ -33,9 +33,9 @@ cases: - to_type: float|double|number values: - - { from_type: 'float|number', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double|float', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number|double', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'float|number', expr: '3.5f', eq: '==' } + - { from_type: 'double|float', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number|double', expr: '1234567e8', eq: '==' } - to_type: Float|Double|Number decl: |- @@ -49,13 +49,13 @@ cases: - to_type: byte|short|int|long|float|double values: - - { from_type: 'byte|float', ref_type: 'Double', expr: '127', eq: '==' } - - { from_type: 'short|int', ref_type: 'Double', expr: '-7', eq: '==' } - - { from_type: 'int|short|byte|double', ref_type: 'Double', expr: '0xCAFE', eq: '==' } - - { from_type: 'long|double', ref_type: 'Double', expr: '0o777', eq: '==' } - - { from_type: 'float|short|double|float', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double|int|long', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number|byte', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'byte|float', expr: '127 as byte', eq: '==' } + - { from_type: 'short|int', expr: '-7', eq: '==' } + - { from_type: 'int|short|byte|double', expr: '0xCAFE', eq: '==' } + - { from_type: 'long|double', expr: '0o777 as long', eq: '==' } + - { from_type: 'float|short|double|float', expr: '3.5f', eq: '==' } + - { from_type: 'double|int|long', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number|byte', expr: '1234567e8', eq: '==' } - to_type: Byte|Short|Int|Long|Float|Double decl: |- diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_arr/comp-arr-un.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_arr/comp-arr-un.ets index c66dcf8e6f3f14f399637121ca67b27558862023..fa6ac5654a102f841e8fa02d58c4432fcbcc5001 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_arr/comp-arr-un.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_arr/comp-arr-un.ets @@ -32,10 +32,10 @@ type UTA = UT[] function main() { {%- for t in c['values'] %} let d{{loop.index}}: ({{c.to_type}})[] = [s{{loop.index}}, s{{loop.index}}] - assertTrue( d{{loop.index}}[1] as {{t.ref_type}} {{t.eq}} {{t.expr|safe}} ) + assertTrue( d{{loop.index}}[1] {{'as ' + t.ref_type if t.ref_type}} {{t.eq}} {{t.expr|safe}} ) let e{{loop.index}}: UTA = [s{{loop.index}}, s{{loop.index}}, s{{loop.index}}] - assertTrue( e{{loop.index}}[2] as {{t.ref_type}} {{t.eq}} {{t.expr|safe}} ) + assertTrue( e{{loop.index}}[2] {{'as ' + t.ref_type if t.ref_type}} {{t.eq}} {{t.expr|safe}} ) {% endfor %} } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_arr/comp-arr-un.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_arr/comp-arr-un.params.yaml index 8ac559c94593727ecc7dadc240a6a13a3d25e60e..450189ed3a3594e5f34690292af55cfc3691b4a3 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_arr/comp-arr-un.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_arr/comp-arr-un.params.yaml @@ -15,10 +15,10 @@ cases: - to_type: byte|short|int|long # normalized to Long values: - - { from_type: 'byte', ref_type: 'Long', expr: '127', eq: '==' } - - { from_type: 'short', ref_type: 'Long', expr: '-7', eq: '==' } - - { from_type: 'int', ref_type: 'Long', expr: '0xCAFE', eq: '==' } - - { from_type: 'long', ref_type: 'Long', expr: '0o777', eq: '==' } + - { from_type: 'byte', expr: '127', eq: '==' } + - { from_type: 'short', expr: '-7', eq: '==' } + - { from_type: 'int', expr: '0xCAFE', eq: '==' } + - { from_type: 'long', expr: '0o777', eq: '==' } - to_type: Byte|Short|Int|Long # normalized to Byte|Short|Int|Long values: @@ -29,9 +29,9 @@ cases: - to_type: float|double|number # normalized to double values: - - { from_type: 'float', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'float', expr: '3.5f', eq: '==' } + - { from_type: 'double', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number', expr: '1234567e8', eq: '==' } - to_type: Float|Double|Number # normalized to Float|Double values: @@ -41,13 +41,13 @@ cases: - to_type: byte|short|int|long|float|double # normalized to Double values: - - { from_type: 'byte', ref_type: 'Double', expr: '127', eq: '==' } - - { from_type: 'short', ref_type: 'Double', expr: '-7', eq: '==' } - - { from_type: 'int', ref_type: 'Double', expr: '0xCAFE', eq: '==' } - - { from_type: 'long', ref_type: 'Double', expr: '0o777', eq: '==' } - - { from_type: 'float', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'byte', expr: '127', eq: '==' } + - { from_type: 'short', expr: '-7', eq: '==' } + - { from_type: 'int', expr: '0xCAFE', eq: '==' } + - { from_type: 'long', expr: '0o777', eq: '==' } + - { from_type: 'float', expr: '3.5f', eq: '==' } + - { from_type: 'double', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number', expr: '1234567e8', eq: '==' } - to_type: Byte|Short|Int|Long|Float|Double # normalized to Byte|Short|Int|Long|Float|Double values: diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_arr/comp-arr-wd.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_arr/comp-arr-wd.params.yaml index d3b628d7df9a5f2319f3e64a92b82f8f1e638495..e15ee3523b41c881c23fbfe611abfdad46fc9f6c 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_arr/comp-arr-wd.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_arr/comp-arr-wd.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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,9 +15,9 @@ cases: - to_type: byte|short|int|long values: - - { from_type: 'byte|short', ref_type: 'Long', expr: '127', eq: '==' } - - { from_type: 'int|byte', ref_type: 'Long', expr: '-128', eq: '==' } - - { from_type: 'long|short|byte', ref_type: 'Long', expr: '0o777', eq: '==' } + - { from_type: 'byte|short', expr: '127 as byte', eq: '==' } + - { from_type: 'int|byte', expr: '-128', eq: '==' } + - { from_type: 'long|short|byte', expr: '0o777', eq: '==' } - to_type: Byte|Short|Int|Long decl: |- @@ -33,9 +33,9 @@ cases: - to_type: float|double|number values: - - { from_type: 'float|number', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double|float', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number|double', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'float|number', expr: '3.5f', eq: '==' } + - { from_type: 'double|float', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number|double', expr: '1234567e8', eq: '==' } - to_type: Float|Double|Number decl: |- @@ -49,13 +49,13 @@ cases: - to_type: byte|short|int|long|float|double values: - - { from_type: 'byte|float', ref_type: 'Double', expr: '127', eq: '==' } - - { from_type: 'short|int', ref_type: 'Double', expr: '-7', eq: '==' } - - { from_type: 'int|short|byte|double', ref_type: 'Double', expr: '0xCAFE', eq: '==' } - - { from_type: 'long|double', ref_type: 'Double', expr: '0o777', eq: '==' } - - { from_type: 'float|short|double|float', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double|int|long', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number|byte', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'byte|float', expr: '127 as byte', eq: '==' } + - { from_type: 'short|int', expr: '-7', eq: '==' } + - { from_type: 'int|short|byte|double', expr: '0xCAFE', eq: '==' } + - { from_type: 'long|double', expr: '0o777 as long', eq: '==' } + - { from_type: 'float|short|double|float', expr: '3.5f', eq: '==' } + - { from_type: 'double|int|long', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number|byte', expr: '1234567e8', eq: '==' } - to_type: Byte|Short|Int|Long|Float|Double decl: |- diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_obj/comp-obj-un.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_obj/comp-obj-un.ets index 1a7d525a2890d5cc4ae5469582317bf256449222..c0c192b36c83d555211392e43143ce78f3de21e2 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_obj/comp-obj-un.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_obj/comp-obj-un.ets @@ -27,7 +27,7 @@ let s{{loop.index}}: {{t.from_type}} = {{t.expr|safe}}; {%- endfor %} class Z { - fld: {{c.to_type}} {%- if c.init_value is defined %} = {{c.init_value}}{%- endif %} + fld?: {{c.to_type}} {%- if c.init_value is defined %} = {{c.init_value}}{%- endif %} } function main() { diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_obj/comp-obj-un.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_obj/comp-obj-un.params.yaml index 5662c75dc02a9f576e470e7624a33e3d4c88759f..ef1ff9d97f0d097d2632dbd6268c4cb9ec32aa13 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_obj/comp-obj-un.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_obj/comp-obj-un.params.yaml @@ -15,10 +15,10 @@ cases: - to_type: byte|short|int|long # normalized to Long values: - - { from_type: 'byte', ref_type: 'Long', expr: '127', eq: '==' } - - { from_type: 'short', ref_type: 'Long', expr: '-7', eq: '==' } - - { from_type: 'int', ref_type: 'Long', expr: '0xCAFE', eq: '==' } - - { from_type: 'long', ref_type: 'Long', expr: '0o777', eq: '==' } + - { from_type: 'byte', ref_type: 'Byte', expr: '127', eq: '==' } + - { from_type: 'short', ref_type: 'Short', expr: '-7', eq: '==' } + - { from_type: 'int', ref_type: 'Int', expr: '0xCAFE', eq: '==' } + - { from_type: 'long', ref_type: 'Long', expr: '0o777', eq: '==' } - to_type: Byte|Short|Int|Long # normalized to Byte|Short|Int|Long init_value: 0 diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_obj/comp-obj-wd.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_obj/comp-obj-wd.ets index 6e4d76e63cf161451d35db1891714ee6380491dc..8fc7d791a13a91df7093ee4a27771bd41464c882 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_obj/comp-obj-wd.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_obj/comp-obj-wd.ets @@ -27,7 +27,7 @@ let s{{loop.index}}: {{t.from_type}} = {{t.expr|safe}}; {%- endfor %} class Z { - fld: {{c.to_type}} {%- if c.init_value is defined %} = {{c.init_value}}{%- endif %} + fld?: {{c.to_type}} {%- if c.init_value is defined %} = {{c.init_value}}{%- endif %} } function main() { diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_obj/comp-obj-wd.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_obj/comp-obj-wd.params.yaml index 97a9d32a3b616d9fee7b0b23ca93a970823aad18..d1f32ba7a9119daa570f7ce3f075c8bfc69b6144 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_obj/comp-obj-wd.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_obj/comp-obj-wd.params.yaml @@ -15,9 +15,9 @@ cases: - to_type: byte|short|int|long values: - - { from_type: 'byte|short', ref_type: 'Long', expr: '127', eq: '==' } - - { from_type: 'int|byte', ref_type: 'Long', expr: '-128', eq: '==' } - - { from_type: 'long|short|byte', ref_type: 'Long', expr: '0o777', eq: '==' } + - { from_type: 'byte|short', expr: '127 as byte', eq: '==' } + - { from_type: 'int|byte', expr: '-128', eq: '==' } + - { from_type: 'long|short|byte', expr: '0o777', eq: '==' } - to_type: Byte|Short|Int|Long init_value: 0 @@ -34,9 +34,9 @@ cases: - to_type: float|double|number values: - - { from_type: 'float|number', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double|float', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number|double', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'float|number', expr: '3.5f', eq: '==' } + - { from_type: 'double|float', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number|double', expr: '1234567e8', eq: '==' } - to_type: Float|Double|Number init_value: 0.0 @@ -51,13 +51,13 @@ cases: - to_type: byte|short|int|long|float|double values: - - { from_type: 'byte|float', ref_type: 'Double', expr: '127', eq: '==' } - - { from_type: 'short|int', ref_type: 'Double', expr: '-7', eq: '==' } - - { from_type: 'int|short|byte|double', ref_type: 'Double', expr: '0xCAFE', eq: '==' } - - { from_type: 'long|double', ref_type: 'Double', expr: '0o777', eq: '==' } - - { from_type: 'float|short|double|float', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double|int|long', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number|byte', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'byte|float', expr: '127 as byte', eq: '==' } + - { from_type: 'short|int', expr: '-7', eq: '==' } + - { from_type: 'int|short|byte|double', expr: '0xCAFE', eq: '==' } + - { from_type: 'long|double', expr: '0o777 as long', eq: '==' } + - { from_type: 'float|short|double|float', expr: '3.5f', eq: '==' } + - { from_type: 'double|int|long', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number|byte', expr: '1234567e8', eq: '==' } - to_type: Byte|Short|Int|Long|Float|Double init_value: 0 diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_field/decl-field-un.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_field/decl-field-un.ets index 613170f5b32812f37fefa639e6e963718b0eeab5..905d768f6d3b72872a1d9e652cfa1902dce6f7e4 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_field/decl-field-un.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_field/decl-field-un.ets @@ -27,7 +27,7 @@ let s{{loop.index}}: {{t.from_type}} = {{t.expr|safe}}; {%- endfor %} class Z { - fld: {{c.to_type}} {%- if c.init_value is defined %} = {{c.init_value}}{%- endif %} + fld?: {{c.to_type}} {%- if c.init_value is defined %} = {{c.init_value}}{%- endif %} } function main() { diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_field/decl-field-un.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_field/decl-field-un.params.yaml index 5662c75dc02a9f576e470e7624a33e3d4c88759f..f1d71435349adbb05f404d2d4c58d997101264d3 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_field/decl-field-un.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_field/decl-field-un.params.yaml @@ -15,9 +15,9 @@ cases: - to_type: byte|short|int|long # normalized to Long values: - - { from_type: 'byte', ref_type: 'Long', expr: '127', eq: '==' } - - { from_type: 'short', ref_type: 'Long', expr: '-7', eq: '==' } - - { from_type: 'int', ref_type: 'Long', expr: '0xCAFE', eq: '==' } + - { from_type: 'byte', ref_type: 'Byte', expr: '127', eq: '==' } + - { from_type: 'short', ref_type: 'Short', expr: '-7', eq: '==' } + - { from_type: 'int', ref_type: 'Int', expr: '0xCAFE', eq: '==' } - { from_type: 'long', ref_type: 'Long', expr: '0o777', eq: '==' } - to_type: Byte|Short|Int|Long # normalized to Byte|Short|Int|Long diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_field/decl-field-wd.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_field/decl-field-wd.ets index 39da439d298ab1e121eb1856c5bde93e5e8a7293..ebeaefdb4ebd50c2360314d9f2b1af076e1f4284 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_field/decl-field-wd.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_field/decl-field-wd.ets @@ -27,7 +27,7 @@ let s{{loop.index}}: {{t.from_type}} = {{t.expr|safe}}; {%- endfor %} class Z { - fld: {{c.to_type}} {%- if c.init_value is defined %} = {{c.init_value}}{%- endif %} + fld?: {{c.to_type}} {%- if c.init_value is defined %} = {{c.init_value}}{%- endif %} } function main() { diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_field/decl-field-wd.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_field/decl-field-wd.params.yaml index f0e41628c9bec3ee49d5a6f203b919864453447f..b33d973889feddfbf350bd7774701ec60f1b6aa8 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_field/decl-field-wd.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_field/decl-field-wd.params.yaml @@ -15,9 +15,9 @@ cases: - to_type: byte|short|int|long values: - - { from_type: 'byte|short', ref_type: 'Long', expr: '127', eq: '==' } - - { from_type: 'int|byte', ref_type: 'Long', expr: '-128', eq: '==' } - - { from_type: 'long|short|byte', ref_type: 'Long', expr: '0o777', eq: '==' } + - { from_type: 'byte|short', expr: '127 as byte', eq: '==' } + - { from_type: 'int|byte', expr: '-128', eq: '==' } + - { from_type: 'long|short|byte', expr: '0o777', eq: '==' } - to_type: Byte|Short|Int|Long init_value: 0 @@ -34,9 +34,9 @@ cases: - to_type: float|double|number values: - - { from_type: 'float|number', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double|float', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number|double', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'float|number', expr: '3.5f', eq: '==' } + - { from_type: 'double|float', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number|double', expr: '1234567e8', eq: '==' } - to_type: Float|Double|Number init_value: 0.0 @@ -51,13 +51,13 @@ cases: - to_type: byte|short|int|long|float|double values: - - { from_type: 'byte|float', ref_type: 'Double', expr: '127', eq: '==' } - - { from_type: 'short|int', ref_type: 'Double', expr: '-7', eq: '==' } - - { from_type: 'int|short|byte|double', ref_type: 'Double', expr: '0xCAFE', eq: '==' } - - { from_type: 'long|double', ref_type: 'Double', expr: '0o777', eq: '==' } - - { from_type: 'float|short|double|float', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double|int|long', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number|byte', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'byte|float', expr: '127 as byte', eq: '==' } + - { from_type: 'short|int', expr: '-7', eq: '==' } + - { from_type: 'int|short|byte|double', expr: '0xCAFE', eq: '==' } + - { from_type: 'long|double', expr: '0o777 as long', eq: '==' } + - { from_type: 'float|short|double|float', expr: '3.5f', eq: '==' } + - { from_type: 'double|int|long', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number|byte', expr: '1234567e8', eq: '==' } - to_type: Byte|Short|Int|Long|Float|Double init_value: 0 diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_var/decl-var-un.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_var/decl-var-un.ets index 40f28a5ea86cbdf9698d91248bbb314e43870fc9..6a423c3772a77c4639a21962553a9833d436eb13 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_var/decl-var-un.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_var/decl-var-un.ets @@ -29,10 +29,10 @@ let s{{loop.index}}: {{t.from_type}} = {{t.expr|safe}}; function main() { {%- for t in c['values'] %} let d{{loop.index}}: {{c.to_type}} = s{{loop.index}} - assertTrue( d{{loop.index}} as {{t.ref_type}} {{t.eq}} {{t.expr|safe}} ) + assertTrue( d{{loop.index}} {{'as ' + t.ref_type if t.ref_type}} {{t.eq}} {{t.expr|safe}} ) const c{{loop.index}}: {{c.to_type}} = s{{loop.index}} - assertTrue( c{{loop.index}} as {{t.ref_type}} {{t.eq}} {{t.expr|safe}} ) + assertTrue( c{{loop.index}} {{'as ' + t.ref_type if t.ref_type}} {{t.eq}} {{t.expr|safe}} ) {% endfor %} } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_var/decl-var-un.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_var/decl-var-un.params.yaml index 8ac559c94593727ecc7dadc240a6a13a3d25e60e..23f845f9d0b7d9ae1b0f63fc1f338bf47cc365f1 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_var/decl-var-un.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_var/decl-var-un.params.yaml @@ -15,10 +15,10 @@ cases: - to_type: byte|short|int|long # normalized to Long values: - - { from_type: 'byte', ref_type: 'Long', expr: '127', eq: '==' } - - { from_type: 'short', ref_type: 'Long', expr: '-7', eq: '==' } - - { from_type: 'int', ref_type: 'Long', expr: '0xCAFE', eq: '==' } - - { from_type: 'long', ref_type: 'Long', expr: '0o777', eq: '==' } + - { from_type: 'byte', expr: '127', eq: '==' } + - { from_type: 'short', expr: '-7', eq: '==' } + - { from_type: 'int', expr: '0xCAFE', eq: '==' } + - { from_type: 'long', expr: '0o777', eq: '==' } - to_type: Byte|Short|Int|Long # normalized to Byte|Short|Int|Long values: @@ -29,7 +29,7 @@ cases: - to_type: float|double|number # normalized to double values: - - { from_type: 'float', ref_type: 'Double', expr: '3.5f', eq: '==' } + - { from_type: 'float', expr: '3.5f', eq: '==' } - { from_type: 'double', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - { from_type: 'number', ref_type: 'Double', expr: '1234567e8', eq: '==' } @@ -41,11 +41,11 @@ cases: - to_type: byte|short|int|long|float|double # normalized to Double values: - - { from_type: 'byte', ref_type: 'Double', expr: '127', eq: '==' } - - { from_type: 'short', ref_type: 'Double', expr: '-7', eq: '==' } - - { from_type: 'int', ref_type: 'Double', expr: '0xCAFE', eq: '==' } - - { from_type: 'long', ref_type: 'Double', expr: '0o777', eq: '==' } - - { from_type: 'float', ref_type: 'Double', expr: '3.5f', eq: '==' } + - { from_type: 'byte', expr: '127', eq: '==' } + - { from_type: 'short', expr: '-7', eq: '==' } + - { from_type: 'int', expr: '0xCAFE', eq: '==' } + - { from_type: 'long', expr: '0o777', eq: '==' } + - { from_type: 'float', expr: '3.5f', eq: '==' } - { from_type: 'double', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - { from_type: 'number', ref_type: 'Double', expr: '1234567e8', eq: '==' } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_var/decl-var-wd.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_var/decl-var-wd.params.yaml index d3b628d7df9a5f2319f3e64a92b82f8f1e638495..e15ee3523b41c881c23fbfe611abfdad46fc9f6c 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_var/decl-var-wd.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_var/decl-var-wd.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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,9 +15,9 @@ cases: - to_type: byte|short|int|long values: - - { from_type: 'byte|short', ref_type: 'Long', expr: '127', eq: '==' } - - { from_type: 'int|byte', ref_type: 'Long', expr: '-128', eq: '==' } - - { from_type: 'long|short|byte', ref_type: 'Long', expr: '0o777', eq: '==' } + - { from_type: 'byte|short', expr: '127 as byte', eq: '==' } + - { from_type: 'int|byte', expr: '-128', eq: '==' } + - { from_type: 'long|short|byte', expr: '0o777', eq: '==' } - to_type: Byte|Short|Int|Long decl: |- @@ -33,9 +33,9 @@ cases: - to_type: float|double|number values: - - { from_type: 'float|number', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double|float', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number|double', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'float|number', expr: '3.5f', eq: '==' } + - { from_type: 'double|float', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number|double', expr: '1234567e8', eq: '==' } - to_type: Float|Double|Number decl: |- @@ -49,13 +49,13 @@ cases: - to_type: byte|short|int|long|float|double values: - - { from_type: 'byte|float', ref_type: 'Double', expr: '127', eq: '==' } - - { from_type: 'short|int', ref_type: 'Double', expr: '-7', eq: '==' } - - { from_type: 'int|short|byte|double', ref_type: 'Double', expr: '0xCAFE', eq: '==' } - - { from_type: 'long|double', ref_type: 'Double', expr: '0o777', eq: '==' } - - { from_type: 'float|short|double|float', ref_type: 'Double', expr: '3.5f', eq: '==' } - - { from_type: 'double|int|long', ref_type: 'Double', expr: '-1.1E-20', eq: '==' } - - { from_type: 'number|byte', ref_type: 'Double', expr: '1234567e8', eq: '==' } + - { from_type: 'byte|float', expr: '127 as byte', eq: '==' } + - { from_type: 'short|int', expr: '-7', eq: '==' } + - { from_type: 'int|short|byte|double', expr: '0xCAFE', eq: '==' } + - { from_type: 'long|double', expr: '0o777 as long', eq: '==' } + - { from_type: 'float|short|double|float', expr: '3.5f', eq: '==' } + - { from_type: 'double|int|long', expr: '-1.1E-20', eq: '==' } + - { from_type: 'number|byte', expr: '1234567e8', eq: '==' } - to_type: Byte|Short|Int|Long|Float|Double decl: |- diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/assn_var/assn-var.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/assn_var/assn-var.params.yaml index 9dda7eb2929bd3532e7d29c45d5b1cb075cdf308..9020a840ef291dd1a06cff85a59c35c4b5f49dd9 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/assn_var/assn-var.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/assn_var/assn-var.params.yaml @@ -22,35 +22,35 @@ cases: - from_type: Short values: - - { to_type: Integral, expr: new Short(Byte.MAX_VALUE as short) } - - { to_type: Numeric, expr: new Short(Byte.MIN_VALUE as short) } + - { to_type: Integral, expr: new Short(Byte.MAX_VALUE.toShort()) } + - { to_type: Numeric, expr: new Short(Byte.MIN_VALUE.toShort()) } - { to_type: Object, expr: new Short() } - { to_type: Comparable, expr: new Short() } - from_type: Int values: - - { to_type: Integral, expr: new Int(Byte.MAX_VALUE as int) } - - { to_type: Numeric, expr: new Int(Byte.MIN_VALUE as int) } + - { to_type: Integral, expr: new Int(Byte.MAX_VALUE.toInt()) } + - { to_type: Numeric, expr: new Int(Byte.MIN_VALUE.toInt()) } - { to_type: Object, expr: new Int() } - { to_type: Comparable, expr: new Int() } - from_type: Long values: - - { to_type: Integral, expr: new Long(Byte.MAX_VALUE as long) } - - { to_type: Numeric, expr: new Long(Byte.MIN_VALUE as long) } + - { to_type: Integral, expr: new Long(Byte.MAX_VALUE.toLong()) } + - { to_type: Numeric, expr: new Long(Byte.MIN_VALUE.toLong()) } - { to_type: Object, expr: new Long() } - { to_type: Comparable, expr: new Long() } - from_type: Float values: - - { to_type: Floating, expr: new Float(Byte.MIN_VALUE as float) } + - { to_type: Floating, expr: new Float(Byte.MIN_VALUE.toFloat()) } - { to_type: Numeric, expr: new Float(-0.0 as float) } - { to_type: Object, expr: new Float(+0.0 as float) } - { to_type: Comparable, expr: new Float(+0.0 as float) } - from_type: Double values: - - { to_type: Floating, expr: new Double(Byte.MIN_VALUE as double) } + - { to_type: Floating, expr: new Double(Byte.MIN_VALUE.toDouble()) } - { to_type: Numeric, expr: new Double(-0.0 as float) } - { to_type: Object, expr: new Double(+0.0 as float) } - { to_type: Comparable, expr: new Double(+0.0 as float) } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/call_cons/call-cons.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/call_cons/call-cons.params.yaml index 9dda7eb2929bd3532e7d29c45d5b1cb075cdf308..9020a840ef291dd1a06cff85a59c35c4b5f49dd9 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/call_cons/call-cons.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/call_cons/call-cons.params.yaml @@ -22,35 +22,35 @@ cases: - from_type: Short values: - - { to_type: Integral, expr: new Short(Byte.MAX_VALUE as short) } - - { to_type: Numeric, expr: new Short(Byte.MIN_VALUE as short) } + - { to_type: Integral, expr: new Short(Byte.MAX_VALUE.toShort()) } + - { to_type: Numeric, expr: new Short(Byte.MIN_VALUE.toShort()) } - { to_type: Object, expr: new Short() } - { to_type: Comparable, expr: new Short() } - from_type: Int values: - - { to_type: Integral, expr: new Int(Byte.MAX_VALUE as int) } - - { to_type: Numeric, expr: new Int(Byte.MIN_VALUE as int) } + - { to_type: Integral, expr: new Int(Byte.MAX_VALUE.toInt()) } + - { to_type: Numeric, expr: new Int(Byte.MIN_VALUE.toInt()) } - { to_type: Object, expr: new Int() } - { to_type: Comparable, expr: new Int() } - from_type: Long values: - - { to_type: Integral, expr: new Long(Byte.MAX_VALUE as long) } - - { to_type: Numeric, expr: new Long(Byte.MIN_VALUE as long) } + - { to_type: Integral, expr: new Long(Byte.MAX_VALUE.toLong()) } + - { to_type: Numeric, expr: new Long(Byte.MIN_VALUE.toLong()) } - { to_type: Object, expr: new Long() } - { to_type: Comparable, expr: new Long() } - from_type: Float values: - - { to_type: Floating, expr: new Float(Byte.MIN_VALUE as float) } + - { to_type: Floating, expr: new Float(Byte.MIN_VALUE.toFloat()) } - { to_type: Numeric, expr: new Float(-0.0 as float) } - { to_type: Object, expr: new Float(+0.0 as float) } - { to_type: Comparable, expr: new Float(+0.0 as float) } - from_type: Double values: - - { to_type: Floating, expr: new Double(Byte.MIN_VALUE as double) } + - { to_type: Floating, expr: new Double(Byte.MIN_VALUE.toDouble()) } - { to_type: Numeric, expr: new Double(-0.0 as float) } - { to_type: Object, expr: new Double(+0.0 as float) } - { to_type: Comparable, expr: new Double(+0.0 as float) } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/call_func/call-func.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/call_func/call-func.params.yaml index 9dda7eb2929bd3532e7d29c45d5b1cb075cdf308..9020a840ef291dd1a06cff85a59c35c4b5f49dd9 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/call_func/call-func.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/call_func/call-func.params.yaml @@ -22,35 +22,35 @@ cases: - from_type: Short values: - - { to_type: Integral, expr: new Short(Byte.MAX_VALUE as short) } - - { to_type: Numeric, expr: new Short(Byte.MIN_VALUE as short) } + - { to_type: Integral, expr: new Short(Byte.MAX_VALUE.toShort()) } + - { to_type: Numeric, expr: new Short(Byte.MIN_VALUE.toShort()) } - { to_type: Object, expr: new Short() } - { to_type: Comparable, expr: new Short() } - from_type: Int values: - - { to_type: Integral, expr: new Int(Byte.MAX_VALUE as int) } - - { to_type: Numeric, expr: new Int(Byte.MIN_VALUE as int) } + - { to_type: Integral, expr: new Int(Byte.MAX_VALUE.toInt()) } + - { to_type: Numeric, expr: new Int(Byte.MIN_VALUE.toInt()) } - { to_type: Object, expr: new Int() } - { to_type: Comparable, expr: new Int() } - from_type: Long values: - - { to_type: Integral, expr: new Long(Byte.MAX_VALUE as long) } - - { to_type: Numeric, expr: new Long(Byte.MIN_VALUE as long) } + - { to_type: Integral, expr: new Long(Byte.MAX_VALUE.toLong()) } + - { to_type: Numeric, expr: new Long(Byte.MIN_VALUE.toLong()) } - { to_type: Object, expr: new Long() } - { to_type: Comparable, expr: new Long() } - from_type: Float values: - - { to_type: Floating, expr: new Float(Byte.MIN_VALUE as float) } + - { to_type: Floating, expr: new Float(Byte.MIN_VALUE.toFloat()) } - { to_type: Numeric, expr: new Float(-0.0 as float) } - { to_type: Object, expr: new Float(+0.0 as float) } - { to_type: Comparable, expr: new Float(+0.0 as float) } - from_type: Double values: - - { to_type: Floating, expr: new Double(Byte.MIN_VALUE as double) } + - { to_type: Floating, expr: new Double(Byte.MIN_VALUE.toDouble()) } - { to_type: Numeric, expr: new Double(-0.0 as float) } - { to_type: Object, expr: new Double(+0.0 as float) } - { to_type: Comparable, expr: new Double(+0.0 as float) } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/call_lmbd/call-lmbd.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/call_lmbd/call-lmbd.params.yaml index 9dda7eb2929bd3532e7d29c45d5b1cb075cdf308..9020a840ef291dd1a06cff85a59c35c4b5f49dd9 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/call_lmbd/call-lmbd.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/call_lmbd/call-lmbd.params.yaml @@ -22,35 +22,35 @@ cases: - from_type: Short values: - - { to_type: Integral, expr: new Short(Byte.MAX_VALUE as short) } - - { to_type: Numeric, expr: new Short(Byte.MIN_VALUE as short) } + - { to_type: Integral, expr: new Short(Byte.MAX_VALUE.toShort()) } + - { to_type: Numeric, expr: new Short(Byte.MIN_VALUE.toShort()) } - { to_type: Object, expr: new Short() } - { to_type: Comparable, expr: new Short() } - from_type: Int values: - - { to_type: Integral, expr: new Int(Byte.MAX_VALUE as int) } - - { to_type: Numeric, expr: new Int(Byte.MIN_VALUE as int) } + - { to_type: Integral, expr: new Int(Byte.MAX_VALUE.toInt()) } + - { to_type: Numeric, expr: new Int(Byte.MIN_VALUE.toInt()) } - { to_type: Object, expr: new Int() } - { to_type: Comparable, expr: new Int() } - from_type: Long values: - - { to_type: Integral, expr: new Long(Byte.MAX_VALUE as long) } - - { to_type: Numeric, expr: new Long(Byte.MIN_VALUE as long) } + - { to_type: Integral, expr: new Long(Byte.MAX_VALUE.toLong()) } + - { to_type: Numeric, expr: new Long(Byte.MIN_VALUE.toLong()) } - { to_type: Object, expr: new Long() } - { to_type: Comparable, expr: new Long() } - from_type: Float values: - - { to_type: Floating, expr: new Float(Byte.MIN_VALUE as float) } + - { to_type: Floating, expr: new Float(Byte.MIN_VALUE.toFloat()) } - { to_type: Numeric, expr: new Float(-0.0 as float) } - { to_type: Object, expr: new Float(+0.0 as float) } - { to_type: Comparable, expr: new Float(+0.0 as float) } - from_type: Double values: - - { to_type: Floating, expr: new Double(Byte.MIN_VALUE as double) } + - { to_type: Floating, expr: new Double(Byte.MIN_VALUE.toDouble()) } - { to_type: Numeric, expr: new Double(-0.0 as float) } - { to_type: Object, expr: new Double(+0.0 as float) } - { to_type: Comparable, expr: new Double(+0.0 as float) } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/call_meth/call-meth.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/call_meth/call-meth.params.yaml index 9dda7eb2929bd3532e7d29c45d5b1cb075cdf308..9020a840ef291dd1a06cff85a59c35c4b5f49dd9 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/call_meth/call-meth.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/call_meth/call-meth.params.yaml @@ -22,35 +22,35 @@ cases: - from_type: Short values: - - { to_type: Integral, expr: new Short(Byte.MAX_VALUE as short) } - - { to_type: Numeric, expr: new Short(Byte.MIN_VALUE as short) } + - { to_type: Integral, expr: new Short(Byte.MAX_VALUE.toShort()) } + - { to_type: Numeric, expr: new Short(Byte.MIN_VALUE.toShort()) } - { to_type: Object, expr: new Short() } - { to_type: Comparable, expr: new Short() } - from_type: Int values: - - { to_type: Integral, expr: new Int(Byte.MAX_VALUE as int) } - - { to_type: Numeric, expr: new Int(Byte.MIN_VALUE as int) } + - { to_type: Integral, expr: new Int(Byte.MAX_VALUE.toInt()) } + - { to_type: Numeric, expr: new Int(Byte.MIN_VALUE.toInt()) } - { to_type: Object, expr: new Int() } - { to_type: Comparable, expr: new Int() } - from_type: Long values: - - { to_type: Integral, expr: new Long(Byte.MAX_VALUE as long) } - - { to_type: Numeric, expr: new Long(Byte.MIN_VALUE as long) } + - { to_type: Integral, expr: new Long(Byte.MAX_VALUE.toLong()) } + - { to_type: Numeric, expr: new Long(Byte.MIN_VALUE.toLong()) } - { to_type: Object, expr: new Long() } - { to_type: Comparable, expr: new Long() } - from_type: Float values: - - { to_type: Floating, expr: new Float(Byte.MIN_VALUE as float) } + - { to_type: Floating, expr: new Float(Byte.MIN_VALUE.toFloat()) } - { to_type: Numeric, expr: new Float(-0.0 as float) } - { to_type: Object, expr: new Float(+0.0 as float) } - { to_type: Comparable, expr: new Float(+0.0 as float) } - from_type: Double values: - - { to_type: Floating, expr: new Double(Byte.MIN_VALUE as double) } + - { to_type: Floating, expr: new Double(Byte.MIN_VALUE.toDouble()) } - { to_type: Numeric, expr: new Double(-0.0 as float) } - { to_type: Object, expr: new Double(+0.0 as float) } - { to_type: Comparable, expr: new Double(+0.0 as float) } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/comp_arr/comp-arr.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/comp_arr/comp-arr.params.yaml index 29fefb9fbdfac865ea7fbd57e76d7db8a69ab8e8..1643b2e0c01bcbe0384545f589bcbb87295fff89 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/comp_arr/comp-arr.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/comp_arr/comp-arr.params.yaml @@ -22,35 +22,35 @@ cases: - from_type: Short values: - - { to_type: Integral, expr: new Short(Byte.MAX_VALUE as short) } - - { to_type: Numeric, expr: new Short(Byte.MIN_VALUE as short) } + - { to_type: Integral, expr: new Short(Byte.MAX_VALUE.toShort()) } + - { to_type: Numeric, expr: new Short(Byte.MIN_VALUE.toShort()) } - { to_type: Object, expr: new Short() } - { to_type: Comparable, expr: new Short() } - from_type: Int values: - - { to_type: Integral, expr: new Int(Byte.MAX_VALUE as int) } - - { to_type: Numeric, expr: new Int(Byte.MIN_VALUE as int) } + - { to_type: Integral, expr: new Int(Byte.MAX_VALUE.toInt()) } + - { to_type: Numeric, expr: new Int(Byte.MIN_VALUE.toInt()) } - { to_type: Object, expr: new Int() } - { to_type: Comparable, expr: new Int() } - from_type: Long values: - - { to_type: Integral, expr: new Long(Byte.MAX_VALUE as long) } - - { to_type: Numeric, expr: new Long(Byte.MIN_VALUE as long) } + - { to_type: Integral, expr: new Long(Byte.MAX_VALUE.toLong()) } + - { to_type: Numeric, expr: new Long(Byte.MIN_VALUE.toLong()) } - { to_type: Object, expr: new Long() } - { to_type: Comparable, expr: new Long() } - from_type: Float values: - - { to_type: Floating, expr: new Float(Byte.MIN_VALUE as float) } + - { to_type: Floating, expr: new Float(Byte.MIN_VALUE.toFloat()) } - { to_type: Numeric, expr: new Float(-0.0 as float) } - { to_type: Object, expr: new Float(+0.0 as float) } - { to_type: Comparable, expr: new Float(+0.0 as float) } - from_type: Double values: - - { to_type: Floating, expr: new Double(Byte.MIN_VALUE as double) } + - { to_type: Floating, expr: new Double(Byte.MIN_VALUE.toDouble()) } - { to_type: Numeric, expr: new Double(-0.0 as float) } - { to_type: Object, expr: new Double(+0.0 as float) } - { to_type: Comparable, expr: new Double(+0.0 as float) } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/comp_obj/comp-clss.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/comp_obj/comp-clss.params.yaml index 7793ae644cd01d37be248bf609d57b12367dfea2..0551a42405c082000ce3cc39537e1773f15cb754 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/comp_obj/comp-clss.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/comp_obj/comp-clss.params.yaml @@ -22,35 +22,35 @@ cases: - from_type: Short values: - - { to_type: Integral, init_value: 0, expr: new Short(Byte.MAX_VALUE as short) } - - { to_type: Numeric, init_value: 0, expr: new Short(Byte.MIN_VALUE as short) } + - { to_type: Integral, init_value: 0, expr: new Short(Byte.MAX_VALUE.toShort()) } + - { to_type: Numeric, init_value: 0, expr: new Short(Byte.MIN_VALUE.toShort()) } - { to_type: Object, init_value: new Object(), expr: new Short() } - { to_type: Comparable, init_value: new Short(), expr: new Short() } - from_type: Int values: - - { to_type: Integral, init_value: 0, expr: new Int(Byte.MAX_VALUE as int) } - - { to_type: Numeric, init_value: 0, expr: new Int(Byte.MIN_VALUE as int) } + - { to_type: Integral, init_value: 0, expr: new Int(Byte.MAX_VALUE.toInt()) } + - { to_type: Numeric, init_value: 0, expr: new Int(Byte.MIN_VALUE.toInt()) } - { to_type: Object, init_value: new Object(), expr: new Int() } - { to_type: Comparable, init_value: new Int(), expr: new Int() } - from_type: Long values: - - { to_type: Integral, init_value: 0, expr: new Long(Byte.MAX_VALUE as long) } - - { to_type: Numeric, init_value: 0, expr: new Long(Byte.MIN_VALUE as long) } + - { to_type: Integral, init_value: 0, expr: new Long(Byte.MAX_VALUE.toLong()) } + - { to_type: Numeric, init_value: 0, expr: new Long(Byte.MIN_VALUE.toLong()) } - { to_type: Object, init_value: new Object(), expr: new Long() } - { to_type: Comparable, init_value: new Long(), expr: new Long() } - from_type: Float values: - - { to_type: Floating, init_value: 0.0, expr: new Float(Byte.MIN_VALUE as float) } + - { to_type: Floating, init_value: 0.0, expr: new Float(Byte.MIN_VALUE.toFloat()) } - { to_type: Numeric, init_value: 0, expr: new Float(-0.0 as float) } - { to_type: Object, init_value: new Object(), expr: new Float(+0.0 as float) } - { to_type: Comparable, init_value: new Float(), expr: new Float(+0.0 as float) } - from_type: Double values: - - { to_type: Floating, init_value: 0.0, expr: new Double(Byte.MIN_VALUE as double) } + - { to_type: Floating, init_value: 0.0, expr: new Double(Byte.MIN_VALUE.toDouble()) } - { to_type: Numeric, init_value: 0, expr: new Double(-0.0 as float) } - { to_type: Object, init_value: new Object(), expr: new Double(+0.0 as float) } - { to_type: Comparable, init_value: new Double(), expr: new Double(+0.0 as float) } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/comp_obj/comp-intf.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/comp_obj/comp-intf.params.yaml index 9dda7eb2929bd3532e7d29c45d5b1cb075cdf308..9020a840ef291dd1a06cff85a59c35c4b5f49dd9 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/comp_obj/comp-intf.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/comp_obj/comp-intf.params.yaml @@ -22,35 +22,35 @@ cases: - from_type: Short values: - - { to_type: Integral, expr: new Short(Byte.MAX_VALUE as short) } - - { to_type: Numeric, expr: new Short(Byte.MIN_VALUE as short) } + - { to_type: Integral, expr: new Short(Byte.MAX_VALUE.toShort()) } + - { to_type: Numeric, expr: new Short(Byte.MIN_VALUE.toShort()) } - { to_type: Object, expr: new Short() } - { to_type: Comparable, expr: new Short() } - from_type: Int values: - - { to_type: Integral, expr: new Int(Byte.MAX_VALUE as int) } - - { to_type: Numeric, expr: new Int(Byte.MIN_VALUE as int) } + - { to_type: Integral, expr: new Int(Byte.MAX_VALUE.toInt()) } + - { to_type: Numeric, expr: new Int(Byte.MIN_VALUE.toInt()) } - { to_type: Object, expr: new Int() } - { to_type: Comparable, expr: new Int() } - from_type: Long values: - - { to_type: Integral, expr: new Long(Byte.MAX_VALUE as long) } - - { to_type: Numeric, expr: new Long(Byte.MIN_VALUE as long) } + - { to_type: Integral, expr: new Long(Byte.MAX_VALUE.toLong()) } + - { to_type: Numeric, expr: new Long(Byte.MIN_VALUE.toLong()) } - { to_type: Object, expr: new Long() } - { to_type: Comparable, expr: new Long() } - from_type: Float values: - - { to_type: Floating, expr: new Float(Byte.MIN_VALUE as float) } + - { to_type: Floating, expr: new Float(Byte.MIN_VALUE.toFloat()) } - { to_type: Numeric, expr: new Float(-0.0 as float) } - { to_type: Object, expr: new Float(+0.0 as float) } - { to_type: Comparable, expr: new Float(+0.0 as float) } - from_type: Double values: - - { to_type: Floating, expr: new Double(Byte.MIN_VALUE as double) } + - { to_type: Floating, expr: new Double(Byte.MIN_VALUE.toDouble()) } - { to_type: Numeric, expr: new Double(-0.0 as float) } - { to_type: Object, expr: new Double(+0.0 as float) } - { to_type: Comparable, expr: new Double(+0.0 as float) } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/decl_const/decl-const.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/decl_const/decl-const.params.yaml index 9dda7eb2929bd3532e7d29c45d5b1cb075cdf308..2894b66feb060153216f6c2187851a453c571e20 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/decl_const/decl-const.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/decl_const/decl-const.params.yaml @@ -22,38 +22,38 @@ cases: - from_type: Short values: - - { to_type: Integral, expr: new Short(Byte.MAX_VALUE as short) } - - { to_type: Numeric, expr: new Short(Byte.MIN_VALUE as short) } + - { to_type: Integral, expr: new Short(Byte.MAX_VALUE.toShort()) } + - { to_type: Numeric, expr: new Short(Byte.MIN_VALUE.toShort()) } - { to_type: Object, expr: new Short() } - { to_type: Comparable, expr: new Short() } - from_type: Int values: - - { to_type: Integral, expr: new Int(Byte.MAX_VALUE as int) } - - { to_type: Numeric, expr: new Int(Byte.MIN_VALUE as int) } + - { to_type: Integral, expr: new Int(Byte.MAX_VALUE.toInt()) } + - { to_type: Numeric, expr: new Int(Byte.MIN_VALUE.toInt()) } - { to_type: Object, expr: new Int() } - { to_type: Comparable, expr: new Int() } - from_type: Long values: - - { to_type: Integral, expr: new Long(Byte.MAX_VALUE as long) } - - { to_type: Numeric, expr: new Long(Byte.MIN_VALUE as long) } + - { to_type: Integral, expr: new Long(Byte.MAX_VALUE.toLong()) } + - { to_type: Numeric, expr: new Long(Byte.MIN_VALUE.toLong()) } - { to_type: Object, expr: new Long() } - { to_type: Comparable, expr: new Long() } - from_type: Float values: - - { to_type: Floating, expr: new Float(Byte.MIN_VALUE as float) } + - { to_type: Floating, expr: new Float(Byte.MIN_VALUE.toFloat()) } - { to_type: Numeric, expr: new Float(-0.0 as float) } - { to_type: Object, expr: new Float(+0.0 as float) } - { to_type: Comparable, expr: new Float(+0.0 as float) } - from_type: Double values: - - { to_type: Floating, expr: new Double(Byte.MIN_VALUE as double) } - - { to_type: Numeric, expr: new Double(-0.0 as float) } - - { to_type: Object, expr: new Double(+0.0 as float) } - - { to_type: Comparable, expr: new Double(+0.0 as float) } + - { to_type: Floating, expr: new Double(Byte.MIN_VALUE.toDouble()) } + - { to_type: Numeric, expr: new Double(-0.0 as double) } + - { to_type: Object, expr: new Double(+0.0 as double) } + - { to_type: Comparable, expr: new Double(+0.0 as double) } - from_type: Char values: diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/decl_field/decl-field.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/decl_field/decl-field.params.yaml index 9dda7eb2929bd3532e7d29c45d5b1cb075cdf308..2894b66feb060153216f6c2187851a453c571e20 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/decl_field/decl-field.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/decl_field/decl-field.params.yaml @@ -22,38 +22,38 @@ cases: - from_type: Short values: - - { to_type: Integral, expr: new Short(Byte.MAX_VALUE as short) } - - { to_type: Numeric, expr: new Short(Byte.MIN_VALUE as short) } + - { to_type: Integral, expr: new Short(Byte.MAX_VALUE.toShort()) } + - { to_type: Numeric, expr: new Short(Byte.MIN_VALUE.toShort()) } - { to_type: Object, expr: new Short() } - { to_type: Comparable, expr: new Short() } - from_type: Int values: - - { to_type: Integral, expr: new Int(Byte.MAX_VALUE as int) } - - { to_type: Numeric, expr: new Int(Byte.MIN_VALUE as int) } + - { to_type: Integral, expr: new Int(Byte.MAX_VALUE.toInt()) } + - { to_type: Numeric, expr: new Int(Byte.MIN_VALUE.toInt()) } - { to_type: Object, expr: new Int() } - { to_type: Comparable, expr: new Int() } - from_type: Long values: - - { to_type: Integral, expr: new Long(Byte.MAX_VALUE as long) } - - { to_type: Numeric, expr: new Long(Byte.MIN_VALUE as long) } + - { to_type: Integral, expr: new Long(Byte.MAX_VALUE.toLong()) } + - { to_type: Numeric, expr: new Long(Byte.MIN_VALUE.toLong()) } - { to_type: Object, expr: new Long() } - { to_type: Comparable, expr: new Long() } - from_type: Float values: - - { to_type: Floating, expr: new Float(Byte.MIN_VALUE as float) } + - { to_type: Floating, expr: new Float(Byte.MIN_VALUE.toFloat()) } - { to_type: Numeric, expr: new Float(-0.0 as float) } - { to_type: Object, expr: new Float(+0.0 as float) } - { to_type: Comparable, expr: new Float(+0.0 as float) } - from_type: Double values: - - { to_type: Floating, expr: new Double(Byte.MIN_VALUE as double) } - - { to_type: Numeric, expr: new Double(-0.0 as float) } - - { to_type: Object, expr: new Double(+0.0 as float) } - - { to_type: Comparable, expr: new Double(+0.0 as float) } + - { to_type: Floating, expr: new Double(Byte.MIN_VALUE.toDouble()) } + - { to_type: Numeric, expr: new Double(-0.0 as double) } + - { to_type: Object, expr: new Double(+0.0 as double) } + - { to_type: Comparable, expr: new Double(+0.0 as double) } - from_type: Char values: diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/decl_var/decl-var.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/decl_var/decl-var.params.yaml index 29fefb9fbdfac865ea7fbd57e76d7db8a69ab8e8..6df5339c54f94cf1bbe134069394450e0cef56fb 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/decl_var/decl-var.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/05.widening_reference_conversions/decl_var/decl-var.params.yaml @@ -22,38 +22,38 @@ cases: - from_type: Short values: - - { to_type: Integral, expr: new Short(Byte.MAX_VALUE as short) } - - { to_type: Numeric, expr: new Short(Byte.MIN_VALUE as short) } + - { to_type: Integral, expr: new Short(Byte.MAX_VALUE.toShort()) } + - { to_type: Numeric, expr: new Short(Byte.MIN_VALUE.toShort()) } - { to_type: Object, expr: new Short() } - { to_type: Comparable, expr: new Short() } - from_type: Int values: - - { to_type: Integral, expr: new Int(Byte.MAX_VALUE as int) } - - { to_type: Numeric, expr: new Int(Byte.MIN_VALUE as int) } + - { to_type: Integral, expr: new Int(Byte.MAX_VALUE.toInt()) } + - { to_type: Numeric, expr: new Int(Byte.MIN_VALUE.toInt()) } - { to_type: Object, expr: new Int() } - { to_type: Comparable, expr: new Int() } - from_type: Long values: - - { to_type: Integral, expr: new Long(Byte.MAX_VALUE as long) } - - { to_type: Numeric, expr: new Long(Byte.MIN_VALUE as long) } + - { to_type: Integral, expr: new Long(Byte.MAX_VALUE.toLong()) } + - { to_type: Numeric, expr: new Long(Byte.MIN_VALUE.toLong()) } - { to_type: Object, expr: new Long() } - { to_type: Comparable, expr: new Long() } - from_type: Float values: - - { to_type: Floating, expr: new Float(Byte.MIN_VALUE as float) } + - { to_type: Floating, expr: new Float(Byte.MIN_VALUE.toFloat()) } - { to_type: Numeric, expr: new Float(-0.0 as float) } - { to_type: Object, expr: new Float(+0.0 as float) } - { to_type: Comparable, expr: new Float(+0.0 as float) } - from_type: Double values: - - { to_type: Floating, expr: new Double(Byte.MIN_VALUE as double) } - - { to_type: Numeric, expr: new Double(-0.0 as float) } - - { to_type: Object, expr: new Double(+0.0 as float) } - - { to_type: Comparable, expr: new Double(+0.0 as float) } + - { to_type: Floating, expr: new Double(Byte.MIN_VALUE.toDouble()) } + - { to_type: Numeric, expr: new Double(-0.0 as double) } + - { to_type: Object, expr: new Double(+0.0 as double) } + - { to_type: Comparable, expr: new Double(+0.0 as double) } - from_type: Char values: diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/assn-var.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/assn-var.ets index a259b4a6de4f3e47ac90d11d10a513eb62a4dcce..d9399f929e6c781e642a7610ae660419f8783bb1 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/assn-var.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/assn-var.ets @@ -30,22 +30,16 @@ const c{{loop.index}}: char = {{v.char}} let s: string function main() { - // from char literals: - -{%- for v in chars %} - s = {{v.char}} - assertEQ( s, {{v.str}} ) -{%- endfor %} // from char variables: {%- for v in chars %} - s = v{{loop.index}} + s = v{{loop.index}}.toString() assertEQ( s, {{v.str}} ) {%- endfor %} // from char constants: {%- for v in chars %} - s = c{{loop.index}} + s = c{{loop.index}}.toString() assertEQ( s, {{v.str}} ) {%- endfor %} } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/call-cons.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/call-cons.ets index a0605d655d11e71aefbf763bf06d7ca50370c050..36f54750ade3f49494b715877f5552f11dd146a6 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/call-cons.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/call-cons.ets @@ -25,8 +25,8 @@ let c{{loop.index}}: char = {{v.char}} class A { fld: string; - constructor(p: string) { - this.fld = p + constructor(p: char) { + this.fld = p.toString() } } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/call-func.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/call-func.ets index dac79b77f83851d5d37c3c5d46b134cb80e675bf..a919e9ba525f96b78f3edf366c31cf3f129e5f7a 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/call-func.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/call-func.ets @@ -23,8 +23,8 @@ desc: >- let c{{loop.index}}: char = {{v.char}} {%- endfor %} -function foo(p: string): string { - return p +function foo(p: char): string { + return p.toString() } function main() { diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/call-lmbd.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/call-lmbd.ets index 0db7bd3a9936fb703f59361ba09fe4961b4da8cf..92c55cf675e3814143dc9a1bfc49e31e4e1df6ae 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/call-lmbd.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/call-lmbd.ets @@ -26,11 +26,11 @@ let c{{loop.index}}: char = {{v.char}} function main() { // from char literals: {%- for v in chars %} - assertTrue( ((p: string): string => { return p })({{v.char}}) == {{v.str}} ) + assertEQ( ((p: string): string => { return p })({{v.char}}.toString()), {{v.str}} ) {%- endfor %} // from char variables: {%- for v in chars %} - assertTrue( ((p: string): string => { return p })(c{{loop.index}}) == {{v.str}} ) + assertEQ( ((p: string): string => { return p })(c{{loop.index}}.toString()), {{v.str}} ) {%- endfor %} } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/call-meth.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/call-meth.ets index e3814d035c72ac7dc5cf37f7a7fd5f8c94a04349..73cb04b277b459cd9a7f5c5215c3fff075ac84c0 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/call-meth.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/call-meth.ets @@ -34,11 +34,11 @@ function main() { // from char literals: {%- for v in chars %} - assertTrue( a.meth({{v.char}}) == {{v.str}} ) + assertEQ( a.meth({{v.char}}.toString()), {{v.str}} ) {%- endfor %} // from char variables: {%- for v in chars %} - assertTrue( a.meth(c{{loop.index}}) == {{v.str}} ) + assertEQ( a.meth(c{{loop.index}}.toString()), {{v.str}} ) {%- endfor %} } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/comp-arr.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/comp-arr.ets index 6cea47350c8312f508172694847bcb99b4dab8bb..35ec663adac7fd0686de30aa1c151eb670bfa888 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/comp-arr.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/comp-arr.ets @@ -24,19 +24,13 @@ let c{{loop.index}}: char = {{v.char}} {%- endfor %} function main() { - // from char literals: -{%- for v in chars %} - let s{{loop.index}}: string[] = [{{v.char}}] - s{{loop.index}} = [] - s{{loop.index}} = [{{v.char}}, {{v.char}}, {{v.char}}] - assertTrue( s{{loop.index}}[2] == {{v.str}} ) -{%- endfor %} // from char variables: {%- for v in chars %} - let q{{loop.index}}: string[] = [c{{loop.index}}] + let q{{loop.index}}: string[] = [c{{loop.index}}.toString()] q{{loop.index}} = [] - q{{loop.index}} = [c{{loop.index}}, c{{loop.index}}, c{{loop.index}}] - assertTrue( q{{loop.index}}[2] == {{v.str}} ) + q{{loop.index}} = [c{{loop.index}}.toString(), c{{loop.index}}.toString(), c{{loop.index}}.toString()] + assertEQ( q{{loop.index}}[2], {{v.str}} ) + assertEQ( q{{loop.index}}[2].length, 1 ) {%- endfor %} } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/comp-clss.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/comp-clss.ets index 60837504fafc382ae464a4f6caa7df00c013bed3..550e55d740d8181c00935cff1fad6c853263e084 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/comp-clss.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/comp-clss.ets @@ -28,15 +28,10 @@ class A { } function main() { - // from char literals: -{%- for v in chars %} - let a{{loop.index}}: A = { fld: {{v.char}} } - assertTrue( a{{loop.index}}.fld == {{v.str}} ) -{%- endfor %} // from char variables: {%- for v in chars %} - let b{{loop.index}}: A = { fld: c{{loop.index}} } + let b{{loop.index}}: A = { fld: c{{loop.index}}.toString() } assertTrue( b{{loop.index}}.fld == {{v.str}} ) {%- endfor %} } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/decl-const.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/decl-const.ets index 6957c867ca04d12f8370a62a63c6025ea84bae69..0910865689248e477cf2a7c0963c839fb1cee6b8 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/decl-const.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/decl-const.ets @@ -24,14 +24,9 @@ let c{{loop.index}}: char = {{v.char}} {%- endfor %} function main() { - // from char literals: -{%- for v in chars %} - const s{{loop.index}}: string = {{v.char}} - assertTrue( s{{loop.index}} == {{v.str}} ) -{%- endfor %} // from char variables: {%- for v in chars %} - const q{{loop.index}}: string = c{{loop.index}} + const q{{loop.index}}: string = c{{loop.index}}.toString() assertTrue( q{{loop.index}} == {{v.str}} ) {%- endfor %} } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/decl-field.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/decl-field.ets index 7b9fb36017a40eb4e812b0dc8a24038d30ffdb0c..8f67c02abea9307b1bad5bab7462789f4ca002b5 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/decl-field.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/decl-field.ets @@ -23,25 +23,14 @@ desc: >- let c{{loop.index}}: char = {{v.char}}; {%- endfor %} -class A { - // from char literals: -{%- for v in chars %} - fld{{loop.index}}: string = {{v.char}} -{%- endfor %} -} - class B { // from char variables: {%- for v in chars %} - fld{{loop.index}}: string = c{{loop.index}} + fld{{loop.index}}: string = c{{loop.index}}.toString() {%- endfor %} } function main() { - let a: A = new A() -{%- for v in chars %} - assertTrue( a.fld{{loop.index}} == {{v.str}} ) -{%- endfor %} let b: B = new B() {%- for v in chars %} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/decl-var.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/decl-var.ets index 4149e6f298d644afdcab129d9c0d725480d23a75..db38bc8f481f0e43dd0693c0b43281831feaee19 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/decl-var.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/06.char_to_string_conversions/decl-var.ets @@ -24,14 +24,10 @@ let c{{loop.index}}: char = {{v.char}} {%- endfor %} function main() { - // from char literals: -{%- for v in chars %} - let s{{loop.index}}: string = {{v.char}} - assertTrue( s{{loop.index}} == {{v.str}} ) -{%- endfor %} + // from char variables: {%- for v in chars %} - let q{{loop.index}}: string = c{{loop.index}} + let q{{loop.index}}: string = c{{loop.index}}.toString() assertTrue( q{{loop.index}} == {{v.str}} ) {%- endfor %} } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/07.constant_string_to_char_conversions/str2char.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/07.constant_string_to_char_conversions/str2char.params.yaml index 5acc5a60692e86e064a81875b2f38d15e4d04a19..4b10a2e430ada28ee8bcebe1a35d7abf099438e4 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/07.constant_string_to_char_conversions/str2char.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/07.constant_string_to_char_conversions/str2char.params.yaml @@ -18,97 +18,97 @@ cases: const r: string = "" use: |- // assignment-like context, variable declaration - let v1: char = "\u0000" - assertEQ( v1, c'\u0000' ) + let v1: string = "\u0000" + assertEQ( v1.charAt(0), c'\u0000' ) - let v2: char = "\uFFFF" + "" - assertEQ( v2, c'\uFFFF' ) + let v2: string = "\uFFFF" + "" + assertEQ( v2.charAt(0), c'\uFFFF' ) - let v3: char = s + let v3: char = s.charAt(0) assertEQ( v3, c'Z' ) - let v4: char = r + s + "" - assertEQ( v4, c'Z' ) + let v4: string = r + s + "" + assertEQ( v4.charAt(0), c'Z' ) // assignment-like context, constant declaration - const c1: char = "\u0000" - assertEQ( c1, c'\u0000' ) + const c1: string = "\u0000" + assertEQ( c1.charAt(0), c'\u0000' ) - const c2: char = "\uFFFF" + "" - assertEQ( c2, c'\uFFFF' ) + const c2: string = "\uFFFF" + "" + assertEQ( c2.charAt(0), c'\uFFFF' ) - const c3: char = s + const c3: char = s.charAt(0) assertEQ( c3, c'Z' ) - const c4: char = r + s + "" - assertEQ( c4, c'Z' ) + const c4: string = r + s + "" + assertEQ( c4.charAt(0), c'Z' ) - decl: |- const s: string = "Z" const r: string = "" // assignment-like context, field declaration class A { - c1: char = "\u0000" - c2: char = "\uCAFE" + "" - c3: char = s - c4: char = r + s + "" + c1: string = "\u0000" + c2: string = "\uCAFE" + "" + c3: char = s.charAt(0) + c4: string = r + s + "" } use: |- let a: A = new A() - assertEQ( a.c1, c'\u0000' ) - assertEQ( a.c2, c'\uCAFE' ) + assertEQ( a.c1.charAt(0), c'\u0000' ) + assertEQ( a.c2.charAt(0), c'\uCAFE' ) assertEQ( a.c3, c'Z' ) - assertEQ( a.c4, c'Z' ) + assertEQ( a.c4.charAt(0), c'Z' ) - decl: |- const s: string = "Z" const r: string = "" - let v1: char - let v2: char + let v1: string + let v2: string let v3: char - let v4: char + let v4: string use: |- // assignment-like context, variable assignment v1 = "\u0000" - assertEQ( v1, c'\u0000' ) + assertEQ( v1.charAt(0), c'\u0000' ) v2 = "\uFFFF" + "" - assertEQ( v2, c'\uFFFF' ) + assertEQ( v2.charAt(0), c'\uFFFF' ) - v3 = s + v3 = s.charAt(0) assertEQ( v3, c'Z' ) v4 = r + s + "" - assertEQ( v4, c'Z' ) + assertEQ( v4.charAt(0), c'Z' ) - decl: |- const s: string = "Z" const r: string = "" // assignment-like context, field assignment class A { - c1: char - c2: char + c1: string = "" + c2: string = "" c3: char - c4: char + c4: string = "" } use: |- let a: A = new A() a.c1 = "\u000F" - assertEQ( a.c1, c'\u000F' ) + assertEQ( a.c1.charAt(0), c'\u000F' ) a.c2 = "\uFFFF" + "" - assertEQ( a.c2, c'\uFFFF' ) + assertEQ( a.c2.charAt(0), c'\uFFFF' ) - a.c3 = s + a.c3 = s.charAt(0) assertEQ( a.c3, c'Z' ) a.c4 = r + s + "" - assertEQ( a.c4, c'Z' ) + assertEQ( a.c4.charAt(0), c'Z' ) - decl: |- // call context, function - function foo(p: char): char { - return p + function foo(p: string): char { + return p.charAt(0) } const s: string = "W" const r: string = "" @@ -121,8 +121,8 @@ cases: - decl: |- // call context, method class A { - meth(p: char): char { - return p + meth(p: string): char { + return p.charAt(0) } } const s: string = "W" @@ -138,8 +138,8 @@ cases: // call context, constructor class A { fld: char - constructor(p: char) { - this.fld = p + constructor(p: string) { + this.fld = p.charAt(0) } } const s: string = "W" @@ -155,30 +155,23 @@ cases: const s: string = "W" const r: string = "" use: |- - assertEQ( ((p: char): char => { return p })("\u0000"), c'\u0000' ) - assertEQ( ((p: char): char => { return p })("" + ("" + "\uCAFE") + ""), c'\uCAFE' ) - assertEQ( ((p: char): char => { return p })(s), c'W' ) - assertEQ( ((p: char): char => { return p })(r + s + ""), c'W' ) + assertEQ( ((p: string): char => { return p.charAt(0) })("\u0000"), c'\u0000' ) + assertEQ( ((p: string): char => { return p.charAt(0) })("" + ("" + "\uCAFE") + ""), c'\uCAFE' ) + assertEQ( ((p: string): char => { return p.charAt(0) })(s), c'W' ) + assertEQ( ((p: string): char => { return p.charAt(0) })(r + s + ""), c'W' ) - decl: |- // array composite const s: string = "W" const r: string = "" + let c1: string = "\u0000" + let c2: string = "\uFFFF" use: |- - let v1: char[] = ["\u0000", c'X', "\uFFFF"] + let v1: char[] = [c1.charAt(0), c'X', c2.charAt(0)] assertEQ( v1[0], c'\u0000' ) assertEQ( v1[1], c'X' ) assertEQ( v1[2], c'\uFFFF' ) - v1 = ["" + "Z" + ""] - assertEQ( v1[0], c'Z' ) - - v1 = [c'X', s, s + r, "" + s] - assertEQ( v1[0], c'X' ) - assertEQ( v1[1], c'W' ) - assertEQ( v1[2], c'W' ) - assertEQ( v1[3], c'W' ) - - decl: |- // object composite const s: string = "W" @@ -187,14 +180,17 @@ cases: fld: char } use: |- - let a: A = { fld: "\u8000" } - assertEQ( a.fld, c'\u8000' ) + let a: string = "\u8000" + let ca: A = { fld: a.charAt(0) } + assertEQ( ca.fld, c'\u8000' ) - a = { fld: "" + "" + "" + "\uCAFE" } - assertEQ( a.fld, c'\uCAFE' ) + a = "" + "" + "" + "\uCAFE" + ca = { fld: a.charAt(0) } + assertEQ( ca.fld, c'\uCAFE' ) - a = { fld: s } - assertEQ( a.fld, c'W' ) + ca = { fld: s.charAt(0) } + assertEQ( ca.fld, c'W' ) - a = { fld: "" + s + r } - assertEQ( a.fld, c'W' ) + a = "" + s + r + ca = { fld: a.charAt(0) } + assertEQ( ca.fld, c'W' ) diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/assn_var/assn-var_n.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/assn_var/assn-var_n.params.yaml index 5f2656753a30ee9c3149b29b2b0584607510922c..7b4c37af65c51003a18b59d2dfabf3bc8dc760f5 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/assn_var/assn-var_n.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/assn_var/assn-var_n.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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 @@ -13,12 +13,6 @@ --- cases: - # different types - - from: - - { type: number, expr: "Double.POSITIVE_INFINITY" } - to: - - { type: Number } - # different number of elements - from: - { type: number, expr: "Double.POSITIVE_INFINITY" } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/assn_var/assn-var_p.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/assn_var/assn-var_p.ets new file mode 100755 index 0000000000000000000000000000000000000000..38a3eb48a79bfea5ff1fe7a7d0a7730917f7017e --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/assn_var/assn-var_p.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 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. + */ + +/*--- +desc: Tuple types conversion is the conversion of one tuple type to another. Assignment-like + context, variable assignment, tuple type conversion, implicit +name: assn-var_n_0 +tags: +- compile-only +---*/ + +let v: [Number]; +let c: [number] = [Double.POSITIVE_INFINITY]; + +function main() { + // variable assignment with another variable + v = c + + // variable assignment with tuple literal + v = [Double.POSITIVE_INFINITY] +} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_cons/call-cons_n.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_cons/call-cons_n.params.yaml index 42f89f4ca16121529864c211f73866a2a55d81a9..997dbda97ddca4ebde013450712d491358cd421f 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_cons/call-cons_n.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_cons/call-cons_n.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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 @@ -13,12 +13,6 @@ --- cases: - # different types - - from: - - { type: number, expr: "Double.POSITIVE_INFINITY" } - to: - - { type: Number } - # different number of elements - from: - { type: number, expr: "Double.POSITIVE_INFINITY" } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_cons/call-cons_p.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_cons/call-cons_p.ets new file mode 100755 index 0000000000000000000000000000000000000000..8e5682bf14c55ddf54ac7a7a857ca1e92fe5d73a --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_cons/call-cons_p.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 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. + */ + +/*--- +desc: Tuple types conversion is the conversion of one tuple type to another. Call + context, constructor, tuple type conversion, implicit +name: call-cons_p +tags: +- compile-only +---*/ + +let s: [number] = [Double.POSITIVE_INFINITY]; +type TUP = [Number] + +class Z { + fld: TUP + constructor(p: TUP) { + this.fld = p + } +} + +function main() { + let z1: Z = new Z(s) + let z2: Z = new Z([Double.POSITIVE_INFINITY]) +} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_func/call-func_n.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_func/call-func_n.params.yaml index 42f89f4ca16121529864c211f73866a2a55d81a9..8c1a072c4c48022b1533e55959656d6c04df70de 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_func/call-func_n.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_func/call-func_n.params.yaml @@ -13,12 +13,6 @@ --- cases: - # different types - - from: - - { type: number, expr: "Double.POSITIVE_INFINITY" } - to: - - { type: Number } - # different number of elements - from: - { type: number, expr: "Double.POSITIVE_INFINITY" } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_func/call-func_p.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_func/call-func_p.ets new file mode 100755 index 0000000000000000000000000000000000000000..c8534c725baa9c193f460fa12d406e4d086921c5 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_func/call-func_p.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 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. + */ + +/*--- +desc: Tuple types conversion is the conversion of one tuple type to another. Call + context, function, tuple type conversion, implicit +name: call-func_n_0 +tags: +- compile-only +---*/ + +let s: [number] = [Double.POSITIVE_INFINITY]; + +function zoo(p: [Number]): [Number] { + return p +} + +function main() { + let res1: [Number] = zoo([Double.POSITIVE_INFINITY]) + let res2: [Number] = zoo(s) +} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_lmbd/call-lmbd_n.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_lmbd/call-lmbd_n.params.yaml index 5f2656753a30ee9c3149b29b2b0584607510922c..7b4c37af65c51003a18b59d2dfabf3bc8dc760f5 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_lmbd/call-lmbd_n.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_lmbd/call-lmbd_n.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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 @@ -13,12 +13,6 @@ --- cases: - # different types - - from: - - { type: number, expr: "Double.POSITIVE_INFINITY" } - to: - - { type: Number } - # different number of elements - from: - { type: number, expr: "Double.POSITIVE_INFINITY" } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_lmbd/call-lmbd_p.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_lmbd/call-lmbd_p.ets new file mode 100755 index 0000000000000000000000000000000000000000..071d46cdb8815c08b4a0803c45e6486b04bca08e --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_lmbd/call-lmbd_p.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 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. + */ + +/*--- +desc: Tuple types conversion is the conversion of one tuple type to another. Call + context, lambda, tuple type conversion, implicit +name: call-lmbd_n_0 +tags: +- compile-only +---*/ + +let s: [number] = [Double.POSITIVE_INFINITY]; + +function main() { + let res1: [Number] = + ((p: [Number]): [Number] => { return p})([Double.POSITIVE_INFINITY]) + let res2: [Number] = + ((p: [Number]): [Number] => { return p})(s) +} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_meth/call-meth_n.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_meth/call-meth_n.params.yaml index 42f89f4ca16121529864c211f73866a2a55d81a9..997dbda97ddca4ebde013450712d491358cd421f 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_meth/call-meth_n.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_meth/call-meth_n.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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 @@ -13,12 +13,6 @@ --- cases: - # different types - - from: - - { type: number, expr: "Double.POSITIVE_INFINITY" } - to: - - { type: Number } - # different number of elements - from: - { type: number, expr: "Double.POSITIVE_INFINITY" } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_meth/call-meth_p.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_meth/call-meth_p.ets new file mode 100755 index 0000000000000000000000000000000000000000..542f3c825ffa9c796f345c285c6e461ac23d6dba --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/call_meth/call-meth_p.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 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. + */ + +/*--- +desc: Tuple types conversion is the conversion of one tuple type to another. Call + context, instance method, tuple type conversion, implicit +name: call-meth_n_0 +tags: +- compile-only +---*/ + +let s: [number] = [Double.POSITIVE_INFINITY]; + +class Z { + meth(p: [Number]): [Number] { + return p + } +} + +function main() { + let res1: [Number] = new Z().meth([Double.POSITIVE_INFINITY]) + let res2: [Number] = new Z().meth(s) +} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/comp_arr/comp-arr_n.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/comp_arr/comp-arr_n.params.yaml index 5f2656753a30ee9c3149b29b2b0584607510922c..7b4c37af65c51003a18b59d2dfabf3bc8dc760f5 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/comp_arr/comp-arr_n.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/comp_arr/comp-arr_n.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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 @@ -13,12 +13,6 @@ --- cases: - # different types - - from: - - { type: number, expr: "Double.POSITIVE_INFINITY" } - to: - - { type: Number } - # different number of elements - from: - { type: number, expr: "Double.POSITIVE_INFINITY" } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/comp_arr/comp-arr_p.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/comp_arr/comp-arr_p.ets new file mode 100755 index 0000000000000000000000000000000000000000..66e5dd732735fd369e48df32b7fe8e48ca8b9e25 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/comp_arr/comp-arr_p.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 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. + */ + +/*--- +desc: Tuple types conversion is the conversion of one tuple type to another. Composite + context, array, tuple type conversion, implicit +name: comp-arr_n_0 +tags: +- compile-only +---*/ + +let s: [number] = [Double.POSITIVE_INFINITY]; + +function main() { + let z: [Number][] = [] + z = [[Double.POSITIVE_INFINITY], s] +} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/comp_obj/comp-obj_n.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/comp_obj/comp-obj_n.params.yaml index 5f2656753a30ee9c3149b29b2b0584607510922c..7b4c37af65c51003a18b59d2dfabf3bc8dc760f5 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/comp_obj/comp-obj_n.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/comp_obj/comp-obj_n.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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 @@ -13,12 +13,6 @@ --- cases: - # different types - - from: - - { type: number, expr: "Double.POSITIVE_INFINITY" } - to: - - { type: Number } - # different number of elements - from: - { type: number, expr: "Double.POSITIVE_INFINITY" } diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/12.adding_functionality_to_existing_types/02.receiver_types/functions_with_receiver_negative.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/comp_obj/comp-obj_p.ets old mode 100644 new mode 100755 similarity index 64% rename from static_core/plugins/ets/tests/ets-templates/17.experimental_features/12.adding_functionality_to_existing_types/02.receiver_types/functions_with_receiver_negative.ets rename to static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/comp_obj/comp-obj_p.ets index 2f5008d0f1162f163a4950d894cfb76afc07491d..a681f2fff734be5698cd83c3d0550a91f23393c8 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/12.adding_functionality_to_existing_types/02.receiver_types/functions_with_receiver_negative.ets +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/comp_obj/comp-obj_p.ets @@ -13,18 +13,22 @@ * limitations under the License. */ -{%- for c in cases %} /*--- -desc: >- - A function with receiver declaration is a top-level declaration (see Top-Level Declarations) that looks almost the same - as Function Declarations, except that the first parameter is mandatory, and the keyword this is used as its name -tags: [compile-only, negative] +desc: Tuple types conversion is the conversion of one tuple type to another. Composite + context, object, tuple type conversion, implicit +name: comp-obj_n_0 +tags: +- compile-only ---*/ -{{c.decl}} +let s: [number] = [Double.POSITIVE_INFINITY]; -function main() { - {{c.use|indent}} +class Z { + fld: [Number] } -{%- endfor %} +function main() { + let z1: Z = { fld: [Double.POSITIVE_INFINITY] } + let z2: Z = { fld: s } + +} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/decl_field/decl-field_n.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/decl_field/decl-field_n.params.yaml index 5f2656753a30ee9c3149b29b2b0584607510922c..7b4c37af65c51003a18b59d2dfabf3bc8dc760f5 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/decl_field/decl-field_n.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/decl_field/decl-field_n.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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 @@ -13,12 +13,6 @@ --- cases: - # different types - - from: - - { type: number, expr: "Double.POSITIVE_INFINITY" } - to: - - { type: Number } - # different number of elements - from: - { type: number, expr: "Double.POSITIVE_INFINITY" } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/decl_field/decl-field_p.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/decl_field/decl-field_p.ets new file mode 100755 index 0000000000000000000000000000000000000000..947cecace714718269d1efd7869c471e20d767b3 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/decl_field/decl-field_p.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 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. + */ + +/*--- +desc: Tuple types conversion is the conversion of one tuple type to another. Assignment-like + context, class field declaration, tuple type conversion, implicit +name: decl-field_n_0 +tags: +- compile-only +---*/ + +let s: [number] = [Double.POSITIVE_INFINITY]; + +class Z { + fld1: [Number] = [Double.POSITIVE_INFINITY] + fld2: [Number] = s +} + +function main() { + let z: Z = new Z() +} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/decl_var/decl-var_n.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/decl_var/decl-var_n.params.yaml index 5f2656753a30ee9c3149b29b2b0584607510922c..7b4c37af65c51003a18b59d2dfabf3bc8dc760f5 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/decl_var/decl-var_n.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/decl_var/decl-var_n.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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 @@ -13,12 +13,6 @@ --- cases: - # different types - - from: - - { type: number, expr: "Double.POSITIVE_INFINITY" } - to: - - { type: Number } - # different number of elements - from: - { type: number, expr: "Double.POSITIVE_INFINITY" } diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/decl_var/decl-var_p.ets b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/decl_var/decl-var_p.ets new file mode 100755 index 0000000000000000000000000000000000000000..0adce88ef440c7b326bd38217fc9eda707508bf3 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/decl_var/decl-var_p.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 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. + */ + +/*--- +desc: Tuple types conversion is the conversion of one tuple type to another. Assignment-like + context, variable declaration, tuple type conversion, implicit +name: decl-var_n_0 +tags: +- compile-only +---*/ + +let s: [number] = [Double.POSITIVE_INFINITY]; + +function main() { + // variable declaration with tuple literal + let v: [Number] = [Double.POSITIVE_INFINITY] + + // variable declaration with another variable + let v2: [Number] = s + + // constant declaration with tuple literal + const c: [Number] = [Double.POSITIVE_INFINITY] + + // constant declaration with another variable + const c2: [Number] = s +} diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/01.normal_and_abrupt_completion_of_expression_evaluation/ae3.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/01.normal_and_abrupt_completion_of_expression_evaluation/ae3.ets index a15633334504ee6d61d2a996db096e3520ea7b92..b909db015f5d80ffeaf160cfab0335eeff1e6c0c 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/01.normal_and_abrupt_completion_of_expression_evaluation/ae3.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/01.normal_and_abrupt_completion_of_expression_evaluation/ae3.ets @@ -25,7 +25,7 @@ function main(): int { let j: long = 0x0fffffff00000000; try { - let v: String = "X" + (a = 2) + (i as int) / (j as int) / (b = 2); + let v: String = "X" + (a = 2) + (i.toInt()) / (j.toInt()) / (b = 2); return 1; } catch (e: ArithmeticError) { if (a != 2 || b != 1) return 1; diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/01.normal_and_abrupt_completion_of_expression_evaluation/aioobe2.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/01.normal_and_abrupt_completion_of_expression_evaluation/aioobe2.ets index cc318bab4a2881e744ba6df619eaecaaa6ec7c56..d8f6ad092f78195e168dd8b31918160e4a5419d1 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/01.normal_and_abrupt_completion_of_expression_evaluation/aioobe2.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/01.normal_and_abrupt_completion_of_expression_evaluation/aioobe2.ets @@ -17,6 +17,7 @@ desc: ArrayIndexOutOfBoundsError is thrown by an array access expression if the array index expression has a value that is negative, or greater than, or equal to the length of the array. +tags: ---*/ function main(): int { diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/01.normal_and_abrupt_completion_of_expression_evaluation/aioobe4.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/01.normal_and_abrupt_completion_of_expression_evaluation/aioobe4.ets index e67053374b9d6fd272ed3f9715345dc7015a9c7c..2ddb2f7c967414934435a2962d9953e87587b954 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/01.normal_and_abrupt_completion_of_expression_evaluation/aioobe4.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/01.normal_and_abrupt_completion_of_expression_evaluation/aioobe4.ets @@ -25,7 +25,7 @@ function main(): int { let b = 1; try { - let i: int = (a = 2) + v[0].length as int + (v[0][0] = new byte[10]).length as int + (b = 2); + let i: int = (a = 2) + v[0].length.toInt() + (v[0][0] = new byte[10]).length.toInt() + (b = 2); if (a != 2 || b != 2) return 1; return 0; } catch (e: RangeError) { diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/01.normal_and_abrupt_completion_of_expression_evaluation/nase2.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/01.normal_and_abrupt_completion_of_expression_evaluation/nase2.ets index 5e82a652fadf8b458ddf04f78e73ec0cffcb158c..29865d8817b64c7a0c6d468989a962ed91ea3864 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/01.normal_and_abrupt_completion_of_expression_evaluation/nase2.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/01.normal_and_abrupt_completion_of_expression_evaluation/nase2.ets @@ -24,7 +24,7 @@ function main(): int { // Changed to small number because it will cause runtime timeout let sz: int = 10; try { - let v: int = 42 + (a = 2) + new byte[sz].length as int + (b = 2); + let v: int = 42 + (a = 2) + new byte[sz].length.toInt() + (b = 2); if (a != 2 || b != 2) return 1; return 0; } catch (e: NegativeArraySizeError) { diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/add.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/add.ets index afb09b85b69a98f6c976cebb2ce039dfe2e5533f..b464956238f006befb59841f17f9f33896791281 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/add.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/add.ets @@ -21,10 +21,10 @@ function main(): int { let res: int, t2 = 2, t3 = 3, t4 = 4, t8 = 8, t255 = 255 // cast - res = t2 + t255 as byte + res = (t2 + t255).toByte() if (res != 1) return 1; - res = t255 as byte + t3 + res = t255.toByte() + t3 if (res != 2) return 1; // shifts diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/cast.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/cast.ets index 0dd4ea36559f57bd05f49511f32aa3422f39deb0..7e7ebb02b644d6366c32437bc25de3dacf55a282 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/cast.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/cast.ets @@ -21,69 +21,69 @@ function main(): int { let res: int, t1 = 1, t2 = 2, t3 = 3, t4 = 4, t255 = 255, t257 = 257, t258 = 258 // shifts - res = t255 << t257 as byte + res = t255 << t257.toByte() if (res != 510) return 1; - res = t257 >> t257 as byte + res = t257 >> t257.toByte() if (res != 128) return 1; - res = - t255 >>> t257 as byte + res = - t255 >>> t257.toByte() if (res != 2147483520) return 1; // relational - if (t2 < t258 as byte) return 1; - if (t3 <= t258 as byte) return 1; - if (t2 > t258 as byte) return 1; - if (t1 >= t258 as byte) return 1; - if (t1 == t258 as byte) return 1; - if (t2 != t258 as byte) return 1; + if (t2 < t258.toByte()) return 1; + if (t3 <= t258.toByte()) return 1; + if (t2 > t258.toByte()) return 1; + if (t1 >= t258.toByte()) return 1; + if (t1 == t258.toByte()) return 1; + if (t2 != t258.toByte()) return 1; // bitwise - res = t255 & t258 as byte + res = t255 & t258.toByte() if (res != 2) return 1; - res = t3 | t258 as byte + res = t3 | t258.toByte() if (res != 3) return 1; - res = t255 ^ t258 as byte + res = t255 ^ t258.toByte() if (res != 253) return 1; // ternary - res = t3 <= t4 ? t257 : t258 as byte + res = t3 <= t4 ? t257 : t258.toByte() if (res != 257) return 1; // assignments - res = t258 += t257 as byte + res = t258 += t257.toByte() if (res != 259) return 1; else t258 = 258; - res = t258 -= t257 as byte + res = t258 -= t257.toByte() if (res != 257) return 1; else t258 = 258; - res = t258 *= t257 as byte + res = t258 *= t257.toByte() if (res != 258) return 1; else t258 = 258; - res = t258 /= t257 as byte + res = t258 /= t257.toByte() if (res != 258) return 1; else t258 = 258; - res = t255 %= t258 as byte + res = t255 %= t258.toByte() if (res != 1) return 1; else t255 = 255; - res = t255 &= t258 as byte + res = t255 &= t258.toByte() if (res != 2) return 1; else t255 = 255; - res = t3 |= t258 as byte + res = t3 |= t258.toByte() if (res != 3) return 1; else t3 = 3; - res = t255 ^= t258 as byte + res = t255 ^= t258.toByte() if (res != 253) return 1; else t255 = 255; - res = t255 <<= t257 as byte + res = t255 <<= t257.toByte() if (res != 510) return 1; else t255 = 255; - res = t257 >>= t257 as byte + res = t257 >>= t257.toByte() if (res != 128) return 1; else t257 = 257; - res = t255 >>>= t257 as byte + res = t255 >>>= t257.toByte() if (res != 127) return 1; else t255 = 255; return 0; diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/div.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/div.ets index 7936399caa95113fcb412e5533e886956c07f075..aff2ebcee56d8fae93c68e8976b1dd0cf62c193b 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/div.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/div.ets @@ -37,10 +37,10 @@ function main(): int { if (res != 0) return 1; // cast - res = t510 / t255 as byte + res = (t510 / t255).toByte() if (res != 2) return 1; - res = t510 as byte / t255 + res = t510.toByte() / t255 if (res != 0) return 1; // shifts diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/mod.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/mod.ets index 740188a2abbd05838f38bf596a93a4acd18735c9..5c815cf58ba414e662f9755068dba7b66577c5bf 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/mod.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/mod.ets @@ -37,11 +37,11 @@ function main(): int { if (res != 5) return 1; // modulo - res = t518 % t255 as byte + res = (t518 % t255).toByte() if (res != 8) return 1; // cast - res = t518 as byte % t255 + res = t518.toByte() % t255 if (res != 6) return 1; // shifts diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/mul.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/mul.ets index 3e3791caee3bb58ccc3c97126204fff9ca2d8660..e3064f604a3190354cd2bb2e69b5f9c94f25d821 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/mul.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/mul.ets @@ -37,10 +37,10 @@ function main(): int { if (res != -10) return 1; // cast - res = t2 * t255 as byte + res = t2 * t255.toByte() if (res != -2) return 1; - res = t255 as byte * t3 + res = t255.toByte() * t3 if (res != -3) return 1; // shifts diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/postfix.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/postfix.ets index db80b6374c6e06af2dc4bfdb7f252c576828d4cd..04c2f5cb322af0497402407b9ba04d2df6e6b1cf 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/postfix.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/postfix.ets @@ -103,12 +103,12 @@ function main(): int { t4 = 4 // casting - res = t255-- as byte - t4++ as byte + res = (t255--).toByte() - (t4++).toByte() if (res != -5 || t255 != 254 || t4 != 5) return 1; t255 = 255 t4 = 4 - res = t255++ as byte - t4-- as byte + res = (t255++).toByte() - (t4--).toByte() if (res != -5 || t255 != 256 || t4 != 3) return 1; t255 = 255 t4 = 4 diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/prefix.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/prefix.ets index 5329b914ffb5f7c96958980a9701e067c5d03f65..4ab88258b00b2d596df7248cf9c65ace70687d89 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/prefix.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/prefix.ets @@ -103,12 +103,12 @@ function main(): int { t4 = 4 // casting - res = --t255 as byte - ++t4 as byte + res = (--t255).toByte() - (++t4).toByte() if (res != -7 || t255 != 254 || t4 != 5) return 1; t255 = 255 t4 = 4 - res = ++t255 as byte - --t4 as byte + res = (++t255).toByte() - (--t4).toByte() if (res != -3 || t255 != 256 || t4 != 3) return 1; t255 = 255 t4 = 4 diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/sub.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/sub.ets index df44ec337a203514ba406fd417a82fb9a99f6eee..bbf43a6598505aace5f84f5ad65020a4ead20572 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/sub.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/sub.ets @@ -21,10 +21,10 @@ function main(): int { let res: int, t2 = 2, t3 = 3, t4 = 4, t8 = 8, t255 = 255 // cast - res = t2 - t255 as byte + res = (t2 - t255).toByte() if (res != 3) return 1; - res = t255 as byte - t3 + res = t255.toByte() - t3 if (res != -4) return 1; // shifts diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/unary.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/unary.ets index 4f475ad12ab5b6f3ba2a3c612f1d87c8e435ebfc..0bac6b7a9a56351eaae0b708d7508105b91c5c5a 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/unary.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/03.operator_precedence/unary.ets @@ -92,18 +92,18 @@ function main(): int { i = ~ - t2 - t4; if (i != -3) return 1; // casting - i = + t258 as byte; if (i != 2) return 1; - i = + + t258 as byte; if (i != 2) return 1; - i = - t258 as byte; if (i != -2) return 1; - i = - - t258 as byte; if (i != 2) return 1; - i = ~ t258 as byte; if (i != -3) return 1; - i = ~ ~ t258 as byte; if (i != 2) return 1; - i = + - t258 as byte; if (i != -2) return 1; - i = + ~ t258 as byte; if (i != -3) return 1; - i = - + t258 as byte; if (i != -2) return 1; - i = - ~ t258 as byte; if (i != 3) return 1; - i = ~ + t258 as byte; if (i != -3) return 1; - i = ~ - t258 as byte; if (i != 1) return 1; + i = (+ t258).toByte(); if (i != 2) return 1; + i = (+ + t258).toByte(); if (i != 2) return 1; + i = (- t258).toByte(); if (i != -2) return 1; + i = (- - t258).toByte(); if (i != 2) return 1; + i = (~ t258).toByte(); if (i != -3) return 1; + i = (~ ~ t258).toByte(); if (i != 2) return 1; + i = (+ - t258).toByte(); if (i != -2) return 1; + i = (+ ~ t258).toByte(); if (i != -3) return 1; + i = (- + t258).toByte(); if (i != -2) return 1; + i = (- ~ t258).toByte(); if (i != 3) return 1; + i = (~ + t258).toByte(); if (i != -3) return 1; + i = (~ - t258).toByte(); if (i != 1) return 1; // right shift i = + t255 >> t3; if (i != 31) return 1; diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/eval_decl.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/eval_decl.ets index e96c0d4615a947157e78f23a61b9530b93cf59bf..1fd220cb3c1bcd9f5411945e311136a5a8ed1ceb 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/eval_decl.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/eval_decl.ets @@ -25,7 +25,7 @@ let sg: int; let ig: int = new Int(1).unboxed(); class A { - public fld: int = 42 + (sg = "abc".length as int); + public fld: int = 42 + (sg = "abc".length.toInt()); private f: Incrementor; public constructor(f: Incrementor) { diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/eval_f.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/eval_f.ets index 0575fa997e21845d9e930c4347a2918779aaecfe..78397af0ef655bf3c9240d92b49c1696b078e5ea 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/eval_f.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/eval_f.ets @@ -22,7 +22,7 @@ desc: >- type Inc = (i: int) => long; function inc(p: int): long { - return (p + 1) as long; + return (p + 1).toLong(); } function foo(i: int, func: Inc): long { diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/eval_se.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/eval_se.ets index 11a2e0aa4b0c1d892d632f7f70994f21ba384cf8..397083becc393001b128ea5aac542ff526d227fe 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/eval_se.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/eval_se.ets @@ -26,14 +26,14 @@ let ig: int = 42; function foo(p: int, s: String): int { sg += s; ig = -1; - return p - s.length as int; + return p - s.length.toInt(); } class A { meth(p: int, s: String): int { sg += s; ig = 1; - return p - s.length as int; + return p - s.length.toInt(); } } @@ -42,7 +42,7 @@ function main(): int { ig = 42; // assignment side effect - let i: int = (sg += "b").length as int + (ig = 43); + let i: int = (sg += "b").length.toInt() + (ig = 43); if (i != 45 || sg != "ab" || ig != 43) return 1; // increment side effect diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/typ.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/typ.ets index 78ac6ecda7dabb11101abfab91d419af4feb1db5..d99b75ae48e2bc8d70dcaeed095f09b380d8e230 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/typ.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/typ.ets @@ -45,37 +45,7 @@ function foo(a: double): int { function foo(a: boolean): int { return 8; } -function foo(a: Byte): int { - return 21; -} -function foo(a: Short): int { - return 22; -} -function foo(a: Char): int { - return 23; -} -function foo(a: Int): int { - return 24; -} -function foo(a: Long): int { - return 25; -} -function foo(a: Float): int { - return 26; -} -function foo(a: Double): int { - return 27; -} -function foo(a: Boolean): int { - return 28; -} -function foo(a: Integral): int { - return 29; -} -function foo(a: Floating): int { - return 30; -} -function foo(a: String): int { +function foo(a: string): int { return 31; } function foo(a: Object): int { @@ -105,46 +75,10 @@ function foo(a: FixedArray): int { function foo(a: FixedArray): int { return 108; } -function foo(a: FixedArray): int { - return 121; -} -function foo(a: FixedArray): int { - return 122; -} -function foo(a: FixedArray): int { - return 123; -} -function foo(a: FixedArray): int { - return 124; -} -function foo(a: FixedArray): int { - return 125; -} -function foo(a: FixedArray): int { - return 126; -} -function foo(a: FixedArray): int { - return 127; -} -function foo(a: FixedArray): int { - return 128; -} -function foo(a: FixedArray): int { - return 129; -} -function foo(a: FixedArray): int { - return 130; -} -function foo(a: FixedArray): int { - return 131; -} -function foo(a: FixedArray): int { - return 132; -} + {{c.defs}} -function main(): int { - if (foo({{c.exp}}) == {{c.res}}) return 0; - return 1; +function main() { + assertEQ(foo({{c.exp}}), {{c.res}}) } {% endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/typ.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/typ.params.yaml index 6bb918e09bf3f5c245cf76402f0c7fa7bc42674c..2cc8cb57bfb75dfe6132e563c8a8064e3ee1606d 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/typ.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/01.evaluation_of_expressions/typ.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 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 @@ -22,17 +22,17 @@ cases: - defs: |- let v: long = 1; let w: int = 12; - exp: v = w / 2 + (v as short) - (42 as byte) + exp: v = w / 2 + (v.toShort()) - (42 as byte) res: 5 - exp: '[1 as short, 2, 3]' - res: 104 + res: 102 - exp: '[new Object(), "abc"]' - res: 132 + res: 32 - exp: '[new Int(1), 2, 3]' - res: 124 + res: 104 - defs: |- let d: Double[]; @@ -43,3 +43,4 @@ cases: let k = new Long[3]; exp: '14 + (k[2] = 2 as long) + k[2] * (k[1] = 1 as long)' res: 5 + diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/03.named_reference/named_reference_20.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/03.named_reference/named_reference_20.ets index bada663a47c1412ec2bfc49116add998a9bb0b1a..26c094ba2729f56e7daf8f6c72d46a9a76a712f6 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/03.named_reference/named_reference_20.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/03.named_reference/named_reference_20.ets @@ -17,7 +17,7 @@ desc: To verify the initialization behavior of default parameter values. ---*/ -let defaultVal = 5; +let defaultVal = 5 as number; function withDefault(param: number = defaultVal + 1): number { return param; diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_assn.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_assn.params.yaml index 2e72aad439c7bf73e99f6942d44fbb1e091e802c..0416b3decaa2da39f55f3aa4ee56b311a3999875 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_assn.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_assn.params.yaml @@ -106,10 +106,11 @@ cases: assertEQ(a.length, 4) - decl: |- - function bar(i: int): char { - return (i + 1) as char + function bar(i: Int): Char { + let v: Int = i + 1 + return v.toChar() } - let a: Array = [] + let a: Array = [] use: |- // assignment context, array of chars a = [bar(42), bar(43), bar(44), ] diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_call.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_call.params.yaml index e929d3865eebf8840c560ee083be7e4770577906..ade8b32dcda27878445d2577d0f2350bbd13c4f2 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_call.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_call.params.yaml @@ -106,10 +106,11 @@ cases: foo(['x', 'x' + '1', 'x' + '2', 'x' + '3', ]) - decl: |- - function bar(i: int): char { - return (i + 1) as char + function bar(i: Int): Char { + let v: Int = i + 1 + return v.toChar() } - function foo(a: Array) { + function foo(a: Array) { assertEQ(a[0], c'+') assertEQ(a[1], c',') assertEQ(a[2], c'-') diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_cast.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_cast.params.yaml index 3c693baaa854dc52e6fdceb9634eb0554c3fe7d0..68b125bbe2f44dba919908eb18820357b4de1e90 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_cast.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_cast.params.yaml @@ -86,12 +86,13 @@ cases: assertEQ(a.length, 4) - decl: |- - function bar(i: int): char { - return (i + 1) as char + function bar(i: Int): Char { + let v: Int = i + 1 + return v.toChar() } use: |- // casting context, array of chars - let a = [bar(42), bar(43), bar(44), ] as Array + let a = [bar(42), bar(43), bar(44), ] as Array assertEQ(a[0], c'+') assertEQ(a[1], c',') assertEQ(a[2], c'-') diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_decl.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_decl.params.yaml index 5ada3cce5396ccd144f3b27b41a596af4136eed7..818c5fcfec8fb10a9598cdf3ba1ac3ec2090e9cd 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_decl.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_decl.params.yaml @@ -86,12 +86,13 @@ cases: assertEQ(a.length, 4) - decl: |- - function bar(i: int): char { - return (i + 1) as char + function bar(i: Int): Char { + let v: Int = i + 1 + return v.toChar() } use: |- // declaration context, array of chars - let a: Array = [bar(42), bar(43), bar(44), ] + let a: Array = [bar(42), bar(43), bar(44), ] assertEQ(a[0], c'+') assertEQ(a[1], c',') assertEQ(a[2], c'-') diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_assn.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_assn.params.yaml index 47e101c72b4f1c7b3db0fbbcfb2492899f51243f..9b1b1e3c815d0047f990cd89fadf6405fbe33b59 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_assn.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_assn.params.yaml @@ -106,10 +106,11 @@ cases: assertEQ(a.length, 4) - decl: |- - function bar(i: int): char { - return (i + 1) as char + function bar(i: Int): Char { + let v: Int = i + 1 + return v.toChar() } - let a: FixedArray = [] + let a: FixedArray = [] use: |- // assignment context, array of chars a = [bar(42), bar(43), bar(44), ] diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_call.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_call.params.yaml index 1e827ece4b6728370a2c4bd1e1b569d7fafa4fea..28c6583e1d4e9dc0a1cd1c694ba1098546a5a68f 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_call.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_call.params.yaml @@ -106,10 +106,11 @@ cases: foo(['x', 'x' + '1', 'x' + '2', 'x' + '3', ]) - decl: |- - function bar(i: int): char { - return (i + 1) as char + function bar(i: Int): Char { + let v: Int = i + 1 + return v.toChar() } - function foo(a: FixedArray) { + function foo(a: FixedArray) { assertEQ(a[0], c'+') assertEQ(a[1], c',') assertEQ(a[2], c'-') diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_cast.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_cast.params.yaml index 823b2d2c538188931e8bb3c92595f9cd86649d19..5c726deda33f2b5ba3732669b648205565413545 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_cast.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_cast.params.yaml @@ -86,12 +86,13 @@ cases: assertEQ(a.length, 4) - decl: |- - function bar(i: int): char { - return (i + 1) as char + function bar(i: Int): Char { + let v: Int = i + 1 + return v.toChar() } use: |- // casting context, array of chars - let a = [bar(42), bar(43), bar(44), ] as FixedArray + let a = [bar(42), bar(43), bar(44), ] as FixedArray assertEQ(a[0], c'+') assertEQ(a[1], c',') assertEQ(a[2], c'-') diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_decl.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_decl.params.yaml index 1906fe378cb8a10c5998e16c15c71b4df47b6200..6d540a3b8a5c33b511ffb16d33e7b9cf3c1fe588 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_decl.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_decl.params.yaml @@ -86,12 +86,13 @@ cases: assertEQ(a.length, 4) - decl: |- - function bar(i: int): char { - return (i + 1) as char + function bar(i: Int): Char { + let v: Int = i + 1 + return v.toChar() } use: |- // declaration context, array of chars - let a: FixedArray = [bar(42), bar(43), bar(44), ] + let a: FixedArray = [bar(42), bar(43), bar(44), ] assertEQ(a[0], c'+') assertEQ(a[1], c',') assertEQ(a[2], c'-') diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr_inf_assn.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr_inf_assn.params.yaml index 5cc34dbe903b580562da2a8cdf60e4946af061da..0fbbf1d74ae220db5fb61cea84d281bcdd63bb2d 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr_inf_assn.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr_inf_assn.params.yaml @@ -106,10 +106,11 @@ cases: assertEQ(a.length, 4) - decl: |- - function bar(i: int): char { - return (i + 1) as char + function bar(i: Int): Char { + let v: Int = i + 1 + return v.toChar() } - let a: char[] = [] + let a: Char[] = [] use: |- // assignment context, array of chars a = [bar(42), bar(43), bar(44), ] diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr_inf_call.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr_inf_call.params.yaml index 1e827ece4b6728370a2c4bd1e1b569d7fafa4fea..fcbf40b1d861bc09a20e1cb5a5bc3d575fb956d6 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr_inf_call.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr_inf_call.params.yaml @@ -106,10 +106,11 @@ cases: foo(['x', 'x' + '1', 'x' + '2', 'x' + '3', ]) - decl: |- - function bar(i: int): char { - return (i + 1) as char + function bar(i: Int): Char { + let v: Int = i + 1 + return v.toChar() } - function foo(a: FixedArray) { + function foo(a: FixedArray) { assertEQ(a[0], c'+') assertEQ(a[1], c',') assertEQ(a[2], c'-') diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr_inf_cast.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr_inf_cast.params.yaml index f983dd68a1a4c1de0ad66e4bf34b69f904805886..b0e8275c5ad92fab124d4bba27f9ed41bb60b741 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr_inf_cast.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr_inf_cast.params.yaml @@ -86,12 +86,13 @@ cases: assertEQ(a.length, 4) - decl: |- - function bar(i: int): char { - return (i + 1) as char + function bar(i: Int): Char { + let v: Int = i + 1 + return v.toChar() } use: |- // casting context, array of chars - let a = [bar(42), bar(43), bar(44), ] as char[] + let a = [bar(42), bar(43), bar(44), ] as Char[] assertEQ(a[0], c'+') assertEQ(a[1], c',') assertEQ(a[2], c'-') diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr_inf_decl.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr_inf_decl.params.yaml index 3301c5c7bf474d0ab4e96700905a96de72d28206..58cafdb8cc8cb2885ccf307fe15e48c8b72fc878 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr_inf_decl.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/01.type_inference_from_context/arr_inf_decl.params.yaml @@ -86,12 +86,13 @@ cases: assertEQ(a.length, 4) - decl: |- - function bar(i: int): char { - return (i + 1) as char + function bar(i: Int): Char { + let v: Int = i + 1 + return v.toChar() } use: |- // declaration context, array of chars - let a: char[] = [bar(42), bar(43), bar(44), ] + let a: Char[] = [bar(42), bar(43), bar(44), ] assertEQ(a[0], c'+') assertEQ(a[1], c',') assertEQ(a[2], c'-') diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2.params.yaml index 565bc5aefbfa41f4902393ceb87f601484480cb3..cd74918e4b72ca6dd6c742a0b7edf693ab3e8eef 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2.params.yaml @@ -41,7 +41,7 @@ cases: - use: |- let x = [new Long(), new Number(), new Short()] - assertTrue( x instanceof number[] ) + assertTrue( x instanceof Numeric[] ) - use: |- let x = [new Long(), new Number(), null, new Short(), undefined] diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2_num1.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2_num1.ets index af74426cd354dc6ce5016b653aa15ff083a3e8de..199d9740e7852b425f948626832b320dc73c40d5 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2_num1.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2_num1.ets @@ -23,6 +23,6 @@ desc: >- {{c.decl}} function main() { - assertTrue( {{c.val}} instanceof number[] ) + assertTrue( {{c.val}} instanceof {%- if c.type is defined %} {{c.type}} {%- else %} Numeric {%- endif %} [] ) } {% endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2_num1.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2_num1.params.yaml index 2cb1e73582dde3d4d9a375a24b2b5e9462956c9d..d47f45c5e42083a99ef2d80ec82b95e4fe8e4517 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2_num1.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2_num1.params.yaml @@ -13,27 +13,31 @@ --- cases: - # zeros - - val: '[0, 0, 0, 0, 0, ]' - - val: '[0.0f]' + # literals + - { val: '[0, 0, 0, 0, 0]', type: number } + - { val: '[0.0, 1.0, 2.0, 3.0, 4.0]', type: number } + - { val: '[0, 1.0, 0, 2.0, 0]', type: number } + - { val: '[0.0f]', type: float } + - val: '[0.0f, 1]' + - val: '[0.0f, 2.0]' - # primitive literals - - val: '[0b01 as byte, 0b10 as byte, 0b11 as byte, 0b01 as byte, 0b10 as byte, ]' - - val: '[0xF as short]' - - val: '[0o7 as int, 0o6 as int, 0o5 as int, ]' - - val: '[-9223372036854775807 as long]' - - val: '[111e11 as float, 222e11 as float, 333e11 as float, ]' - - val: '[222e22 as double]' - - val: '[11111111111n]' + # primitives + - { val: '[0b01 as byte, 0b10 as byte, 0b11 as byte, 0b01 as byte, 0b10 as byte, ]', type: byte } + - { val: '[0xF as short]', type: short } + - { val: '[0o7 as int, 0o6 as int, 0o5 as int, ]', type: int } + - { val: '[-9223372036854775807 as long]', type: long } + - { val: '[111e11 as float, 222e11 as float, 333e11 as float, ]', type: float } + - { val: '[222e22 as double]', type: number } + - { val: '[11111111111n]', type: BigInt } # boxed - - val: '[new Byte]' - - val: '[new Short]' - - val: '[new Int]' - - val: '[new Long]' - - val: '[new Float]' - - val: '[new Double]' - - val: '[new BigInt(5)]' + - { val: '[new Byte]', type: byte } + - { val: '[new Short]', type: short } + - { val: '[new Int]', type: int } + - { val: '[new Long]', type: long } + - { val: '[new Float]', type: float } + - { val: '[new Double]', type: number } + - { val: '[new BigInt(5)]', type: BigInt } # combinations - val: '[0b1, 0xF, 0o7, 1e1, 3f, 9223372036854775807]' @@ -70,6 +74,7 @@ cases: let f: Double = 6 let g: bigint = 7n val: '[a, b, c, d, e, f, g]' + type: Object - decl: |- let a: Byte = 1 @@ -80,6 +85,8 @@ cases: let f: double = 6 let g: BigInt = new BigInt(7) val: '[a, b, c, d, e, f, g]' + type: Object + # variables and constants - decl: |- @@ -109,6 +116,7 @@ cases: let f: Double = 6 const g: bigint = 7n val: '[a, b, 0, c, d, e, f, g]' + type: Object - decl: |- const a: Byte = 1 @@ -119,3 +127,4 @@ cases: let f: double = 6 const g: BigInt = new BigInt(7) val: '[a, b, c, 0, d, e, f, g]' + type: Object diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2_num2.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2_num2.ets index a222482a953de585d3efa54b86a75495f7585961..f59fe7ab88dbbde57a0da4ef3b56033b3d74b129 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2_num2.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2_num2.ets @@ -23,6 +23,6 @@ desc: >- {{c.decl}} function main() { - assertTrue( {{c.val}} instanceof number[][] ) + assertTrue( {{c.val}} instanceof {%- if c.type is defined %} {{c.type}} {%- else %} Numeric {%- endif %} [][] ) } {% endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2_num2.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2_num2.params.yaml index acbdafe98c225261ed8c012a0cba4dc382a16b87..0a8e9b71938e8ee2e225f8680948a4bbb626b241 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2_num2.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2_num2.params.yaml @@ -13,27 +13,31 @@ --- cases: - # zeros - - val: '[[0]]' - - val: '[[0.0f]]' + # literals + - { val: '[[0]]', type: number } + - { val: '[[0.0, 1.0], [2.0, 3.0], [4.0]]', type: number } + - { val: '[[0, 1.0], [0, 2.0]]', type: number } + - { val: '[[0.0f]]', type: float } + - val: '[[0.0f, 1]]' + - val: '[[0.0f, 2.0]]' # primitives - - val: '[[0b1 as byte]]' - - val: '[[0xF as short]]' - - val: '[[0o7 as int]]' - - val: '[[-9223372036854775807 as long]]' - - val: '[[111e11 as float]]' - - val: '[[222e22 as double]]' - - val: '[[11111111111n]]' + - { val: '[[0b1 as byte]]', type: byte } + - { val: '[[0xF as short]]', type: short} + - { val: '[[0o7 as int]]', type: int } + - { val: '[[-9223372036854775807 as long]]', type: long } + - { val: '[[111e11 as float]]', type: float } + - { val: '[[222e22 as double]]', type: number } + - { val: '[[11111111111n]]', type: BigInt } # boxed - - val: '[[new Byte]]' - - val: '[[new Short]]' - - val: '[[new Int]]' - - val: '[[new Long]]' - - val: '[[new Float]]' - - val: '[[new Double]]' - - val: '[[new BigInt(5)]]' + - { val: '[[new Byte]]', type: byte } + - { val: '[[new Short]]', type: short } + - { val: '[[new Int]]', type: int } + - { val: '[[new Long]]', type: long } + - { val: '[[new Float]]', type: float } + - { val: '[[new Double]]', type: number } + - { val: '[[new BigInt(5)]]', type: BigInt } # combinations - val: '[[0b1, 0xF, 0o7, 1e1, 3f, 9223372036854775807]]' @@ -70,6 +74,7 @@ cases: let f: Double = 6 let g: bigint = 7n val: '[[a, b, c, d, e, f, g]]' + type: Object - decl: |- let a: Byte = 1 @@ -80,6 +85,7 @@ cases: let f: double = 6 let g: BigInt = new BigInt(7) val: '[[a, b, c, d, e, f, g]]' + type: Object # variables and constants - decl: |- @@ -89,7 +95,7 @@ cases: const d: long = 4 let e: float = 5 const f: double = 6 - val: '[[0, a], [b, c, d], [e, f,]]' + val: '[[0, a] as Integral[], [b, c, d] as Integral[], [e, f,] as Numeric[]]' - decl: |- const a: Byte = 1 @@ -98,7 +104,7 @@ cases: let d: Long = 4 const e: Float = 5 let f: Double = 6 - val: '[[a, 0, b, c], [d, e, f,]]' + val: '[[a, 0, b, c] as Integral[], [d, e, f,] as Numeric[]]' - decl: |- const a: byte = 1 @@ -108,7 +114,8 @@ cases: const e: float = 5 let f: Double = 6 const g: bigint = 7n - val: '[[a, b], [0, c], [d, e], [f, g]]' + val: '[[a, b] as Integral[], [0, c] as Integral[], [d, e] as Numeric[], [f, g] as Object[]]' + type: Object - decl: |- const a: Byte = 1 @@ -118,4 +125,5 @@ cases: const e: Float = 5 let f: double = 6 const g: BigInt = new BigInt(7) - val: '[[a, b], [c, 0], [d, e], [f, g]]' + val: '[[a, b] as Integral[], [c, 0] as Integral[], [d, e] as Numeric[], [f, g] as Object[]]' + type: Object diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/09.field_access_expressions/01.accessing_current_object_fields/access_static_field_nn.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/09.field_access_expressions/01.accessing_current_object_fields/access_static_field_nn.params.yaml index 35e604eb33a1caef9765fe78b6acc7501c906fba..4f023400df39e2559c299deebf1c4418e035f12b 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/09.field_access_expressions/01.accessing_current_object_fields/access_static_field_nn.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/09.field_access_expressions/01.accessing_current_object_fields/access_static_field_nn.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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,7 +16,7 @@ cases: - { type: "byte", value: "2", assert: "A.a == 2"} - { type: "short", value: "2", assert: "A.a == 2"} - { type: "long", value: "2", assert: "A.a == 2"} - - { type: "float", value: "1.2", assert: "A.a == 1.2 as float"} + - { type: "float", value: "1.2f", assert: "A.a == 1.2f as float"} - { type: "double", value: "2", assert: "A.a == 2"} - { type: "char", value: "c'a'", assert: "A.a == c'a'"} - { type: "boolean", value: "true", assert: "A.a == true"} @@ -25,7 +25,7 @@ cases: - { type: "Short", value: "new Short(2 as short)", assert: "A.a == 2"} - { type: "Int", value: "new Int(2)", assert: "A.a == 2"} - { type: "Long", value: "new Long(2)", assert: "A.a == 2"} - - { type: "Float", value: "new Float(1.2)", assert: "A.a == 1.2 as float"} + - { type: "Float", value: "new Float(1.2)", assert: "A.a == 1.2f as float"} - { type: "Double", value: "new Double(1.2)", assert: "A.a == 1.2"} - { type: "Char", value: "new Char(c'a')", assert: "A.a == c'a'"} - { type: "Boolean", value: "new Boolean(true)", assert: "A.a == true"} diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/09.field_access_expressions/02.accessing_superclass_fields/access_by_super_in_field_nn.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/09.field_access_expressions/02.accessing_superclass_fields/access_by_super_in_field_nn.params.yaml index e37a2b806b6a47ff936f1afc0c4975ab28403c62..5714e30f589a3af533b1f16f37de790caeebf276 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/09.field_access_expressions/02.accessing_superclass_fields/access_by_super_in_field_nn.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/09.field_access_expressions/02.accessing_superclass_fields/access_by_super_in_field_nn.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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,7 +16,7 @@ cases: - { type: "byte", value: "2", assert: "instance.b == 2"} - { type: "short", value: "2", assert: "instance.b == 2"} - { type: "long", value: "2", assert: "instance.b == 2"} - - { type: "float", value: "1.2", assert: "instance.b == 1.2 as float"} + - { type: "float", value: "1.2f", assert: "instance.b == 1.2f as float"} - { type: "double", value: "2", assert: "instance.b == 2"} - { type: "char", value: "c'a'", assert: "instance.b == c'a'"} - { type: "boolean", value: "true", assert: "instance.b == true"} diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/10.method_call_expression/02.step_2_selection_of_method/step2.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/10.method_call_expression/02.step_2_selection_of_method/step2.ets index 9961eddd0619c3cee9c0f118ffbf42bd49ce654a..7994e0704de535a3c8cd89a947b5504f0aebc120 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/10.method_call_expression/02.step_2_selection_of_method/step2.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/10.method_call_expression/02.step_2_selection_of_method/step2.ets @@ -17,6 +17,7 @@ limitations under the License. /*--- desc: >- As there is more than one applicable method, the most specific method must be selected. +tags: [{{c.tags}}] ---*/ {{c.decl}} diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/10.method_call_expression/02.step_2_selection_of_method/step2.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/10.method_call_expression/02.step_2_selection_of_method/step2.params.yaml index 5fdbbe4b7c20ff8db5b5301977d34614ebd679ed..2ed7918775f36efb1c420dcab933e116eb358ce4 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/10.method_call_expression/02.step_2_selection_of_method/step2.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/10.method_call_expression/02.step_2_selection_of_method/step2.params.yaml @@ -22,6 +22,7 @@ cases: return "N" } } + tags: 'compile-only, negative' use: |- // select method with no boxing/unboxing let c: C = new C() @@ -64,6 +65,7 @@ cases: return "NR" } } + tags: 'compile-only, negative' use: |- // select method with rest parameter let c: C = new C() @@ -106,6 +108,7 @@ cases: return "ND1" } } + tags: 'compile-only, negative' use: |- // select method with default parameter let c: C = new C() @@ -148,6 +151,7 @@ cases: return "ND2" } } + tags: 'compile-only, negative' use: |- // select method with undefined parameter let c: C = new C() @@ -180,7 +184,9 @@ cases: assertEQ( c.met(0.0), "ND2" ) assertEQ( c.met(new Number()), "ND2" ) - + # step2_12 + # The best candidate is the candidate that requires no transformation for all arguments. + # If such a candidate is available, then other candidates are not considered. - decl: |- class C { met(...p: number[]): string { @@ -190,29 +196,31 @@ cases: return "ND1" } } + tags: 'compile-only' use: |- // select method with rest parameter and default parameter let c: C = new C() - assertEQ( c.met(0.0), "ND1" ) - assertEQ( c.met(new Number()), "ND1" ) - + assertEQ( c.met(0.0), "nR" ) + assertEQ( c.met(1, 2), "ND1" ) + # step2_13 - decl: |- class C { met(...p: number[]): string { return "nR" } met(p: Number, q?: Number): string { - return "ND2" + return "nR" } } + tags: 'compile-only' use: |- // select method with rest parameter and undefined parameter let c: C = new C() - assertEQ( c.met(0.0), "ND2" ) - assertEQ( c.met(new Number()), "ND2" ) - + assertEQ( c.met(0.0), "nR" ) + assertEQ( c.met(2, 3), "ND2" ) + # step2_14 - decl: |- class C { met(p: number, q: number = 0.0): string { @@ -222,13 +230,14 @@ cases: return "NR" } } + tags: 'compile-only' use: |- // select method with rest parameter and default parameter let c: C = new C() assertEQ( c.met(0.0), "nD1" ) - assertEQ( c.met(new Number()), "NR" ) - + assertEQ( c.met(3, 4), "NR" ) + # step2_15 - decl: |- class C { met(p: number, q?: Number): string { @@ -238,11 +247,12 @@ cases: return "NR" } } + tags: 'compile-only' use: |- // select method with rest parameter and default parameter let c: C = new C() assertEQ( c.met(0.0), "nD2" ) - assertEQ( c.met(new Number()), "NR" ) + assertEQ( c.met(4, 5), "NR" ) - decl: |- @@ -260,11 +270,12 @@ cases: return "NR" } } + tags: 'compile-only, negative' use: |- // select method without boxing/unboxing and without rest let c: C = new C() assertEQ( c.met(0.0), "n" ) - assertEQ( c.met(new Number()), "N" ) + assertEQ( c.met(new Number()), "n" ) - decl: |- @@ -310,12 +321,6 @@ cases: met(p: number): string { return "n" } - met(p: Number): string { - return "N" - } - met(p: number, q: number = 0.0): string { - return "nD1" - } met(p: Number, q: number = 0.0): string { return "ND1" } @@ -324,7 +329,7 @@ cases: // select method without boxing/unboxing and without default parameter let c: C = new C() assertEQ( c.met(0.0), "n" ) - assertEQ( c.met(new Number()), "N" ) + assertEQ( c.met(new Number()), "n" ) - decl: |- @@ -370,12 +375,6 @@ cases: met(p: number): string { return "n" } - met(p: Number): string { - return "N" - } - met(p: number, q?: Number): string { - return "nD2" - } met(p: Number, q?: Number): string { return "ND2" } @@ -384,7 +383,7 @@ cases: // select method without boxing/unboxing and without undefined parameter let c: C = new C() assertEQ( c.met(0.0), "n" ) - assertEQ( c.met(new Number()), "N" ) + assertEQ( c.met(new Number()), "n" ) - decl: |- @@ -424,7 +423,7 @@ cases: assertEQ( c.met(0.0), "N" ) assertEQ( c.met(new Number()), "N" ) - + # step2_25 - decl: |- class A { met(p: boolean): string { @@ -433,7 +432,7 @@ cases: } class B extends A { met(p: Boolean): string { - return "B-" + p.unboxed() + return "B-" + p } } class C extends B { @@ -441,15 +440,13 @@ cases: return "C-" + p } } + tags: 'compile-only' use: |- let a: A = new C() - assertEQ( a.met(true), "C-true" ) - assertEQ( a.met(new Boolean()), "B-false" ) + assertEQ( a.met(true), "C-true" ) // overriding let b: B = new B() - assertEQ( b.met(true), "A-true" ) - assertEQ( b.met(new Boolean()), "B-false" ) - + assertEQ( b.met(false), "B-false" ) - decl: |- class C { diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/11.function_call_expression/step_1_selection_of_function/step1.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/11.function_call_expression/step_1_selection_of_function/step1.params.yaml index 7a83ee8f436d2e53877e96ecec5226fbf604c931..795877357ccb424605ee73d2ff9cdd2f69e60f34 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/11.function_call_expression/step_1_selection_of_function/step1.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/11.function_call_expression/step_1_selection_of_function/step1.params.yaml @@ -43,7 +43,7 @@ cases: assertEQ( foo(new Number()), "UT" ) - - tags: negative, compile-only + - tags: negative, compile-only decl: |- type UT = 1 | 2 | 3 | number // normalized to Number function foo(p: Number|null): string { @@ -59,7 +59,7 @@ cases: // select the most-specific function without boxing/unboxing assertEQ( foo(new Number()), "UT" ) - + # step1_3 - decl: |- function foo(p: Number|null): string { return "NN" @@ -67,10 +67,11 @@ cases: function foo(p: number): string { return "n" } + tags: 'compile-only' use: |- // select the most-specific function without boxing/unboxing assertEQ( foo(0.0), "n" ) - assertEQ( foo(new Number()), "NN" ) + assertEQ( foo(null), "NN" ) - decl: |- @@ -145,6 +146,7 @@ cases: function foo(p: Number|null, q: number = 1.0): string { return "NND1" } + tags: 'compile-only, negative' use: |- // select function with default parameter assertEQ( foo(0.0), "nD1" ) @@ -184,6 +186,7 @@ cases: function foo(p: Number, q?: Number): string { return "ND2" } + tags: 'compile-only, negative' use: |- // select function with undefined parameter assertEQ( foo(0.0), "nD2" ) @@ -212,7 +215,7 @@ cases: assertEQ( foo(0.0), "ND2" ) assertEQ( foo(new Number()), "ND2" ) - + #step1_15 - decl: |- function foo(p: Number|null, q: number = 1.0): string { return "NND1" @@ -223,12 +226,15 @@ cases: function foo(p: Number, q: number = 0.0): string { return "ND1" } + tags: 'compile-only' use: |- // select function with rest parameter and default parameter - assertEQ( foo(0.0), "ND1" ) - assertEQ( foo(new Number()), "ND1" ) + assertEQ( foo(0.0), "nR" ) + assertEQ( foo(1, 2), "ND1" ) + assertEQ( foo(null), "NND1" ) + #step1_16 - decl: |- function foo(...p: number[]): string { return "nR" @@ -239,10 +245,12 @@ cases: function foo(p: Number|null, q?: Number): string { return "NND2" } + tags: 'compile-only' use: |- // select function with rest parameter and undefined parameter - assertEQ( foo(0.0), "ND2" ) - assertEQ( foo(new Number()), "ND2" ) + assertEQ( foo(0.0), "nR" ) + assertEQ( foo(1, 2), "ND2" ) + assertEQ( foo(null), "NND2" ) - decl: |- @@ -290,6 +298,7 @@ cases: function foo(...p: FixedArray): string { return "NR" } + tags: 'compile-only, negative' use: |- // select function without boxing/unboxing and without rest assertEQ( foo(0.0), "n" ) @@ -427,54 +436,47 @@ cases: // more than one applicable function assertEQ( foo(0.0), "n" ) + # step1_26 - decl: |- - type UT = int | number // normalized to Number - function foo(p: Number): string { - return "N" - } - function foo(p: UT): string { + type UT = int | number + function foo(p: UT): string { return "UT" } + function foo(p: Number | number): string { + return "N" + } + use: |- // duplicate functions - assertEQ( foo(new Number()), "N" ) - + assertEQ( foo(1.0), "N" ) + assertEQ( foo(1 as int), "UT" ) + # step1_27 - decl: |- function foo(p: number): string { return "n" } - function foo(p: Number): string { - return "N" - } - function foo(p: number, q: number = 0.0): string { - return "nD1" - } + function foo(p: Number, q: number = 0.0): string { return "ND1" } use: |- - // select function without boxing/unboxing and without default parameter assertEQ( foo(0.0), "n" ) - assertEQ( foo(new Number()), "N" ) - + assertEQ( foo(1, 2), "ND1" ) + # step1_28 - decl: |- function foo(p: number): string { return "n" } - function foo(p: number, q: number = 0.0): string { - return "nD1" - } function foo(p: Number, q: number = 0.0): string { return "ND1" } use: |- - // select function with unboxing and without default parameter assertEQ( foo(0.0), "n" ) - assertEQ( foo(new Number()), "ND1" ) - + assertEQ( foo(1 ,2), "ND1" ) + # step1_29 - decl: |- function foo(p: Number): string { return "N" @@ -482,29 +484,6 @@ cases: function foo(p: number, q: number = 0.0): string { return "nD1" } - function foo(p: Number, q: number = 0.0): string { - return "ND1" - } use: |- - // select function with boxing and without default parameter - assertEQ( foo(0.0), "nD1" ) - assertEQ( foo(new Number()), "N" ) - - - - decl: |- - function foo(p: number): string { - return "n" - } - function foo(p: Number): string { - return "N" - } - function foo(p: number, q?: Number): string { - return "nD2" - } - function foo(p: Number, q?: Number): string { - return "ND2" - } - use: |- - // select function without boxing/unboxing and without undefined parameter - assertEQ( foo(0.0), "n" ) - assertEQ( foo(new Number()), "N" ) + assertEQ( foo(0.0), "N" ) + assertEQ( foo(1, 2), "nD1" ) diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/15.cast_expressions/cast.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/15.cast_expressions/cast.params.yaml index 18c85d8092004e18100510c9bb63435821aab83f..8889533f5a5ce8443c99a89937c532f41b30b650 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/15.cast_expressions/cast.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/15.cast_expressions/cast.params.yaml @@ -15,13 +15,13 @@ cases: - decl: |- let s = 42 use: |- - let t = s as number // primitive widening + let t = Int.toDouble(s) // primitive widening assertEQ( t, 42.0 ) - decl: |- let s = 42 use: |- - let t = s as Number // primitive widening and boxing + let t = Int.toDouble(s) // primitive widening and boxing assertTrue( t instanceof Number && t.unboxed() == 42.0 ) - decl: |- @@ -45,13 +45,13 @@ cases: - decl: |- let s = 42.0 use: |- - let t = s as int // primitive narrowing + let t = Double.toInt(s) // primitive narrowing assertEQ( t, 42 ) - decl: |- let s: byte = 0x40 as byte use: |- - let t = s as char // primitive widening and narrowing + let t = Byte.toChar(s) // primitive widening and narrowing assertEQ( t, c'@' ) - decl: |- diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/16.instanceof_expression/operand_that_is_not_a_reference_type.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/16.instanceof_expression/operand_that_is_not_a_reference_type.ets index 79748b2d76091623689bacb0de1da905fc390d3f..b5056da686082a18fb1b0c629e67c523336dff3a 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/16.instanceof_expression/operand_that_is_not_a_reference_type.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/16.instanceof_expression/operand_that_is_not_a_reference_type.ets @@ -15,7 +15,6 @@ limitations under the License. /*--- desc: Test with an left-operand that is not a reference type -tags: [compile-only, negative] ---*/ function main(): void { diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/16.instanceof_expression/right_operand_that_is_not_a_reference_type.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/16.instanceof_expression/right_operand_that_is_not_a_reference_type.ets index ae512e0d9402ef6081b4930b59b29cc897c5df7d..2385cfb220908dbf815d9debe0cb2118a4d5c2a9 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/16.instanceof_expression/right_operand_that_is_not_a_reference_type.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/16.instanceof_expression/right_operand_that_is_not_a_reference_type.ets @@ -15,7 +15,6 @@ limitations under the License. /*--- desc: Test with an right-operand that is not a reference type -tags: [compile-only, negative] ---*/ function main(): void { diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/17.typeof_expression/negative.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/17.typeof_expression/negative.ets index c4e0fef79d75f67643a395889eefa7504b9f6f7b..6db6fabf7e07cb9bdd57fcf7cd9954b59853bacb 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/17.typeof_expression/negative.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/17.typeof_expression/negative.ets @@ -19,8 +19,6 @@ desc: If evaluation causes an error, then the result of a typeof expression cannot be determined. ---*/ -//tags: [negative] - {{c.decl}} function main() { @@ -28,7 +26,7 @@ function main() { try { t = typeof {{c.exp}} - }catch (error) { + } catch (error) { // do nothing } diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/17.typeof_expression/negative.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/17.typeof_expression/negative.params.yaml index 6172051cd100aaefcdb969dde294852e9f06a669..c7abeb2a385c934d5de041294bcc5597552d4db2 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/17.typeof_expression/negative.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/17.typeof_expression/negative.params.yaml @@ -22,9 +22,13 @@ cases: exp: array[4] - decl: |- - const a:int = 4 - const b:int = 0 - exp: (a / b) + let a: int = 4 + let b: int = 0 + + function foo(): string|int { + return a > b ? a/b : "" + } + exp: foo() - decl: |- function foo(flag: boolean) { diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/19.nullish-coalescing_expression/lazy_operator_2.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/19.nullish-coalescing_expression/lazy_operator_2.ets index de1fd2e4b933a40cae843005f244fddd9f9fd57f..ffce735427487538c8f6b40bd0cda84d6e0a8723 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/19.nullish-coalescing_expression/lazy_operator_2.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/19.nullish-coalescing_expression/lazy_operator_2.ets @@ -15,7 +15,6 @@ /*--- desc: null safety -> Null-Coalescing Operator. -tags: [negative, compile-only] ---*/ function main(): void { diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/19.nullish-coalescing_expression/left_hand_side_value_type.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/19.nullish-coalescing_expression/left_hand_side_value_type.ets index 52dfff42c64c61c0ab32d12f57d042f39196e53e..ff9a7d54a38d80430bebb2245c2805bf5e66fb5a 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/19.nullish-coalescing_expression/left_hand_side_value_type.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/19.nullish-coalescing_expression/left_hand_side_value_type.ets @@ -16,12 +16,11 @@ /*--- desc: null safety -> Null-Coalescing Operator. assert: It is a compile-time error if the type of the left-hand-side expression is not reference type. -tags: [negative, compile-only] ---*/ function main(): void { let a: int = 5; let b: Int = 4; - let x = a ?? b; + let x = a ?? b; } diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/20.unary_expressions/07.bitwise_complement/bitwise_complement.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/20.unary_expressions/07.bitwise_complement/bitwise_complement.params.yaml index f8033fc5727398505e8a8382095819aa6a3898f4..7d0e469eb0cf44b63a6fc148264a1485a680084e 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/20.unary_expressions/07.bitwise_complement/bitwise_complement.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/20.unary_expressions/07.bitwise_complement/bitwise_complement.params.yaml @@ -53,12 +53,12 @@ bitwise_complement: - {type: long, origin: -3856, dest: 3855} - {type: long, origin: 9223372036854775807, dest: -9223372036854775808} - - {type: float, origin: 0.0, dest: -1.0} - - {type: float, origin: 127.0, dest: -128.0} - - {type: float, origin: 32767.0, dest: -32768.0} - - {type: float, origin: 2147483647.0, dest: -2147483648.0} - - {type: float, origin: 2147483648.0, dest: -2147483648.0} - - {type: float, origin: 2147483649.0, dest: -2147483648.0} + - {type: float, origin: 0.0f, dest: -1.0f} + - {type: float, origin: 127.0f, dest: -128.0f} + - {type: float, origin: 32767.0f, dest: -32768.0f} + - {type: float, origin: 2147483647.0f, dest: -2147483648.0f} + - {type: float, origin: 2147483648.0f, dest: -2147483648.0f} + - {type: float, origin: 2147483649.0f, dest: -2147483648.0f} - {type: double, origin: 0.0, dest: -1.0} diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/22.additive_expressions/02.additive_operators_for_numeric_types/float.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/22.additive_expressions/02.additive_operators_for_numeric_types/float.params.yaml index 7e90275467eb60cd68acdc35368a63a3327906cf..931df340c962fd81f8fa1a685a5b11dc3e59dc7b 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/22.additive_expressions/02.additive_operators_for_numeric_types/float.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/22.additive_expressions/02.additive_operators_for_numeric_types/float.params.yaml @@ -13,13 +13,13 @@ --- # List of addition tests where float float: - - {x: 0.0, y: -0.0, type: "float", result: 0.0} - - {x: -0.0, y: 0.0, type: "float", result: 0.0} - - {x: -0.0, y: -0.0, type: "float", result: -0.0} - - {x: 0.0, y: 0.0, type: "float", result: 0.0} - - {x: 0.0, y: 1.0, type: "float", result: 1.0} - - {x: 1.0, y: 0.0, type: "float", result: 1.0} - - {x: 1.0, y: -1.0, type: "float", result: 0.0} + - {x: 0.0f, y: -0.0f, type: "float", result: 0.0f} + - {x: -0.0f, y: 0.0f, type: "float", result: 0.0f} + - {x: -0.0f, y: -0.0f, type: "float", result: -0.0f} + - {x: 0.0f, y: 0.0f, type: "float", result: 0.0f} + - {x: 0.0f, y: 1.0f, type: "float", result: 1.0f} + - {x: 1.0f, y: 0.0f, type: "float", result: 1.0f} + - {x: 1.0f, y: -1.0f, type: "float", result: 0.0f} - {x: 0.0, y: -0.0, type: "double", result: 0.0} - {x: -0.0, y: 0.0, type: "double", result: 0.0} diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/24.relational_expressions/01.numerical_comparison_operators/float_comparison.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/24.relational_expressions/01.numerical_comparison_operators/float_comparison.ets index e7ac9ff3a2bc0a9aaa6e0018b1131411c840818c..7a2e8cbd68b8e0f5dea853ef11a535839bd90509 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/24.relational_expressions/01.numerical_comparison_operators/float_comparison.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/24.relational_expressions/01.numerical_comparison_operators/float_comparison.ets @@ -20,9 +20,9 @@ desc: Integer comparison {{fc.xvalue}} {{fc.op}} {{fc.yvalue}} ---*/ function main(): void { - let x: {{fc.xtype}} = {{fc.xvalue}} as {{fc.xtype}}; + let x: {{fc.xtype}} = {{fc.xvalue}}.to{{fc.xboxed}}(); let bx: {{fc.xboxed}} = new {{fc.xboxed}}(x); - let y: {{fc.ytype}} = {{fc.yvalue}} as {{fc.ytype}}; + let y: {{fc.ytype}} = {{fc.yvalue}}.to{{fc.yboxed}}(); let by: {{fc.yboxed}} = new {{fc.yboxed}}(y); assertEQ( (x {{fc.op}} y), {{fc.result}} ) assertEQ( (bx {{fc.op}} by), {{fc.result}} ) diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/24.relational_expressions/01.numerical_comparison_operators/float_comparison.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/24.relational_expressions/01.numerical_comparison_operators/float_comparison.params.yaml index 089032baad8dafc24dfc8a4a594174315e4d87b6..609c1a0091a42a427196580e798ae64c6fd13d17 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/24.relational_expressions/01.numerical_comparison_operators/float_comparison.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/24.relational_expressions/01.numerical_comparison_operators/float_comparison.params.yaml @@ -22,10 +22,10 @@ float_comparison: # >, with type promotion - - {xtype: float, xboxed: Float, xvalue: 0.0, ytype: float, yboxed: Float, yvalue: 1.0, op: ">", result: "false"} - - {xtype: float, xboxed: Float, xvalue: 1.0, ytype: float, yboxed: Float, yvalue: 0.0, op: ">", result: "true"} - - {xtype: float, xboxed: Float, xvalue: -1.0, ytype: float, yboxed: Float, yvalue: 0.0, op: ">", result: "false"} - - {xtype: float, xboxed: Float, xvalue: 0.0, ytype: float, yboxed: Float, yvalue: -1.0, op: ">", result: "true"} + - {xtype: float, xboxed: Float, xvalue: 0.0f, ytype: float, yboxed: Float, yvalue: 1.0f, op: ">", result: "false"} + - {xtype: float, xboxed: Float, xvalue: 1.0f, ytype: float, yboxed: Float, yvalue: 0.0f, op: ">", result: "true"} + - {xtype: float, xboxed: Float, xvalue: -1.0f, ytype: float, yboxed: Float, yvalue: 0.0f, op: ">", result: "false"} + - {xtype: float, xboxed: Float, xvalue: 0.0f, ytype: float, yboxed: Float, yvalue: -1.0f, op: ">", result: "true"} # <, no type promotion @@ -36,10 +36,10 @@ float_comparison: # <, with type promotion - - {xtype: float, xboxed: Float, xvalue: 0.0, ytype: float, yboxed: Float, yvalue: 1.0, op: "<", result: "true"} - - {xtype: float, xboxed: Float, xvalue: 1.0, ytype: float, yboxed: Float, yvalue: 0.0, op: "<", result: "false"} - - {xtype: float, xboxed: Float, xvalue: -1.0, ytype: float, yboxed: Float, yvalue: 0.0, op: "<", result: "true"} - - {xtype: float, xboxed: Float, xvalue: 0.0, ytype: float, yboxed: Float, yvalue: -1.0, op: "<", result: "false"} + - {xtype: float, xboxed: Float, xvalue: 0.0f, ytype: float, yboxed: Float, yvalue: 1.0f, op: "<", result: "true"} + - {xtype: float, xboxed: Float, xvalue: 1.0f, ytype: float, yboxed: Float, yvalue: 0.0f, op: "<", result: "false"} + - {xtype: float, xboxed: Float, xvalue: -1.0f, ytype: float, yboxed: Float, yvalue: 0.0f, op: "<", result: "true"} + - {xtype: float, xboxed: Float, xvalue: 0.0f, ytype: float, yboxed: Float, yvalue: -1.0f, op: "<", result: "false"} # >=, no type promotion @@ -50,10 +50,10 @@ float_comparison: # >=, with type promotion - - {xtype: double, xboxed: Double, xvalue: 0.0, ytype: float, yboxed: Float, yvalue: 1.0, op: ">=", result: "false"} - - {xtype: double, xboxed: Double, xvalue: 1.0, ytype: float, yboxed: Float, yvalue: 0.0, op: ">=", result: "true"} - - {xtype: double, xboxed: Double, xvalue: -1.0, ytype: float, yboxed: Float, yvalue: 0.0, op: ">=", result: "false"} - - {xtype: double, xboxed: Double, xvalue: 0.0, ytype: float, yboxed: Float, yvalue: -1.0, op: ">=", result: "true"} + - {xtype: double, xboxed: Double, xvalue: 0.0, ytype: float, yboxed: Float, yvalue: 1.0f, op: ">=", result: "false"} + - {xtype: double, xboxed: Double, xvalue: 1.0, ytype: float, yboxed: Float, yvalue: 0.0f, op: ">=", result: "true"} + - {xtype: double, xboxed: Double, xvalue: -1.0, ytype: float, yboxed: Float, yvalue: 0.0f, op: ">=", result: "false"} + - {xtype: double, xboxed: Double, xvalue: 0.0, ytype: float, yboxed: Float, yvalue: -1.0f, op: ">=", result: "true"} # <=, no type promotion @@ -64,21 +64,21 @@ float_comparison: # <=, with type promotion - - {xtype: float, xboxed: Float, xvalue: 0.0, ytype: float, yboxed: Float, yvalue: 1.0, op: "<=", result: "true"} - - {xtype: float, xboxed: Float, xvalue: 1.0, ytype: float, yboxed: Float, yvalue: 0.0, op: "<=", result: "false"} - - {xtype: float, xboxed: Float, xvalue: -1.0, ytype: float, yboxed: Float, yvalue: 0.0, op: "<=", result: "true"} - - {xtype: float, xboxed: Float, xvalue: 0.0, ytype: float, yboxed: Float, yvalue: -1.0, op: "<=", result: "false"} + - {xtype: float, xboxed: Float, xvalue: 0.0f, ytype: float, yboxed: Float, yvalue: 1.0f, op: "<=", result: "true"} + - {xtype: float, xboxed: Float, xvalue: 1.0f, ytype: float, yboxed: Float, yvalue: 0.0f, op: "<=", result: "false"} + - {xtype: float, xboxed: Float, xvalue: -1.0f, ytype: float, yboxed: Float, yvalue: 0.0f, op: "<=", result: "true"} + - {xtype: float, xboxed: Float, xvalue: 0.0f, ytype: float, yboxed: Float, yvalue: -1.0f, op: "<=", result: "false"} # >=, <= - - {xtype: float, xboxed: Double, xvalue: 0.0, ytype: float, yboxed: Float, yvalue: -0.0, op: ">=", result: "true"} - - {xtype: float, xboxed: Double, xvalue: 0.0, ytype: float, yboxed: Float, yvalue: -0.0, op: "<=", result: "true"} + - {xtype: float, xboxed: Double, xvalue: 0.0f, ytype: float, yboxed: Float, yvalue: -0.0f, op: ">=", result: "true"} + - {xtype: float, xboxed: Double, xvalue: 0.0f, ytype: float, yboxed: Float, yvalue: -0.0f, op: "<=", result: "true"} - - {xtype: float, xboxed: Double, xvalue: 1.0, ytype: float, yboxed: Float, yvalue: 1.0, op: ">=", result: "true"} - - {xtype: float, xboxed: Double, xvalue: 1.0, ytype: float, yboxed: Float, yvalue: 1.0, op: "<=", result: "true"} + - {xtype: float, xboxed: Double, xvalue: 1.0f, ytype: float, yboxed: Float, yvalue: 1.0f, op: ">=", result: "true"} + - {xtype: float, xboxed: Double, xvalue: 1.0f, ytype: float, yboxed: Float, yvalue: 1.0f, op: "<=", result: "true"} - - {xtype: float, xboxed: Double, xvalue: -1.0, ytype: float, yboxed: Float, yvalue: -1.0, op: ">=", result: "true"} - - {xtype: float, xboxed: Double, xvalue: -1.0, ytype: float, yboxed: Float, yvalue: -1.0, op: "<=", result: "true"} + - {xtype: float, xboxed: Double, xvalue: -1.0f, ytype: float, yboxed: Float, yvalue: -1.0f, op: ">=", result: "true"} + - {xtype: float, xboxed: Double, xvalue: -1.0f, ytype: float, yboxed: Float, yvalue: -1.0f, op: "<=", result: "true"} - {xtype: double, xboxed: Double, xvalue: 0.0, ytype: double, yboxed: Double, yvalue: -0.0, op: ">=", result: "true"} @@ -92,17 +92,17 @@ float_comparison: # NaNs - - {xtype: float, xboxed: Float, xvalue: "sqrt(-1)", ytype: float, yboxed: Float, yvalue: 0.0, op: ">", result: "false"} - - {xtype: float, xboxed: Float, xvalue: 0.0, ytype: float, yboxed: Float, yvalue: "sqrt(-1)", op: ">", result: "false"} + - {xtype: float, xboxed: Float, xvalue: "sqrt(-1f)", ytype: float, yboxed: Float, yvalue: 0.0f, op: ">", result: "false"} + - {xtype: float, xboxed: Float, xvalue: 0.0f, ytype: float, yboxed: Float, yvalue: "sqrt(-1f)", op: ">", result: "false"} - - {xtype: float, xboxed: Float, xvalue: "sqrt(-1)", ytype: float, yboxed: Float, yvalue: 0.0, op: "<", result: "false"} - - {xtype: float, xboxed: Float, xvalue: 0.0, ytype: float, yboxed: Float, yvalue: "sqrt(-1)", op: "<", result: "false"} + - {xtype: float, xboxed: Float, xvalue: "sqrt(-1f)", ytype: float, yboxed: Float, yvalue: 0.0f, op: "<", result: "false"} + - {xtype: float, xboxed: Float, xvalue: 0.0f, ytype: float, yboxed: Float, yvalue: "sqrt(-1f)", op: "<", result: "false"} - - {xtype: float, xboxed: Float, xvalue: "sqrt(-1)", ytype: float, yboxed: Float, yvalue: 0.0, op: ">=", result: "false"} - - {xtype: float, xboxed: Float, xvalue: 0.0, ytype: float, yboxed: Float, yvalue: "sqrt(-1)", op: ">=", result: "false"} + - {xtype: float, xboxed: Float, xvalue: "sqrt(-1f)", ytype: float, yboxed: Float, yvalue: 0.0f, op: ">=", result: "false"} + - {xtype: float, xboxed: Float, xvalue: 0.0f, ytype: float, yboxed: Float, yvalue: "sqrt(-1f)", op: ">=", result: "false"} - - {xtype: float, xboxed: Float, xvalue: "sqrt(-1)", ytype: float, yboxed: Float, yvalue: 0.0, op: "<=", result: "false"} - - {xtype: float, xboxed: Float, xvalue: 0.0, ytype: float, yboxed: Float, yvalue: "sqrt(-1)", op: "<=", result: "false"} + - {xtype: float, xboxed: Float, xvalue: "sqrt(-1)", ytype: float, yboxed: Float, yvalue: 0.0f, op: "<=", result: "false"} + - {xtype: float, xboxed: Float, xvalue: 0.0f, ytype: float, yboxed: Float, yvalue: "sqrt(-1f)", op: "<=", result: "false"} - {xtype: double, xboxed: Double, xvalue: "sqrt(-1)", ytype: double, yboxed: Double, yvalue: 0.0, op: ">", result: "false"} - {xtype: double, xboxed: Double, xvalue: 0.0, ytype: double, yboxed: Double, yvalue: "sqrt(-1)", op: ">", result: "false"} @@ -118,20 +118,20 @@ float_comparison: # INFs - - {xtype: float, xboxed: Float, xvalue: "log(0)", ytype: float, yboxed: Float, yvalue: 0.0, op: "<", result: "true"} - - {xtype: float, xboxed: Float, xvalue: "log(0)", ytype: float, yboxed: Float, yvalue: 0.0, op: "<=", result: "true"} - - {xtype: float, xboxed: Float, xvalue: "log(0)", ytype: float, yboxed: Float, yvalue: 0.0, op: ">", result: "false"} - - {xtype: float, xboxed: Float, xvalue: "log(0)", ytype: float, yboxed: Float, yvalue: 0.0, op: ">=", result: "false"} + - {xtype: float, xboxed: Float, xvalue: "log(0f)", ytype: float, yboxed: Float, yvalue: 0.0f, op: "<", result: "true"} + - {xtype: float, xboxed: Float, xvalue: "log(0f)", ytype: float, yboxed: Float, yvalue: 0.0f, op: "<=", result: "true"} + - {xtype: float, xboxed: Float, xvalue: "log(0f)", ytype: float, yboxed: Float, yvalue: 0.0f, op: ">", result: "false"} + - {xtype: float, xboxed: Float, xvalue: "log(0f)", ytype: float, yboxed: Float, yvalue: 0.0f, op: ">=", result: "false"} - - {xtype: float, xboxed: Float, xvalue: 0.0, ytype: float, yboxed: Float, yvalue: 1.0/0.0, op: "<", result: "true"} - - {xtype: float, xboxed: Float, xvalue: 0.0, ytype: float, yboxed: Float, yvalue: 1.0/0.0, op: "<=", result: "true"} - - {xtype: float, xboxed: Float, xvalue: 0.0, ytype: float, yboxed: Float, yvalue: 1.0/0.0, op: ">", result: "false"} - - {xtype: float, xboxed: Float, xvalue: 0.0, ytype: float, yboxed: Float, yvalue: 1.0/0.0, op: ">=", result: "false"} + - {xtype: float, xboxed: Float, xvalue: 0.0f, ytype: float, yboxed: Float, yvalue: 1.0f/0.0f, op: "<", result: "true"} + - {xtype: float, xboxed: Float, xvalue: 0.0f, ytype: float, yboxed: Float, yvalue: 1.0f/0.0f, op: "<=", result: "true"} + - {xtype: float, xboxed: Float, xvalue: 0.0f, ytype: float, yboxed: Float, yvalue: 1.0f/0.0f, op: ">", result: "false"} + - {xtype: float, xboxed: Float, xvalue: 0.0f, ytype: float, yboxed: Float, yvalue: 1.0f/0.0f, op: ">=", result: "false"} - - {xtype: float, xboxed: Float, xvalue: "log(0)", ytype: float, yboxed: Float, yvalue: 1.0/0.0, op: "<", result: "true"} - - {xtype: float, xboxed: Float, xvalue: "log(0)", ytype: float, yboxed: Float, yvalue: 1.0/0.0, op: "<=", result: "true"} - - {xtype: float, xboxed: Float, xvalue: "log(0)", ytype: float, yboxed: Float, yvalue: 1.0/0.0, op: ">", result: "false"} - - {xtype: float, xboxed: Float, xvalue: "log(0)", ytype: float, yboxed: Float, yvalue: 1.0/0.0, op: ">=", result: "false"} + - {xtype: float, xboxed: Float, xvalue: "log(0f)", ytype: float, yboxed: Float, yvalue: 1.0f/0.0f, op: "<", result: "true"} + - {xtype: float, xboxed: Float, xvalue: "log(0f)", ytype: float, yboxed: Float, yvalue: 1.0f/0.0f, op: "<=", result: "true"} + - {xtype: float, xboxed: Float, xvalue: "log(0f)", ytype: float, yboxed: Float, yvalue: 1.0f/0.0f, op: ">", result: "false"} + - {xtype: float, xboxed: Float, xvalue: "log(0f)", ytype: float, yboxed: Float, yvalue: 1.0f/0.0f, op: ">=", result: "false"} - {xtype: double, xboxed: Double, xvalue: "log(0)", ytype: double, yboxed: Double, yvalue: 0.0, op: "<", result: "true"} diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/25.equality_expressions/strict_primitive_compare.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/25.equality_expressions/strict_primitive_compare.params.yaml index d7f8103af1b73a8af9326d4e62fe04b082334c2b..7d14c4eff505be218d223b4427e5982dbb8b795c 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/25.equality_expressions/strict_primitive_compare.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/25.equality_expressions/strict_primitive_compare.params.yaml @@ -15,7 +15,7 @@ primitives: - { type: 'boolean', value: "true" } - { type: 'byte', value: "12" } - - { type: 'char', value: "'c'" } + - { type: 'Char', value: "c'c'" } - { type: 'double', value: "234.0" } - { type: 'float', value: "123.0f" } - { type: 'int' , value: "456" } diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/01.simple_assignment_operator/ord22.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/01.simple_assignment_operator/ord22.ets index e48ac2594660ce0cfdaf216b529f4e753bc508c6..ba754a32e5834b275396b2b9ad20b8d2654074d9 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/01.simple_assignment_operator/ord22.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/01.simple_assignment_operator/ord22.ets @@ -24,6 +24,7 @@ desc: >- If this evaluation completes abruptly, then the assignment expression completes abruptly for the same reason; the right-hand operand is not evaluated and no assignment occurs. params: abrupt completion, reference +tags: [compile-only, negative] ---*/ let result: string = "" diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/01.simple_assignment_operator/ord24.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/01.simple_assignment_operator/ord24.ets index 383ae800b4cb77b98b75145fa588624aa91da34a..c97dc1bc566e366b076eb598b881347364fe1c8a 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/01.simple_assignment_operator/ord24.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/01.simple_assignment_operator/ord24.ets @@ -26,6 +26,7 @@ desc: >- - Otherwise, the right-hand operand is evaluated. If this evaluation completes abruptly, then the assignment expression completes abruptly for the same reason and no assignment occurs. params: abrupt completion, right-hand operand +tags: [compile-only, negative] ---*/ let result: string = "" diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/01.simple_assignment_operator/ord3.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/01.simple_assignment_operator/ord3.ets index f705a8fb41943f159330d24fa0c604ef0cde9b08..a5fdfc53d0c2285f09375ecaf5bad586b045ae03 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/01.simple_assignment_operator/ord3.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/01.simple_assignment_operator/ord3.ets @@ -20,6 +20,7 @@ desc: >- - Next, the right hand operand is evaluated. If evaluation of the right hand expression completes abruptly, the assignment expression completes abruptly for the same reason. - Finally, the variable denoted by e.f is assigned the value of the right hand operand as computed above. params: abrupt completion, left-hand operand, instance +tags: [compile-only, negative] ---*/ let result: string = "" diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/01.simple_assignment_operator/ord4.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/01.simple_assignment_operator/ord4.ets index 80f17ab8842f3460c168ef4c88b4fcd66826e3bb..929914cc54a0f0ef32ad8736b59192f4580fcb8b 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/01.simple_assignment_operator/ord4.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/01.simple_assignment_operator/ord4.ets @@ -20,7 +20,7 @@ desc: >- - Next, the right hand operand is evaluated. If evaluation of the right hand expression completes abruptly, the assignment expression completes abruptly for the same reason. - Finally, the variable denoted by e.f is assigned the value of the right hand operand as computed above. params: abrupt completion, left-hand operand, static -tags: [no-warmup] +tags: [no-warmup, compile-only, negative] ---*/ let result: string = "" diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/01.simple_assignment_operator/ord5.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/01.simple_assignment_operator/ord5.ets index ba4f6d78f390e2dcc782003dca6ce187ad1f45ac..50552906722c4a8e3ef96c6505ea9955fbe0c9a4 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/01.simple_assignment_operator/ord5.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/01.simple_assignment_operator/ord5.ets @@ -20,6 +20,7 @@ desc: >- - Next, the right hand operand is evaluated. If evaluation of the right hand expression completes abruptly, the assignment expression completes abruptly for the same reason. - Finally, the variable denoted by e.f is assigned the value of the right hand operand as computed above. params: abrupt completion, right-hand operand, instance +tags: [compile-only, negative] ---*/ let result: string = "" diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/01.simple_assignment_operator/ord6.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/01.simple_assignment_operator/ord6.ets index 3f8fbc547c3f814f230ba46a77820f60e185e3b1..420781a9f412d3a42c707a5b9c393d8ca818283a 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/01.simple_assignment_operator/ord6.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/01.simple_assignment_operator/ord6.ets @@ -20,6 +20,7 @@ desc: >- - Next, the right hand operand is evaluated. If evaluation of the right hand expression completes abruptly, the assignment expression completes abruptly for the same reason. - Finally, the variable denoted by e.f is assigned the value of the right hand operand as computed above. params: abrupt completion, right-hand operand, static +tags: [compile-only, negative] ---*/ let result: string = "" diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/02.compound_assignment_operators/ops.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/02.compound_assignment_operators/ops.ets index 25991187e1e11c0558c691705945616581b64636..65da841511225b307f8084e0912331ea1831de40 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/02.compound_assignment_operators/ops.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/02.compound_assignment_operators/ops.ets @@ -24,7 +24,7 @@ params: {{c.type}}, "{{c.op|safe}}=" function main(): int { let v:{{c.type}} = {{c.v}} let q:{{c.type}} = {{c.q}} - if ((v {{c.op}} q) as {{c.type}} != (v {{c.op}}= q)) { + if ((v {{c.op}} q).to{{c.type}}() != (v {{c.op}}= q)) { return 1 } return 0 diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/02.compound_assignment_operators/ops.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/02.compound_assignment_operators/ops.params.yaml index a8c6bc778fe87f10c5ae59e8f7d915bb445e95f1..a4b557f58560ae21abe79ec98495148f5379e6b8 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/02.compound_assignment_operators/ops.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/02.compound_assignment_operators/ops.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 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 @@ -13,296 +13,297 @@ --- cases: - - { type: byte, v: 127, op: '+', q: 1 } - - { type: byte, v: 127, op: '+', q: 127 } - - { type: byte, v: -128, op: '+', q: -1 } - - - { type: short, v: 32767, op: '+', q: 1 } - - { type: short, v: 32767, op: '+', q: 32767 } - - { type: short, v: -32768, op: '+', q: -1 } - - - { type: int, v: 2147483647, op: '+', q: 1 } - - { type: int, v: 2147483647, op: '+', q: 2147483647 } - - { type: int, v: -2147483648, op: '+', q: -1 } - - - { type: long, v: 9223372036854775807, op: '+', q: 1 } - - { type: long, v: 9223372036854775807, op: '+', q: 9223372036854775807 } - - { type: long, v: -9223372036854775808, op: '+', q: -1 } - - - { type: float, v: 3.4023235e+38, op: '+', q: 1.0 } - - { type: float, v: 3.4023235e+38, op: '+', q: 3.4023235e+38 } - - { type: float, v: -3.4023235e+38, op: '+', q: -1.0 } - - { type: float, v: Float.POSITIVE_INFINITY, op: '+', q: Float.POSITIVE_INFINITY } - - { type: float, v: Float.NEGATIVE_INFINITY, op: '+', q: Float.NEGATIVE_INFINITY } - - { type: float, v: 0.0, op: '+', q: -0.0 } - - - { type: double, v: 1.7976931348623157e+308, op: '+', q: 1.0 } - - { type: double, v: 1.7976931348623157e+308, op: '+', q: 1.7976931348623157e+308 } - - { type: double, v: -1.7976931348623157e+308, op: '+', q: -1.0 } - - { type: double, v: Double.POSITIVE_INFINITY, op: '+', q: Double.POSITIVE_INFINITY } - - { type: double, v: Double.NEGATIVE_INFINITY, op: '+', q: Double.NEGATIVE_INFINITY } - - { type: double, v: 0.0, op: '+', q: -0.0 } - - - { type: char, v: "c'\\uFFFF'", op: '+', q: "c'\\u0001'" } - - { type: char, v: "c'\\uFFFF'", op: '+', q: "c'\\uFFFF'" } - - { type: char, v: "c'\\u0000'", op: '+', q: "c'\\uFFFF'" } + # ops_0 + - { type: Byte, v: 127, op: '+', q: 1 } + - { type: Byte, v: 127, op: '+', q: 127 } + - { type: Byte, v: -128, op: '+', q: -1 } + + - { type: Short, v: 32767, op: '+', q: 1 } + - { type: Short, v: 32767, op: '+', q: 32767 } + - { type: Short, v: -32768, op: '+', q: -1 } + + - { type: Int, v: 2147483647, op: '+', q: 1 } + - { type: Int, v: 2147483647, op: '+', q: 2147483647 } + - { type: Int, v: -2147483648, op: '+', q: -1 } + + - { type: Long, v: 9223372036854775807, op: '+', q: 1 } + - { type: Long, v: 9223372036854775807, op: '+', q: 9223372036854775807 } + - { type: Long, v: -9223372036854775808, op: '+', q: -1 } + # ops_12 + - { type: Float, v: 3.4023235e+38f, op: '+', q: 1.0f } + - { type: Float, v: 3.4023235e+38f, op: '+', q: 3.4023235e+38f } + - { type: Float, v: -3.4023235e+38f, op: '+', q: -1.0f } + - { type: Float, v: Float.POSITIVE_INFINITY, op: '+', q: Float.POSITIVE_INFINITY } + - { type: Float, v: Float.NEGATIVE_INFINITY, op: '+', q: Float.NEGATIVE_INFINITY } + - { type: Float, v: 0.0f, op: '+', q: -0.0f } + # ops_18 + - { type: Double, v: 1.7976931348623157e+308, op: '+', q: 1.0 } + - { type: Double, v: 1.7976931348623157e+308, op: '+', q: 1.7976931348623157e+308 } + - { type: Double, v: -1.7976931348623157e+308, op: '+', q: -1.0 } + - { type: Double, v: Double.POSITIVE_INFINITY, op: '+', q: Double.POSITIVE_INFINITY } + - { type: Double, v: Double.NEGATIVE_INFINITY, op: '+', q: Double.NEGATIVE_INFINITY } + - { type: Double, v: 0.0, op: '+', q: -0.0 } + + - { type: Char, v: "c'\\uFFFF'", op: '+', q: "c'\\u0001'" } + - { type: Char, v: "c'\\uFFFF'", op: '+', q: "c'\\uFFFF'" } + - { type: Char, v: "c'\\u0000'", op: '+', q: "c'\\uFFFF'" } - { type: String, v: '"xyz"', op: '+', q: '"abc"' } - { type: String, v: '"1"', op: '+', q: '"2"' } - { type: String, v: '"null"', op: '+', q: '"null"' } - - { type: byte, v: 127, op: '-', q: -1 } - - { type: byte, v: -128, op: '-', q: -128 } - - { type: byte, v: -128, op: '-', q: 1 } - - - { type: short, v: 32767, op: '-', q: -1 } - - { type: short, v: -32768, op: '-', q: -32768 } - - { type: short, v: -32768, op: '-', q: 1 } - - - { type: int, v: 2147483647, op: '-', q: -1 } - - { type: int, v: -2147483648, op: '-', q: -2147483648 } - - { type: int, v: -2147483648, op: '-', q: 1 } - - - { type: long, v: 9223372036854775807, op: '-', q: -1 } - - { type: long, v: -9223372036854775808, op: '-', q: -9223372036854775808 } - - { type: long, v: -9223372036854775808, op: '-', q: 1 } - - - { type: float, v: 3.4023235e+38, op: '-', q: 1.0 } - - { type: float, v: 3.4023235e+38, op: '-', q: 3.4023235e+38 } - - { type: float, v: -3.4023235e+38, op: '-', q: -1.0 } - - { type: float, v: Float.POSITIVE_INFINITY, op: '-', q: Float.NEGATIVE_INFINITY } - - { type: float, v: Float.NEGATIVE_INFINITY, op: '-', q: Float.POSITIVE_INFINITY } - - { type: float, v: -0.0, op: '-', q: 0.0 } - - - { type: double, v: 1.7976931348623157e+308, op: '-', q: 1.0 } - - { type: double, v: 1.7976931348623157e+308, op: '-', q: 1.7976931348623157e+308 } - - { type: double, v: -1.7976931348623157e+308, op: '-', q: -1.0 } - - { type: double, v: Double.POSITIVE_INFINITY, op: '-', q: Double.NEGATIVE_INFINITY } - - { type: double, v: Double.NEGATIVE_INFINITY, op: '-', q: Double.POSITIVE_INFINITY } - - { type: double, v: -0.0, op: '-', q: 0.0 } - - - { type: char, v: "c'\\uFFFF'", op: '-', q: "c'\\u0001'" } - - { type: char, v: "c'\\uFFFF'", op: '-', q: "c'\\uFFFF'" } - - { type: char, v: "c'\\u0000'", op: '-', q: "c'\\uFFFF'" } - - - { type: byte, v: 127, op: '*', q: 1 } - - { type: byte, v: 127, op: '*', q: 127 } - - { type: byte, v: -128, op: '*', q: -1 } - - - { type: short, v: 32767, op: '*', q: 1 } - - { type: short, v: 32767, op: '*', q: 32767 } - - { type: short, v: -32768, op: '*', q: -1 } - - - { type: int, v: 2147483647, op: '*', q: 1 } - - { type: int, v: 2147483647, op: '*', q: 2147483647 } - - { type: int, v: -2147483648, op: '*', q: -1 } - - - { type: long, v: 9223372036854775807, op: '*', q: 1 } - - { type: long, v: 9223372036854775807, op: '*', q: 9223372036854775807 } - - { type: long, v: -9223372036854775808, op: '*', q: -1 } - - - { type: float, v: 3.4023235e+38, op: '*', q: 1.0 } - - { type: float, v: 3.4023235e+38, op: '*', q: 3.4023235e+38 } - - { type: float, v: -3.4023235e+38, op: '*', q: -1.0 } - - { type: float, v: Float.POSITIVE_INFINITY, op: '*', q: Float.POSITIVE_INFINITY } - - { type: float, v: Float.NEGATIVE_INFINITY, op: '*', q: Float.NEGATIVE_INFINITY } - - { type: float, v: 0.0, op: '*', q: -0.0 } - - - { type: double, v: 1.7976931348623157e+308, op: '*', q: 1.0 } - - { type: double, v: 1.7976931348623157e+308, op: '*', q: 1.7976931348623157e+308 } - - { type: double, v: -1.7976931348623157e+308, op: '*', q: -1.0 } - - { type: double, v: Double.POSITIVE_INFINITY, op: '*', q: Double.POSITIVE_INFINITY } - - { type: double, v: Double.NEGATIVE_INFINITY, op: '*', q: Double.NEGATIVE_INFINITY } - - { type: double, v: 0.0, op: '*', q: -0.0 } - - - { type: char, v: "c'\\uFFFF'", op: '*', q: "c'\\u0001'" } - - { type: char, v: "c'\\uFFFF'", op: '*', q: "c'\\uFFFF'" } - - { type: char, v: "c'\\u0000'", op: '*', q: "c'\\uFFFF'" } - - - { type: byte, v: 127, op: '/', q: 1 } - - { type: byte, v: 127, op: '/', q: 127 } - - { type: byte, v: -128, op: '/', q: -1 } - - - { type: short, v: 32767, op: '/', q: 1 } - - { type: short, v: 32767, op: '/', q: 32767 } - - { type: short, v: -32768, op: '/', q: -1 } - - - { type: int, v: 2147483647, op: '/', q: 1 } - - { type: int, v: 2147483647, op: '/', q: 2147483647 } - - { type: int, v: -2147483648, op: '/', q: -1 } - - - { type: long, v: 9223372036854775807, op: '/', q: 1 } - - { type: long, v: 9223372036854775807, op: '/', q: 9223372036854775807 } - - { type: long, v: -9223372036854775808, op: '/', q: -1 } - - - { type: float, v: 3.4023235e+38, op: '/', q: 1.0 } - - { type: float, v: 3.4023235e+38, op: '/', q: 3.4023235e+38 } - - { type: float, v: -3.4023235e+38, op: '/', q: -1.0 } - - - { type: double, v: 1.7976931348623157e+308, op: '/', q: 1.0 } - - { type: double, v: 1.7976931348623157e+308, op: '/', q: 1.7976931348623157e+308 } - - { type: double, v: -1.7976931348623157e+308, op: '/', q: -1.0 } - - - { type: char, v: "c'\\uFFFF'", op: '/', q: "c'\\u0001'" } - - { type: char, v: "c'\\uFFFF'", op: '/', q: "c'\\uFFFF'" } - - { type: char, v: "c'\\u0000'", op: '/', q: "c'\\uFFFF'" } - - - { type: byte, v: 127, op: '%', q: 1 } - - { type: byte, v: 127, op: '%', q: 127 } - - { type: byte, v: -128, op: '%', q: -1 } - - - { type: short, v: 32767, op: '%', q: 1 } - - { type: short, v: 32767, op: '%', q: 32767 } - - { type: short, v: -32768, op: '%', q: -1 } - - - { type: int, v: 2147483647, op: '%', q: 1 } - - { type: int, v: 2147483647, op: '%', q: 2147483647 } - - { type: int, v: -2147483648, op: '%', q: -1 } - - - { type: long, v: 9223372036854775807, op: '%', q: 1 } - - { type: long, v: 9223372036854775807, op: '%', q: 9223372036854775807 } - - { type: long, v: -9223372036854775808, op: '%', q: -1 } - - - { type: float, v: 3.4023235e+38, op: '%', q: 1.0 } - - { type: float, v: 3.4023235e+38, op: '%', q: 3.4023235e+38 } - - { type: float, v: -3.4023235e+38, op: '%', q: -1.0 } - - - { type: double, v: 1.7976931348623157e+308, op: '%', q: 1.0 } - - { type: double, v: 1.7976931348623157e+308, op: '%', q: 1.7976931348623157e+308 } - - { type: double, v: -1.7976931348623157e+308, op: '%', q: -1.0 } - - - { type: char, v: "c'\\uFFFF'", op: '%', q: "c'\\u0001'" } - - { type: char, v: "c'\\uFFFF'", op: '%', q: "c'\\uFFFF'" } - - { type: char, v: "c'\\u0000'", op: '%', q: "c'\\uFFFF'" } - - - { type: byte, v: 127, op: '<<', q: 1 } - - { type: byte, v: 127, op: '<<', q: 127 } - - { type: byte, v: -128, op: '<<', q: -1 } - - - { type: short, v: 32767, op: '<<', q: 1 } - - { type: short, v: 32767, op: '<<', q: 32767 } - - { type: short, v: -32768, op: '<<', q: -1 } - - - { type: int, v: 2147483647, op: '<<', q: 1 } - - { type: int, v: 2147483647, op: '<<', q: 2147483647 } - - { type: int, v: -2147483648, op: '<<', q: -1 } - - - { type: long, v: 9223372036854775807, op: '<<', q: 1 } - - { type: long, v: 9223372036854775807, op: '<<', q: 9223372036854775807 } - - { type: long, v: -9223372036854775808, op: '<<', q: -1 } - - - { type: char, v: "c'\\uFFFF'", op: '<<', q: "c'\\u0001'" } - - { type: char, v: "c'\\uFFFF'", op: '<<', q: "c'\\uFFFF'" } - - { type: char, v: "c'\\u0000'", op: '<<', q: "c'\\uFFFF'" } - - - { type: byte, v: 127, op: '>>', q: 1 } - - { type: byte, v: 127, op: '>>', q: 127 } - - { type: byte, v: -128, op: '>>', q: -1 } - - - { type: short, v: 32767, op: '>>', q: 1 } - - { type: short, v: 32767, op: '>>', q: 32767 } - - { type: short, v: -32768, op: '>>', q: -1 } - - - { type: int, v: 2147483647, op: '>>', q: 1 } - - { type: int, v: 2147483647, op: '>>', q: 2147483647 } - - { type: int, v: -2147483648, op: '>>', q: -1 } - - - { type: long, v: 9223372036854775807, op: '>>', q: 1 } - - { type: long, v: 9223372036854775807, op: '>>', q: 9223372036854775807 } - - { type: long, v: -9223372036854775808, op: '>>', q: -1 } - - - { type: char, v: "c'\\uFFFF'", op: '>>', q: "c'\\u0001'" } - - { type: char, v: "c'\\uFFFF'", op: '>>', q: "c'\\uFFFF'" } - - { type: char, v: "c'\\u0000'", op: '>>', q: "c'\\uFFFF'" } + - { type: Byte, v: 127, op: '-', q: -1 } + - { type: Byte, v: -128, op: '-', q: -128 } + - { type: Byte, v: -128, op: '-', q: 1 } + + - { type: Short, v: 32767, op: '-', q: -1 } + - { type: Short, v: -32768, op: '-', q: -32768 } + - { type: Short, v: -32768, op: '-', q: 1 } + + - { type: Int, v: 2147483647, op: '-', q: -1 } + - { type: Int, v: -2147483648, op: '-', q: -2147483648 } + - { type: Int, v: -2147483648, op: '-', q: 1 } + + - { type: Long, v: 9223372036854775807, op: '-', q: -1 } + - { type: Long, v: -9223372036854775808, op: '-', q: -9223372036854775808 } + - { type: Long, v: -9223372036854775808, op: '-', q: 1 } + # ops_42 + - { type: Float, v: 3.4023235e+38f, op: '-', q: 1.0f } + - { type: Float, v: 3.4023235e+38f, op: '-', q: 3.4023235e+38f } + - { type: Float, v: -3.4023235e+38f, op: '-', q: -1.0f } + - { type: Float, v: Float.POSITIVE_INFINITY, op: '-', q: Float.NEGATIVE_INFINITY } + - { type: Float, v: Float.NEGATIVE_INFINITY, op: '-', q: Float.POSITIVE_INFINITY } + - { type: Float, v: -0.0f, op: '-', q: 0.0f } + + - { type: Double, v: 1.7976931348623157e+308, op: '-', q: 1.0 } + - { type: Double, v: 1.7976931348623157e+308, op: '-', q: 1.7976931348623157e+308 } + - { type: Double, v: -1.7976931348623157e+308, op: '-', q: -1.0 } + - { type: Double, v: Double.POSITIVE_INFINITY, op: '-', q: Double.NEGATIVE_INFINITY } + - { type: Double, v: Double.NEGATIVE_INFINITY, op: '-', q: Double.POSITIVE_INFINITY } + - { type: Double, v: -0.0, op: '-', q: 0.0 } + + - { type: Char, v: "c'\\uFFFF'", op: '-', q: "c'\\u0001'" } + - { type: Char, v: "c'\\uFFFF'", op: '-', q: "c'\\uFFFF'" } + - { type: Char, v: "c'\\u0000'", op: '-', q: "c'\\uFFFF'" } + + - { type: Byte, v: 127, op: '*', q: 1 } + - { type: Byte, v: 127, op: '*', q: 127 } + - { type: Byte, v: -128, op: '*', q: -1 } + + - { type: Short, v: 32767, op: '*', q: 1 } + - { type: Short, v: 32767, op: '*', q: 32767 } + - { type: Short, v: -32768, op: '*', q: -1 } + + - { type: Int, v: 2147483647, op: '*', q: 1 } + - { type: Int, v: 2147483647, op: '*', q: 2147483647 } + - { type: Int, v: -2147483648, op: '*', q: -1 } + + - { type: Long, v: 9223372036854775807, op: '*', q: 1 } + - { type: Long, v: 9223372036854775807, op: '*', q: 9223372036854775807 } + - { type: Long, v: -9223372036854775808, op: '*', q: -1 } + # ops_69 + - { type: Float, v: 3.4023235e+38f, op: '*', q: 1.0f } + - { type: Float, v: 3.4023235e+38f, op: '*', q: 3.4023235e+38f } + - { type: Float, v: -3.4023235e+38f, op: '*', q: -1.0f } + - { type: Float, v: Float.POSITIVE_INFINITY, op: '*', q: Float.POSITIVE_INFINITY } + - { type: Float, v: Float.NEGATIVE_INFINITY, op: '*', q: Float.NEGATIVE_INFINITY } + - { type: Float, v: 0.0f, op: '*', q: -0.0f } + + - { type: Double, v: 1.7976931348623157e+308, op: '*', q: 1.0 } + - { type: Double, v: 1.7976931348623157e+308, op: '*', q: 1.7976931348623157e+308 } + - { type: Double, v: -1.7976931348623157e+308, op: '*', q: -1.0 } + - { type: Double, v: Double.POSITIVE_INFINITY, op: '*', q: Double.POSITIVE_INFINITY } + - { type: Double, v: Double.NEGATIVE_INFINITY, op: '*', q: Double.NEGATIVE_INFINITY } + - { type: Double, v: 0.0, op: '*', q: -0.0 } + + - { type: Char, v: "c'\\uFFFF'", op: '*', q: "c'\\u0001'" } + - { type: Char, v: "c'\\uFFFF'", op: '*', q: "c'\\uFFFF'" } + - { type: Char, v: "c'\\u0000'", op: '*', q: "c'\\uFFFF'" } + + - { type: Byte, v: 127, op: '/', q: 1 } + - { type: Byte, v: 127, op: '/', q: 127 } + - { type: Byte, v: -128, op: '/', q: -1 } + + - { type: Short, v: 32767, op: '/', q: 1 } + - { type: Short, v: 32767, op: '/', q: 32767 } + - { type: Short, v: -32768, op: '/', q: -1 } + + - { type: Int, v: 2147483647, op: '/', q: 1 } + - { type: Int, v: 2147483647, op: '/', q: 2147483647 } + - { type: Int, v: -2147483648, op: '/', q: -1 } + + - { type: Long, v: 9223372036854775807, op: '/', q: 1 } + - { type: Long, v: 9223372036854775807, op: '/', q: 9223372036854775807 } + - { type: Long, v: -9223372036854775808, op: '/', q: -1 } + # ops_96 + - { type: Float, v: 3.4023235e+38f, op: '/', q: 1.0f } + - { type: Float, v: 3.4023235e+38f, op: '/', q: 3.4023235e+38f } + - { type: Float, v: -3.4023235e+38f, op: '/', q: -1.0f } + + - { type: Double, v: 1.7976931348623157e+308, op: '/', q: 1.0 } + - { type: Double, v: 1.7976931348623157e+308, op: '/', q: 1.7976931348623157e+308 } + - { type: Double, v: -1.7976931348623157e+308, op: '/', q: -1.0 } + + - { type: Char, v: "c'\\uFFFF'", op: '/', q: "c'\\u0001'" } + - { type: Char, v: "c'\\uFFFF'", op: '/', q: "c'\\uFFFF'" } + - { type: Char, v: "c'\\u0000'", op: '/', q: "c'\\uFFFF'" } + + - { type: Byte, v: 127, op: '%', q: 1 } + - { type: Byte, v: 127, op: '%', q: 127 } + - { type: Byte, v: -128, op: '%', q: -1 } + + - { type: Short, v: 32767, op: '%', q: 1 } + - { type: Short, v: 32767, op: '%', q: 32767 } + - { type: Short, v: -32768, op: '%', q: -1 } + + - { type: Int, v: 2147483647, op: '%', q: 1 } + - { type: Int, v: 2147483647, op: '%', q: 2147483647 } + - { type: Int, v: -2147483648, op: '%', q: -1 } + + - { type: Long, v: 9223372036854775807, op: '%', q: 1 } + - { type: Long, v: 9223372036854775807, op: '%', q: 9223372036854775807 } + - { type: Long, v: -9223372036854775808, op: '%', q: -1 } + # ops_117 + - { type: Float, v: 3.4023235e+38f, op: '%', q: 1.0f } + - { type: Float, v: 3.4023235e+38f, op: '%', q: 3.4023235e+38f } + - { type: Float, v: -3.4023235e+38f, op: '%', q: -1.0f } + + - { type: Double, v: 1.7976931348623157e+308, op: '%', q: 1.0 } + - { type: Double, v: 1.7976931348623157e+308, op: '%', q: 1.7976931348623157e+308 } + - { type: Double, v: -1.7976931348623157e+308, op: '%', q: -1.0 } + + - { type: Char, v: "c'\\uFFFF'", op: '%', q: "c'\\u0001'" } + - { type: Char, v: "c'\\uFFFF'", op: '%', q: "c'\\uFFFF'" } + - { type: Char, v: "c'\\u0000'", op: '%', q: "c'\\uFFFF'" } + + - { type: Byte, v: 127, op: '<<', q: 1 } + - { type: Byte, v: 127, op: '<<', q: 127 } + - { type: Byte, v: -128, op: '<<', q: -1 } + + - { type: Short, v: 32767, op: '<<', q: 1 } + - { type: Short, v: 32767, op: '<<', q: 32767 } + - { type: Short, v: -32768, op: '<<', q: -1 } + + - { type: Int, v: 2147483647, op: '<<', q: 1 } + - { type: Int, v: 2147483647, op: '<<', q: 2147483647 } + - { type: Int, v: -2147483648, op: '<<', q: -1 } + + - { type: Long, v: 9223372036854775807, op: '<<', q: 1 } + - { type: Long, v: 9223372036854775807, op: '<<', q: 9223372036854775807 } + - { type: Long, v: -9223372036854775808, op: '<<', q: -1 } + + - { type: Char, v: "c'\\uFFFF'", op: '<<', q: "c'\\u0001'" } + - { type: Char, v: "c'\\uFFFF'", op: '<<', q: "c'\\uFFFF'" } + - { type: Char, v: "c'\\u0000'", op: '<<', q: "c'\\uFFFF'" } + + - { type: Byte, v: 127, op: '>>', q: 1 } + - { type: Byte, v: 127, op: '>>', q: 127 } + - { type: Byte, v: -128, op: '>>', q: -1 } + + - { type: Short, v: 32767, op: '>>', q: 1 } + - { type: Short, v: 32767, op: '>>', q: 32767 } + - { type: Short, v: -32768, op: '>>', q: -1 } + + - { type: Int, v: 2147483647, op: '>>', q: 1 } + - { type: Int, v: 2147483647, op: '>>', q: 2147483647 } + - { type: Int, v: -2147483648, op: '>>', q: -1 } + + - { type: Long, v: 9223372036854775807, op: '>>', q: 1 } + - { type: Long, v: 9223372036854775807, op: '>>', q: 9223372036854775807 } + - { type: Long, v: -9223372036854775808, op: '>>', q: -1 } + + - { type: Char, v: "c'\\uFFFF'", op: '>>', q: "c'\\u0001'" } + - { type: Char, v: "c'\\uFFFF'", op: '>>', q: "c'\\uFFFF'" } + - { type: Char, v: "c'\\u0000'", op: '>>', q: "c'\\uFFFF'" } + + - { type: Byte, v: 127, op: '>>>', q: 1 } + - { type: Byte, v: 127, op: '>>>', q: 127 } + - { type: Byte, v: -128, op: '>>>', q: -1 } + + - { type: Short, v: 32767, op: '>>>', q: 1 } + - { type: Short, v: 32767, op: '>>>', q: 32767 } + - { type: Short, v: -32768, op: '>>>', q: -1 } + + - { type: Int, v: 2147483647, op: '>>>', q: 1 } + - { type: Int, v: 2147483647, op: '>>>', q: 2147483647 } + - { type: Int, v: -2147483648, op: '>>>', q: -1 } + + - { type: Long, v: 9223372036854775807, op: '>>>', q: 1 } + - { type: Long, v: 9223372036854775807, op: '>>>', q: 9223372036854775807 } + - { type: Long, v: -9223372036854775808, op: '>>>', q: -1 } + + - { type: Char, v: "c'\\uFFFF'", op: '>>>', q: "c'\\u0001'" } + - { type: Char, v: "c'\\uFFFF'", op: '>>>', q: "c'\\uFFFF'" } + - { type: Char, v: "c'\\u0000'", op: '>>>', q: "c'\\uFFFF'" } + + - { type: Byte, v: 127, op: '&', q: 1 } + - { type: Byte, v: 127, op: '&', q: 127 } + - { type: Byte, v: -128, op: '&', q: -1 } + + - { type: Short, v: 32767, op: '&', q: 1 } + - { type: Short, v: 32767, op: '&', q: 32767 } + - { type: Short, v: -32768, op: '&', q: -1 } + + - { type: Int, v: 2147483647, op: '&', q: 1 } + - { type: Int, v: 2147483647, op: '&', q: 2147483647 } + - { type: Int, v: -2147483648, op: '&', q: -1 } + + - { type: Long, v: 9223372036854775807, op: '&', q: 1 } + - { type: Long, v: 9223372036854775807, op: '&', q: 9223372036854775807 } + - { type: Long, v: -9223372036854775808, op: '&', q: -1 } + + - { type: Char, v: "c'\\uFFFF'", op: '&', q: "c'\\u0001'" } + - { type: Char, v: "c'\\uFFFF'", op: '&', q: "c'\\uFFFF'" } + - { type: Char, v: "c'\\u0000'", op: '&', q: "c'\\uFFFF'" } + + - { type: Boolean, v: 'true', op: '&', q: 'true' } + - { type: Boolean, v: 'true', op: '&', q: 'false' } + - { type: Boolean, v: 'false', op: '&', q: 'true' } + + - { type: Byte, v: 127, op: '|', q: 1 } + - { type: Byte, v: 127, op: '|', q: 127 } + - { type: Byte, v: -128, op: '|', q: -1 } + + - { type: Short, v: 32767, op: '|', q: 1 } + - { type: Short, v: 32767, op: '|', q: 32767 } + - { type: Short, v: -32768, op: '|', q: -1 } - - { type: byte, v: 127, op: '>>>', q: 1 } - - { type: byte, v: 127, op: '>>>', q: 127 } - - { type: byte, v: -128, op: '>>>', q: -1 } + - { type: Int, v: 2147483647, op: '|', q: 1 } + - { type: Int, v: 2147483647, op: '|', q: 2147483647 } + - { type: Int, v: -2147483648, op: '|', q: -1 } - - { type: short, v: 32767, op: '>>>', q: 1 } - - { type: short, v: 32767, op: '>>>', q: 32767 } - - { type: short, v: -32768, op: '>>>', q: -1 } + - { type: Long, v: 9223372036854775807, op: '|', q: 1 } + - { type: Long, v: 9223372036854775807, op: '|', q: 9223372036854775807 } + - { type: Long, v: -9223372036854775808, op: '|', q: -1 } - - { type: int, v: 2147483647, op: '>>>', q: 1 } - - { type: int, v: 2147483647, op: '>>>', q: 2147483647 } - - { type: int, v: -2147483648, op: '>>>', q: -1 } + - { type: Char, v: "c'\\uFFFF'", op: '|', q: "c'\\u0001'" } + - { type: Char, v: "c'\\uFFFF'", op: '|', q: "c'\\uFFFF'" } + - { type: Char, v: "c'\\u0000'", op: '|', q: "c'\\uFFFF'" } - - { type: long, v: 9223372036854775807, op: '>>>', q: 1 } - - { type: long, v: 9223372036854775807, op: '>>>', q: 9223372036854775807 } - - { type: long, v: -9223372036854775808, op: '>>>', q: -1 } + - { type: Boolean, v: 'false', op: '|', q: 'false' } + - { type: Boolean, v: 'true', op: '|', q: 'false' } + - { type: Boolean, v: 'false', op: '|', q: 'true' } - - { type: char, v: "c'\\uFFFF'", op: '>>>', q: "c'\\u0001'" } - - { type: char, v: "c'\\uFFFF'", op: '>>>', q: "c'\\uFFFF'" } - - { type: char, v: "c'\\u0000'", op: '>>>', q: "c'\\uFFFF'" } + - { type: Byte, v: 127, op: '^', q: 1 } + - { type: Byte, v: 127, op: '^', q: 127 } + - { type: Byte, v: -128, op: '^', q: -1 } - - { type: byte, v: 127, op: '&', q: 1 } - - { type: byte, v: 127, op: '&', q: 127 } - - { type: byte, v: -128, op: '&', q: -1 } + - { type: Short, v: 32767, op: '^', q: 1 } + - { type: Short, v: 32767, op: '^', q: 32767 } + - { type: Short, v: -32768, op: '^', q: -1 } - - { type: short, v: 32767, op: '&', q: 1 } - - { type: short, v: 32767, op: '&', q: 32767 } - - { type: short, v: -32768, op: '&', q: -1 } + - { type: Int, v: 2147483647, op: '^', q: 1 } + - { type: Int, v: 2147483647, op: '^', q: 2147483647 } + - { type: Int, v: -2147483648, op: '^', q: -1 } - - { type: int, v: 2147483647, op: '&', q: 1 } - - { type: int, v: 2147483647, op: '&', q: 2147483647 } - - { type: int, v: -2147483648, op: '&', q: -1 } + - { type: Long, v: 9223372036854775807, op: '^', q: 1 } + - { type: Long, v: 9223372036854775807, op: '^', q: 9223372036854775807 } + - { type: Long, v: -9223372036854775808, op: '^', q: -1 } - - { type: long, v: 9223372036854775807, op: '&', q: 1 } - - { type: long, v: 9223372036854775807, op: '&', q: 9223372036854775807 } - - { type: long, v: -9223372036854775808, op: '&', q: -1 } + - { type: Char, v: "c'\\uFFFF'", op: '^', q: "c'\\u0001'" } + - { type: Char, v: "c'\\uFFFF'", op: '^', q: "c'\\uFFFF'" } + - { type: Char, v: "c'\\u0000'", op: '^', q: "c'\\uFFFF'" } - - { type: char, v: "c'\\uFFFF'", op: '&', q: "c'\\u0001'" } - - { type: char, v: "c'\\uFFFF'", op: '&', q: "c'\\uFFFF'" } - - { type: char, v: "c'\\u0000'", op: '&', q: "c'\\uFFFF'" } - - - { type: boolean, v: 'true', op: '&', q: 'true' } - - { type: boolean, v: 'true', op: '&', q: 'false' } - - { type: boolean, v: 'false', op: '&', q: 'true' } - - - { type: byte, v: 127, op: '|', q: 1 } - - { type: byte, v: 127, op: '|', q: 127 } - - { type: byte, v: -128, op: '|', q: -1 } - - - { type: short, v: 32767, op: '|', q: 1 } - - { type: short, v: 32767, op: '|', q: 32767 } - - { type: short, v: -32768, op: '|', q: -1 } - - - { type: int, v: 2147483647, op: '|', q: 1 } - - { type: int, v: 2147483647, op: '|', q: 2147483647 } - - { type: int, v: -2147483648, op: '|', q: -1 } - - - { type: long, v: 9223372036854775807, op: '|', q: 1 } - - { type: long, v: 9223372036854775807, op: '|', q: 9223372036854775807 } - - { type: long, v: -9223372036854775808, op: '|', q: -1 } - - - { type: char, v: "c'\\uFFFF'", op: '|', q: "c'\\u0001'" } - - { type: char, v: "c'\\uFFFF'", op: '|', q: "c'\\uFFFF'" } - - { type: char, v: "c'\\u0000'", op: '|', q: "c'\\uFFFF'" } - - - { type: boolean, v: 'false', op: '|', q: 'false' } - - { type: boolean, v: 'true', op: '|', q: 'false' } - - { type: boolean, v: 'false', op: '|', q: 'true' } - - - { type: byte, v: 127, op: '^', q: 1 } - - { type: byte, v: 127, op: '^', q: 127 } - - { type: byte, v: -128, op: '^', q: -1 } - - - { type: short, v: 32767, op: '^', q: 1 } - - { type: short, v: 32767, op: '^', q: 32767 } - - { type: short, v: -32768, op: '^', q: -1 } - - - { type: int, v: 2147483647, op: '^', q: 1 } - - { type: int, v: 2147483647, op: '^', q: 2147483647 } - - { type: int, v: -2147483648, op: '^', q: -1 } - - - { type: long, v: 9223372036854775807, op: '^', q: 1 } - - { type: long, v: 9223372036854775807, op: '^', q: 9223372036854775807 } - - { type: long, v: -9223372036854775808, op: '^', q: -1 } - - - { type: char, v: "c'\\uFFFF'", op: '^', q: "c'\\u0001'" } - - { type: char, v: "c'\\uFFFF'", op: '^', q: "c'\\uFFFF'" } - - { type: char, v: "c'\\u0000'", op: '^', q: "c'\\uFFFF'" } - - - { type: boolean, v: 'true', op: '^', q: 'true' } - - { type: boolean, v: 'true', op: '^', q: 'false' } - - { type: boolean, v: 'false', op: '^', q: 'true' } + - { type: Boolean, v: 'true', op: '^', q: 'true' } + - { type: Boolean, v: 'true', op: '^', q: 'false' } + - { type: Boolean, v: 'false', op: '^', q: 'true' } diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/02.compound_assignment_operators/ops_boxed.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/02.compound_assignment_operators/ops_boxed.ets index 97c89fae62ee70f517b75de85f6101b442c60289..65da841511225b307f8084e0912331ea1831de40 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/02.compound_assignment_operators/ops_boxed.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/02.compound_assignment_operators/ops_boxed.ets @@ -24,7 +24,7 @@ params: {{c.type}}, "{{c.op|safe}}=" function main(): int { let v:{{c.type}} = {{c.v}} let q:{{c.type}} = {{c.q}} - if ((v {{c.op}} q) as {{c.type.lower()}} != (v {{c.op}}= q)) { + if ((v {{c.op}} q).to{{c.type}}() != (v {{c.op}}= q)) { return 1 } return 0 diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/02.compound_assignment_operators/ops_boxed.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/02.compound_assignment_operators/ops_boxed.params.yaml index 682297e3b694057040c98cbf88b4fdb15bb4f702..d09893b7d41a0ea92d124aa6051746a576a44080 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/02.compound_assignment_operators/ops_boxed.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/02.compound_assignment_operators/ops_boxed.params.yaml @@ -29,12 +29,12 @@ cases: - { type: Long, v: 9223372036854775807, op: '+', q: 9223372036854775807 } - { type: Long, v: -9223372036854775808, op: '+', q: -1 } - - { type: Float, v: 3.4023235e+38, op: '+', q: 1.0 } - - { type: Float, v: 3.4023235e+38, op: '+', q: 3.4023235e+38 } - - { type: Float, v: -3.4023235e+38, op: '+', q: -1.0 } + - { type: Float, v: 3.4023235e+38f, op: '+', q: 1.0f } + - { type: Float, v: 3.4023235e+38f, op: '+', q: 3.4023235e+38f } + - { type: Float, v: -3.4023235e+38f, op: '+', q: -1.0f } - { type: Float, v: Float.POSITIVE_INFINITY, op: '+', q: Float.POSITIVE_INFINITY } - { type: Float, v: Float.NEGATIVE_INFINITY, op: '+', q: Float.NEGATIVE_INFINITY } - - { type: Float, v: 0.0, op: '+', q: -0.0 } + - { type: Float, v: 0.0f, op: '+', q: -0.0f } - { type: Double, v: 1.7976931348623157e+308, op: '+', q: 1.0 } - { type: Double, v: 1.7976931348623157e+308, op: '+', q: 1.7976931348623157e+308 } @@ -63,12 +63,12 @@ cases: - { type: Long, v: -9223372036854775808, op: '-', q: -9223372036854775808 } - { type: Long, v: -9223372036854775808, op: '-', q: 1 } - - { type: Float, v: 3.4023235e+38, op: '-', q: 1.0 } - - { type: Float, v: 3.4023235e+38, op: '-', q: 3.4023235e+38 } - - { type: Float, v: -3.4023235e+38, op: '-', q: -1.0 } + - { type: Float, v: 3.4023235e+38f, op: '-', q: 1.0f } + - { type: Float, v: 3.4023235e+38f, op: '-', q: 3.4023235e+38f } + - { type: Float, v: -3.4023235e+38f, op: '-', q: -1.0f } - { type: Float, v: Float.POSITIVE_INFINITY, op: '-', q: Float.NEGATIVE_INFINITY } - { type: Float, v: Float.NEGATIVE_INFINITY, op: '-', q: Float.POSITIVE_INFINITY } - - { type: Float, v: -0.0, op: '-', q: 0.0 } + - { type: Float, v: -0.0f, op: '-', q: 0.0f } - { type: Double, v: 1.7976931348623157e+308, op: '-', q: 1.0 } - { type: Double, v: 1.7976931348623157e+308, op: '-', q: 1.7976931348623157e+308 } @@ -97,12 +97,12 @@ cases: - { type: Long, v: 9223372036854775807, op: '*', q: 9223372036854775807 } - { type: Long, v: -9223372036854775808, op: '*', q: -1 } - - { type: Float, v: 3.4023235e+38, op: '*', q: 1.0 } - - { type: Float, v: 3.4023235e+38, op: '*', q: 3.4023235e+38 } - - { type: Float, v: -3.4023235e+38, op: '*', q: -1.0 } + - { type: Float, v: 3.4023235e+38f, op: '*', q: 1.0f } + - { type: Float, v: 3.4023235e+38f, op: '*', q: 3.4023235e+38f } + - { type: Float, v: -3.4023235e+38f, op: '*', q: -1.0f } - { type: Float, v: Float.POSITIVE_INFINITY, op: '*', q: Float.POSITIVE_INFINITY } - { type: Float, v: Float.NEGATIVE_INFINITY, op: '*', q: Float.NEGATIVE_INFINITY } - - { type: Float, v: 0.0, op: '*', q: -0.0 } + - { type: Float, v: 0.0f, op: '*', q: -0.0f } - { type: Double, v: 1.7976931348623157e+308, op: '*', q: 1.0 } - { type: Double, v: 1.7976931348623157e+308, op: '*', q: 1.7976931348623157e+308 } @@ -131,9 +131,9 @@ cases: - { type: Long, v: 9223372036854775807, op: '/', q: 9223372036854775807 } - { type: Long, v: -9223372036854775808, op: '/', q: -1 } - - { type: Float, v: 3.4023235e+38, op: '/', q: 1.0 } - - { type: Float, v: 3.4023235e+38, op: '/', q: 3.4023235e+38 } - - { type: Float, v: -3.4023235e+38, op: '/', q: -1.0 } + - { type: Float, v: 3.4023235e+38f, op: '/', q: 1.0f } + - { type: Float, v: 3.4023235e+38f, op: '/', q: 3.4023235e+38f } + - { type: Float, v: -3.4023235e+38f, op: '/', q: -1.0f } - { type: Double, v: 1.7976931348623157e+308, op: '/', q: 1.0 } - { type: Double, v: 1.7976931348623157e+308, op: '/', q: 1.7976931348623157e+308 } @@ -159,9 +159,9 @@ cases: - { type: Long, v: 9223372036854775807, op: '%', q: 9223372036854775807 } - { type: Long, v: -9223372036854775808, op: '%', q: -1 } - - { type: Float, v: 3.4023235e+38, op: '%', q: 1.0 } - - { type: Float, v: 3.4023235e+38, op: '%', q: 3.4023235e+38 } - - { type: Float, v: -3.4023235e+38, op: '%', q: -1.0 } + - { type: Float, v: 3.4023235e+38f, op: '%', q: 1.0f } + - { type: Float, v: 3.4023235e+38f, op: '%', q: 3.4023235e+38f } + - { type: Float, v: -3.4023235e+38f, op: '%', q: -1.0f } - { type: Double, v: 1.7976931348623157e+308, op: '%', q: 1.0 } - { type: Double, v: 1.7976931348623157e+308, op: '%', q: 1.7976931348623157e+308 } diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/02.compound_assignment_operators/ops_neg_rt.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/02.compound_assignment_operators/ops_neg_rt.params.yaml index c7529573cf3dc96a286cf7ce141e0e7a8ece1a9d..e7fb00d1c083ddf090264f6455c835682307ef96 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/02.compound_assignment_operators/ops_neg_rt.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/29.assignment/02.compound_assignment_operators/ops_neg_rt.params.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 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 @@ -26,12 +26,12 @@ cases: - { type: float, v: Float.NEGATIVE_INFINITY, op: '%', q: Float.NEGATIVE_INFINITY } - { type: double, v: Double.POSITIVE_INFINITY, op: '%', q: Double.POSITIVE_INFINITY } - { type: double, v: Double.NEGATIVE_INFINITY, op: '%', q: Double.NEGATIVE_INFINITY } - - { type: float, v: 0.0, op: '/', q: -0.0 } + - { type: float, v: 0.0f, op: '/', q: -0.0f } - { type: double, v: 0.0, op: '/', q: -0.0 } - - { type: float, v: 0.0, op: '%', q: -0.0 } + - { type: float, v: 0.0f, op: '%', q: -0.0f } - { type: double, v: 0.0, op: '%', q: -0.0 } - # boxed + # aliases - { type: Float, v: Float.POSITIVE_INFINITY, op: '-', q: Float.POSITIVE_INFINITY } - { type: Float, v: Float.NEGATIVE_INFINITY, op: '-', q: Float.NEGATIVE_INFINITY } - { type: Double, v: Double.POSITIVE_INFINITY, op: '-', q: Double.POSITIVE_INFINITY } @@ -44,7 +44,7 @@ cases: - { type: Float, v: Float.NEGATIVE_INFINITY, op: '%', q: Float.NEGATIVE_INFINITY } - { type: Double, v: Double.POSITIVE_INFINITY, op: '%', q: Double.POSITIVE_INFINITY } - { type: Double, v: Double.NEGATIVE_INFINITY, op: '%', q: Double.NEGATIVE_INFINITY } - - { type: Float, v: 0.0, op: '/', q: -0.0 } + - { type: Float, v: 0.0f, op: '/', q: -0.0f } - { type: Double, v: 0.0, op: '/', q: -0.0 } - - { type: Float, v: 0.0, op: '%', q: -0.0 } + - { type: Float, v: 0.0f, op: '%', q: -0.0f } - { type: Double, v: 0.0, op: '%', q: -0.0 } diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/30.conditional_expressions/conditional_expression_object_8.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/30.conditional_expressions/conditional_expression_object_8.ets index 82e24ca11bc11db78d220fe68f906d2a7aad6a57..575157b98c38da30b5e2db18ad3a26400508e697 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/30.conditional_expressions/conditional_expression_object_8.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/30.conditional_expressions/conditional_expression_object_8.ets @@ -34,17 +34,22 @@ function foo(p: BA): int { return 3; } +let a: CBA = new CBA(); +let b: DA = new DA(); +let d: A = new A(); +let f: BA = new BA(); + +function check(): boolean { + return true +} + function main(): void { - let a: CBA = new CBA(); - let b: DA = new DA(); - let c = true ? a : b; - assertTrue(foo(c) == 2); - - let d: A = new A(); - let e = true ? a : d; - assertTrue(foo(e) == 2); - - let f: BA = new BA(); - let g = true ? a : f; - assertTrue(foo(g) == 3); + let c = check() ? a : b; + assertEQ(foo(c), 2); + + let e = check() ? a : d; + assertEQ(foo(e), 2); + + let g = check() ? a : f; + assertEQ(foo(g), 3); } diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/30.conditional_expressions/test_with_two_operands_of_different_types.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/30.conditional_expressions/test_with_two_operands_of_different_types.ets index a98caf02538470805973b81b7125cd1e78be72ef..797b72cab3c3d4f74f32e9447ac7b4f009d74d37 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/30.conditional_expressions/test_with_two_operands_of_different_types.ets +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/30.conditional_expressions/test_with_two_operands_of_different_types.ets @@ -15,7 +15,7 @@ /*--- desc: Test with an object incompatible with the specified type -tags: [compile-only, negative] +tags: [compile-only] ---*/ diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/31.string_interpolation_expressions/siexp.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/31.string_interpolation_expressions/siexp.params.yaml index b333e9c3cdbe392cd302d7d383a85954b4db8bd4..65c3c1ad643590a2035d184a192782a05dceca12 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/31.string_interpolation_expressions/siexp.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/31.string_interpolation_expressions/siexp.params.yaml @@ -95,6 +95,10 @@ cases: - use: |- const v = `'value' = ${c'\u0000' + '0000'}` + const expected = "'value' = 00000" + + - use: |- + const v = `'value' = ${'\u0000' + '0000'}` const expected = "'value' = \u00000000" - use: |- diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/33.constant_expression/check_enum/constant_logical_expression.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/33.constant_expression/check_enum/constant_logical_expression.params.yaml index 1b27f54352fd08ff1edf8b732f396af316f3df31..a88c3c312e4b33186d13c51b12660f953182e33b 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/33.constant_expression/check_enum/constant_logical_expression.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/33.constant_expression/check_enum/constant_logical_expression.params.yaml @@ -22,7 +22,7 @@ cases: - { type: char, value: c'p', expression: '== 112', expected: 'yes p' } - { type: char, value: c'p', expression: '> 100', expected: 'yes p' } - - { type: char, value: c'p', expression: '== "p"', expected: 'yes p' } - - { type: char, value: c'p', expression: '>= "W"', expected: 'yes p' } + - { type: string, value: '"p"', expression: '== "p"', expected: 'yes p' } + - { type: string, value: '"p"', expression: '>= "W"', expected: 'yes p' } - { type: float, value: 26.7f, expression: '== 26.7', expected: 'yes 26.7' } - { type: number, value: 26.3, expression: '== 26.3f', expected: 'yes 26.3' } diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/33.constant_expression/check_enum/constant_num_chain_initializer.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/33.constant_expression/check_enum/constant_num_chain_initializer.params.yaml index 5a9c8b46f47639ff1fc7c25151d6ef8700c7089d..163d6d21ea6a718189d93eb8fc86807e113c5e60 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/33.constant_expression/check_enum/constant_num_chain_initializer.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/33.constant_expression/check_enum/constant_num_chain_initializer.params.yaml @@ -15,10 +15,8 @@ cases: - { type1: byte, type2: byte } - { type1: byte, type2: short } - { type1: byte, type2: int } - - { type1: byte, type2: char } - { type1: short, type2: short } - { type1: short, type2: int } - - { type1: char, type2: char } - { type1: char, type2: int } - { type1: int, type2: int } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/33.constant_expression/check_enum/constant_num_chain_initializer_neg.ets b/static_core/plugins/ets/tests/ets-templates/07.expressions/33.constant_expression/check_enum/constant_num_chain_initializer_neg.ets new file mode 100644 index 0000000000000000000000000000000000000000..60c89f30201b2002fb554b8c9ab14cf6e841b42c --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/33.constant_expression/check_enum/constant_num_chain_initializer_neg.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 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. + */ + +{% for c in cases %} +/*--- +desc: + Constant expression numeric chain initializer. +tags: +- compile-only +- negative +---*/ + +const const1: {{c.type1}} = 101 +const const2: {{c.type2}} = const1 + +function main() { + enum TestEnum { One = const2 } + assertEQ(TestEnum.One.valueOf(), 101) +} + +{% endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/12.adding_functionality_to_existing_types/02.receiver_types/functions_with_receiver_negative.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/33.constant_expression/check_enum/constant_num_chain_initializer_neg.params.yaml similarity index 86% rename from static_core/plugins/ets/tests/ets-templates/17.experimental_features/12.adding_functionality_to_existing_types/02.receiver_types/functions_with_receiver_negative.params.yaml rename to static_core/plugins/ets/tests/ets-templates/07.expressions/33.constant_expression/check_enum/constant_num_chain_initializer_neg.params.yaml index 9d4368a014b1d2a0ec032ba9e202e9c38f4cc91e..023db1b771c7f772638f49ebe6f54c06dd7fbf31 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/12.adding_functionality_to_existing_types/02.receiver_types/functions_with_receiver_negative.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/33.constant_expression/check_enum/constant_num_chain_initializer_neg.params.yaml @@ -10,11 +10,8 @@ # 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. - --- cases: - - decl: | - function f(this: number) {} - use: | - let n: number = 1 - f(n) + - { type1: byte, type2: char } + - { type1: char, type2: char } + \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/33.constant_expression/constant_expression.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/33.constant_expression/constant_expression.params.yaml index 06da78ffa2b3a148ddc4d8a9ad3e7d844484d00d..dd9400e3e54ba3cd0f4029ed1ec06173da819902 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/33.constant_expression/constant_expression.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/33.constant_expression/constant_expression.params.yaml @@ -33,8 +33,6 @@ cases: enum Comp2 { EQ = 3 == 3 ? 1 : 2, NotEQ = 3 != 3 ? 3 : 4 } - use: | enum BitOp { And = 3 & 3, Xor = 3 ^ 3, Or = 3 | 3 } - - use: | - enum Bool { Or = 3 || 3, And = 3 && 3 } - use: | enum Parenthesized { Par = (3 + 3) } - use: | @@ -46,4 +44,3 @@ cases: const num2: int = 2 use: | enum Num { Num1 = num1, Num2 = num2 } - \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/07.expressions/33.constant_expression/wrong_constant_expression.params.yaml b/static_core/plugins/ets/tests/ets-templates/07.expressions/33.constant_expression/wrong_constant_expression.params.yaml index b3001f8842ad6c74981d90f0a250730428afa1e5..fadbbcb02c6996b5bd6de4529048383e38f0cbaa 100644 --- a/static_core/plugins/ets/tests/ets-templates/07.expressions/33.constant_expression/wrong_constant_expression.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/07.expressions/33.constant_expression/wrong_constant_expression.params.yaml @@ -25,4 +25,6 @@ cases: - use: | enum Now { DateNow = Date.now() } - use: | - enum Num { One = Number(1.0), Two = Number(2.0) } \ No newline at end of file + enum Num { One = Number(1.0), Two = Number(2.0) } + - use: | + enum Bool { Or = 3 || 3, And = 3 && 3 } diff --git a/static_core/plugins/ets/tests/ets-templates/08.statements/08.for_statements/for_loop_parameters.params.yaml b/static_core/plugins/ets/tests/ets-templates/08.statements/08.for_statements/for_loop_parameters.params.yaml index b8b1e130cf5cf5132e08672192dc2767e1cb6216..0a8da0adf4a2c03483e0c7228cca83b6624c5fd8 100644 --- a/static_core/plugins/ets/tests/ets-templates/08.statements/08.for_statements/for_loop_parameters.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/08.statements/08.for_statements/for_loop_parameters.params.yaml @@ -198,8 +198,8 @@ cases: - doc: For loop with Float type in init. decl: |- - let a:Float = 0.0; - for(let i: Float = 0 ; i<10 ; i += 1.01 ) { + let a:Float = 0.0f; + for(let i: Float = 0f ; i<10f ; i += 1.01f ) { a = i; } assertTrue( a > 9 ); diff --git a/static_core/plugins/ets/tests/ets-templates/08.statements/09.for_of_statements/for_of.params.yaml b/static_core/plugins/ets/tests/ets-templates/08.statements/09.for_of_statements/for_of.params.yaml index 13d273a0dfa88cd819989f8fa293705f3560a48c..504de9f26c16de381f8959112910de54cb6d3ff2 100644 --- a/static_core/plugins/ets/tests/ets-templates/08.statements/09.for_of_statements/for_of.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/08.statements/09.for_of_statements/for_of.params.yaml @@ -53,8 +53,8 @@ cases: assertEQ( res, "1234" ) - use: |- - let v: float; - for (v of [1.1,2.2,3.3,4.4] as float[]) res += v + let v: Float; + for (v of [1.1f,2.2f,3.3f,4.4f] as Float[]) res += v assertEQ( res, "1.12.23.34.4" ) - use: |- diff --git a/static_core/plugins/ets/tests/ets-templates/09.classes/06.method_declarations/06.overriding_methods/different_access_modifiers.params.yaml b/static_core/plugins/ets/tests/ets-templates/09.classes/06.method_declarations/06.overriding_methods/different_access_modifiers.params.yaml index eaf670c56702e6e35ae025f5bf2a722d6379ad84..51ee4205068537fc2a1e932da98d6d906638fcd6 100644 --- a/static_core/plugins/ets/tests/ets-templates/09.classes/06.method_declarations/06.overriding_methods/different_access_modifiers.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/09.classes/06.method_declarations/06.overriding_methods/different_access_modifiers.params.yaml @@ -21,7 +21,7 @@ cases: } - tags: |- - compile-only + compile-only, negative decl: |- class A { constructor(i: Int) { } diff --git a/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/test_class_usage_of_conflicting_constants/test_class_usage_of_conflicting_constants_18.ets b/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/test_class_usage_of_conflicting_constants/test_class_usage_of_conflicting_constants_18.ets index 35ecef0eb2ae212cc1cd76faf245a22b531ec35f..2bdeb702e4db0606d65d62cd978ce04d0be4b1a8 100644 --- a/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/test_class_usage_of_conflicting_constants/test_class_usage_of_conflicting_constants_18.ets +++ b/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/test_class_usage_of_conflicting_constants/test_class_usage_of_conflicting_constants_18.ets @@ -36,5 +36,5 @@ class EnumConflictClass implements EnumConflictInterface { function main(): void { const instance = new EnumConflictClass(); assertEQ(instance.CONST, 'enumConflictValue'); - assertEQ(instance.getEnumValue() as number, 1); + assertEQ(instance.getEnumValue().valueOf(), 1); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_methods_constants/multi_layer_interface_inheritance_25.ets b/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_methods_constants/multi_layer_interface_inheritance_25.ets index b2b3703fb3873711364f3046296f3d4b1290a2ef..b5b09db85e3e1f2255a100b3721bd88dd9581f84 100644 --- a/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_methods_constants/multi_layer_interface_inheritance_25.ets +++ b/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_methods_constants/multi_layer_interface_inheritance_25.ets @@ -43,6 +43,6 @@ class ConcreteClass implements ChildInterface { function main(): void { const obj: ChildInterface = new ConcreteClass(); - assertEQ(obj.GRANDPARENT_CONST as number, 0); - assertEQ(obj.PARENT_CONST as number, 1); + assertEQ(obj.GRANDPARENT_CONST.valueOf(), 0); + assertEQ(obj.PARENT_CONST.valueOf(), 1); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_methods_constants/multi_layer_interface_inheritance_32.ets b/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_methods_constants/multi_layer_interface_inheritance_32.ets index 9c38f28ef321eb1aef44831664678273b9344770..a1c7005a29fac674ca0ee15a71e5fbf3cb95cb8e 100644 --- a/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_methods_constants/multi_layer_interface_inheritance_32.ets +++ b/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_methods_constants/multi_layer_interface_inheritance_32.ets @@ -48,8 +48,8 @@ function main(): void { const obj: ChildInterface = new ConcreteClass(); let tmp1: ColorSet = obj.grandparentMethod(); - assertEQ(tmp1 as number, 0); + assertEQ(tmp1.valueOf(), 0); let tmp2: ColorSet = obj.parentMethod(); - assertEQ(tmp2 as number, 1); + assertEQ(tmp2.valueOf(), 1); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_override/multi_layer_interface_inheritance_override_24.ets b/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_override/multi_layer_interface_inheritance_override_24.ets index 49003fdc12a1c5d947291fda07ca829729a2e8bd..f265d62c839ee6d4814755d3a3f1b596c0b1933f 100644 --- a/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_override/multi_layer_interface_inheritance_override_24.ets +++ b/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_override/multi_layer_interface_inheritance_override_24.ets @@ -44,6 +44,6 @@ class ConcreteClass implements ChildInterface { function main(): void { const obj: ChildInterface = new ConcreteClass(); - assertEQ(obj.GRANDPARENT_CONST as number, 0); - assertEQ(obj.PARENT_CONST as number, 0); + assertEQ(obj.GRANDPARENT_CONST.valueOf(), 0); + assertEQ(obj.PARENT_CONST.valueOf(), 0); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_override/multi_layer_interface_inheritance_override_ext.params.yaml b/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_override/multi_layer_interface_inheritance_override_ext.params.yaml index 8ae533cca935aeef87527c412127073dc3921297..5b9d9cb1dc43dda6b1ff92ae13d5919293bc4134 100644 --- a/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_override/multi_layer_interface_inheritance_override_ext.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_override/multi_layer_interface_inheritance_override_ext.params.yaml @@ -243,9 +243,9 @@ cases: logic: |- const obj: ChildInterface = new ConcreteClass(); let tmp1: ColorSet = obj.grandparentMethod(); - assertEQ(tmp1 as number, 1); + assertEQ(tmp1.valueOf(), 1); let tmp2: ColorSet = obj.parentMethod(); - assertEQ(tmp2 as number, 0); + assertEQ(tmp2.valueOf(), 0); - desc: The upper-layer interface has a method. In multi-layer inheritance, the sub-interface overrides all the methods of the upper-layer interface. The return value of the method is of the char data type. decl: |- interface GrandParentInterface { diff --git a/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/multiple_interface/abstract_method_same_name/abstract_method_02.ets b/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/multiple_interface/abstract_method_same_name/abstract_method_02.ets index c8abab8b80fd42e0affe9ff1b83bad2758a2f590..642fd734558234392a40755d7106bb412d09e118 100644 --- a/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/multiple_interface/abstract_method_same_name/abstract_method_02.ets +++ b/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/multiple_interface/abstract_method_same_name/abstract_method_02.ets @@ -14,8 +14,7 @@ */ /*--- -desc: Method signature of the same name is incompatible. -tags: [compile-only, negative] +desc: The method with the same name has the different parameters parameter type but same return types, valid overloading. ---*/ let resultString: string = ""; diff --git a/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/multiple_interface/abstract_method_same_name/abstract_method_12.ets b/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/multiple_interface/abstract_method_same_name/abstract_method_12.ets index bb5e6671f4637fd97870b80d6e7c4afaa93862bb..925eb8383e161fbf4571de124f61e867057a0210 100644 --- a/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/multiple_interface/abstract_method_same_name/abstract_method_12.ets +++ b/static_core/plugins/ets/tests/ets-templates/10.interfaces/07.interface_inheritance/multiple_interface/abstract_method_same_name/abstract_method_12.ets @@ -14,8 +14,7 @@ */ /*--- -desc: The method with the same name has the same type and number of parameters, but the parameter order is different. -tags: [compile-only, negative] +desc: The method with the same name has the different parameters parameter type but same return types, valid overloading. ---*/ interface Parent1 { diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/08.namespace_declarations/namespace_declarations_neg7.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/08.namespace_declarations/namespace_declarations_neg7.ets index 1512ed70af0bc19fd9fc32d879af20ed061bbe23..0d04479c07cb1b2940e6344451e0014466b2d2ad 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/08.namespace_declarations/namespace_declarations_neg7.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/08.namespace_declarations/namespace_declarations_neg7.ets @@ -14,13 +14,13 @@ limitations under the License. ---*/ /*--- -desc: ES2PANDA_FAIL TypeError 'nsConstValue' is not exported in 'myNamespace' +desc: ES2PANDA_FAIL TypeError 'returnConst' is not exported in 'myNamespace' tags: [compile-only, negative] ---*/ namespace myNamespace { - const nsConstValue = 53; - export function returnConst() { + export const nsConstValue = 53; + function returnConst() { return myNamespace.nsConstValue } } diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/04.invariance_covariance_and_contravariance/invariance/invariance_function.params.yaml b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/04.invariance_covariance_and_contravariance/invariance/invariance_function.params.yaml index 94a80b324f385f65983aad56a04af14a0bd0c5b6..c925d17641e524e9baea60b46057b1d9973e79d7 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/04.invariance_covariance_and_contravariance/invariance/invariance_function.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/04.invariance_covariance_and_contravariance/invariance/invariance_function.params.yaml @@ -66,12 +66,12 @@ cases: - argtype: float input: - -0.2 + -0.2f - argtype: Float input: - -0.0000008 + -0.0000008f - argtype: Object diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/05.compatibility_call_args/tuple_rest_params.params.yaml b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/05.compatibility_call_args/tuple_rest_params.params.yaml index 789bade92a5c7b773c25cd02beae442cd592b420..e9cf9b48445a1034dc062a7905e120e5d2109ec5 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/05.compatibility_call_args/tuple_rest_params.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/05.compatibility_call_args/tuple_rest_params.params.yaml @@ -13,20 +13,20 @@ --- cases: - - to_type: |- + - to_type: |- [short, int, double] value: |- [0b0 as byte, 0b0 as short, 0] - result: + result: - 0b0 as short - 0 - 0.0 - - to_type: |- + - to_type: |- [int, long, double] value: |- - [0b0 as short, Byte.MIN_VALUE, 3.4028234663852886e38 as float] - result: + [0b0 as short, Byte.MIN_VALUE, 3.4028234663852886e38f as float] + result: - 0 - -128 as long - 3.4028234663852886e38 as double diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/06.type_inference/01.smart_types/un_num_ops.params.yaml b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/06.type_inference/01.smart_types/un_num_ops.params.yaml index 2c8ea0b195e53b39695a83a650917ddb5b521015..39f4db599cabd53b4000366bc9a075c409787243 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/06.type_inference/01.smart_types/un_num_ops.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/06.type_inference/01.smart_types/un_num_ops.params.yaml @@ -121,7 +121,7 @@ cases: let v: string|number|Error|null = new Error() v = -42.0 if (!res) { - res = ~v + ~(~v) == -1 + res = v == -42 } - code: |- @@ -129,8 +129,7 @@ cases: if (!res) { v = -42.0 } - res = ~v + ~(~v) == -1 - tags: 'compile-only, negative' + res = v == -42 - code: |- let v: string|number|Error|null = new Error() diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/neg.params.yaml b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/neg.params.yaml index 0a415d69af9bf0af2acb1803faea13958987b875..8ed550cc1b2418f18bcab1f1e63ca67a2e97cc06 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/neg.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/neg.params.yaml @@ -104,3 +104,7 @@ cases: public constructor (a: Int[]) {} public constructor (b: T1) {} } + + - decl: |- + function foo(a: int) {} + function foo(a: Int) {} diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/overload_equivalent_example_2.ets b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/overload_equivalent_example_2.ets index eef347eeaffb33113b4abbee12ddf384db79c233..691a807e1dfd3c443e96d597181c3aa8c4abfa26 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/overload_equivalent_example_2.ets +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/overload_equivalent_example_2.ets @@ -24,6 +24,7 @@ desc: >- • All other parameter types in S1 are equal to parameter types in the same positions in S2. Parameter names and return types do not influence overload-equivalence. The following signatures are not overload-equivalent. +tags: [negative, compile-only] ---*/ let res: int = 0; diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/overload_equivalent_example_3.ets b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/overload_equivalent_example_3.ets index 6105511473cd653d1bfd07e3457a4e13e65b6d5d..a2ba66c9f25a7ebfa15bb38896d11aa91bb585bb 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/overload_equivalent_example_3.ets +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/overload_equivalent_example_3.ets @@ -24,6 +24,7 @@ desc: >- • All other parameter types in S1 are equal to parameter types in the same positions in S2. Parameter names and return types do not influence overload-equivalence. The following signatures are not overload-equivalent. +tags: [negative, compile-only] ---*/ let res: int = 0; diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/pos.params.yaml b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/pos.params.yaml index b94e0e35a5d06cfe1e65a68fe6acc0d7db2a1adf..730ca9b70555dfba1d63a7ca0008632153c63536 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/pos.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/pos.params.yaml @@ -14,10 +14,6 @@ --- cases: # functions - - decl: |- - function foo(a: int) {} - function foo(a: Int) {} - tags: [compile-only] - decl: |- function foo(a: Int) {} diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/interface_override_with_object_example_return.params.yaml b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/interface_override_with_object_example_return.params.yaml index 9a7c89525e3585f0b570361a8635dc24b9670190..0ab4479188b04578cb681944fc88eefcc674399f 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/interface_override_with_object_example_return.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/interface_override_with_object_example_return.params.yaml @@ -20,3 +20,4 @@ cases: - E1 - Base[] - [ Base, Base ] + - number diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/interface_override_with_object_example_return_neg.params.yaml b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/interface_override_with_object_example_return_neg.params.yaml index 50ba02ac0ff8f520adba889f9ae2ead058e22d62..e994252a4fe555ff36ab1c65b6b8fc2d7fef2b16 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/interface_override_with_object_example_return_neg.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/interface_override_with_object_example_return_neg.params.yaml @@ -13,7 +13,6 @@ --- cases: - - { base: "Object", derived: "number" } - { base: "number", derived: "Object" } - { base: "Derived", derived: "Object" } - { base: "(q: Base)=>Derived", derived: "Object" } diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/override_compatibility_primitive.params.yaml b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/override_compatibility_primitive.params.yaml index bffccd7d8ecb426eb7cf134707c16041060c8281..3a3eb034d7557e28843f9d048a69b4179c901574 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/override_compatibility_primitive.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/override_compatibility_primitive.params.yaml @@ -53,28 +53,6 @@ cases: } params: override-incompatible parameter (no invariance) - - tags: 'negative, compile-only' - base: |- - foo(i: Number): void { - res = 1 - } - derived: |- - override foo(i: number): void { - res = 2 - } - params: override-incompatible parameter - - - tags: 'negative, compile-only' - base: |- - foo(i: number): void { - res = 1 - } - derived: |- - override foo(i: Number): void { - res = 2 - } - params: override-incompatible parameter - # PRIMITIVES, RETURN VALUE - base: |- foo(): number { @@ -104,32 +82,6 @@ cases: } params: override-incompatible return value - - tags: 'negative, compile-only' - base: |- - foo(): number { - res = 1 - return 1.0 - } - derived: |- - foo(): Number { - res = 2 - return new Number() - } - params: override-incompatible return value - - - tags: 'negative, compile-only' - base: |- - foo(): Number { - res = 1 - return new Number() - } - derived: |- - foo(): number { - res = 2 - return 1.0 - } - params: override-incompatible return value - - tags: 'negative, compile-only' base: |- foo(): void { diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/override_with_object.params.yaml b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/override_with_object.params.yaml index 1568c0a89f95009a3b631603c265f523c5d3f49c..0f5b8b8b10cd68bc5e70b442d69792cce1b2353b 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/override_with_object.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/override_with_object.params.yaml @@ -201,33 +201,7 @@ cases: call: new Derived().foo(1) result: 2 - # override-compatible argument (covariance) - - tags: negative, compile-only - base: |- - foo( i: string ): void { - res = 1; - } - derived: |- - override foo(i: string): void { - res = 2; - } - call: new Derived().foo("some string"); - result: 2 - - # override-incompatible argument (covariance) - - tags: negative, compile-only - base: |- - foo( i: Number ): void { - res = 1; - } - derived: |- - override foo(i: number): void { - res = 2; - } - call: new Derived().foo(1); - result: 2 - - # override-compatible argument (covariance) + # override-compatible argument (invariance) - base: |- foo( i: String ): void { res = 1; @@ -236,33 +210,7 @@ cases: override foo(i: string): void { res = 2; } - call: new Derived().foo(1); - result: 2 - - # override-incompatible argument (contravariance) - - tags: negative, compile-only - base: |- - foo( i: number ): void { - res = 1; - } - derived: |- - override foo(i: Number): void { - res = 2; - } - call: new Derived().foo(1); - result: 2 - - # override-incompatible argument (contravariance) - - tags: negative, compile-only - base: |- - foo( i: string ): void { - res = 1; - } - derived: |- - override foo(i: String): void { - res = 2; - } - call: new Derived().foo("\"some string\""); + call: new Derived().foo("str"); result: 2 # override-compatible return value (invariance) @@ -279,79 +227,18 @@ cases: call: new Derived().foo(1); result: 2 - # override-incompatible return value (covariance) - - tags: negative, compile-only - base: |- - foo( i: number ): Number { - res = 1; - return i; - } - derived: |- - override foo(i: number): number { - res = 2; - return i; - } - call: new Derived().foo(1); - result: 2 - - # override-incompatible return value (covariance) - - tags: negative, compile-only - base: |- - foo( i: number ): String { - res = 1; - return i; - } - derived: |- - override foo(i: number): string { - res = 2; - return i; - } - call: new Derived().foo("\"some string\""); - result: 2 - - # override-incompatible return value (contravariance) - - tags: negative, compile-only - base: |- - foo( i: number ): number { - res = 1; - return i; - } - derived: |- - override foo(i: number): Number { - res = 2; - return i; - } - call: new Derived().foo(1); - result: 2 - - # override-incompatible return value (contravariance) - - tags: negative, compile-only - base: |- - foo( i: number ): number { - res = 1; - return i; - } - derived: |- - override foo(i: number): void { - res = 2; - return i; - } - call: new Derived().foo(1); - result: 2 - - # override-incompatible return value (contravariance) - - tags: negative, compile-only - base: |- - foo( i: number ): string { - res = 1; - return i; + # override-compatible return value (invariance) + - base: |- + foo(): String { + res = 1 + return "str1" } derived: |- - override foo(i: number): String { - res = 2; - return i; + override foo(): string { + res = 2 + return "str2" } - call: new Derived().foo("\"some string\""); + call: new Derived().foo() result: 2 # ARRAY TYPE diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/03.overloading_for_functions/function_argument_equivalent_n.ets b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/03.overloading_for_functions/function_argument_equivalent_n.ets index a104ab93ef0667f4e51cad63050978a5275fe909..996c781e4cb55f27809248701f92824f1ba2f670 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/03.overloading_for_functions/function_argument_equivalent_n.ets +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/03.overloading_for_functions/function_argument_equivalent_n.ets @@ -17,6 +17,7 @@ limitations under the License. desc: >- The correctness check for functions overloading is performed if two or more functions with the same name are acces- sible (see Accessible) in a scope (see Scopes). +tags: [compile-only, negative] ---*/ let res: number = 0; diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/03.overloading_for_functions/function_import_from_same_cu.ets b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/03.overloading_for_functions/function_import_from_same_cu.ets index 9f8cf9ea1a883fb4147028b7fe9172fe2bd98e8e..43d764d2e68c64fd59051911d6de988c6b876571 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/03.overloading_for_functions/function_import_from_same_cu.ets +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/03.overloading_for_functions/function_import_from_same_cu.ets @@ -1,17 +1,17 @@ -/*--- -Copyright (c) 2024-2025 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. ----*/ +/* + * Copyright (c) 2024-2025 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. + */ /*--- desc: >- @@ -31,22 +31,22 @@ function main(): void { let tpl: TPL = [new Number(), new String()]; assertEQ( foo(true), 2 ); - assertEQ( foo(new Boolean()), 3 ); + assertEQ( foo(new Boolean()), 2 ); assertEQ( foo(c'A'), 4 ); - assertEQ( foo(new Char()), 5 ); + assertEQ( foo(new Char()), 4 ); assertEQ( foo(1 as short), 6 ); - assertEQ( foo(new Short()), 7 ); + assertEQ( foo(new Short()), 6 ); assertEQ( foo(1 as int), 8 ); - assertEQ( foo(new Int()), 9 ); + assertEQ( foo(new Int()), 8 ); assertEQ( foo(1 as long), 10 ); - assertEQ( foo(new Long()), 11 ); + assertEQ( foo(new Long()), 10 ); assertEQ( foo(1.1 as float), 12 ); - assertEQ( foo(new Float()), 13 ); + assertEQ( foo(new Float()), 12 ); assertEQ( foo(1.2 as double), 14 ); - assertEQ( foo(new Number()), 15 ); + assertEQ( foo(new Number()), 14 ); assertEQ( foo("knock-knock"), 16 ); assertEQ( foo(new Object()), 17 ); - assertEQ( foo(new Number[2]), 18 ); + assertEQ( foo(new number[2]), 18 ); assertEQ( foo(tpl), 19 ); assertEQ( foo(new Number(), new String()), 20 ); assertEQ( foo( () => { return false; } ), 21 ); diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/03.overloading_for_functions/modules/function_export_all.ets b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/03.overloading_for_functions/modules/function_export_all.ets index c45dd1a8a3ca6bd8c2ef498865a5c0db3f266026..5a1ac03bf0736e80c1665016ca32b8d1e4c68922 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/03.overloading_for_functions/modules/function_export_all.ets +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/03.overloading_for_functions/modules/function_export_all.ets @@ -30,58 +30,30 @@ export function foo(i: boolean): int { return 2; } -export function foo(i: Boolean): int { - return 3; -} - export function foo(i: char): int { return 4; } -export function foo(i: Char): int { - return 5; -} - export function foo(i: short): int { return 6; } -export function foo(i: Short): int { - return 7; -} - export function foo(i: int): int { return 8; } -export function foo(i: Int): int { - return 9; -} - export function foo(i: long): int { return 10; } -export function foo(i: Long): int { - return 11; -} - export function foo(i: float): int { return 12; } -export function foo(i: Float): int { - return 13; -} - export function foo(i: double): int { return 14; } -export function foo(i: Number): int { - return 15; -} - export function foo(i: string): int { return 16; } @@ -90,7 +62,7 @@ export function foo(i: Object): int { return 17; } -export function foo(i: Number[]): int { +export function foo(i: number[]): int { return 18; } diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/access_modifier_over.params.yaml b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/access_modifier_over.params.yaml index a31dc598775777d110859267826a8c8a34d73f92..9b779b8026ebf157265fdc25b8166e7953beb286 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/access_modifier_over.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/access_modifier_over.params.yaml @@ -301,16 +301,14 @@ cases: a.get_foo(new Number(), "some str"); assertEQ( res, 11); + # access_modifier_over_34 - decl: |- class Derived extends Base { protected protected_foo(i: number) { res = 11;} get_foo(a: Number) {this.protected_foo(a)} - get_foo(a: number) {this.protected_foo(a)} } use: |- let a = new Derived(); - a.get_foo(new Number()); - assertEQ( res, 2); a.get_foo(1 as number); assertEQ( res, 11); diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/constructor_overload.ets b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/constructor_overload.ets index d374069baefea501eb3959742861f3f02953c76c..ce30c63dcd71a56b99f7da3eb5e02388e2b69660 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/constructor_overload.ets +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/constructor_overload.ets @@ -33,7 +33,6 @@ class Base { constructor() { res = 1;} constructor(i: number) { res = 2;} constructor(i: string) { res = 3;} - constructor(i: Number) { res = 4;} constructor(i: byte[]) { res = 5;} constructor(i: TPL) { res = 6;} constructor(i: BoolFun) { res = 7;} diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/constructor_overload.params.yaml b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/constructor_overload.params.yaml index c8d220bbb8d6df41f13c8ea43dad44a32f3a29af..5ccea351ed22c63b3fb68492fdb97ede88a65220 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/constructor_overload.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/constructor_overload.params.yaml @@ -29,7 +29,7 @@ cases: assertEQ( res, 21 ); - decl: |- - constructor() { + constructor() { super(1.1 as number); res += 20; } @@ -38,7 +38,7 @@ cases: assertEQ( res, 22 ); - decl: |- - constructor() { + constructor() { super("some string"); res += 20; } @@ -110,7 +110,7 @@ cases: - decl: |- constructor(i: TPL) { res = 26;} use: |- - let a: TPL = [ false, 1.2]; + let a: TPL = [ false, 1.2f]; new Derived(a); assertEQ( res, 26 ); diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/instance_method_over_n2.params.yaml b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/instance_method_over_n2.params.yaml index 3b30c6d6a6d342000596217f2201cee39f4acfe0..043b69cdf4fa35816860df6112bd57ad68147309 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/instance_method_over_n2.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/instance_method_over_n2.params.yaml @@ -17,7 +17,7 @@ cases: - { base: "i: Number|undefined|null", derived: "i: undefined|Number|null", call: "undefined", res: 2 } - { base: "i: Number|undefined|null", derived: "i: undefined|null|Number", call: "null", res: 2 } # overload base method as arguments are different - - { base: "i: Number, j: number", derived: "i: number, k: Number", call: "new Number(), 1", res: 1 } + - { base: "i: Number, j: number", derived: "i: number, k: Number", call: "new Number(), 1", res: 2 } - { base: "i: Number, j: number", derived: "i: number, k: Number", call: "1, new Number()", res: 2 } # Class diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/single_class_overload_n.params.yaml b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/single_class_overload_n.params.yaml index 621c605b24aac39eb26da600b90aa82bfac52423..177921922d2adc49a938a625ecca550bba38571a 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/single_class_overload_n.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/single_class_overload_n.params.yaml @@ -17,79 +17,94 @@ cases: - decl: |- constructor() { res = 1;} constructor(i: short) { res = 2;} - constructor(i: Short) { res = 3;} constructor(i: int) { res = 4;} - constructor(i: Int) { res = 5;} constructor(i: long) { res = 6;} - constructor(i: Long) { res = 7;} constructor(i: float) { res = 8;} - constructor(i: Float) { res = 9;} constructor(i: double) { res = 10;} - constructor(i: Number) { res = 11;} constructor(i: char) { res = 12;} - constructor(i: Char) { res = 13;} constructor(i: string) { res = 14;} constructor(i: byte) { res = 15;} - constructor(i: Byte) { res = 16;} constructor(i: boolean) { res = 17;} - constructor(i: Boolean) { res = 18;} constructor(i: int, j: int) { res = 19;} constructor(i: Gen) { res = 20;} constructor(i: Gen2) { res = 21;} constructor(i: Number|undefined|null) { res = 22;} constructor(i: number, j: Number) { res = 23;} - constructor(i: Number, j: number) { res = 24;} use: |- new Base(); assertEQ( res, 1); + new Base(1 as short); assertEQ( res, 2); + new Base(new Short()); - assertEQ( res, 3); + assertEQ( res, 2); + new Base(1 as int); assertEQ( res, 4); + new Base(new Int()); - assertEQ( res, 5); + assertEQ( res, 4); + new Base(1 as long); assertEQ( res, 6); + new Base(new Long()); - assertEQ( res, 7); + assertEQ( res, 6); + new Base(1.1 as float); assertEQ( res, 8); + new Base(new Float()); - assertEQ( res, 9); + assertEQ( res, 8); + new Base(1.2 as double); assertEQ( res, 10); + new Base(new Number()); - assertEQ( res, 11); + assertEQ( res, 10); + new Base(c'A'); assertEQ( res, 12); + new Base(new Char()); - assertEQ( res, 13); + assertEQ( res, 12); + new Base("some str"); assertEQ( res, 14); + new Base(1 as byte); assertEQ( res, 15); + new Base(new Byte()); - assertEQ( res, 16); + assertEQ( res, 15); + new Base(false); assertEQ( res, 17); + new Base(new Boolean()); - assertEQ( res, 18); + assertEQ( res, 17); + new Base(1 as int, 1 as int); assertEQ( res, 19); + new Base(new Gen()); assertEQ( res, 20); + new Base(new Gen2()); assertEQ( res, 21); + new Base(undefined); assertEQ( res, 22); + new Base(null); assertEQ( res, 22); + new Base(1.1 as number, new Number()); assertEQ( res, 23); + new Base(new Number(), 1.1 as number); - assertEQ( res, 24); + assertEQ( res, 23); - tags: negative, compile-only decl: |- @@ -120,22 +135,14 @@ cases: - decl: |- foo() { res = 1;} foo(i: short) { res = 2;} - foo(i: Short) { res = 3;} foo(i: int) { res = 4;} - foo(i: Int) { res = 5;} foo(i: long) { res = 6;} - foo(i: Long) { res = 7;} foo(i: float) { res = 8;} - foo(i: Float) { res = 9;} foo(i: double) { res = 10;} - foo(i: Number) { res = 11;} foo(i: char) { res = 12;} - foo(i: Char) { res = 13;} foo(i: string) { res = 14;} foo(i: byte) { res = 15;} - foo(i: Byte) { res = 16;} foo(i: boolean) { res = 17;} - foo(i: Boolean) { res = 18;} foo(i: int, j: int) { res = 19;} foo(i: Gen) { res = 20;} foo(i: Gen2) { res = 21;} @@ -144,48 +151,70 @@ cases: let a = new Base(); a.foo(); assertEQ( res, 1); + a.foo(1 as short); assertEQ( res, 2); + a.foo(new Short()); - assertEQ( res, 3); + assertEQ( res, 2); + a.foo(1 as int); assertEQ( res, 4); + a.foo(new Int()); - assertEQ( res, 5); + assertEQ( res, 4); + a.foo(1 as long); assertEQ( res, 6); + a.foo(new Long()); - assertEQ( res, 7); + assertEQ( res, 6); + a.foo(1.1 as float); assertEQ( res, 8); + a.foo(new Float()); - assertEQ( res, 9); + assertEQ( res, 8); + a.foo(1.2 as double); assertEQ( res, 10); + a.foo(new Number()); - assertEQ( res, 11); + assertEQ( res, 10); + a.foo(c'A'); assertEQ( res, 12); + a.foo(new Char()); - assertEQ( res, 13); + assertEQ( res, 12); + a.foo("some str"); assertEQ( res, 14); + a.foo(1 as byte); assertEQ( res, 15); + a.foo(new Byte()); - assertEQ( res, 16); + assertEQ( res, 15); + a.foo(false); assertEQ( res, 17); + a.foo(new Boolean()); - assertEQ( res, 18); + assertEQ( res, 17); + a.foo(1 as int, 1 as int); assertEQ( res, 19); + a.foo(new Gen()); assertEQ( res, 20); + a.foo(new Gen2()); assertEQ( res, 21); + a.foo(undefined); assertEQ( res, 22); + a.foo(null); assertEQ( res, 22); @@ -226,65 +255,77 @@ cases: - decl: |- static foo() { res = 1;} static foo(i: short) { res = 2;} - static foo(i: Short) { res = 3;} static foo(i: int) { res = 4;} - static foo(i: Int) { res = 5;} static foo(i: long) { res = 6;} - static foo(i: Long) { res = 7;} static foo(i: float) { res = 8;} - static foo(i: Float) { res = 9;} static foo(i: double) { res = 10;} - static foo(i: Number) { res = 11;} static foo(i: char) { res = 12;} - static foo(i: Char) { res = 13;} static foo(i: string) { res = 14;} static foo(i: byte) { res = 15;} - static foo(i: Byte) { res = 16;} static foo(i: boolean) { res = 17;} - static foo(i: Boolean) { res = 18;} static foo(i: int, j: int) { res = 19;} static foo(i: Number|undefined|null) { res = 20;} use: |- Base.foo(); assertEQ( res, 1); + Base.foo(1 as short); assertEQ( res, 2); + Base.foo(new Short()); - assertEQ( res, 3); + assertEQ( res, 2); + Base.foo(1 as int); assertEQ( res, 4); + Base.foo(new Int()); - assertEQ( res, 5); + assertEQ( res, 4); + Base.foo(1 as long); assertEQ( res, 6); + Base.foo(new Long()); - assertEQ( res, 7); + assertEQ( res, 6); + Base.foo(1.1 as float); assertEQ( res, 8); + Base.foo(new Float()); - assertEQ( res, 9); + assertEQ( res, 8); + Base.foo(1.2 as double); assertEQ( res, 10); + Base.foo(new Number()); - assertEQ( res, 11); + assertEQ( res, 10); + Base.foo(c'A'); assertEQ( res, 12); + Base.foo(new Char()); - assertEQ( res, 13); + assertEQ( res, 12); + Base.foo("some str"); assertEQ( res, 14); + Base.foo(1 as byte); assertEQ( res, 15); + Base.foo(new Byte()); - assertEQ( res, 16); + assertEQ( res, 15); + Base.foo(false); assertEQ( res, 17); + Base.foo(new Boolean()); - assertEQ( res, 18); + assertEQ( res, 17); + Base.foo(1 as int, 1 as int); assertEQ( res, 19); + Base.foo(undefined); assertEQ( res, 20); + Base.foo(null); assertEQ( res, 20); diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/static_method_over_n2.params.yaml b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/static_method_over_n2.params.yaml index 29460334e750a704577b43100fd054f1197dfbdc..2060b7a7063988bbf5ec5a235d4f592ccaeaf741 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/static_method_over_n2.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/static_method_over_n2.params.yaml @@ -17,7 +17,7 @@ cases: - { base: "i: Number|undefined|null", derived: "i: undefined|Number|null", call: "undefined", res: 2 } - { base: "i: Number|undefined|null", derived: "i: undefined|null|Number", call: "null", res: 2 } # not overload-equivalent -> overload base method - - { base: "i: Number, j: number", derived: "i: number, k: Number", call: "new Number(), 1", res: 1 } + - { base: "i: Number, j: number", derived: "i: number, k: Number", call: "new Number(), 1", res: 2 } - { base: "i: Number, j: number", derived: "i: number, k: Number", call: "1, new Number()", res: 2 } # Class diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/two_class_method_over_n.ets b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/two_class_method_over_n.ets index a985001096b28dfa8ae29e162574661d7186559b..ffd95d04786fd729c361f7719a7ef39589d6f8cf 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/two_class_method_over_n.ets +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/two_class_method_over_n.ets @@ -59,7 +59,7 @@ class Derived2 extends Base { function main(): void { let a = new Derived(); let b = new Derived2(); - let c: TPL = [ false, 1.2]; + let c: TPL = [ false, 1.2f]; b.foo({{c.call}}); // base instance method call assertEQ( res, 100 + {{c.res}} ); a.foo({{c.call}}); // derived instance method call diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/two_class_method_over_n.params.yaml b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/two_class_method_over_n.params.yaml index 3e7f312f6e980b3f7bb755b10bdfecd0295c70e0..5b77edb68d110d41c454d1de8b09df63663abb91 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/two_class_method_over_n.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/two_class_method_over_n.params.yaml @@ -14,22 +14,14 @@ --- cases: - { arg: "", call: "", res: 1} - - { arg: "i: short", call: "1 as short", res: 2} - { arg: "i: Short", call: "new Short()", res: 3} - - { arg: "i: int", call: "1 as int", res: 4} - { arg: "i: Int", call: "new Int()", res: 5} - - { arg: "i: long", call: "1 as long", res: 6} - { arg: "i: Long", call: "new Long()", res: 7} - - { arg: "i: float", call: "1.1 as float", res: 8} - { arg: "i: Float", call: "new Float()", res: 9} - - { arg: "i: double", call: "1.2 as double", res: 10} - { arg: "i: Number", call: "new Number()", res: 11} - - { arg: "i: char", call: "c'x'", res: 12} - { arg: "i: Char", call: "new Char()", res: 13} - { arg: "i: string", call: "\"some str\"", res: 14} - - { arg: "i: byte", call: "1 as byte", res: 15} - { arg: "i: Byte", call: "new Byte()", res: 16} - - { arg: "i: boolean", call: "false", res: 17} - { arg: "i: Boolean", call: "new Boolean()", res: 18} - { arg: "i: int, j: int", call: "1 as int, 2 as int", res: 19} - { arg: "i: Gen", call: "new Gen", res: 20} diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/05.overloading_and_overriding_in_interfaces/im_over2.params.yaml b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/05.overloading_and_overriding_in_interfaces/im_over2.params.yaml index ef7661bb0293045302f2e4d52134d000607416e4..c2a0fc364bb2cc2496dcd8b77998a15e6cb3f937 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/05.overloading_and_overriding_in_interfaces/im_over2.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/07.overloading_and_overriding/05.overloading_and_overriding_in_interfaces/im_over2.params.yaml @@ -57,20 +57,17 @@ cases: - decl: |- // method overloaded with boxing/unboxing parameters interface J { - m(a: boolean): number { return 1.0 } - m(a: Boolean): number { return 2.0 } - m(a: boolean, b: number): number { return 3.0 } - m(a: boolean, b: Number): number { return 4.0 } - m(a: Boolean, b: Number): number { return 5.0 } + m(a: boolean): number { return 1.0 } + m(a: boolean, b: number): number { return 3.0 } } class A implements J {} use: |- let a = new A() assertEQ( a.m(true), 1.0 ) - assertEQ( a.m(new Boolean()), 2.0 ) + assertEQ( a.m(new Boolean()), 1.0 ) assertEQ( a.m(true, 1.0), 3.0 ) - assertEQ( a.m(false, new Double()), 4.0 ) - assertEQ( a.m(new Boolean(), new Double()), 5.0 ) + assertEQ( a.m(false, new Double()), 3.0 ) + assertEQ( a.m(new Boolean(), new Double()), 3.0 ) - decl: |- // method overloaded with rest parameters diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/08.overload_resolution/02.best_candidate_selection/better_shorter_conversion_0.ets b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/08.overload_resolution/02.best_candidate_selection/better_shorter_conversion_0.ets index a20f4862ffdc6a3dabae233918da41d694f56624..01c6e86fae801b7600dde4c9d8dcefe13f5e9bb5 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/08.overload_resolution/02.best_candidate_selection/better_shorter_conversion_0.ets +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/08.overload_resolution/02.best_candidate_selection/better_shorter_conversion_0.ets @@ -19,7 +19,7 @@ desc: >- If argument type is of a numeric type (see Numeric Types), char, or its boxed counterpart, then the candidate with a shorter conversion is better. assert: No transformation is better than any transformation -tags: [] +tags: [compile-only, negative] ---*/ let candidate = 0; diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/cond_t2.params.yaml b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/cond_t2.params.yaml index c916b2f74de4f37b2079160d448c40e3ae37afc2..20cf44fc11bed6eb16404a991327a012931d8f83 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/cond_t2.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/cond_t2.params.yaml @@ -17,9 +17,9 @@ cases: - { val: '0x8000 as short', type: 'short' } - { val: '0x80000000', type: 'int' } - { val: '0x8000000000000000 as long', type: 'long' } - - { val: '0.000001', type: 'float' } + - { val: '0.000001f', type: 'float' } - { val: '0.0000000001', type: 'double' } - - { val: '0.000001', type: 'float' } + - { val: '0.000001f', type: 'float' } - { val: 'Byte.MIN_VALUE', type: 'byte' } - { val: 'Byte.MAX_VALUE', type: 'byte' } diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/do_t.params.yaml b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/do_t.params.yaml index c916b2f74de4f37b2079160d448c40e3ae37afc2..20cf44fc11bed6eb16404a991327a012931d8f83 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/do_t.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/do_t.params.yaml @@ -17,9 +17,9 @@ cases: - { val: '0x8000 as short', type: 'short' } - { val: '0x80000000', type: 'int' } - { val: '0x8000000000000000 as long', type: 'long' } - - { val: '0.000001', type: 'float' } + - { val: '0.000001f', type: 'float' } - { val: '0.0000000001', type: 'double' } - - { val: '0.000001', type: 'float' } + - { val: '0.000001f', type: 'float' } - { val: 'Byte.MIN_VALUE', type: 'byte' } - { val: 'Byte.MAX_VALUE', type: 'byte' } diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/for_t.params.yaml b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/for_t.params.yaml index c916b2f74de4f37b2079160d448c40e3ae37afc2..20cf44fc11bed6eb16404a991327a012931d8f83 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/for_t.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/for_t.params.yaml @@ -17,9 +17,9 @@ cases: - { val: '0x8000 as short', type: 'short' } - { val: '0x80000000', type: 'int' } - { val: '0x8000000000000000 as long', type: 'long' } - - { val: '0.000001', type: 'float' } + - { val: '0.000001f', type: 'float' } - { val: '0.0000000001', type: 'double' } - - { val: '0.000001', type: 'float' } + - { val: '0.000001f', type: 'float' } - { val: 'Byte.MIN_VALUE', type: 'byte' } - { val: 'Byte.MAX_VALUE', type: 'byte' } diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/if_t2.params.yaml b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/if_t2.params.yaml index c916b2f74de4f37b2079160d448c40e3ae37afc2..20cf44fc11bed6eb16404a991327a012931d8f83 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/if_t2.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/if_t2.params.yaml @@ -17,9 +17,9 @@ cases: - { val: '0x8000 as short', type: 'short' } - { val: '0x80000000', type: 'int' } - { val: '0x8000000000000000 as long', type: 'long' } - - { val: '0.000001', type: 'float' } + - { val: '0.000001f', type: 'float' } - { val: '0.0000000001', type: 'double' } - - { val: '0.000001', type: 'float' } + - { val: '0.000001f', type: 'float' } - { val: 'Byte.MIN_VALUE', type: 'byte' } - { val: 'Byte.MAX_VALUE', type: 'byte' } diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/while_t.params.yaml b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/while_t.params.yaml index c916b2f74de4f37b2079160d448c40e3ae37afc2..20cf44fc11bed6eb16404a991327a012931d8f83 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/while_t.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/while_t.params.yaml @@ -17,9 +17,9 @@ cases: - { val: '0x8000 as short', type: 'short' } - { val: '0x80000000', type: 'int' } - { val: '0x8000000000000000 as long', type: 'long' } - - { val: '0.000001', type: 'float' } + - { val: '0.000001f', type: 'float' } - { val: '0.0000000001', type: 'double' } - - { val: '0.000001', type: 'float' } + - { val: '0.000001f', type: 'float' } - { val: 'Byte.MIN_VALUE', type: 'byte' } - { val: 'Byte.MAX_VALUE', type: 'byte' } diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/01.character_literals/char_literals.ets b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/01.character_literals/char_literals.ets index 8a2d968391af6c486ac6262585b419355abaa7b7..019b1211c9937a2972e328689e710fe2ec662857 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/01.character_literals/char_literals.ets +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/01.character_literals/char_literals.ets @@ -19,14 +19,14 @@ desc: Correct char literals function main() { // check escaped characters - let escaped_chars: char[] = [ c'\b', c'\f', c'\n', c'\r', c'\t', c'\v', c'\\', c'\'', c'\"' ] - let escaped_vals: int[] = [ 8, 12, 10, 13, 9, 11, 92, 39, 34 ] + let escaped_chars: Char[] = [ c'\b', c'\f', c'\n', c'\r', c'\t', c'\v', c'\\', c'\'', c'\"' ] + let escaped_vals: Int[] = [ 8, 12, 10, 13, 9, 11, 92, 39, 34 ] for (let i = 0; i < escaped_chars.length; i++) { - assertEQ( escaped_chars[i] as int, escaped_vals[i] ) + assertEQ( escaped_chars[i], escaped_vals[i].toChar() ) } // check hex-formatted characters - let hex_chars: char[] = [ c'\x00', c'\x01', c'\x02', c'\x03', c'\x04', c'\x05', c'\x06', + let hex_chars: Char[] = [ c'\x00', c'\x01', c'\x02', c'\x03', c'\x04', c'\x05', c'\x06', c'\x07', c'\x08', c'\x09', c'\x0a', c'\x0b', c'\x0c', c'\x0d', c'\x0e', c'\x0f', c'\x10', c'\x11', c'\x12', c'\x13', c'\x14', c'\x15', c'\x16', c'\x17', c'\x18', c'\x19', c'\x1a', c'\x1b', c'\x1c', c'\x1d', c'\x1e', c'\x1f', c'\x20', c'\x21', @@ -42,12 +42,12 @@ function main() { c'\x73', c'\x74', c'\x75', c'\x76', c'\x77', c'\x78', c'\x79', c'\x7a', c'\x7b', c'\x7c', c'\x7d', c'\x7e', c'\x7f' ] - for (let i = 0; i < 128; i++) { - assertEQ( hex_chars[i] as int, i ) + for (let i: Int = 0; i < 128; i++) { + assertEQ( hex_chars[i], i.toChar() ) } // check unicode-formatted characters - let unicode_chars: char[] = [ c'\u0041', c'\u0429', c'\u0811', c'\u0bf9', c'\u0fe1', c'\u13c9', + let unicode_chars: Char[] = [ c'\u0041', c'\u0429', c'\u0811', c'\u0bf9', c'\u0fe1', c'\u13c9', c'\u17b1', c'\u1b99', c'\u1f81', c'\u2369', c'\u2751', c'\u2b39', c'\u2f21', c'\u3309', c'\u36f1', c'\u3ad9', c'\u3ec1', c'\u42a9', c'\u4691', c'\u4a79', c'\u4e61', c'\u5249', c'\u5631', c'\u5a19', c'\u5e01', c'\u61e9', c'\u65d1', c'\u69b9', c'\u6da1', c'\u7189', @@ -58,7 +58,7 @@ function main() { c'\uf271', c'\uf659', c'\ufa41', c'\ufe29' ] let j = 0; - for (let i = 65; i < 65536; i += 1000) { - assertEQ( unicode_chars[j++] as int, i ) + for (let i: Int = 65; i < 65536; i += 1000) { + assertEQ( unicode_chars[j++], i.toChar() ) } } diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/addition/add_arr_ref.ets b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/addition/add_arr_ref.ets index 7a80483daae0b29ce60462345b543faecc6504d0..97895c892c11bd168a819e2a1ef4bc984e1ba0c9 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/addition/add_arr_ref.ets +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/addition/add_arr_ref.ets @@ -25,7 +25,7 @@ function main() { const v1 = new Char({{v.v1}}) const v2 = new Char({{v.v2}}) - a[0] = ({{v.exp}}) as Char // Explicit cast to Char is needed here + a[0] = ({{v.exp}}).toChar() // Explicit cast to Char is needed here assertEQ(a[0], {{v.r}}) } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/addition/add_func_ref.ets b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/addition/add_func_ref.ets index 14e12d27992a01fb946f5eab3370a203f5bdfafa..5767d872e141b09a3d936d3e7a183dcfa5689015 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/addition/add_func_ref.ets +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/addition/add_func_ref.ets @@ -20,7 +20,7 @@ desc: >- ---*/ function add(p: Char, q: Char): Char { - return (p + q) as Char + return (p + q).toChar() } function main() { diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/addition/add_func_ref.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/addition/add_func_ref.params.yaml index 75457d8c8d5c4775134334d49732ea59f25c8f40..f2cf8746bb37f78666e26bd476733bfdc665f86f 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/addition/add_func_ref.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/addition/add_func_ref.params.yaml @@ -19,7 +19,7 @@ vals: - v1: c'\u0020' v2: c'\u0001' - exp: "(add(v1, v2) + c' ') as Char" + exp: "(add(v1, v2) + c' ').toChar()" r: c'A' - v1: c'\uFFFF' @@ -39,7 +39,7 @@ vals: - v1: c'\u1010' v2: c'\u0101' - exp: "add((v1 + c'\\u1010') as Char, (v2 + c'\\u0101') as Char)" + exp: "add((v1 + c'\\u1010').toChar(), (v2 + c'\\u0101').toChar())" r: c'\u2222' - v1: c'∫' diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/addition/add_func_val.ets b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/addition/add_func_val.ets index a86c47c92fb0538be55ca6541f5f3600c971b0ef..34e855f072ef6da2c77e94c6e93dc34b190917fb 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/addition/add_func_val.ets +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/addition/add_func_val.ets @@ -20,7 +20,7 @@ desc: >- ---*/ function add(p: char, q: char): char { - return (p + q) as char + return (p + q).toChar() } function main() { diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/addition/add_func_val.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/addition/add_func_val.params.yaml index 350e6f5e0ca80da5c05b122a15b971ddfba6ff02..f2cf8746bb37f78666e26bd476733bfdc665f86f 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/addition/add_func_val.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/addition/add_func_val.params.yaml @@ -19,7 +19,7 @@ vals: - v1: c'\u0020' v2: c'\u0001' - exp: "(add(v1, v2) + c' ') as char" + exp: "(add(v1, v2) + c' ').toChar()" r: c'A' - v1: c'\uFFFF' @@ -39,7 +39,7 @@ vals: - v1: c'\u1010' v2: c'\u0101' - exp: "add((v1 + c'\\u1010') as char, (v2 + c'\\u0101') as char)" + exp: "add((v1 + c'\\u1010').toChar(), (v2 + c'\\u0101').toChar())" r: c'\u2222' - v1: c'∫' diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/concat/conc2.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/concat/conc2.params.yaml index a7a294cbb9dcba28a1e8fb015f6d875c0a75be7a..e0b1a903a5124fb64171789e1bd9155f99acade0 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/concat/conc2.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/concat/conc2.params.yaml @@ -18,11 +18,11 @@ vals: res: '"abcd"' - expr: "c'a' + 'b' + 'c' + c'd'" res: '"abcd"' - - expr: "(c'a' + c'b' + c'c' + c'd') as char" + - expr: "(c'a' + c'b' + c'c' + c'd').toChar()" res: c'Ɗ' - - expr: "(c'a' + c'b' + c'c' ) as char + 'd'" + - expr: "(c'a' + c'b' + c'c' ).toChar() + 'd'" res: '"Ħd"' - - expr: "(c'a' + c'b') as char + 'c' + 'd'" + - expr: "(c'a' + c'b').toChar() + 'c' + 'd'" res: '"Ãcd"' - expr: "'a' + new Char(c'b') + 'c' + new Char(c'd')" @@ -31,9 +31,9 @@ vals: res: '"abcd"' - expr: "new Char(c'a') + 'b' + 'c' + new Char(c'd')" res: '"abcd"' - - expr: "(new Char(c'a') + new Char(c'b') + new Char(c'c') + new Char(c'd')) as char" + - expr: "(new Char(c'a') + new Char(c'b') + new Char(c'c') + new Char(c'd')).toChar()" res: c'Ɗ' - - expr: "(new Char(c'a') + new Char(c'b') + new Char(c'c')) as char + 'd'" + - expr: "(new Char(c'a') + new Char(c'b') + new Char(c'c')).toChar() + 'd'" res: '"Ħd"' - - expr: "(new Char(c'a') + new Char(c'b')) as char + 'c' + 'd'" + - expr: "(new Char(c'a') + new Char(c'b')).toChar() + 'c' + 'd'" res: '"Ãcd"' diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/concat/conc_ref.ets b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/concat/conc_ref.ets index e2e839720226236de36e930b0f3253e09d7b5392..72230fce78e5065b9d478ff3fc3f1859221d6c70 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/concat/conc_ref.ets +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/concat/conc_ref.ets @@ -25,14 +25,14 @@ function main() { assertEQ("" + v1 + v2, {{v.r1}}) assertEQ(v1 + "" + v2, {{v.r1}}) - assertEQ((v1 + v2) as Char + "", {{v.r2}}) + assertEQ((v1 + v2).toChar() + "", {{v.r2}}) assertEQ("" + {{v.v1}} + v2, {{v.r1}}) assertEQ({{v.v1}} + "" + v2, {{v.r1}}) - assertEQ(({{v.v1}} + v2) as Char + "", {{v.r2}}) + assertEQ(({{v.v1}} + v2).toChar() + "", {{v.r2}}) assertEQ("" + {{v.v1}} + {{v.v2}}, {{v.r1}}) assertEQ({{v.v1}} + "" + {{v.v2}}, {{v.r1}}) - assertEQ(({{v.v1}} + {{v.v2}}) as Char + "", {{v.r2}}) + assertEQ(({{v.v1}} + {{v.v2}}).toChar() + "", {{v.r2}}) } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/concat/conc_val.ets b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/concat/conc_val.ets index 85b4c4e6a0e1f3d5835e059dcacdfdcc0ebf41f8..64fca89f2f1e3cd57ea2a877e10da286320a2870 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/concat/conc_val.ets +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/concat/conc_val.ets @@ -25,14 +25,14 @@ function main() { assertEQ("" + v1 + v2, {{v.r1}}) assertEQ(v1 + "" + v2, {{v.r1}}) - assertEQ((v1 + v2) as char + "", {{v.r2}}) + assertEQ((v1 + v2).toChar() + "", {{v.r2}}) assertEQ("" + {{v.v1}} + v2, {{v.r1}}) assertEQ({{v.v1}} + "" + v2, {{v.r1}}) - assertEQ(({{v.v1}} + v2) as char + "", {{v.r2}}) + assertEQ(({{v.v1}} + v2).toChar() + "", {{v.r2}}) assertEQ("" + {{v.v1}} + {{v.v2}}, {{v.r1}}) assertEQ({{v.v1}} + "" + {{v.v2}}, {{v.r1}}) - assertEQ(({{v.v1}} + {{v.v2}}) as char + "", {{v.r2}}) + assertEQ(({{v.v1}} + {{v.v2}}).toChar() + "", {{v.r2}}) } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/conditional/cond_exp_val.ets b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/conditional/cond_exp_val.ets index 8b52f8a9fca500bacc9bd93e25660eec119af36d..f4316b5b1246cc7953fc03b5e354ddbfeb17b32c 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/conditional/cond_exp_val.ets +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/conditional/cond_exp_val.ets @@ -25,6 +25,6 @@ class A { } function main() { - assertEQ((A.r - (A.b ? {{v.v1}} : {{v.v2}})) as Char, c'\u0000') + assertEQ((A.r - (A.b ? {{v.v1}} : {{v.v2}})).toChar(), c'\u0000') } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/conditional/cond_exp_val.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/conditional/cond_exp_val.params.yaml index 43074d883e4bf9ec1df3cd95fb0d0af028a2d596..47da7ed281eb7b2c43f6d465b3f8797bbddbce45 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/conditional/cond_exp_val.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/conditional/cond_exp_val.params.yaml @@ -22,8 +22,8 @@ vals: b: 'false' r: c'A' + c'\uF000' - - v1: (c'\uFFFE' + c'\u0023') as char - v2: (c'\u0021' + c'\u0001') as char + - v1: (c'\uFFFE' + c'\u0023').toChar() + v2: (c'\u0021' + c'\u0001').toChar() b: 'true' r: c'!' diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/conditional/cond_func_ref.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/conditional/cond_func_ref.params.yaml index 4c81c257765f9aa9edc7a32e3996e74428c3655c..a3c8b3e956d4f35fb93304d5cc548f7671bf3b16 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/conditional/cond_func_ref.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/conditional/cond_func_ref.params.yaml @@ -19,7 +19,7 @@ vals: - v1: c'\u0020' v2: c'\u0021' - exp: "(foo(false, v1, v2) + v1) as Char" + exp: "(foo(false, v1, v2) + v1).toChar()" r: c'A' - v1: c'\u0020' @@ -29,10 +29,10 @@ vals: - v1: c'\u0020' v2: c'\u0021' - exp: "(c' ' + foo(false, v1, v2) + v1) as Char" + exp: "(c' ' + foo(false, v1, v2) + v1).toChar()" r: c'a' - v1: c'\u0020' v2: c'\u0021' - exp: "(c' ' + foo(false, (v2 + v1) as Char, (v2 - v1) as Char)) as Char" + exp: "(c' ' + foo(false, (v2 + v1).toChar(), (v2 - v1).toChar())).toChar()" r: v2 diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/conditional/cond_func_val.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/conditional/cond_func_val.params.yaml index 9a835c6dcf5ee45bb5611e917836d93a44f305a4..ada8048b92758cd23f7c2dfaa76f777427f6221c 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/conditional/cond_func_val.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/conditional/cond_func_val.params.yaml @@ -21,7 +21,7 @@ vals: # 1. - v1: c'\u0020' v2: c'\u0021' - exp: (foo(false, v1, v2) +v1) as char + exp: (foo(false, v1, v2) +v1).toChar() r: c'A' # 2. @@ -33,11 +33,11 @@ vals: # 3. - v1: c'\u0020' v2: c'\u0021' - exp: "(c' ' + foo(false, v1, v2) + v1) as char" + exp: "(c' ' + foo(false, v1, v2) + v1).toChar()" r: c'a' # 4. - v1: c'\u0020' v2: c'\u0021' - exp: "(c' ' + foo(false, (v2 + v1) as char, (v2 - v1) as char)) as char" + exp: "(c' ' + foo(false, (v2 + v1).toChar(), (v2 - v1).toChar())).toChar()" r: v2 diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/decrement/dec_func_ref.ets b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/decrement/dec_func_ref.ets index 2ff293da1dba930f1c66aa79e40e424507a6e6d0..472f2f59321046f616ae9c579f1f85f872d5c8b2 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/decrement/dec_func_ref.ets +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/decrement/dec_func_ref.ets @@ -20,12 +20,12 @@ desc: >- ---*/ function decPre(p: Char): Char { - return --p + return (--p).toChar() } function decPost(p: Char): Char { p-- - return p + return (p).toChar() } function main() { diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/decrement/dec_func_ref.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/decrement/dec_func_ref.params.yaml index b808360b1938949f97d4537c044b482c0080e373..0312caf85d07dd26376e743b578a5a4f6f75c8ba 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/decrement/dec_func_ref.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/decrement/dec_func_ref.params.yaml @@ -21,11 +21,11 @@ vals: res: c'!' - v1: c'"' - exp: "(c' ' + decPre(v1)) as Char" + exp: "(c' ' + decPre(v1)).toChar()" res: c'A' - v1: c'\u0020' - exp: "(c' ' + decPost(v1)) as Char" + exp: "(c' ' + decPost(v1)).toChar()" res: c'?' - v1: c'\u0000' @@ -37,27 +37,27 @@ vals: res: c'\uFFFF' - v1: c'\u00FF' - exp: "decPre((c'!' + v1 + v1) as Char)" + exp: "decPre((c'!' + v1 + v1).toChar())" res: c'\u021E' - v1: c'\u0001' - exp: "decPost((v1 - c'!' - v1) as Char)" + exp: "decPost((v1 - c'!' - v1).toChar())" res: c'\uFFDE' - v1: c'\u0F0F' - exp: "(decPre((v1 - c'1') as Char) - decPre(c'\\uACD9')) as Char" + exp: "(decPre((v1 - c'1').toChar()) - decPre(c'\\uACD9')).toChar()" res: c'\u6205' - v1: c'\u0F0F' - exp: "(decPost((v1 + c'1') as Char) + decPost(c'\\uACD9')) as Char" + exp: "(decPost((v1 + c'1').toChar()) + decPost(c'\\uACD9')).toChar()" res: c'\uBC17' - v1: c'\u1110' - exp: "(decPre(c'\\u0000') - decPre(v1)) as Char" + exp: "(decPre(c'\\u0000') - decPre(v1)).toChar()" res: c'\uEEF0' - v1: c'\u1000' - exp: "(decPost(c'\\u0000') - decPost(v1)) as Char" + exp: "(decPost(c'\\u0000') - decPost(v1)).toChar()" res: c'\uF000' - v1: c'∬' diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/decrement/dec_func_val.ets b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/decrement/dec_func_val.ets index df21e7f4730a418c39756f7d6d3e18694ef88c33..0bdca909423ea096cfa3621b2520a510995f7339 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/decrement/dec_func_val.ets +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/decrement/dec_func_val.ets @@ -20,12 +20,12 @@ desc: >- ---*/ function decPre(p: char): char { - return --p + return (--p).toChar() } function decPost(p: char): char { p-- - return p + return (p).toChar() } function main() { diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/decrement/dec_func_val.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/decrement/dec_func_val.params.yaml index ad9861fa1c1a799c4bf3eca9bd5fced5000dd7c6..64f27ba28e0e59421eef7f3b9736a198c6c3e43b 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/decrement/dec_func_val.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/decrement/dec_func_val.params.yaml @@ -23,12 +23,12 @@ vals: # 2. - v1: c'"' - exp: "(c' ' + decPre(v1)) as char" + exp: "(c' ' + decPre(v1)).toChar()" res: c'A' # 3. - v1: c'\u0020' - exp: "(c' ' + decPost(v1)) as char" + exp: "(c' ' + decPost(v1)).toChar()" res: c'?' # 4. @@ -43,32 +43,32 @@ vals: # 6. Widening to int happens - v1: c'\u00FF' - exp: "decPre((c'!' + v1 + v1) as char)" + exp: "decPre((c'!' + v1 + v1).toChar())" res: c'\u021E' # 7. Widening to int happens - v1: c'\u0001' - exp: "decPost((v1 - c'!' - v1) as char)" + exp: "decPost((v1 - c'!' - v1).toChar())" res: c'\uFFDE' # 8. Widening to int happens - v1: c'\u0F0F' - exp: "(decPre((v1 - c'1') as char) - decPre(c'\\uACD9')) as char" + exp: "(decPre((v1 - c'1').toChar()) - decPre(c'\\uACD9')).toChar()" res: c'\u6205' # 9. Widening to int happens - v1: c'\u0F0F' - exp: "(decPost((v1 + c'1') as char) + decPost(c'\\uACD9')) as char" + exp: "(decPost((v1 + c'1').toChar()) + decPost(c'\\uACD9')).toChar()" res: c'\uBC17' # 10. - v1: c'\u1110' - exp: "(decPre(c'\\u0000') - decPre(v1)) as char" + exp: "(decPre(c'\\u0000') - decPre(v1)).toChar()" res: c'\uEEF0' # 11. - v1: c'\u1000' - exp: "(decPost(c'\\u0000') - decPost(v1)) as char" + exp: "(decPost(c'\\u0000') - decPost(v1)).toChar()" res: c'\uF000' # 12. diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/increment/inc_func_ref.ets b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/increment/inc_func_ref.ets index d0f6d4471278acb996c2538cbc9a8c2f27d00d86..b072b58f8f73365c4b8e90a38291f2352e3b1d8d 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/increment/inc_func_ref.ets +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/increment/inc_func_ref.ets @@ -20,12 +20,12 @@ desc: >- ---*/ function incPre(p: Char): Char { - return ++p + return (++p).toChar() } function incPost(p: Char): Char { p++ - return p + return (p).toChar() } function main() { diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/increment/inc_func_ref.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/increment/inc_func_ref.params.yaml index 0381261b2dc55b3b61276ba71d7301f3180ba694..34926bf8d0b151acdfd95c1b3d0ed27854dd6ba6 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/increment/inc_func_ref.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/increment/inc_func_ref.params.yaml @@ -21,11 +21,11 @@ vals: res: c'!' - v1: c'\u0020' - exp: "(c' ' + incPre(v1)) as Char" + exp: "(c' ' + incPre(v1)).toChar()" res: c'A' - v1: c'\u0020' - exp: "(c' ' + incPost(v1)) as Char" + exp: "(c' ' + incPost(v1)).toChar()" res: c'A' - v1: c'\uFFFF' @@ -37,27 +37,27 @@ vals: res: c'\x00' - v1: c'\uFFFF' - exp: "incPre((c'!' + v1 + v1) as Char)" + exp: "incPre((c'!' + v1 + v1).toChar())" res: c'\u0020' - v1: c'\uFFFF' - exp: "incPost((c'!' + v1 + v1) as Char)" + exp: "incPost((c'!' + v1 + v1).toChar())" res: c'\u0020' - v1: c'\u0F0F' - exp: "(incPre((v1 + c'1') as Char) + incPre(c'\\uACD9')) as Char" + exp: "(incPre((v1 + c'1').toChar()) + incPre(c'\\uACD9')).toChar()" res: c'\uBC1B' - v1: c'\u0F0F' - exp: "(incPost((v1 + c'1') as Char) + incPost(c'\\uACD9')) as Char" + exp: "(incPost((v1 + c'1').toChar()) + incPost(c'\\uACD9')).toChar()" res: c'\uBC1B' - v1: c'\u007F' - exp: "(incPre(c'\\u0000') + incPre(v1)) as Char" + exp: "(incPre(c'\\u0000') + incPre(v1)).toChar()" res: c'\u0081' - v1: c'\u007F' - exp: "(incPost(c'\\u0000') + incPost(v1)) as Char" + exp: "(incPost(c'\\u0000') + incPost(v1)).toChar()" res: c'\u0081' - v1: c'∫' diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/increment/inc_func_val.ets b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/increment/inc_func_val.ets index 5c62e9609216bee927542d8fd5796a6457665537..4fe69dd1c4f26300f3e24f0872cfcf38ff24e1ec 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/increment/inc_func_val.ets +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/increment/inc_func_val.ets @@ -20,12 +20,12 @@ desc: >- ---*/ function incPre(p: char): char { - return ++p + return (++p).toChar() } function incPost(p: char): char { p++ - return p + return p.toChar() } function main() { diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/increment/inc_func_val.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/increment/inc_func_val.params.yaml index 33c5fcd8ebef14c43dd5638f5a320b928f1f89be..0d13a5bccbac49647e655a26fc29fb907db0a1e6 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/increment/inc_func_val.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/increment/inc_func_val.params.yaml @@ -24,12 +24,12 @@ vals: # 2. - v1: c'\u0020' - exp: "(c' ' + incPre(v1)) as char" + exp: "(c' ' + incPre(v1)).toChar()" res: c'A' # 3. - v1: c'\u0020' - exp: "(c' ' + incPost(v1)) as char" + exp: "(c' ' + incPost(v1)).toChar()" res: c'A' # 4. @@ -44,30 +44,30 @@ vals: # 6. Widening to int happens - v1: c'\uFFFF' - exp: "incPre((c'!' + v1 + v1) as char)" + exp: "incPre((c'!' + v1 + v1).toChar())" res: c'\u0020' # 7. Widening to int happens - v1: c'\uFFFF' - exp: "incPost((c'!' + v1 + v1) as char)" + exp: "incPost((c'!' + v1 + v1).toChar())" res: c'\u0020' # 8. Widening to int happens - v1: c'\u0F0F' - exp: "(incPre((v1 + c'1') as char) + incPre(c'\\uACD9')) as char" + exp: "(incPre((v1 + c'1').toChar()) + incPre(c'\\uACD9')).toChar()" res: c'\uBC1B' # 9. Widening to int happens - v1: c'\u0F0F' - exp: "(incPost((v1 + c'1') as char) + incPost(c'\\uACD9')) as char" + exp: "(incPost((v1 + c'1').toChar()) + incPost(c'\\uACD9')).toChar()" res: c'\uBC1B' - v1: c'\u007F' - exp: "(incPre(c'\\u0000') + incPre(v1)) as char" + exp: "(incPre(c'\\u0000') + incPre(v1)).toChar()" res: c'\u0081' - v1: c'\u007F' - exp: "(incPost(c'\\u0000') + incPost(v1)) as char" + exp: "(incPost(c'\\u0000') + incPost(v1)).toChar()" res: c'\u0081' - v1: c'∫' diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/subtraction/sub_arr_ref.ets b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/subtraction/sub_arr_ref.ets index 33675a727af11ae4392122c7f09d1402684d6aec..2811f8a8cb177cb6ab41e678944ad8d088b22fdc 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/subtraction/sub_arr_ref.ets +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/subtraction/sub_arr_ref.ets @@ -25,7 +25,7 @@ function main() { const v1 = new Char({{v.v1}}) const v2 = new Char({{v.v2}}) - a[0] = ({{v.exp}}) as Char + a[0] = ({{v.exp}}).toChar() assertEQ( a[0], {{v.r}} ) } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/subtraction/sub_func_ref.ets b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/subtraction/sub_func_ref.ets index 5764ddc61c6a65cfd68b45c2bbce02068c355c97..8d49f1484a0a4116f3c87d660a858dd67a3943ce 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/subtraction/sub_func_ref.ets +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/subtraction/sub_func_ref.ets @@ -20,7 +20,7 @@ desc: >- ---*/ function sub(p: Char, q: Char): Char { - return (p - q) as Char + return (p - q).toChar() } function main() { diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/subtraction/sub_func_ref.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/subtraction/sub_func_ref.params.yaml index 45485a194874db06c5f3d2f88a891137db561e32..51fee54e9943bb5036695397b7baa96b759fa285 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/subtraction/sub_func_ref.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/subtraction/sub_func_ref.params.yaml @@ -19,7 +19,7 @@ vals: - v1: c'\u0041' v2: c'\u0001' - exp: "(sub(v1, v2) - c' ') as Char" + exp: "(sub(v1, v2) - c' ').toChar()" r: c' ' - v1: c'\uFFFF' @@ -39,7 +39,7 @@ vals: - v1: c'\u1010' v2: c'\u0101' - exp: "sub((v1 - c'\\u0101') as Char, (v2 - c'\\u1010') as Char)" + exp: "sub((v1 - c'\\u0101').toChar(), (v2 - c'\\u1010').toChar())" r: c'\u1E1E' - v1: c'∬' diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/subtraction/sub_func_val.ets b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/subtraction/sub_func_val.ets index 0caad2c3282c9d0a9ff1bd8c746b53474ab25e03..6efcea636100749e60e038dd164e0f8c4210cba3 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/subtraction/sub_func_val.ets +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/subtraction/sub_func_val.ets @@ -20,7 +20,7 @@ desc: >- ---*/ function sub(p: char, q: char): char { - return (p - q) as char + return (p - q).toChar() } function main() { diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/subtraction/sub_func_val.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/subtraction/sub_func_val.params.yaml index 70db1c45c27e37158a748ca41971469a76126da7..f3f3c78e5736d6ab19e6222beabcbe30088acdb6 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/subtraction/sub_func_val.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/subtraction/sub_func_val.params.yaml @@ -21,7 +21,7 @@ vals: # 1. - v1: c'\u0041' v2: c'\u0001' - exp: "(sub(v1, v2) - c' ') as char" + exp: "(sub(v1, v2) - c' ').toChar()" r: c' ' # 2. @@ -45,7 +45,7 @@ vals: # 5. Widening to int happens - v1: c'\u1010' v2: c'\u0101' - exp: "sub((v1 - c'\\u0101') as char, (v2 - c'\\u1010') as char)" + exp: "sub((v1 - c'\\u0101').toChar(), (v2 - c'\\u1010').toChar())" r: c'\u1E1E' # 6. diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/unary/unary_ref.ets b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/unary/unary_ref.ets index 4c55b30b2083a1e850dfe2cd3548e3428629dc48..cfb761010ece7470088344f97784af2a64c6adae 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/unary/unary_ref.ets +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/unary/unary_ref.ets @@ -21,12 +21,12 @@ desc: >- function minus(p: Char): Char { // Widening to int happens - return -p as Char + return (-p).toChar() } function plus(p: Char): Char { // Widening to int happens - return +p as Char + return (+p).toChar() } function main() { diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/unary/unary_ref.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/unary/unary_ref.params.yaml index c80222d0f1bf9824b6b63b280048676c00494fca..88e68ec0bd546aaf7606630d5d2b701b45a5273f 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/unary/unary_ref.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/unary/unary_ref.params.yaml @@ -13,7 +13,7 @@ --- vals: - v1: c'\u0020' - exp: '(minus(plus(v1)) - plus(minus(v1))) as char' + exp: '(minus(plus(v1)) - plus(minus(v1))).toChar()' r: c'\u0000' - v1: c'∬' diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/unary/unary_val.ets b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/unary/unary_val.ets index dea172224c6f3fd0a6414f0ff67469e5df0a308b..2ac0b0a94cc876bdca71b719e609ddd3f40a00e9 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/unary/unary_val.ets +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/unary/unary_val.ets @@ -21,12 +21,12 @@ desc: >- function minus(p: char): char { // Widening to int happens - return -p as Char + return (-p).toChar() } function plus(p: char): char { // Widening to int happens - return +p as Char + return (+p).toChar() } function main() { diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/unary/unary_val.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/unary/unary_val.params.yaml index c80222d0f1bf9824b6b63b280048676c00494fca..88e68ec0bd546aaf7606630d5d2b701b45a5273f 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/unary/unary_val.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/01.character_type_and_literals/02.character_types_and_operations/unary/unary_val.params.yaml @@ -13,7 +13,7 @@ --- vals: - v1: c'\u0020' - exp: '(minus(plus(v1)) - plus(minus(v1))) as char' + exp: '(minus(plus(v1)) - plus(minus(v1))).toChar()' r: c'\u0000' - v1: c'∬' diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/02.fixed_array_types/fixed_array.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/02.fixed_array_types/fixed_array.params.yaml index bf63cd7aaa5f2f4d0e03c6b0f8767719c298e083..cc47c237deda6c0576b0ba8b55e8a9d61dd09f85 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/02.fixed_array_types/fixed_array.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/02.fixed_array_types/fixed_array.params.yaml @@ -18,7 +18,7 @@ cases: - use: |- let a : FixedArray = ["a", "b", "c"] - use: |- - let a : FixedArray = ["a"] + let a : FixedArray = [c'a'] - use: |- let a : FixedArray = [4] - use: |- diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/03.array_creation_expressions/expr.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/03.array_creation_expressions/expr.params.yaml index 73997c21c4ec52c000e6f0601bed848b60197695..13a58ce1fa506f715d6b146b07695900be4f083d 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/03.array_creation_expressions/expr.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/03.array_creation_expressions/expr.params.yaml @@ -42,7 +42,7 @@ cases: assertTrue( v[0] instanceof Byte && v[0] == 42 ) - use: |- - let size: float = 1.0 // narrowing dimension conversion + let size: float = 1.0f // narrowing dimension conversion let v: Byte[] = new Byte[size] v[0] = new Byte(42 as byte) @@ -93,8 +93,8 @@ cases: assertEQ( v[size1 - 1][size2 - 1][size3 - 1], "abc" ) - use: |- - let size: char = c'A' // widening conversion - let v: char[] = new char[size] + let size: Char = c'A' // widening conversion + let v: Char[] = new Char[size.toInt()] v[0] = c'X' assertEQ( v[0], c'X' ) diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/01.function_overloading/fn_overloading.ets b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/01.function_overloading/fn_overloading.ets index c82c0bd63df8bf305dff7bb361af0c3f7f7d2eba..f9da9f4253f7d2655c76eaf3f252594d362609a3 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/01.function_overloading/fn_overloading.ets +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/01.function_overloading/fn_overloading.ets @@ -47,41 +47,14 @@ function foo(a: double): int { function foo(a: boolean): int { return 8; } -function foo(a: Byte): int { - return 21; +function foo(a: bigint): int { + return 9; } -function foo(a: Short): int { - return 22; -} -function foo(a: Char): int { - return 23; -} -function foo(a: Int): int { - return 24; -} -function foo(a: Long): int { - return 25; -} -function foo(a: Float): int { - return 26; -} -function foo(a: Double): int { - return 27; -} -function foo(a: Boolean): int { - return 28; -} -function foo(a: Integral): int { - return 29; -} -function foo(a: Floating): int { - return 30; -} -function foo(a: String): int { - return 31; +function foo(a: string): int { + return 10; } function foo(a: Object): int { - return 32; + return 11; } function foo(a: FixedArray): int { return 101; @@ -107,46 +80,12 @@ function foo(a: FixedArray): int { function foo(a: FixedArray): int { return 108; } -function foo(a: FixedArray): int { - return 121; -} -function foo(a: FixedArray): int { - return 122; -} -function foo(a: FixedArray): int { - return 123; -} -function foo(a: FixedArray): int { - return 124; -} -function foo(a: FixedArray): int { - return 125; -} -function foo(a: FixedArray): int { - return 126; -} -function foo(a: FixedArray): int { - return 127; -} -function foo(a: FixedArray): int { - return 128; -} -function foo(a: FixedArray): int { - return 129; -} -function foo(a: FixedArray): int { - return 130; -} -function foo(a: FixedArray): int { - return 131; -} function foo(a: FixedArray): int { - return 132; + return 109; } -function main(): int { +function main(): void { let v: {{c.type}} = {{c.val}}; - if (foo(v) == {{c.res}}) return 0; - return 1; + assertEQ(foo(v), {{c.res}}) } -{% endfor %} +{% endfor %} \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/01.function_overloading/fn_overloading.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/01.function_overloading/fn_overloading.params.yaml index 2ebd8c5dc1f9820d759955a728a84f98febf81fe..a03806940c3d58444d91b8cf5159e596410d45fd 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/01.function_overloading/fn_overloading.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/01.function_overloading/fn_overloading.params.yaml @@ -21,35 +21,35 @@ cases: - { type: float, val: (-1.0) as float, res: 6 } - { type: double, val: -1.0, res: 7 } - { type: boolean, val: 'false', res: 8 } - - { type: Byte, val: new Byte(), res: 21 } - - { type: Short, val: new Short(), res: 22 } - - { type: Char, val: new Char(), res: 23 } - - { type: Int, val: new Int(), res: 24 } - - { type: Long, val: new Long(), res: 25 } - - { type: Float, val: new Float(), res: 26 } - - { type: Double, val: new Double(), res: 27 } - - { type: Boolean, val: new Boolean(), res: 28 } - - { type: Integral, val: new Short(), res: 22 } - - { type: Floating, val: new Float(), res: 26 } - - { type: String, val: '""', res: 31 } - - { type: Object, val: '""', res: 31 } + - { type: bigint, val: -1n, res: 9 } + - { type: Byte, val: (-1) as byte, res: 1 } + - { type: Short, val: (-1) as short, res: 2 } + - { type: Char, val: "c' '", res: 3 } + - { type: Int, val: -1, res: 4 } + - { type: Long, val: -1 as long, res: 5 } + - { type: Float, val: (-1.0) as float, res: 6 } + - { type: Double, val: -1.0, res: 7 } + - { type: Boolean, val: 'false', res: 8 } + - { type: BigInt, val: new BigInt(-1), res: 9 } + - { type: string, val: '""', res: 10 } + - { type: Object, val: '""', res: 11 } - { type: 'FixedArray', val: '[0 as byte]', res: 101 } - { type: 'FixedArray', val: '[0 as short]', res: 102 } - { type: 'FixedArray', val: '[]', res: 103 } - { type: 'FixedArray', val: '[1, 2, 3, 4, 5, 6, 7, 8, 9, 0]', res: 104 } - { type: 'FixedArray', val: '[1 as long, 2 as long, 3 as long]', res: 105} - - { type: 'FixedArray', val: '[1.0 as float, 2.0 as float, 3.0 as float]', res: 106 } + - { type: 'FixedArray', val: '[1.0f as float, 2.0f as float, 3.0f as float]', res: 106 } - { type: 'FixedArray', val: '[true, true, false]', res: 108 } - - { type: 'FixedArray', val: '[new Byte()]', res: 121 } - - { type: 'FixedArray', val: 'new Char[1]', res: 123 } - - { type: 'FixedArray', val: 'new Int[200]', res: 124 } - - { type: 'FixedArray>>', val: 'new String[1][1][1]', res: 132 } + - { type: 'FixedArray', val: '[new Byte()]', res: 101 } + - { type: 'FixedArray', val: "new Char[1]", res: 103 } + - { type: 'FixedArray', val: 'new Int[200]', res: 104 } + - { type: 'FixedArray', val: 'new Short[200]', res: 102 } + - { type: 'FixedArray>>', val: 'new String[1][1][1]', res: 109 } - { type: 'FixedArray', val: '[new Boolean(), new Boolean(), new Boolean()]', - res: 128, + res: 108 } - - { type: 'FixedArray', val: '[]', res: 130 } - - { type: 'FixedArray', val: '[new Int(1), new Boolean()]', res: 132 } - - { type: StringBuilder, val: new StringBuilder(), res: 32 } - - { type: 'Comparable[]', val: '[new Int(0)]', res: 32 } + - { type: 'FixedArray', val: '[new Int(1), new Boolean()]', res: 109 } + - { type: StringBuilder, val: new StringBuilder(), res: 11 } + - { type: 'Comparable[]', val: '[new Int(0)]', res: 32 } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/02.class_method_overloading/cm_over1.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/02.class_method_overloading/cm_over1.params.yaml index 787f15839d635bca1bcde8dfdfdd17c3cd101ad8..7a2606a157628ce56e7b0648ace7f10cfc664392 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/02.class_method_overloading/cm_over1.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/02.class_method_overloading/cm_over1.params.yaml @@ -46,32 +46,24 @@ cases: class A { meth(p: Object): string { return "Object" } // should never be called meth(p: byte): string { return "byte" } - meth(p: Byte): string { return "Byte" } - meth(p: short): string { return "short" } - meth(p: Short): string { return "Short" } + meth(p: Short): string { return "short" } meth(p: int): string { return "int" } - meth(p: Int): string { return "Int" } - meth(p: long): string { return "long" } - meth(p: Long): string { return "Long" } + meth(p: Long): string { return "long" } meth(p: char): string { return "char" } - meth(p: Char): string { return "Char" } - meth(p: boolean): string { return "boolean" } - meth(p: Boolean): string { return "Boolean" } + meth(p: Boolean): string { return "boolean" } meth(p: float): string { return "float" } - meth(p: Float): string { return "Float" } - meth(p: double): string { return "double" } - meth(p: Double): string { return "Double" } + meth(p: Double): string { return "double" } } use: |- let a: A = new A() - assertEQ( a.meth(new Byte(-1 as byte)), "Byte" ) - assertEQ( a.meth(new Short(-1 as short)), "Short" ) - assertEQ( a.meth(new Int(-1 as int)), "Int" ) - assertEQ( a.meth(new Long(-1 as long)), "Long" ) - assertEQ( a.meth(new Char(c'A')), "Char" ) - assertEQ( a.meth(new Boolean(false)), "Boolean" ) - assertEQ( a.meth(new Float(3.14 as float)), "Float" ) - assertEQ( a.meth(new Double(3.14)), "Double" ) + assertEQ( a.meth(new Byte(-1 as byte)), "byte" ) + assertEQ( a.meth(new Short(-1 as short)), "short" ) + assertEQ( a.meth(new Int(-1 as int)), "int" ) + assertEQ( a.meth(new Long(-1 as long)), "long" ) + assertEQ( a.meth(new Char(c'A')), "char" ) + assertEQ( a.meth(new Boolean(false)), "boolean" ) + assertEQ( a.meth(new Float(3.14 as float)), "float" ) + assertEQ( a.meth(new Double(3.14)), "double" ) assertEQ( a.meth(-1 as long), "long" ) assertEQ( a.meth(-1 as int), "int" ) assertEQ( a.meth(-1 as short), "short" ) @@ -85,47 +77,36 @@ cases: // primitives and boxed, with sub/superclass abstract class B { meth(p: Object): string { return "" } // should never be called - meth(p: byte): string { return "" } - meth(p: Byte): string { return "Byte" } - meth(p: short): string { return "" } - meth(p: Short): string { return "Short" } - meth(p: int): string { return "" } - meth(p: Int): string { return "" } - meth(p: long): string { return "" } - meth(p: Long): string { return "" } - meth(p: char): string { return "" } - meth(p: Char): string { return "Char" } + meth(p: byte): string { return "byte" } + meth(p: short): string { return "short" } + meth(p: int): string { return "int" } + meth(p: long): string { return "long" } + meth(p: char): string { return "char" } meth(p: boolean): string { return "boolean" } - meth(p: Boolean): string { return "" } meth(p: float): string { return "float" } - meth(p: Float): string { return "" } - meth(p: double): string { return "" } - abstract meth(p: Double): string + meth(p: double): string { return "double" } } class A extends B { meth(p: Object): string { return "" } // should never be called meth(p: byte): string { return "byte" } meth(p: short): string { return "short" } meth(p: int): string { return "int" } - meth(p: Int): string { return "Int" } meth(p: long): string { return "long" } - meth(p: Long): string { return "Long" } meth(p: char): string { return "char" } - meth(p: Boolean): string { return "Boolean" } - meth(p: Float): string { return "Float" } - meth(p: double): string { return "double" } - meth(p: Double): string { return "Double" } + meth(p: Boolean): string { return "boolean" } + meth(p: Float): string { return "float" } + meth(p: Double): string { return "double" } } use: |- let a: A = new A() - assertEQ( a.meth(new Byte(-1 as byte)), "Byte" ) - assertEQ( a.meth(new Short(-1 as short)), "Short" ) - assertEQ( a.meth(new Int(-1 as int)), "Int" ) - assertEQ( a.meth(new Long(-1 as long)), "Long" ) - assertEQ( a.meth(new Char(c'A')), "Char" ) - assertEQ( a.meth(new Boolean(false)), "Boolean" ) - assertEQ( a.meth(new Float(3.14 as float)), "Float" ) - assertEQ( a.meth(new Double(3.14)), "Double" ) + assertEQ( a.meth(new Byte(-1 as byte)), "byte" ) + assertEQ( a.meth(new Short(-1 as short)), "short" ) + assertEQ( a.meth(new Int(-1 as int)), "int" ) + assertEQ( a.meth(new Long(-1 as long)), "long" ) + assertEQ( a.meth(new Char(c'A')), "char" ) + assertEQ( a.meth(new Boolean(false)), "boolean" ) + assertEQ( a.meth(new Float(3.14 as float)), "float" ) + assertEQ( a.meth(new Double(3.14)), "double" ) assertEQ( a.meth(-1 as long), "long" ) assertEQ( a.meth(-1 as int), "int" ) assertEQ( a.meth(-1 as short), "short" ) @@ -217,14 +198,14 @@ cases: assertEQ( a.meth([false]), "boolean" ) assertEQ( a.meth([3.14 as float]), "float" ) assertEQ( a.meth([3.14]), "double" ) - assertEQ( a.meth([new Byte(-1 as byte)]), "Byte" ) - assertEQ( a.meth([new Short(-1 as short)]), "Short" ) - assertEQ( a.meth([new Int(-1)]), "Int" ) - assertEQ( a.meth([new Long(-1 as long)]), "Long" ) - assertEQ( a.meth([new Char(c'A')]), "Char" ) - assertEQ( a.meth([new Boolean(false)]), "Boolean" ) - assertEQ( a.meth([new Float(3.14 as float)]), "Float" ) - assertEQ( a.meth([new Double(3.14)]), "Double" ) + assertEQ( a.meth([new Byte(-1 as byte)]), "byte" ) + assertEQ( a.meth([new Short(-1 as short)]), "short" ) + assertEQ( a.meth([new Int(-1)]), "int" ) + assertEQ( a.meth([new Long(-1 as long)]), "long" ) + assertEQ( a.meth([new Char(c'A')]), "char" ) + assertEQ( a.meth([new Boolean(false)]), "boolean" ) + assertEQ( a.meth([new Float(3.14 as float)]), "float" ) + assertEQ( a.meth([new Double(3.14)]), "double" ) assertEQ( a.meth([new Object()]), "Object" ) assertEQ( a.meth([Color.Red]), "Color" ) assertEQ( a.meth([Size.M]), "Size" ) @@ -284,14 +265,14 @@ cases: assertEQ( a.meth([false]), "boolean" ) assertEQ( a.meth([3.14 as float]), "float" ) assertEQ( a.meth([3.14]), "double" ) - assertEQ( a.meth([new Byte(-1 as byte)]), "Byte" ) - assertEQ( a.meth([new Short(-1 as short)]), "Short" ) - assertEQ( a.meth([new Int(-1)]), "Int" ) - assertEQ( a.meth([new Long(-1 as long)]), "Long" ) - assertEQ( a.meth([new Char(c'A')]), "Char" ) - assertEQ( a.meth([new Boolean(false)]), "Boolean" ) - assertEQ( a.meth([new Float(3.14 as float)]), "Float" ) - assertEQ( a.meth([new Double(3.14)]), "Double" ) + assertEQ( a.meth([new Byte(-1 as byte)]), "byte" ) + assertEQ( a.meth([new Short(-1 as short)]), "short" ) + assertEQ( a.meth([new Int(-1)]), "int" ) + assertEQ( a.meth([new Long(-1 as long)]), "long" ) + assertEQ( a.meth([new Char(c'A')]), "char" ) + assertEQ( a.meth([new Boolean(false)]), "boolean" ) + assertEQ( a.meth([new Float(3.14 as float)]), "float" ) + assertEQ( a.meth([new Double(3.14)]), "double" ) assertEQ( a.meth([new Object()]), "Object" ) assertEQ( a.meth([Color.Red]), "Color" ) assertEQ( a.meth([Size.M]), "Size" ) diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/02.class_method_overloading/cm_over2.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/02.class_method_overloading/cm_over2.params.yaml index d8cb3b622aa2bdb4a1fd807a4dd97c755cff9f8f..f29980ec0181f147d2547e6553b19d7cee796272 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/02.class_method_overloading/cm_over2.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/02.class_method_overloading/cm_over2.params.yaml @@ -58,7 +58,7 @@ cases: assertEQ( a.meth(new Byte(-1 as byte)), Byte.MAX_VALUE ) assertEQ( a.meth(new Int(-1 as int)), Int.MAX_VALUE ) assertEQ( a.meth(new Char(c'A')), Char.MAX_VALUE ) - assertEQ( a.meth(new Float(3.14 as float)), Float.MAX_VALUE ) + assertEQ( a.meth(new Float(3.14f)), Float.MAX_VALUE ) assertEQ( a.meth(-1 as long), Long.MIN_VALUE ) assertEQ( a.meth(-1 as short), Short.MIN_VALUE ) assertEQ( a.meth(false), false ) diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/02.class_method_overloading/cm_over3.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/02.class_method_overloading/cm_over3.params.yaml index a833e50147c0c6377d44a5ae8de1f2893b2d74aa..bd473b3ea1cf63d46d316cf03bb147075d41c31d 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/02.class_method_overloading/cm_over3.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/02.class_method_overloading/cm_over3.params.yaml @@ -56,17 +56,14 @@ cases: // method overloaded with boxing/unboxing parameters class A { m(a: boolean): number { return 1.0 } - m(a: Boolean): number { return 2.0 } - m(a: boolean, b: number): number { return 3.0 } - m(a: boolean, b: Number): number { return 4.0 } m(a: Boolean, b: Number): number { return 5.0 } } use: |- let a = new A() assertEQ( a.m(true), 1.0 ) - assertEQ( a.m(new Boolean()), 2.0 ) - assertEQ( a.m(true, 1.0), 3.0 ) - assertEQ( a.m(false, new Double()), 4.0 ) + assertEQ( a.m(new Boolean()), 1.0 ) + assertEQ( a.m(true, 1.0), 5.0 ) + assertEQ( a.m(false, new Double()), 5.0 ) assertEQ( a.m(new Boolean(), new Double()), 5.0 ) - decl: |- diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/03.constructor_overloading/co1_over.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/03.constructor_overloading/co1_over.params.yaml index 2c09f1f9d32d6f8413b144b7c9ad6861a4ae6de0..8fcff38f69152478222cfc34e8d9587f2a564df2 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/03.constructor_overloading/co1_over.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/03.constructor_overloading/co1_over.params.yaml @@ -67,31 +67,23 @@ cases: } constructor(p: Object) { this.t = "should never be called" } constructor(p: byte) { this.t = "byte" } - constructor(p: Byte) { this.t = "Byte" } constructor(p: short) { this.t = "short" } - constructor(p: Short) { this.t = "Short" } constructor(p: int) { this.t = "int" } - constructor(p: Int) { this.t = "Int" } constructor(p: long) { this.t = "long" } - constructor(p: Long) { this.t = "Long" } constructor(p: char) { this.t = "char" } - constructor(p: Char) { this.t = "Char" } constructor(p: boolean) { this.t = "boolean" } - constructor(p: Boolean) { this.t = "Boolean" } constructor(p: float) { this.t = "float" } - constructor(p: Float) { this.t = "Float" } constructor(p: double) { this.t = "double" } - constructor(p: Double) { this.t = "Double" } } use: |- - assertTrue(new A(new Byte(-1 as byte)).getType() == "Byte") - assertTrue(new A(new Short(-1 as short)).getType() == "Short") - assertTrue(new A(new Int(-1 as int)).getType() == "Int") - assertTrue(new A(new Long(-1 as long)).getType() == "Long") - assertTrue(new A(new Char(c'A')).getType() == "Char") - assertTrue(new A(new Boolean(false)).getType() == "Boolean") - assertTrue(new A(new Float(3.14 as float)).getType() == "Float") - assertTrue(new A(new Double(3.14)).getType() == "Double") + assertTrue(new A(new Byte(-1 as byte)).getType() == "byte") + assertTrue(new A(new Short(-1 as short)).getType() == "short") + assertTrue(new A(new Int(-1 as int)).getType() == "int") + assertTrue(new A(new Long(-1 as long)).getType() == "long") + assertTrue(new A(new Char(c'A')).getType() == "char") + assertTrue(new A(new Boolean(false)).getType() == "boolean") + assertTrue(new A(new Float(3.14 as float)).getType() == "float") + assertTrue(new A(new Double(3.14)).getType() == "double") assertTrue(new A(-1 as long).getType() == "long") assertTrue(new A(-1).getType() == "int") assertTrue(new A(-1 as short).getType() == "short") @@ -187,6 +179,7 @@ cases: assertTrue(new A("abc").getType() == "string") assertTrue(new A(Size.L).getType() == "Size") + # co1_over_8 - decl: |- // arrays enum Color { Red, Green = 82, Blue } @@ -228,14 +221,14 @@ cases: assertTrue(new A([false]).getType() == "boolean") assertTrue(new A([3.14 as float]).getType() == "float") assertTrue(new A([3.14]).getType() == "double") - assertTrue(new A([new Byte(-1 as byte)]).getType() == "Byte") - assertTrue(new A([new Short(-1 as short)]).getType() == "Short") - assertTrue(new A([new Int(-1)]).getType() == "Int") - assertTrue(new A([new Long(-1 as long)]).getType() == "Long") - assertTrue(new A([new Char(c'A')]).getType() == "Char") - assertTrue(new A([new Boolean(false)]).getType() == "Boolean") - assertTrue(new A([new Float(3.14 as float)]).getType() == "Float") - assertTrue(new A([new Double(3.14)]).getType() == "Double") + assertTrue(new A([new Byte(-1 as byte)]).getType() == "byte") + assertTrue(new A([new Short(-1 as short)]).getType() == "short") + assertTrue(new A([new Int(-1)]).getType() == "int") + assertTrue(new A([new Long(-1 as long)]).getType() == "long") + assertTrue(new A([new Char(c'A')]).getType() == "char") + assertTrue(new A([new Boolean(false)]).getType() == "boolean") + assertTrue(new A([new Float(3.14 as float)]).getType() == "float") + assertTrue(new A([new Double(3.14)]).getType() == "double") assertTrue(new A([new Object()]).getType() == "Object") assertTrue(new A([Color.Red]).getType() == "Color") assertTrue(new A([Size.M]).getType() == "Size") diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/03.constructor_overloading/co2_over.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/03.constructor_overloading/co2_over.params.yaml index eacbbf14491a78fcd493ba17daad83351189e0f4..0d146b48ce0d4094a846bbe8702137a53eb822d6 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/03.constructor_overloading/co2_over.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/03.constructor_overloading/co2_over.params.yaml @@ -86,7 +86,7 @@ cases: assertTrue(new A(new Byte(-1 as byte)).getType() == "Byte") assertTrue(new A(new Int(-1 as int)).getType() == "Int") assertTrue(new A(new Char(c'A')).getType() == "Char") - assertTrue(new A(new Float(3.14 as float)).getType() == "Float") + assertTrue(new A(new Float(3.14f)).getType() == "Float") assertTrue(new A(-1 as long).getType() == "long") assertTrue(new A(-1 as short).getType() == "short") assertTrue(new A(false).getType() == "boolean") diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/03.constructor_overloading/co3_over.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/03.constructor_overloading/co3_over.params.yaml index 01491ebf4e791223bc766fd7bbbb30d5b34066dd..6e0f7b18a869530272c447f2929520f767300a76 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/03.constructor_overloading/co3_over.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/08.function_method_and_constructor_overloading/03.constructor_overloading/co3_over.params.yaml @@ -88,20 +88,17 @@ cases: class A { fld: number constructor(a: boolean) { this.fld = 1.0 } - constructor(a: Boolean) { this.fld = 2.0 } - constructor(a: boolean, b: number) { this.fld = 3.0 } - constructor(a: boolean, b: Number) { this.fld = 4.0 } constructor(a: Boolean, b: Number) { this.fld = 5.0 } } use: |- let a = new A(true) - assertEQ(a.fld, 1.0) + assertEQ(a.fld, 1.0) a = new A(new Boolean()) - assertEQ(a.fld, 2.0) + assertTrue(a.fld == 1.0) a = new A(true, 1.0) - assertEQ(a.fld, 3.0) + assertTrue(a.fld == 5.0) a = new A(false, new Double()) - assertEQ(a.fld, 4.0) + assertTrue(a.fld == 5.0) a = new A(new Boolean(), new Double()) assertEQ(a.fld, 5.0) diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/12.adding_functionality_to_existing_types/02.receiver_types/functions_with_receiver.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/12.adding_functionality_to_existing_types/02.receiver_types/functions_with_receiver.params.yaml index 0ae4f7cde916cc39aca99472bb80443e642bbe1b..a6bdb4637a2c80d72cffbf3a0d139c0660ee7e5c 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/12.adding_functionality_to_existing_types/02.receiver_types/functions_with_receiver.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/12.adding_functionality_to_existing_types/02.receiver_types/functions_with_receiver.params.yaml @@ -57,3 +57,8 @@ cases: use: | let i: I = {} i.f() + - decl: | + function f(this: number) {} + use: | + let n: number = 1 + f(n) diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/16.async_functions_and_methods/01.async_functions/afunc.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/16.async_functions_and_methods/01.async_functions/afunc.params.yaml index a78b0e9d2bd8e314babdda11199cf54d4dae2ad7..24dc13b9657e43f7df2d2aab257eb9d81994149c 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/16.async_functions_and_methods/01.async_functions/afunc.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/16.async_functions_and_methods/01.async_functions/afunc.params.yaml @@ -493,58 +493,3 @@ cases: .then((p: string): string => p + p) assertTrue((await r) == 'AAAAAAAA') - - - decl: |- - type EN = Error|null - let s = 'A' - async function foo(p: string): Promise { - if (p == 'A') { - throw new Error('E') - } - return 'X' - } - use: |- - // Catch error in chained catch - let r = foo(s) - .then((p: string): string => p + p) // skipped - .catch((p: EN): string => p!.message) - .then((p: string): string => p + p) - - assertTrue((await r) == 'EE') - - - decl: |- - type EN = Error|null - let s = 'A' - async function foo(p: string): Promise { - return p + p - } - use: |- - // Throw error in chained then and catch in the following chained catch - let r: Promise = foo(s) - .then((p: string): string => { throw new Error(p) }) - .catch((p: EN): string => p!.message + p!.message) - - assertTrue((await r) == 'AAAA') - - - decl: |- - type EN = Error|null - let s = 'A' - async function foo(p: string): Promise { - if (p == 'A') { - throw new Error('E') - } - return 'X' - } - use: |- - // Throw error in chained catch - let r: Promise = foo(s) - .then((p: string): string => p + p) - .catch((p: EN): string => { throw p! }) - - try { - await r - } catch (e: Error) { - assertTrue(e.message == 'E') - return - } - assertTrue(false) diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/16.async_functions_and_methods/01.async_functions/afunc_n.ets b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/16.async_functions_and_methods/01.async_functions/afunc_n.ets index 11981b950fd2342e7299affd16ca9ac36f0dd057..ee97734857ce2f8c12fee3be6687ee1f61bf569f 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/16.async_functions_and_methods/01.async_functions/afunc_n.ets +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/16.async_functions_and_methods/01.async_functions/afunc_n.ets @@ -21,5 +21,7 @@ tags: [compile-only, negative] {{c.decl}} -function main() {} +function main() { +{{c.use}} +} {% endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/16.async_functions_and_methods/01.async_functions/afunc_n.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/16.async_functions_and_methods/01.async_functions/afunc_n.params.yaml index f9bf7eb59cdfddeef9410fa0113ed2e138627535..cbce1768f2bbd61526b2db88c0f3b911c2cc27d0 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/16.async_functions_and_methods/01.async_functions/afunc_n.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/16.async_functions_and_methods/01.async_functions/afunc_n.params.yaml @@ -65,3 +65,59 @@ cases: if (p == 1) return 1.0 return true } + + - decl: |- + type EN = Error|null + let s = 'A' + async function foo(p: string): Promise { + if (p == 'A') { + throw new Error('E') + } + return 'X' + } + use: |- + // Catch error in chained catch + let r = foo(s) + .then((p: string): string => p + p) // skipped + .catch((p: EN): string => p!.message) + .then((p: string): string => p + p) + + assertTrue((await r) == 'EE') + + - decl: |- + type EN = Error|null + let s = 'A' + async function foo(p: string): Promise { + return p + p + } + use: |- + // Throw error in chained then and catch in the following chained catch + let r: Promise = foo(s) + .then((p: string): string => { throw new Error(p) }) + .catch((p: EN): string => p!.message + p!.message) + + assertTrue((await r) == 'AAAA') + + - decl: |- + type EN = Error|null + let s = 'A' + async function foo(p: string): Promise { + if (p == 'A') { + throw new Error('E') + } + return 'X' + } + use: |- + // Throw error in chained catch + // await is forbidden for non-async functions + let r: Promise = foo(s) + .then((p: string): string => p + p) + .catch((p: EN): string => { throw p! }) + + try { + await r + } catch (e: Error) { + assertTrue(e.message == 'E') + return + } + assertTrue(false) diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/16.async_functions_and_methods/02.async_methods/ameth.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/16.async_functions_and_methods/02.async_methods/ameth.params.yaml index 9325c6ae1f9aebc89f76966cb0a79969371ef609..709fe3103150cf3bcebae840e73a3fad673da6ad 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/16.async_functions_and_methods/02.async_methods/ameth.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/16.async_functions_and_methods/02.async_methods/ameth.params.yaml @@ -579,64 +579,3 @@ cases: .then((p: string): string => p + p) assertTrue((await r) == 'AAAAAAAA') - - - decl: |- - type EN = Error|null - let s = 'A' - class A { - async foo(p: string): Promise { - if (p == 'A') { - throw new Error('E') - } - return 'X' - } - } - use: |- - // Catch error in chained catch - let r = new A().foo(s) - .then((p: string): string => p + p) // skipped - .catch((p: EN): string => p!.message) - .then((p: string): string => p + p) - - assertTrue((await r) == 'EE') - - - decl: |- - type EN = Error|null - let s = 'A' - class A { - async static foo(p: string): Promise { - return p + p - } - } - use: |- - // Throw error in chained then and catch in the following chained catch - let r: Promise = A.foo(s) - .then((p: string): string => { throw new Error(p) }) - .catch((p: EN): string => p!.message + p!.message) - - assertTrue((await r) == 'AAAA') - - - decl: |- - type EN = Error|null - let s = 'A' - class A { - async foo(p: string): Promise { - if (p == 'A') { - throw new Error('E') - } - return 'X' - } - } - use: |- - // Throw error in chained catch - let r = new A().foo(s) - .then((p: string): string => p + p) - .catch((p: EN): string => { throw p! }) - - try { - await r - } catch (e: Error) { - assertTrue(e.message == 'E') - return - } - assertTrue(false) diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/16.async_functions_and_methods/02.async_methods/ameth_n.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/16.async_functions_and_methods/02.async_methods/ameth_n.params.yaml index 47f5743888eca34a870d8389880417cb7bfecc21..9c8d89d120a61068d0e127f6ab136b31d2e88cfe 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/16.async_functions_and_methods/02.async_methods/ameth_n.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/16.async_functions_and_methods/02.async_methods/ameth_n.params.yaml @@ -101,3 +101,64 @@ cases: return true } } + + - decl: |- + type EN = Error|null + let s = 'A' + class A { + async foo(p: string): Promise { + if (p == 'A') { + throw new Error('E') + } + return 'X' + } + } + use: |- + // Catch error in chained catch + let r = new A().foo(s) + .then((p: string): string => p + p) // skipped + .catch((p: EN): string => p!.message) + .then((p: string): string => p + p) + + assertTrue((await r) == 'EE') + + - decl: |- + type EN = Error|null + let s = 'A' + class A { + async static foo(p: string): Promise { + return p + p + } + } + use: |- + // Throw error in chained then and catch in the following chained catch + let r: Promise = A.foo(s) + .then((p: string): string => { throw new Error(p) }) + .catch((p: EN): string => p!.message + p!.message) + + assertTrue((await r) == 'AAAA') + + - decl: |- + type EN = Error|null + let s = 'A' + class A { + async foo(p: string): Promise { + if (p == 'A') { + throw new Error('E') + } + return 'X' + } + } + use: |- + // Throw error in chained catch + // await is forbidden for non-async methods + let r = new A().foo(s) + .then((p: string): string => p + p) + .catch((p: EN): string => { throw p! }) + try { + await r + } catch (e: Error) { + assertTrue(e.message == 'E') + return + } + assertTrue(false) \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/02.package_initializer/p3/packageP3/init3_2.ets b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/02.package_initializer/p3/packageP3/init3_2.ets index 99dd1b3b50a4987fd5000dba8e655b2d18f700a7..a3185201136f9eb7cfb0e4d267910cc7758ee6d1 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/02.package_initializer/p3/packageP3/init3_2.ets +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/02.package_initializer/p3/packageP3/init3_2.ets @@ -23,7 +23,8 @@ tags: [compile-only] package p3 -export let pi: float; +export let pi: Float; static { - pi = 3.14159 + let pid: Double = 3.14159 + pi = pid.toFloat() } diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkg_a/pkg.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkg_a/pkg.params.yaml index b6adfeacedba093b2020d6e49e229d9c994820b0..3d28ef1411d63b5ee7881ae1e722a2b1e964b76f 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkg_a/pkg.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkg_a/pkg.params.yaml @@ -19,7 +19,7 @@ cases: - sig2: 'p1: Byte, p2: Short, p3: Int, p4: Long, p5: Float, p6: Double, p7: Boolean, p8: Char' # 2 - - sig2: 'p1: FixedArray, p2: Object, p3: FixedArray' + - sig2: 'p1: FixedArray, p2: Object, p3: FixedArray' # 3 - sig2: 'p1: FixedArray, p2: FixedArray' diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkg_b/pkg.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkg_b/pkg.params.yaml index f228751609f69aba5f44b5da26e73434aee460ac..c623c540463d95fb506b9a5c6c55893171582aad 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkg_b/pkg.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkg_b/pkg.params.yaml @@ -19,7 +19,7 @@ cases: - sig1: 'p1: Byte, p2: Short, p3: Int, p4: Long, p5: Float, p6: Double, p7: Boolean' # 2 - - sig1: 'p1: Object, p2: FixedArray, p3: FixedArray' + - sig1: 'p1: Object, p2: FixedArray, p3: FixedArray' # 3 - sig1: 'p1: A3[], p2: B3[]' diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_0.ets b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_0.ets index fd776c3c153442e4fc23d4dc9ab879a270f462b7..59af7d25dd20cb0dcc182d6607370d75e13fa34a 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_0.ets +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_0.ets @@ -28,9 +28,10 @@ function foo({{c.sig2}}): int { return 2 } -function main(): int { +function main(): void { let v1 = foo({{c.arg1}}) let v2 = foo({{c.arg2}}) - return v1 == 1 && v2 == 2 ? 0 : 1 + assertEQ(v1, 1) + assertEQ(v2, 2) } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_0.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_0.params.yaml index fefc5103234bc8980f4ab5048493103579be792d..32967dea29e486156ca5a0a427ba678c4a389cb0 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_0.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_0.params.yaml @@ -25,13 +25,13 @@ cases: arg2: "new Byte(127 as byte), new Short(-128 as short), new Int(), new Long(-1 as long), new Float(-0.001f), new Number(99.99), new Boolean(false), new Char(c'2')" # 2 - - sig1: 'p1: Object, p2: FixedArray, p3: FixedArray' - arg1: 'a2, a1, a2' - sig2: 'p1: FixedArray, p2: Object, p3: FixedArray' - arg2: 'a2, a1, a1' + - sig1: 'p1: Object, p2: FixedArray, p3: FixedArray' + arg1: 'a2, a2, a1' + sig2: 'p1: FixedArray, p2: Object, p3: FixedArray' + arg2: 'a1, a2, a2' decl: |- let a1: FixedArray = [1, 2, 3] - let a2: FixedArray = [new Int(), new Int(1)] + let a2: FixedArray = [c'a', c'b'] # 3 - sig1: 'p1: FixedArray, p2: FixedArray' diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_a.ets b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_a.ets index 90263b56984e6fe43768dd3106df381951024ae4..55c0d6662866537f7f475b094beddb8613e720b0 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_a.ets +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_a.ets @@ -28,9 +28,10 @@ function foo{{loop.index0}}({{c.sig1}}): int { return 1 } -function main(): int { +function main(): void { let v1 = foo{{loop.index0}}({{c.arg1}}) let v2 = foo{{loop.index0}}({{c.arg2}}) - return v1 == 1 && v2 == 2 ? 0 : 1 + assertEQ(v1, 1) + assertEQ(v2, 2) } {%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_a.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_a.params.yaml index 878fedc6fc1dc8f49887c20fc776ba8be170cda2..d6fde54bf66bb1a8bfe2771a777885fb068e69ec 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_a.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_a.params.yaml @@ -23,12 +23,12 @@ cases: arg2: "new Byte(127 as byte), new Short(-128 as short), new Int(), new Long(-1 as long), new Float(-0.001f), new Number(99.99), new Boolean(false), new Char(c'2')" # 2 - - sig1: 'p1: Object, p2: FixedArray, p3: FixedArray' - arg1: 'a2, a1, a2' - arg2: 'a2, a1, a1' + - sig1: 'p1: Object, p2: FixedArray, p3: FixedArray' + arg1: 'a2, a2, a1' + arg2: 'a1, a1, a1' decl: |- - let a1: FixedArray = [1, 2, 3] - let a2: FixedArray = [new Int(), new Int(1)] + let a1: FixedArray = [1, 2, 3] + let a2: FixedArray = [c'a', c'b'] # 3 - sig1: 'p1: FixedArray, p2: FixedArray' diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_a2.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_a2.params.yaml index a9365429ab0d86bbe8637c54cd82df750e02193d..32df62cb040a1da68633ee2de5295bc280602904 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_a2.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_a2.params.yaml @@ -23,11 +23,11 @@ cases: arg2: "new Byte(127 as byte), new Short(-128 as short), new Int(), new Long(-1 as long), new Float(-0.001f), new Number(99.99), new Boolean(false), new Char(c'2')" # 2 - - sig1: 'p1: Object, p2: FixedArray, p3: FixedArray' + - sig1: 'p1: Object, p2: FixedArray, p3: FixedArray' arg1: 'a2, a1, a2' arg2: 'a2, a1, a1' decl: |- - let a1: FixedArray = [1, 2, 3] + let a1: FixedArray = [1, 2, 3] let a2: FixedArray = [new Int(), new Int(1)] # 3 diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_a3.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_a3.params.yaml index a9365429ab0d86bbe8637c54cd82df750e02193d..32df62cb040a1da68633ee2de5295bc280602904 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_a3.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_a3.params.yaml @@ -23,11 +23,11 @@ cases: arg2: "new Byte(127 as byte), new Short(-128 as short), new Int(), new Long(-1 as long), new Float(-0.001f), new Number(99.99), new Boolean(false), new Char(c'2')" # 2 - - sig1: 'p1: Object, p2: FixedArray, p3: FixedArray' + - sig1: 'p1: Object, p2: FixedArray, p3: FixedArray' arg1: 'a2, a1, a2' arg2: 'a2, a1, a1' decl: |- - let a1: FixedArray = [1, 2, 3] + let a1: FixedArray = [1, 2, 3] let a2: FixedArray = [new Int(), new Int(1)] # 3 diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_ab.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_ab.params.yaml index 0f765f78f24b4c9fe126f27702a7d84f65325f54..e04938cc38c2f68bbe53f1c14f33e3fa99dd5f81 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_ab.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_ab.params.yaml @@ -21,11 +21,11 @@ cases: arg2: "new Byte(127 as byte), new Short(-128 as short), new Int(), new Long(-1 as long), new Float(-0.001f), new Number(99.99), new Boolean(false), new Char(c'2')" # 2 - - arg1: 'a2, a1, a2' - arg2: 'a2, a1, a1' + - arg1: 'a2, a1, a1' + arg2: 'a1, a2, a1' decl: |- - let a1: FixedArray = [1, 2, 3] - let a2: FixedArray = [new Int(), new Int(1)] + let a1: FixedArray = [1, 2, 3] + let a2: FixedArray = [c'a', c'b'] # 3 - arg1: '[new A3(), new A3()], [new B3(), new B3()]' diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_ab2.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_ab2.params.yaml index d241ca7b2eb3620849f681424b88f627bb35b990..fd5dc0ff2dba4960f3d7f4f85df31bb0e3504eb3 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_ab2.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_ab2.params.yaml @@ -24,7 +24,7 @@ cases: - arg1: 'a2, a1, a2' arg2: 'a2, a1, a1' decl: |- - let a1: FixedArray = [1, 2, 3] + let a1: FixedArray = [1, 2, 3] let a2: FixedArray = [new Int(), new Int(1)] # 3 diff --git a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_ab3.params.yaml b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_ab3.params.yaml index d241ca7b2eb3620849f681424b88f627bb35b990..fd5dc0ff2dba4960f3d7f4f85df31bb0e3504eb3 100644 --- a/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_ab3.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_ab3.params.yaml @@ -24,7 +24,7 @@ cases: - arg1: 'a2, a1, a2' arg2: 'a2, a1, a1' decl: |- - let a1: FixedArray = [1, 2, 3] + let a1: FixedArray = [1, 2, 3] let a2: FixedArray = [new Int(), new Int(1)] # 3 diff --git a/static_core/plugins/ets/tests/ets_func_tests/algorithms/ChecksumsTest.ets b/static_core/plugins/ets/tests/ets_func_tests/algorithms/ChecksumsTest.ets index 16f4e0a155c0ee8768fdf962de60c6e7a4de4933..4a9e2185fea36098413e5002f1a51289a03ead64 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/algorithms/ChecksumsTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/algorithms/ChecksumsTest.ets @@ -27,7 +27,7 @@ function crc32(s: String): int { let crc: int = 0xFFFFFFFF; let poly: int = 0xEDB88320; for (let i: int = 0; i < s.length; i++) { - let c: int = s.charAt(i) as int; + let c: int = s.charAt(i).toInt(); let tmp: int = (crc ^ c) & 0xFF; for (let j: int = 0; j < 8; j++) { if ((tmp & 1) == 1) { diff --git a/static_core/plugins/ets/tests/ets_func_tests/algorithms/PrimesTest.ets b/static_core/plugins/ets/tests/ets_func_tests/algorithms/PrimesTest.ets index 79840110cb05a72e1769350032c0eb4bc544229a..c3c1a55a68fe8d18b70d1d8f0c2dcc5d70907df4 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/algorithms/PrimesTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/algorithms/PrimesTest.ets @@ -33,7 +33,7 @@ function prime_factors_trivial(n0: long): FixedArray { while (n > 1 && factor < n0) { if (n % factor == 0) { primes = concat(primes, [factor]); - n = (n / factor) as long; + n = (n / factor).toLong(); } else { factor++; } @@ -47,12 +47,12 @@ function prime_factors_trivial_plus(n0: long): FixedArray { let n: long = n0; while (n % 2 == 0) { primes = concat(primes, [2 as long]); - n = (n / 2) as long; + n = (n / 2).toLong(); } while (factor * factor <= n) { if (n % factor == 0) { primes = concat(primes, [factor]); - n = (n / factor) as long; + n = (n / factor).toLong(); } else { factor += 2; } @@ -77,7 +77,7 @@ function sieve_primes(n: int): FixedArray { } for (let i = 2; i < n+1; i++) { if (is_prime[i]) { - primes = concat(primes, [i as long]); + primes = concat(primes, [i.toLong()]); } } return primes; diff --git a/static_core/plugins/ets/tests/ets_func_tests/algorithms/SortingTest.ets b/static_core/plugins/ets/tests/ets_func_tests/algorithms/SortingTest.ets index f6d9c924348cba8b2420a71d5c614b38b7adcf92..663b360e4afc1c7437028f52df00e499aa70de40 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/algorithms/SortingTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/algorithms/SortingTest.ets @@ -84,7 +84,7 @@ function shaker_sort(arr: FixedArray): void { } function comb_sort(arr: FixedArray): void { - const factor: float = 1.2473309; + const factor: float = 1.2473309f; let step: int = arr.length - 1; while (step >= 1) { for (let i: int = 0; i + step < arr.length; ++i) { @@ -92,7 +92,7 @@ function comb_sort(arr: FixedArray): void { swap(arr, i, i + step); } } - step = (step / factor) as int; + step = (step / factor).toInt(); } for (let i: int = 0; i + 1 < arr.length; ++i) { for (let j = 0; j + 1 < arr.length - i; ++j) { diff --git a/static_core/plugins/ets/tests/ets_func_tests/algorithms/StringsTest.ets b/static_core/plugins/ets/tests/ets_func_tests/algorithms/StringsTest.ets index 19fa4d1993cc975d1b255d1749ef6f19ac8af634..f564816c80a54b72ea39d65a716062f7ecc7c2b7 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/algorithms/StringsTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/algorithms/StringsTest.ets @@ -15,9 +15,9 @@ function is_palindrom(text: String): boolean { - let halve: int = text.length as int / 2; + let halve: int = text.length.toInt() / 2; for (let i: int = 0; i < halve; i++) { - if (text.charAt(i) != text.charAt(text.length as int - i - 1)) { + if (text.charAt(i) != text.charAt(text.length.toInt() - i - 1)) { return false; } } @@ -29,7 +29,7 @@ function random_string(len: int): String { const l = t.length; let sb = new StringBuilder(); for (let i = 0; i < len; i++) { - sb.append(t.charAt((random()*l) as int)); + sb.append(t.charAt((random()*l).toInt())); } return sb.toString(); } diff --git a/static_core/plugins/ets/tests/ets_func_tests/algorithms/division-by-zero-in-class.ets b/static_core/plugins/ets/tests/ets_func_tests/algorithms/division-by-zero-in-class.ets index 9c63f3be3ef575c582bd795c12470141d2f18457..3903b816aafe02453bfa915f92a859d4f4d2adb7 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/algorithms/division-by-zero-in-class.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/algorithms/division-by-zero-in-class.ets @@ -13,19 +13,13 @@ * limitations under the License. */ +/*--- +desc: Division by zero in class initializer block +tags: [compile-only, negative] +---*/ class AA { - p=1/0; + p = 1/0; } -function main() : void { - let caught_counter = 0; - try { - let aa = new AA(); - aa.p; - } catch (error: ArithmeticError) { - caught_counter++; - } - assertEQ(caught_counter, 1) -} \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets_func_tests/escompat/ArrayBufferTest3.ets b/static_core/plugins/ets/tests/ets_func_tests/escompat/ArrayBufferTest3.ets index cb4a3783335e9fbece23d39e784251964cee1d2d..58de300b5fedfa0638940fd6178d0391a02e2278 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/escompat/ArrayBufferTest3.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/escompat/ArrayBufferTest3.ets @@ -86,13 +86,13 @@ function resizeArrayBuffer(): void { assertEQ(a.byteLength, 5) errorCheck = (e: Error | Exception) => { return (e instanceof IndexOutOfBoundsError) } - expectThrow((): void throws => { a.set(5, 0 as byte) }, errorCheck) + expectThrow((): void throws => { a.set(5, 0 .toByte()) }, errorCheck) expectThrow((): void throws => { a.at(5) }, errorCheck) // Return previous length a.resize(10); assertEQ(a.byteLength, 10) - const VALUE = 42 as byte + const VALUE = 42 .toByte() a.set(5, VALUE) assertEQ(a.at(5), VALUE) @@ -102,7 +102,7 @@ function resizeArrayBuffer(): void { a = new ArrayBuffer(10, 12) errorCheck = (e: Error | Exception) => { return (e instanceof IndexOutOfBoundsError) } - expectThrow((): void throws => { a.set(10, 0 as byte) }, errorCheck) + expectThrow((): void throws => { a.set(10, 0 .toByte()) }, errorCheck) expectThrow((): void throws => { a.at(10) }, errorCheck) a.resize(11) @@ -116,7 +116,7 @@ function testManagedAccessors(): void { let a = new ArrayBuffer(FULL_LENGTH, FULL_LENGTH) const expectedBytes = new byte[a.getByteLength()] for (let i = 0; i < a.getByteLength(); i++) { - expectedBytes[i] = i as byte + expectedBytes[i] = i .toByte() } for (let i = 0; i < a.getByteLength(); i++) { diff --git a/static_core/plugins/ets/tests/ets_func_tests/escompat/ArrayShrinkTest.ets b/static_core/plugins/ets/tests/ets_func_tests/escompat/ArrayShrinkTest.ets index ef64eab1a033a11a6a8d7c54e8dd0204c482c7db..7a26ef609a7cf7e39e93f1c7d83a92f1ee3423f4 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/escompat/ArrayShrinkTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/escompat/ArrayShrinkTest.ets @@ -30,7 +30,7 @@ class TestData { static readonly expected2 = TestData.src.slice(0, 2); static readonly arrayLength3: number = 5; static readonly expected3 = Array.from(TestData.src); - static readonly arrayLength4: number = Int.MIN_VALUE as number; + static readonly arrayLength4: number = Int.MIN_VALUE.toDouble() static readonly limit4: number = 10; static readonly expected4 = new Array; } diff --git a/static_core/plugins/ets/tests/ets_func_tests/escompat/ArrayTest8.ets b/static_core/plugins/ets/tests/ets_func_tests/escompat/ArrayTest8.ets index 0bad1631ea9bc0af5865a61a9fd17d9c70cfb852..df8f125dbaeeda9aaa20f5d4dfa45c0ea960b064 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/escompat/ArrayTest8.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/escompat/ArrayTest8.ets @@ -26,7 +26,7 @@ function main() { function testInvokeArrayNumber() { let arr = Array(1.0, 2.0, 3.0, 4.0) for (let i: int = 0; i < arr.length; i++) { - assertEQ(arr[i], (i + 1) as double) + assertEQ(arr[i], (i + 1).toDouble()) } } @@ -45,7 +45,7 @@ function testInvokeArrayStringManyValues() { function testInvokeArrayNumberWithInt() { let arr = Array(1, 2, 3) for (let i: int = 0; i < arr.length; i++) { - assertEQ(arr[i], (i + 1) as double) + assertEQ(arr[i], (i + 1).toDouble()) } } diff --git a/static_core/plugins/ets/tests/ets_func_tests/escompat/DeepCopyTest.ets b/static_core/plugins/ets/tests/ets_func_tests/escompat/DeepCopyTest.ets index 82030c79bd47f0b0eaa33706aac82972dedffbfd..9b9d748cd65b40af1980ac55bd1f61c83be340f2 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/escompat/DeepCopyTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/escompat/DeepCopyTest.ets @@ -40,7 +40,7 @@ class Obj { c: char = c'a' s: short = 0 l: long = 0 - f: float = 0.0 + f: float = 0.0f d: double = 0.0 constructor(id: int = 0, name: string | undefined = undefined) { @@ -245,4 +245,4 @@ function main(): int { suite.addTest("Promise clone", testPromiseClone) return suite.run() -} \ No newline at end of file +} diff --git a/static_core/plugins/ets/tests/ets_func_tests/escompat/JsonTest.ets b/static_core/plugins/ets/tests/ets_func_tests/escompat/JsonTest.ets index 3a0e685b9f6d880213cc0558d852eb57db6fe50f..54be518780a4807f5647e3e3ee07bb0ce34e48be 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/escompat/JsonTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/escompat/JsonTest.ets @@ -451,7 +451,7 @@ class A { integerValue: int = 0; longValue: long = 1; shortValue: short = 1; - floatValue: float = 1.2; + floatValue: float = 1.2f; byteValue: byte = 1; } @@ -463,7 +463,7 @@ function testJSONParse(): int { assertEQ(parsingResult.integerValue, 12) assertEQ(parsingResult.longValue, 2) assertEQ(parsingResult.shortValue, 3) - assertEQ(parsingResult.floatValue, 1.5) + assertEQ(parsingResult.floatValue, 1.5f) assertEQ(parsingResult.byteValue, 7) return testResult } diff --git a/static_core/plugins/ets/tests/ets_func_tests/escompat/ReflectGetBadCases.ets b/static_core/plugins/ets/tests/ets_func_tests/escompat/ReflectGetBadCases.ets index 644095b2bc61de722d8285efe1fd088bc5135956..815f3296a00383bfdb7bd082a82ade861593cce2 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/escompat/ReflectGetBadCases.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/escompat/ReflectGetBadCases.ets @@ -48,7 +48,7 @@ function reflectGetBadCases(): int { let sh: short = 20 let i: int = 30 let lo: long = 40 - let fl: float = 50.0 + let fl: float = 50.0f let dou: double = 60.0 let s: string = "abc" diff --git a/static_core/plugins/ets/tests/ets_func_tests/escompat/ReflectOwnKeys.ets b/static_core/plugins/ets/tests/ets_func_tests/escompat/ReflectOwnKeys.ets index 93dbbe8240946d068204dfcbec1ea7964bb160a0..8d78f0eaa04166e09aaea2907b7e2c0fbbf03022 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/escompat/ReflectOwnKeys.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/escompat/ReflectOwnKeys.ets @@ -63,7 +63,7 @@ function reflectOwnKeys(): int { let sh: short = 20 let i: int = 30 let lo: long = 40 - let fl: float = 50.0 + let fl: float = 50.0f let dou: double = 60.0 let arr: FixedArray = [10, 20, 30] diff --git a/static_core/plugins/ets/tests/ets_func_tests/escompat/ReflectSet.ets b/static_core/plugins/ets/tests/ets_func_tests/escompat/ReflectSet.ets index 738b1f63b719a467bd4a738717ac8128f0f0ac0f..46b7f5c026706ca853b0674cc7f5b19c761995ba 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/escompat/ReflectSet.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/escompat/ReflectSet.ets @@ -45,7 +45,7 @@ class Point3D extends Point2D { class C { public p1:number = 0; - public p2:float = 0.0; + public p2:float = 0.0f; public p3:long = 0; public p4:int = 0; public p5:short = 0; @@ -92,7 +92,7 @@ function reflectSetTypeConvert(): int { let b: short = 2; let c: int = 3; let d: long = 4; - let e: float = 5.0; + let e: float = 5.0f; Reflect.set(sample, 'p1', a); result += (sample.p1 == a) ? 0 : 1 diff --git a/static_core/plugins/ets/tests/ets_func_tests/escompat/RegExpMatchAllTest.ets b/static_core/plugins/ets/tests/ets_func_tests/escompat/RegExpMatchAllTest.ets index 82a5d7af7772ffb15ac03f87ee074e29f83c14b7..f64bf601f747b5e045f2941f2fc17481841d7d0d 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/escompat/RegExpMatchAllTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/escompat/RegExpMatchAllTest.ets @@ -31,14 +31,14 @@ function main(): int { let regexp = new RegExp(".", "g") let s = "abc" regexp.exec(s) - failure += checkTestResult(regexp.lastIndex as int, 1) + failure += checkTestResult(regexp.lastIndex.toInt(), 1) let iter = s.matchAll(regexp) regexp.exec(s) - failure += checkTestResult(regexp.lastIndex as int, 2) + failure += checkTestResult(regexp.lastIndex.toInt(), 2) let next_result = iter.next() failure += checkTestResult(next_result.value!, new RegExpMatchArray(1, "abc", ["b"])) failure += checkTestResult(next_result.done, false) - failure += checkTestResult(regexp.lastIndex as int, 2) + failure += checkTestResult(regexp.lastIndex.toInt(), 2) let regexplastIndextest = new RegExp("(?:ab|cd)\\d?","g"); regexplastIndextest.lastIndex = -1; diff --git a/static_core/plugins/ets/tests/ets_func_tests/escompat/RegExpReplaceFunctionTest.ets b/static_core/plugins/ets/tests/ets_func_tests/escompat/RegExpReplaceFunctionTest.ets index f2f5b5bfa06969b9cf6e337f04a1c3244ae4361a..cafc1c56bc0772bd2b561efffc73c84cf401699f 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/escompat/RegExpReplaceFunctionTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/escompat/RegExpReplaceFunctionTest.ets @@ -20,7 +20,7 @@ function test1(shor: String): int { let lambda : (str: String, args: Object[]) => String = (str: String, args: Object[]) : String => { failure += checkTestResult(str, "x") failure += checkTestResult(args[0] as Double, new Double(0.0)) - failure += checkTestResult(args[1] as String, shor) + failure += checkTestResult(args[1].toString(), shor) let ans = ctr.toString(); ctr++; return ans; @@ -37,7 +37,7 @@ function test2(shor: String): int { let lambda : (str: String, args: Object[]) => String = (str: String, args: Object[]) : String => { failure += checkTestResult(str, "x") failure += checkTestResult(args[0] as Double, new Double(0.0)) - failure += checkTestResult(args[1] as String, shor) + failure += checkTestResult(args[1].toString(), shor) let ans = ctr.toString(); ctr++; return ans; @@ -54,8 +54,8 @@ function test3(shor: String): int { let lambda : (str: String, args: Object[]) => String = (str: String, args: Object[]) : String => { failure += checkTestResult(str, "x") - failure += checkTestResult(args[0] as Double, new Double((ctr.unboxed() * 2) as double)) - failure += checkTestResult(args[1] as String, shor) + failure += checkTestResult(args[0] as Double, new Double((ctr.unboxed() * 2).toDouble())) + failure += checkTestResult(args[1].toString(), shor) let ans = ctr.toString(); ctr++; return ans; @@ -72,10 +72,10 @@ function test4(shor: String): int { let test : String[] = ["a", "b", "c"] let lambda : (str: String, args: Object[]) => String = (str: String, args: Object[]) : String => { failure += checkTestResult(str, "x") - failure += checkTestResult(args[0] as String, "x") - failure += checkTestResult(args[1] as String, test[ctr.unboxed()]) - failure += checkTestResult(args[2] as Double, new Double((ctr.unboxed() * 2) as double)) - failure += checkTestResult(args[3] as String, shor) + failure += checkTestResult(args[0].toString(), "x") + failure += checkTestResult(args[1].toString(), test[ctr.unboxed()]) + failure += checkTestResult(args[2] as Double, new Double((ctr.unboxed() * 2).toDouble())) + failure += checkTestResult(args[3].toString(), shor) let ans = ctr.toString(); ctr++; return ans; diff --git a/static_core/plugins/ets/tests/ets_func_tests/regression/16056_0.ets b/static_core/plugins/ets/tests/ets_func_tests/regression/16056_0.ets index b0443bf3787305a952dcb741aac6f1ab39388144..d4c49b500213a2412b12835adcfb5759ed99ecfd 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/regression/16056_0.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/regression/16056_0.ets @@ -23,5 +23,5 @@ type float32 = float export type EasingCurve = (t: float32) => float32 function vis(v0: float32, f: float32): EasingCurve { - return (value: float32): float32 => ((v0 / (-4.2) * f) * (Math.exp((-4.2) * value * f) -1)) as float32 + return (value: float32): float32 => ((v0 / (-4.2f) * f) * (Math.exp((-4.2) * value * f).toFloat() -1)) as float32 } diff --git a/static_core/plugins/ets/tests/ets_func_tests/spec/03.types/References_Types/unions/union_cast_05.ets b/static_core/plugins/ets/tests/ets_func_tests/spec/03.types/References_Types/unions/union_cast_05.ets index c976fcbd830d55b7876351a9dc951738acea0a15..bf4465921d4393251e629f359fe9eca8b1e97688 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/spec/03.types/References_Types/unions/union_cast_05.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/spec/03.types/References_Types/unions/union_cast_05.ets @@ -23,6 +23,6 @@ type Margin = number | string function main(): void { let a1: Margin = 5 - let b1: byte = a1 as byte + let b1: byte = a1.toByte() assertEQ( b1, 5) } diff --git a/static_core/plugins/ets/tests/ets_func_tests/spec/03.types/References_Types/unions/union_cast_06.ets b/static_core/plugins/ets/tests/ets_func_tests/spec/03.types/References_Types/unions/union_cast_06.ets index 951fcdee09cb4135489b9f09f1ad023e57334002..746c0c8c11d153179f7be3550cb54d8ca64b3ca0 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/spec/03.types/References_Types/unions/union_cast_06.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/spec/03.types/References_Types/unions/union_cast_06.ets @@ -23,6 +23,6 @@ type Margin = number | string function main(): void { let a1: Margin = 65536 - let b1: long = a1 as long + let b1: long = a1.toLong() assertEQ( b1, 65536) } diff --git a/static_core/plugins/ets/tests/ets_func_tests/spec/03.types/References_Types/unions/union_generics_01.ets b/static_core/plugins/ets/tests/ets_func_tests/spec/03.types/References_Types/unions/union_generics_01.ets index f3cda8862a54be4190cfb24ba35c217f34454844..4149a65bfc2bb67cc7fe17e6784f9f279df82659 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/spec/03.types/References_Types/unions/union_generics_01.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/spec/03.types/References_Types/unions/union_generics_01.ets @@ -36,9 +36,9 @@ function superMax(items: FixedArray, comparator: ((l: T, r: T) => int) | n function getNumber(param: Margin): int { if (param instanceof string) { - return (param as string).length as int + return param.length.toInt() } - return (param as number) as int + return param.toInt() } function compareMargin(left: Margin, right: Margin): int { @@ -50,5 +50,5 @@ function compareMargin(left: Margin, right: Margin): int { function main(): void { let arr: FixedArray = [5, "hello", "bye", 7] let maxx = superMax(arr, compareMargin) - assertEQ( (maxx as number), 7) + assertEQ(maxx, 7) } diff --git a/static_core/plugins/ets/tests/ets_func_tests/spec/04.Names_Declarations_and_Scopes/4.8.Function_Declarations/4.8.5.Rest_Parameter/RestParamsTest_PassLambdasArrayAndSpread.ets b/static_core/plugins/ets/tests/ets_func_tests/spec/04.Names_Declarations_and_Scopes/4.8.Function_Declarations/4.8.5.Rest_Parameter/RestParamsTest_PassLambdasArrayAndSpread.ets index 8b9375a0e0c7acd805f2efda350cee13abe1d73a..3fd959ce8be867f5959e5369cc491db06b11a121 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/spec/04.Names_Declarations_and_Scopes/4.8.Function_Declarations/4.8.5.Rest_Parameter/RestParamsTest_PassLambdasArrayAndSpread.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/spec/04.Names_Declarations_and_Scopes/4.8.Function_Declarations/4.8.5.Rest_Parameter/RestParamsTest_PassLambdasArrayAndSpread.ets @@ -53,8 +53,8 @@ function main(): int { let test = new Testee(); let result: int = 0; - let l1: StringToInt = (str: String) => { return str.length as int } - let larr: StringToInt[] = [l1, l1, (str: String) => { return str.length as int }]; + let l1: StringToInt = (str: String) => { return str.length.toInt() } + let larr: StringToInt[] = [l1, l1, (str: String) => { return str.length.toInt() }]; result = test.callLambda(...larr); if(result != 15) return 1; diff --git a/static_core/plugins/ets/tests/ets_func_tests/spec/05.Generics/tuple_as_generic_args_0020.ets b/static_core/plugins/ets/tests/ets_func_tests/spec/05.Generics/tuple_as_generic_args_0020.ets index d6cd543e6f5282a732a1aaf70f45f968ce6a8caf..0ec43df96d462806695d3d47cb3b9578016a2767 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/spec/05.Generics/tuple_as_generic_args_0020.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/spec/05.Generics/tuple_as_generic_args_0020.ets @@ -24,6 +24,6 @@ function foo(data : T): void { function main() { - let a: [number, string, float] = [1,"2", 2.0] + let a: [number, string, float] = [1,"2", 2.0f] foo<[number, string, float]>(a) } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets_func_tests/spec/13.Compilation_Units_Packages_and_Modules/06.Export_Directives/02.export_type_directives/import_type_alias_with_qualified_access.ets b/static_core/plugins/ets/tests/ets_func_tests/spec/13.Compilation_Units_Packages_and_Modules/06.Export_Directives/02.export_type_directives/import_type_alias_with_qualified_access.ets index b37afb9e811304b6358b2e924b6339ccd4f9d564..1b437ef82bb6cbc504daa9dc6b3440c109ba36ce 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/spec/13.Compilation_Units_Packages_and_Modules/06.Export_Directives/02.export_type_directives/import_type_alias_with_qualified_access.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/spec/13.Compilation_Units_Packages_and_Modules/06.Export_Directives/02.export_type_directives/import_type_alias_with_qualified_access.ets @@ -31,7 +31,7 @@ function f2(): types.int16 { } function f3(): types.float_n { - return 0.0; + return 0.0f; } function f4(): types.text { diff --git a/static_core/plugins/ets/tests/ets_func_tests/spec/15.Semantic_Rules/Compatibility_Features/Extended_Conditional_Expressions/numeric/loop/numeric-loop-for-double-zero-expression.ets b/static_core/plugins/ets/tests/ets_func_tests/spec/15.Semantic_Rules/Compatibility_Features/Extended_Conditional_Expressions/numeric/loop/numeric-loop-for-double-zero-expression.ets index f37e49a0b7086ce5ed475cd289f16aa203f0188a..2dfdf8e6e7cce21353d6c219e6f8bf258e22b612 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/spec/15.Semantic_Rules/Compatibility_Features/Extended_Conditional_Expressions/numeric/loop/numeric-loop-for-double-zero-expression.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/spec/15.Semantic_Rules/Compatibility_Features/Extended_Conditional_Expressions/numeric/loop/numeric-loop-for-double-zero-expression.ets @@ -20,7 +20,7 @@ tags: [] function main(): int { - let zeroNumber: double = 0.0; + let zeroNumber: double = 0.0f; let counter : int = 0; for (let i = 0; zeroNumber; i++ ) { counter = counter + 1; diff --git a/static_core/plugins/ets/tests/ets_func_tests/spec/15.Semantic_Rules/Compatibility_Features/Extended_Conditional_Expressions/numeric/loop/numeric-loop-for-float-nonzero-expression.ets b/static_core/plugins/ets/tests/ets_func_tests/spec/15.Semantic_Rules/Compatibility_Features/Extended_Conditional_Expressions/numeric/loop/numeric-loop-for-float-nonzero-expression.ets index ef9690d44e9b9fc0a2383875eae136fa80adf4d5..d8832b3680d35f14285a9899811113d212c34163 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/spec/15.Semantic_Rules/Compatibility_Features/Extended_Conditional_Expressions/numeric/loop/numeric-loop-for-float-nonzero-expression.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/spec/15.Semantic_Rules/Compatibility_Features/Extended_Conditional_Expressions/numeric/loop/numeric-loop-for-float-nonzero-expression.ets @@ -20,7 +20,7 @@ tags: [] function main(): int { - let nonZeroNumber: float = 1.0; + let nonZeroNumber: float = 1.0f; let counter : int = 0; for (let i = 0; nonZeroNumber; i++ ) { counter = counter + 1; diff --git a/static_core/plugins/ets/tests/ets_func_tests/spec/15.Semantic_Rules/Compatibility_Features/Extended_Conditional_Expressions/numeric/loop/numeric-loop-for-float-zero-expression.ets b/static_core/plugins/ets/tests/ets_func_tests/spec/15.Semantic_Rules/Compatibility_Features/Extended_Conditional_Expressions/numeric/loop/numeric-loop-for-float-zero-expression.ets index a09e566540e59d113d691cc5b07e99873d7423a6..456a7c65fdb49c0724d27a2756ee9040c9b7a37d 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/spec/15.Semantic_Rules/Compatibility_Features/Extended_Conditional_Expressions/numeric/loop/numeric-loop-for-float-zero-expression.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/spec/15.Semantic_Rules/Compatibility_Features/Extended_Conditional_Expressions/numeric/loop/numeric-loop-for-float-zero-expression.ets @@ -20,7 +20,7 @@ tags: [] function main(): int { - let zeroNumber: float = 0.0; + let zeroNumber: float = 0.0f; let counter : int = 0; for (let i = 0; zeroNumber; i++ ) { counter = counter + 1; diff --git a/static_core/plugins/ets/tests/ets_func_tests/spec/16.Support_for_GUI_Programming/callable-classes/type-call-instantiate_8.ets b/static_core/plugins/ets/tests/ets_func_tests/spec/16.Support_for_GUI_Programming/callable-classes/type-call-instantiate_8.ets index 1025fdf36dd98f74b407235d364b13581dbf26b4..0754257e0583c75d8394ac3964b3c1f5a3e6559d 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/spec/16.Support_for_GUI_Programming/callable-classes/type-call-instantiate_8.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/spec/16.Support_for_GUI_Programming/callable-classes/type-call-instantiate_8.ets @@ -27,7 +27,7 @@ class CallMeTrinity { static $_instantiate(factory: () => CallMeTrinity, ...values: int[]): CallMeTrinity { let x = factory(); - x.value = values.length as int; + x.value = values.length.toInt(); return x; } diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/concurrency/AsyncLockTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/concurrency/AsyncLockTest.ets index 16523ab40679f3b9e513e96fd4004d69e8a6ab0a..ac16df18f9ff5e35993bf5a6e15cf424c52107fa 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/std/concurrency/AsyncLockTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/concurrency/AsyncLockTest.ets @@ -20,7 +20,7 @@ function asyncLockQueryTest(): int { let lock = AsyncLock.request("asyncLockQueryTest"); let promise = lock.lockAsync((): int => { let state = lock.query(); - return state.held.length as int; + return state.held.length.toInt(); }); let result = await promise; diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/BasicMapTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/BasicMapTest.ets index 57d6af74a4e704fb56a59d0df2899b023b8faf04..d8550b210cebf0b9bd4a341f20cab450a03ac722 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/BasicMapTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/BasicMapTest.ets @@ -64,9 +64,9 @@ function createMapAddAndCheckEntriesOrder(): int { map.set(c'a', 3.0) let entries = map.entries() - if (entries.next().value![0] as Char as char == c'c' && - entries.next().value![0] as Char as char == c'x' && - entries.next().value![0] as Char as char == c'a') { + if (entries.next().value![0] == c'c' && + entries.next().value![0] == c'x' && + entries.next().value![0] == c'a') { return success } @@ -100,7 +100,7 @@ function createMapAddAndCheckHasKey(): int { function createEmptyMap(): int { let map: Map = new Map() - return map.size as int + return map.size.toInt() } function createMapAddAndGet(): int { @@ -253,7 +253,7 @@ function createMapAddAndClear(): int { map.set(c'c', 3.0) map.clear() - return map.size as int + return map.size.toInt() } function createMapAndAdd(): int { diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/BasicSetTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/BasicSetTest.ets index 6b04b291c20ab22b8ef38e57a6a25236d18dbb61..fd9135a5b1cd610c56e9a46d8126dce547322824 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/BasicSetTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/BasicSetTest.ets @@ -55,7 +55,7 @@ function createSetAddAndCheckHasValue(): int { function createEmptySet(): int { let set: Set = new Set - return set.size as int + return set.size.toInt() } function createSetAndGetValues(): int { diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/TrivialArrayTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/TrivialArrayTest.ets index 44e6c51c8cb670495aee237d83bf60898970b511..a72e2803c9bfa2bb220e41ec5a07f93e0cacfe6a 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/TrivialArrayTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/TrivialArrayTest.ets @@ -18,15 +18,15 @@ function main(): void { assertEQ( arr.length, 0) for (let i = 0; i < 30; i++) { assertEQ( arr.length, i) - arr.push(i as number) + arr.push(i) } for (let i = 0; i < 30; i++) { - assertTrue( arr.includes(i as number, undefined)) + assertTrue( arr.includes(i, undefined)) } assertEQ( arr.at(50), undefined) assertEQ( arr.length, 30) for (let i = 0; i < 30; i++) { - assertEQ( arr.pop()! as Object as Double as double as int, 30 - 1 - i) + assertEQ( arr.pop()!, 30 - 1 - i) } assertEQ( arr.length, 0) @@ -40,26 +40,26 @@ function test_reverse(): void { assertEQ( arr.length, 0) for (let i = 0; i < 30; i++) { assertEQ( arr.length, i) - arr.push(i as number) + arr.push(i) } arr.reverse() for (let i = 0; i < 30; i++) { - assertEQ( arr.indexOf(i as number, undefined), 30 - 1 - i) + assertEQ( arr.indexOf(i, undefined), 30 - 1 - i) } } function test_splice_1(): void { const arr = new Array() for (let i = 0; i <= 3; i++) { - arr.push(i as number) + arr.push(i) } const other = arr.splice(1) assertEQ( arr.length, 1) - assertEQ( arr.indexOf(0 as number, undefined), 0) + assertEQ( arr.indexOf(0, undefined), 0) assertEQ( other.length, 3) for (let i = 1; i <= 3; i++) { - assertEQ( other.indexOf(i as number, undefined), i - 1) + assertEQ( other.indexOf(i, undefined), i - 1) } other.splice(1, undefined, 6, 7, 8); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_GetEndTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_GetEndTest.ets index e0bc016aa6f9fb440d639c324422bf53062021ba..de7d3d6ab9ec4bace4ac4218620c77aca983b11c 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_GetEndTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_GetEndTest.ets @@ -32,7 +32,7 @@ function main(): int { assertEQ(el, queueInt.pop()); } for (let i: int = 0; i < elementsNum; ++i) { - let el = (random() * 10000) as int; + let el = (random() * 10000).toInt(); queueInt.push(el); assertEQ(el, queueInt.getEnd()); } diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_GetFirstTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_GetFirstTest.ets index 1d0a11debcd4719b29826d1326bfd4ed75a433e5..c8f903115490df45549f11492da84a254dc8d7bb 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_GetFirstTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_GetFirstTest.ets @@ -113,7 +113,7 @@ function main(): int { } let frontNum = 0; for (let i: int = 0; i < elementsNum; ++i) { - let el = (random() * 10000) as int; + let el = (random() * 10000).toInt(); queueInt.push(el); if (i == 0) { frontNum = el; diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_PopTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_PopTest.ets index 8d8d58eddc85f7ca31f5cc369f32ab2d45680ba4..abe7ac7af111c365110f76877131de5ff407d1c5 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_PopTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_PopTest.ets @@ -84,7 +84,7 @@ function main(): int { let queueIntPop: ArrayBlockingQueue = new ArrayBlockingQueue(200); assertEQ(queueIntPop.size, 0); for (let i: int = 0; i < elementsNum; ++i) { - let el = (random() * 10000) as int; + let el = (random() * 10000).toInt(); queueIntPop.push(el); } assertEQ(queueIntPop.size, elementsNum); @@ -132,7 +132,7 @@ function main(): int { function pusherInt() { for (let i = 0; i < elementsNum; i++) { - let el = (random() * 10000) as int; + let el = (random() * 10000).toInt(); testArrayInt[i] = el; queueInt.push(el); } diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_PushTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_PushTest.ets index 542971fe950718191ac968e0b5863c15fb2fbaf3..549c8df62f84378108007f558372606cbbb7c1ec 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_PushTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_PushTest.ets @@ -31,7 +31,7 @@ function main(): int { { let arr: Array = new Array(elementsNum); for (let i: int = 0; i < arr.length; ++i) { - let el = (random() * 10000) as int; + let el = (random() * 10000).toInt(); arr[i] = el; queueInt.push(el); assertEQ(el, queueInt.getEnd()); @@ -81,7 +81,7 @@ function main(): int { function pusherInt() { for (let i = 0; i < elementsNum; i++) { - let el = (random() * 10000) as int; + let el = (random() * 10000).toInt(); testArrayInt[i] = el; queueInt.push(el); } diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/blocking_queue.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/blocking_queue.ets index 03e9d1391413b8057f9f0b8d0a6f3263cc0817a5..634a138605765698434500dba2999529c4b1031e 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/blocking_queue.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/blocking_queue.ets @@ -34,7 +34,7 @@ function wait(): int { function pusherInt() { for (let i = 0; i < elementsNum; i++) { wait(); - let el = (random() * 10000) as int; + let el = (random() * 10000).toInt(); testArrayInt[i] = el; queueInt.push(el); } @@ -136,7 +136,7 @@ function concurrentPushPopTestStr() { function simpleQueuePushPopFrontBackSizeEmptyTest() { let arr: Array = new Array(elementsNum); for (let i: int = 0; i < arr.length; ++i) { - let el = (random() * 10000) as int; + let el = (random() * 10000).toInt(); arr[i] = el; queueInt.push(el); assertEQ(el, (queueInt as ArrayBlockingQueue).getEnd()); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_ForEachTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_ForEachTest.ets index 2ef376683ef5eec6f1f57b10ce52fa87531a48a9..d859bfbb2f47152356bac1e6b1405941f1a65cd0 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_ForEachTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_ForEachTest.ets @@ -325,7 +325,7 @@ function setAll() { function getAll() { for (let i: int = 0; i < 10; i++) { if (concurrentHashMapOne.has(i)) { - let getVal = concurrentHashMapOne.get(i) as string; + let getVal = concurrentHashMapOne.get(i).toString(); arrValuesTest[i] = getVal; } } @@ -359,7 +359,7 @@ function forEachZero() { function forEachOne() { concurrentHashMapOne.forEach((val: string) => { - let index = Atomics.load(flag, 0) as int; + let index = Atomics.load(flag, 0).toInt(); arrValuesTest[index] = val; Atomics.add(flag, 0, 1); }); @@ -367,7 +367,7 @@ function forEachOne() { function forEachTwo() { concurrentHashMapOne.forEach((val: string, key: number) => { - let index = Atomics.load(flag, 0) as int; + let index = Atomics.load(flag, 0).toInt(); arrKeysTest[index] = key; arrValuesTest[index] = val; Atomics.add(flag, 0, 1); @@ -376,7 +376,7 @@ function forEachTwo() { function forEachThree() { concurrentHashMapOne.forEach((val: string, key: number, map: ConcurrentHashMap) => { - let index = Atomics.load(flag, 0) as int; + let index = Atomics.load(flag, 0).toInt(); arrKeysTest[index] = key; arrValuesTest[index] = val; Atomics.add(flag, 0, 1); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_PressureTest_Remove.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_PressureTest_Remove.ets index 26681fceb33f2cae635e8017107dc386831b3128..adad150533aab82bdee50c1344b9772174c913bb 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_PressureTest_Remove.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_PressureTest_Remove.ets @@ -54,8 +54,8 @@ function main(): int { } function removeForPressure(pressureFlag: number) { - let num = pressureFlag as int; + let num = pressureFlag.toInt(); for (let i: int = num; i < num + 1; i++) { - arrValuesTest[i] = concurrentHashMapOne.remove(i) as string; + arrValuesTest[i] = concurrentHashMapOne.remove(i).toString(); } } diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/core/Object.ets b/static_core/plugins/ets/tests/ets_func_tests/std/core/Object.ets index 0cd3026ef645a9f05d87530688c53569954164f0..0d776901843b5f215eb13eb8e66f49dc349924b3 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/std/core/Object.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/core/Object.ets @@ -125,7 +125,7 @@ function objectKeys(): int { let sh: short = 20 let i: int = 30 let lo: long = 40 - let fl: float = 50.0 + let fl: float = 50.0f let dou: double = 60.0 let arr: FixedArray = [10, 20, 30] @@ -168,7 +168,7 @@ function objectValues(): int { let sh: short = 20 let i: int = 30 let lo: long = 40 - let fl: float = 50.0 + let fl: float = 50.0f let dou: double = 60.0 let arr: FixedArray = [10, 20, 30] diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/core/TypeClassTypeTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/core/TypeClassTypeTest.ets index a45ea75167bd020490803d0a1986f2dd909453d5..a1ef2f6e76e7dec2a4572cef1407df1ef3f102d4 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/std/core/TypeClassTypeTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/core/TypeClassTypeTest.ets @@ -56,11 +56,11 @@ class Point3D extends Point { constructor(x: double, y: double, z: double) { super(x, y) this.z = z - this.state = 0.0 + this.state = 0 } constructor(state: int) { this(0, 0, 0) - this.state = 1.0 + this.state = 1 } } @@ -85,7 +85,7 @@ final class HTMLWriter extends Writer { function findMethodsByName(type: ClassType, names: Array): Array { const methods = new Array() - const namesLength = names.length as int + const namesLength = names.length.toInt() const foundMethods = new Map() const methodsNum = type.getMethodsNum() diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/core/TypeCreateErasedBodyTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/core/TypeCreateErasedBodyTest.ets index 3ad439834d67d2b4ca0d61a4e50342900b4a2135..6e175aabaf90557c4aab69a5a56c6fd1bee1f4ec 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/std/core/TypeCreateErasedBodyTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/core/TypeCreateErasedBodyTest.ets @@ -27,19 +27,19 @@ class C { function erasedM(recv: NullishType, args: FixedArray): NullishType { assertEQ( args.length, 1) - return (args[0] as string) + "123" + (recv as C).dat + return (args[0]?.toString()) + "123" + (recv as C).dat } function erased(recv: NullishType, args: FixedArray): NullishType { assertEQ( args.length, 3) - const a1: int = args[0] as Int - const a2: long = args[1] as Long - const c: boolean = args[2] as Boolean + const a1: int = args[0].toInt() + const a2: long = args[1].toLong() + const c: boolean = args[2].toBoolean() if (c) { - const r = a1 as long - return r as Long + const r = a1.toLong() + return r.toLong() } else { - return a2 as Long + return a2.toLong() } } diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/core/TypeMethodInvoke.ets b/static_core/plugins/ets/tests/ets_func_tests/std/core/TypeMethodInvoke.ets index b68401769ac32b21f15b4de7c7b862526cf65a40..9f28b9349bfb4c3bbfee6de16f21ca031093c7b2 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/std/core/TypeMethodInvoke.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/core/TypeMethodInvoke.ets @@ -19,7 +19,7 @@ class C { } static sum(a: int, b: int): long { - return a as long + b + return a.toLong() + b } a: int = 0 @@ -29,8 +29,8 @@ function testSum(sum: Method): void { const args : FixedArray = new NullishType[2] args[0] = Int.MAX_VALUE args[1] = 30 - const res = sum.invoke(null, args) as Long - assertEQ( res, (Int.MAX_VALUE as long + 30)) + const res = sum.invoke(null, args).toLong() + assertEQ( res, (Int.MAX_VALUE.toLong() + 30)) } function testGetIsEvenPlusX(getIsEvenPlusX: Method): void { @@ -39,13 +39,13 @@ function testGetIsEvenPlusX(getIsEvenPlusX: Method): void { const args : FixedArray = new NullishType[1] args[0] = 13 - assertEQ( getIsEvenPlusX.invoke(c, args) as Boolean, true) + assertEQ( getIsEvenPlusX.invoke(c, args).toBoolean(), true) c.a = 14 - assertEQ( getIsEvenPlusX.invoke(c, args) as Boolean, false) + assertEQ( getIsEvenPlusX.invoke(c, args).toBoolean(), false) args[0] = 30 - assertEQ( getIsEvenPlusX.invoke(c, args) as Boolean, true) + assertEQ( getIsEvenPlusX.invoke(c, args).toBoolean(), true) } function main(): void { diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/time/DateChangeTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/time/DateChangeTest.ets index 5c5260908c6903f1005ec88de1000064c0d3869c..2453722de777d63154978a33c9a52612129989b1 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/std/time/DateChangeTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/time/DateChangeTest.ets @@ -108,7 +108,7 @@ function testDateChangeMonthBad(): int { function testDateChangeDay(): int { let date: Date = new Date(); - let day: byte = date.getDate() as byte; + let day: byte = date.getDate().toByte(); let newDay: byte = 15; if(newDay == day) newDay++; date.setDate(newDay); @@ -119,7 +119,7 @@ function testDateChangeDay(): int { function testDateChangeHour(): int { let date: Date = new Date(); - let hour: byte = date.getHours() as byte; + let hour: byte = date.getHours().toByte(); let newHour: byte = 12; if(newHour == hour) newHour = 11; date.setHours(newHour); @@ -130,7 +130,7 @@ function testDateChangeHour(): int { function testDateChangeMinutes(): int { let date: Date = new Date(); - let minutes: byte = date.getMinutes() as byte; + let minutes: byte = date.getMinutes().toByte(); let newMinutes: byte = 30; if(newMinutes == minutes) newMinutes = 21; date.setMinutes(newMinutes); @@ -141,7 +141,7 @@ function testDateChangeMinutes(): int { function testDateChangeSeconds(): int { let date: Date = new Date(); - let seconds: byte = date.getSeconds() as byte; + let seconds: byte = date.getSeconds().toByte(); let newSeconds: byte = 30; if(newSeconds == seconds) newSeconds = 21; date.setSeconds(newSeconds); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/time/DateConstructorTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/time/DateConstructorTest.ets index 14c93d0e8aaf346c5850a7c4e087b8b15f0b5f3a..462a2329cd0e832701e4c0acb2dc4ceb2ddf39c0 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/std/time/DateConstructorTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/time/DateConstructorTest.ets @@ -68,7 +68,7 @@ const dateString: string[] = ["2019-11-14T00:55:31.820Z", "2024-02-29T00:55:31.9 function testIntMsConstructor(): void { for(let i: int = 0; i < longYears.length; i++) { let cd = new Date(longYears[i]); - assertEQ(cd.valueOf() as long, longYears[i]) + assertEQ(Double.toLong(cd.valueOf()), longYears[i]) } } @@ -77,7 +77,7 @@ function testIntYearMonthConstructor(): void { let cd = new Date(longYears[i], longMonths[i]); let utc = Date.UTC(longYears[i], longMonths[i]); - assertEQ(utc as long, (cd.valueOf() - cd.getTimezoneOffset() * msPerMinute) as long) + assertEQ(Double.toLong(utc), Double.toLong((cd.valueOf() - cd.getTimezoneOffset() * msPerMinute))) checkDateWithLongYMD(cd, valueLongYears[i], longMonths[i], 1) } } @@ -88,7 +88,7 @@ function testIntYearMonthDayConstructor(): void { let cd = new Date(longYears[i], longMonths[i], day); let utc = Date.UTC(longYears[i], longMonths[i], day); - assertEQ(utc as long, (cd.valueOf() - cd.getTimezoneOffset() * msPerMinute) as long) + assertEQ(Double.toLong(utc), Double.toLong((cd.valueOf() - cd.getTimezoneOffset() * msPerMinute))) checkDateWithLongYMD(cd, valueLongYears[i], longMonths[i], day); } } @@ -99,7 +99,7 @@ function testIntYearMonthDayHoursConstructor(): void { let cd = new Date(longYears[i], longMonths[i], day, longHours[i]); let utc = Date.UTC(longYears[i], longMonths[i], day, longHours[i]); - assertEQ(utc as long, (cd.valueOf() - cd.getTimezoneOffset() * msPerMinute) as long) + assertEQ(Double.toLong(utc), Double.toLong((cd.valueOf() - cd.getTimezoneOffset() * msPerMinute))) checkDateWithLongYMDH(cd, valueLongYears[i], longMonths[i], day, longHours[i]); } } @@ -110,7 +110,7 @@ function testIntYearMonthDayHoursMinutesConstructor(): void { let cd = new Date(longYears[i], longMonths[i], day, longHours[i], longMinutes[i]); let utc = Date.UTC(longYears[i], longMonths[i], day, longHours[i], longMinutes[i]); - assertEQ(utc as long, (cd.valueOf() - cd.getTimezoneOffset() * msPerMinute) as long) + assertEQ(Double.toLong(utc), Double.toLong((cd.valueOf() - cd.getTimezoneOffset() * msPerMinute))) checkDateWithLongYMDHM(cd, valueLongYears[i], longMonths[i], day, longHours[i], longMinutes[i]); } } @@ -121,7 +121,7 @@ function testIntYearMonthDayHoursMinutesSecondsConstructor(): void { let cd = new Date(longYears[i], longMonths[i], day, longHours[i], longMinutes[i], longMinutes[i]); let utc = Date.UTC(longYears[i], longMonths[i], day, longHours[i], longMinutes[i], longMinutes[i]); - assertEQ(utc as long, (cd.valueOf() - cd.getTimezoneOffset() * msPerMinute) as long) + assertEQ(Double.toLong(utc), Double.toLong((cd.valueOf() - cd.getTimezoneOffset() * msPerMinute))) checkDateWithLongYMDHMS(cd, valueLongYears[i], longMonths[i], day, longHours[i], longMinutes[i], longMinutes[i]); } } @@ -134,7 +134,7 @@ function testIntYearMonthDayHoursMinutesSecondsMillisConstructor(): void { let cd = new Date(longYears[i], longMonths[i], day, longHours[i], longMinutes[i], longMinutes[i], millis); let utc = Date.UTC(longYears[i], longMonths[i], day, longHours[i], longMinutes[i], longMinutes[i], millis); - assertEQ(utc as long, (cd.valueOf() - cd.getTimezoneOffset() * msPerMinute) as long) + assertEQ(Double.toLong(utc), Double.toLong((cd.valueOf() - cd.getTimezoneOffset() * msPerMinute))) checkDateWithLongYMDHMSM(cd, valueLongYears[i], longMonths[i], day, longHours[i], longMinutes[i], longMinutes[i], millis); } } @@ -151,7 +151,7 @@ function testDoubleYearMonthConstructor(): void { let cd = new Date(doubleYears[i], doubleMonths[i]); let utc = Date.UTC(doubleYears[i], doubleMonths[i]); - assertEQ(utc as long, (cd.valueOf() - cd.getTimezoneOffset() * msPerMinute) as long) + assertEQ(Double.toLong(utc), Double.toLong((cd.valueOf() - cd.getTimezoneOffset() * msPerMinute))) checkDateWithDoubleYMD(cd, valueDoubleYears[i], doubleMonths[i], 1); } } @@ -162,7 +162,7 @@ function testDoubleYearMonthDayConstructor(): void { let cd = new Date(doubleYears[i], doubleMonths[i], day); let utc = Date.UTC(doubleYears[i], doubleMonths[i], new Double(day)); - assertEQ(utc as long, (cd.valueOf() - cd.getTimezoneOffset() * msPerMinute) as long) + assertEQ(Double.toLong(utc), Double.toLong((cd.valueOf() - cd.getTimezoneOffset() * msPerMinute))) checkDateWithDoubleYMD(cd, valueDoubleYears[i], doubleMonths[i], day); } } @@ -173,7 +173,7 @@ function testDoubleYearMonthDayHoursConstructor(): void { let cd = new Date(doubleYears[i], doubleMonths[i], day, doubleHours[i]); let utc = Date.UTC(doubleYears[i], doubleMonths[i], new Double(day), new Double(doubleHours[i])); - assertEQ(utc as long, (cd.valueOf() - cd.getTimezoneOffset() * msPerMinute) as long) + assertEQ(Double.toLong(utc), Double.toLong((cd.valueOf() - cd.getTimezoneOffset() * msPerMinute))) checkDateWithDoubleYMDH(cd, valueDoubleYears[i], doubleMonths[i], day, doubleHours[i]); } } @@ -184,7 +184,7 @@ function testDoubleYearMonthDayHoursMinutesConstructor(): void { let cd = new Date(doubleYears[i], doubleMonths[i], day, doubleHours[i], doubleMinutes[i]); let utc = Date.UTC(doubleYears[i], doubleMonths[i], new Double(day), new Double(doubleHours[i]), new Double(doubleMinutes[i])); - assertEQ(utc as long, (cd.valueOf() - cd.getTimezoneOffset() * msPerMinute) as long) + assertEQ(Double.toLong(utc), Double.toLong((cd.valueOf() - cd.getTimezoneOffset() * msPerMinute))) checkDateWithDoubleYMDHM(cd, valueDoubleYears[i], doubleMonths[i], day, doubleHours[i], doubleMinutes[i]); } } @@ -195,7 +195,7 @@ function testDoubleYearMonthDayHoursMinutesSecondsConstructor(): void { let cd = new Date(doubleYears[i], doubleMonths[i], day, doubleHours[i], doubleMinutes[i], doubleMinutes[i]); let utc = Date.UTC(doubleYears[i], doubleMonths[i], new Double(day), new Double(doubleHours[i]), new Double(doubleMinutes[i]), new Double(doubleMinutes[i])); - assertEQ(utc as long, (cd.valueOf() - cd.getTimezoneOffset() * msPerMinute) as long) + assertEQ(Double.toLong(utc), Double.toLong((cd.valueOf() - cd.getTimezoneOffset() * msPerMinute))) checkDateWithDoubleYMDHMS(cd, valueDoubleYears[i], doubleMonths[i], day, doubleHours[i], doubleMinutes[i], doubleMinutes[i]); } } @@ -209,7 +209,7 @@ function testDoubleYearMonthDayHoursMinutesSecondsMillisConstructor(): void { let utc = Date.UTC(doubleYears[i], doubleMonths[i], new Double(day), new Double(doubleHours[i]), new Double(doubleMinutes[i]), new Double(doubleMinutes[i]), new Double(millis)); - assertEQ(utc as long, (cd.valueOf() - cd.getTimezoneOffset() * msPerMinute) as long) + assertEQ(Double.toLong(utc), Double.toLong((cd.valueOf() - cd.getTimezoneOffset() * msPerMinute))) checkDateWithDoubleYMDHMSM(cd, valueDoubleYears[i], doubleMonths[i], day, doubleHours[i], doubleMinutes[i], doubleMinutes[i], millis); } } diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/time/DateCtorTypes.ets b/static_core/plugins/ets/tests/ets_func_tests/std/time/DateCtorTypes.ets index a9c7a197d3ac2b784718ff55261d0ca4ec158308..a65694970e03de7c4c185f665487b565c7bc09f1 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/std/time/DateCtorTypes.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/time/DateCtorTypes.ets @@ -33,22 +33,22 @@ const doubleMinutes: double[] = [0.0, 4.4, 8.8, 12.12, 16.16, 20.20, 24.24, 28.2 function tests_long(): void { for(let i: int = 0; i < intYears.length; i++) { - let cd = new Date(intYears[i] as long); + let cd = new Date(intYears[i].toLong()); let cd1 = new Date(intYears[i]); } for(let i: int = 0; i < intMonths.length; i++) { - let cd = new Date(intMonths[i] as long); + let cd = new Date(intMonths[i].toLong()); let cd1 = new Date(intMonths[i]); } for(let i: int = 0; i < intHours.length; i++) { - let cd = new Date(intHours[i] as long); + let cd = new Date(intHours[i].toLong()); let cd1 = new Date(intHours[i]); } for(let i: int = 0; i < intMinutes.length; i++) { - let cd = new Date(intMinutes[i] as long); + let cd = new Date(intMinutes[i].toLong()); let cd1 = new Date(intMinutes[i]); } } @@ -56,22 +56,22 @@ function tests_long(): void { function tests_double(): void { for(let i: int = 0; i < doubleYears.length; i++) { - let cd = new Date(doubleYears[i] as double); + let cd = new Date(doubleYears[i].toDouble()); let cd1 = new Date(doubleYears[i]); } for(let i: int = 0; i < doubleMonths.length; i++) { - let cd = new Date(doubleMonths[i] as double); + let cd = new Date(doubleMonths[i].toDouble()); let cd1 = new Date(doubleMonths[i]); } for(let i: int = 0; i < doubleHours.length; i++) { - let cd = new Date(doubleHours[i] as double); + let cd = new Date(doubleHours[i].toDouble()); let cd1 = new Date(doubleHours[i]); } for(let i: int = 0; i < doubleMinutes.length; i++) { - let cd = new Date(doubleMinutes[i] as double); + let cd = new Date(doubleMinutes[i].toDouble()); let cd1 = new Date(doubleMinutes[i]); } } diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_return.ets b/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_return.ets index adc9b03d45ab16579514774f7c1ac5767119e706..da3453f9b734f8a457be56d901a3cf5498beb699 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_return.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_return.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -const FLOAT_PI: float = 3.14; +const FLOAT_PI: float = 3.14f; async function byteFunc(): Promise { return -3 as byte as Object; diff --git a/static_core/plugins/ets/tests/ets_test_suite/functions/name.ets b/static_core/plugins/ets/tests/ets_test_suite/functions/name.ets index d2c06970b55a8198cea8e68ebda4f372fbc98fa0..a32316dcceb31bec3eef71123e3114a965f6f6eb 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/functions/name.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/functions/name.ets @@ -52,7 +52,7 @@ function main() { assertEQ(a.lambda.name, "lambda") assertEQ(A.staticBar.name, "staticBar") assertEQ(b.buzz.name, "buzz") - assertEQ(def?.name, "") + assertEQ(def?.name, "def") assertEQ(returnFunctionName(foo), "foo") assertEQ(returnFunctionName(x), "x") @@ -61,7 +61,5 @@ function main() { assertEQ(returnFunctionName(A.staticBar), "staticBar") assertEQ(returnFunctionName(b.buzz), "buzz") assertEQ(returnFunctionName(() => 1), "") - if (def) { - assertEQ(returnFunctionName(def), "") - } + assertEQ(returnFunctionName(def), "def") } diff --git a/static_core/plugins/ets/tests/ets_test_suite/gc/heap_info_test.ets b/static_core/plugins/ets/tests/ets_test_suite/gc/heap_info_test.ets index 1f65e9cb3242ef193960bb6f28c357e217069cfd..42cbee300f6a24e3b2c6e5231e77d34e770118db 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/gc/heap_info_test.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/gc/heap_info_test.ets @@ -28,7 +28,7 @@ function main(): void { const MAX_ALLOCATION_COUNT = 100; const MAX_ALLOC_SIZE = 100; for (let i = 0; i < MAX_ALLOCATION_COUNT; ++i) { - let alloc_size = (random() * MAX_ALLOC_SIZE) as int; + let alloc_size = (random() * MAX_ALLOC_SIZE).toInt(); new Object[alloc_size]; checkHeapInfo(); } diff --git a/static_core/plugins/ets/tests/ets_test_suite/generics/CMakeLists.txt b/static_core/plugins/ets/tests/ets_test_suite/generics/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..5c26170b08021194d22dcdc61eb7663803d78035 --- /dev/null +++ b/static_core/plugins/ets/tests/ets_test_suite/generics/CMakeLists.txt @@ -0,0 +1,23 @@ +# Copyright (c) 2021-2025 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. + +# #21382 fixed array -> T[] casts +# run_int_jit_aot_ets_code( +# "${CMAKE_CURRENT_SOURCE_DIR}/generics_methods.ets" +# "${CMAKE_CURRENT_BINARY_DIR}" +# ets_test_suite_generics_methods) + +run_int_jit_aot_ets_code( + "${CMAKE_CURRENT_SOURCE_DIR}/generics_functions.ets" + "${CMAKE_CURRENT_BINARY_DIR}" + ets_test_suite_generics_functions) diff --git a/static_core/plugins/ets/tests/ets_test_suite/intrinsics/CMakeLists.txt b/static_core/plugins/ets/tests/ets_test_suite/intrinsics/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..2e5cdecf537dcf4530771af27ae153fdbe904986 --- /dev/null +++ b/static_core/plugins/ets/tests/ets_test_suite/intrinsics/CMakeLists.txt @@ -0,0 +1,96 @@ +# Copyright (c) 2023-2025 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. + +set(intrinsics_tests + bigint64array_sort + float32array_sort + float64array_sort + int8array_sort + int16array_sort + int32array_sort + isNaN + isFinite + isInteger + isSafeInteger + string_equals + string_length + string_isempty + string_from_string + string_from_char_code + string_from_chars + string_substring + string_getchars + string_getbytes + string_hashcode + string_concat + string_trim + string_startswith + string_endswith + string_indexof + string_repeat + string_compare_to + typed_arrays_reverse + char_isuppercase + abs + min + max + round + floor + ceil + trunc + stringbuilder_oom + stringbuilder + uint8array_sort + uint8clampedarray_sort + uint16array_sort + uint32array_sort + biguint64array_sort +) + +if (NOT PANDA_TARGET_ARM32) + # need coroutine support + # #21382: fixed array -> T[] casts + # list(APPEND intrinsics_tests to_string_cache) +endif() + +set(intrinsics_tests_in_dir "${CMAKE_CURRENT_SOURCE_DIR}") +set(intrinsics_tests_out_dir "${CMAKE_CURRENT_BINARY_DIR}") + +add_custom_target(ets_test_suite_intrinsics) + +foreach(test ${intrinsics_tests}) + set(test_out_dir "${intrinsics_tests_out_dir}/${test}") + + set(test_in "${intrinsics_tests_in_dir}/${test}.ets") + set(target ets_test_suite_intrinsics_${test}) + set(extra_options "") + + # disable OSR for the tests throwing exceptions + if ("${test}" STREQUAL "stringbuilder_oom") + set(extra_options RUNTIME_EXTRA_OPTIONS "--compiler-enable-osr=false") + endif() + + # enable heap-verifier to check the TLB cleanup before going to the slow path + if ("${test}" STREQUAL "string_from_char_code") + set(extra_options RUNTIME_EXTRA_OPTIONS "--heap-verifier=fail_on_verification:pre:into:before_g1_concurrent:post") + endif() + + if ("${test}" STREQUAL "stringbuilder" OR + "${test}" STREQUAL "string_compare_to" OR + "${test}" STREQUAL "string_from_char_code") + run_int_jit_aot_ets_code_foreach_gc(ets_test_suite_intrinsics ${test_in} ${test_out_dir} ${target}) + else() + run_int_jit_aot_ets_code(${test_in} ${test_out_dir} ${target} ${extra_options}) + add_dependencies(ets_test_suite_intrinsics ${target}) + endif() +endforeach() diff --git a/static_core/plugins/ets/tests/ets_test_suite/strings/string_api.ets b/static_core/plugins/ets/tests/ets_test_suite/strings/string_api.ets index 41fa66aa22aa50955cf83d4d552c67781f0dfb03..adba859b211e08a773cb9ee1dfe55e52a4183016 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/strings/string_api.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/strings/string_api.ets @@ -40,7 +40,7 @@ function main(): void { assertEQ(chars[4], c'o', "Fifth letter must be `o`"); str2 = "bytesStr"; - let byteChars: byte[] = str2.getBytes(0, str2.length as int); + let byteChars: byte[] = str2.getBytes(0, str2.length.toInt()); assertEQ(byteChars[0], 98, "First byte must be 98"); assertEQ(byteChars[1], 121, "Second byte must be 121"); assertEQ(byteChars[2], 116, "Third byte must be 116"); diff --git a/static_core/plugins/ets/tests/ets_test_suite/strings/string_compare_to.ets b/static_core/plugins/ets/tests/ets_test_suite/strings/string_compare_to.ets index 38c0b97c970bb08922e2ac522714df1d2fc19a50..583a04caab9468a065b0c0eab7582ecb7e8053d2 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/strings/string_compare_to.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/strings/string_compare_to.ets @@ -159,7 +159,7 @@ function main(): int { let str1: String = checks[i][0] let str2: String = checks[i][1] let expected: int = checks[i][2] - let actual: int = math.sign(str1.compareTo(str2) as double) as int; + let actual: int = math.sign(str1.compareTo(str2).toDouble()); if (expected != actual) { console.println("'" + str1 + "' compared to '" + str2 + "' expected: " + diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAll.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAll.ets index 961a8a20663ce9b9a4ae593ac0357ef3f6420339..d904fa531c95497b82a7f9f9f67f6dc1c6ae4c29 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAll.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAll.ets @@ -19,7 +19,7 @@ let p1 = Promise.resolve(3); let p2 = new Promise((_: (value:number)=>void, _reject: (err: Error)=>void) => { reject = _reject; }); -Promise.all([p1, p2]).then((values: Array): void => { +Promise.all([p1, p2]).then((values): void => { console.log('Test failed. The promise should not be resolved.'); }, (err: Error): void => { if (err != error) { diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllReject.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllReject.ets index e61a658509f7812ad628ec398f95748f0d07746f..32884a1b3b3fe893f923453b57628952acdf5391 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllReject.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllReject.ets @@ -27,7 +27,7 @@ class Thenable implements PromiseLike { let error = new Error('abc'); let thenable = new Thenable(error); -Promise.all([thenable]).then((value: Array): void => { +Promise.all([thenable]).then((value): void => { console.log('Test failed. The promise should not be resolved.'); }, (e: Error): void => { if (error !== e) { diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllRejectDeferred.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllRejectDeferred.ets index 961a8a20663ce9b9a4ae593ac0357ef3f6420339..d904fa531c95497b82a7f9f9f67f6dc1c6ae4c29 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllRejectDeferred.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllRejectDeferred.ets @@ -19,7 +19,7 @@ let p1 = Promise.resolve(3); let p2 = new Promise((_: (value:number)=>void, _reject: (err: Error)=>void) => { reject = _reject; }); -Promise.all([p1, p2]).then((values: Array): void => { +Promise.all([p1, p2]).then((values): void => { console.log('Test failed. The promise should not be resolved.'); }, (err: Error): void => { if (err != error) { diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllRejectIgnoredDeferred.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllRejectIgnoredDeferred.ets index 6a20c902fb86e28ae5b4d89cc0b37dc9a025e60b..63c15c1bceedfc080e1015aa1c1f4b2c3220a233 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllRejectIgnoredDeferred.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllRejectIgnoredDeferred.ets @@ -32,7 +32,7 @@ class Reject implements PromiseLike { } let thenable: PromiseLike[] = [new Fulfill(), new Reject()]; -Promise.all(thenable).then((values: Array): void => { +Promise.all(thenable).then((values): void => { if (values.length != 2) { console.log('Test failed. Expected a string array of length 2 but got length ' + values.length + '.'); return; diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllSettledEmpty.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllSettledEmpty.ets index 58a4da52edcfc01a6e819c1258e94931c8b8b3c3..1300e763d6a5f9c0e2a865d4e5d82e32074ae35c 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllSettledEmpty.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllSettledEmpty.ets @@ -14,7 +14,7 @@ */ let array: Promise[] = []; -Promise.allSettled(array).then((values: PromiseSettledResult[]): void => { +Promise.allSettled(array).then((values): void => { if (values.length != 0) { console.log('Test failed. Expected an empty string array but got length ' + values.length + '.'); return; diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllSettledMixed.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllSettledMixed.ets index 88e8b1b36ad6e8555ce4dffb2cc09c8c60337c80..c29925522189487bde06f787e8d249d8c0417991 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllSettledMixed.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllSettledMixed.ets @@ -19,7 +19,7 @@ let r2 = Promise.reject(new Error('rejected 2')); let f2 = Promise.resolve('fulfilled 3'); let r3 = Promise.reject(new Error('rejected 4')); let f3 = Promise.resolve('fulfilled 5'); -Promise.allSettled([r1, f1, r2, f2, r3, f3]).then((values: PromiseSettledResult[]): void => { +Promise.allSettled([r1, f1, r2, f2, r3, f3]).then((values): void => { if (values.length != 6) { console.log('Test failed. Expected a string array of length 6 but got length ' + values.length + '.'); return; diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllSettledRejectAll.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllSettledRejectAll.ets index c928043ec3a9ef926f68629fbce9a55f4054f5f7..c82761b25b2051da689922759fdc0f0861e0aa9f 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllSettledRejectAll.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllSettledRejectAll.ets @@ -16,7 +16,7 @@ let r1 = Promise.reject(new Error('rejected 0')) let r2 = Promise.reject(new Error('rejected 1')); let r3 = Promise.reject(new Error('rejected 2')); -Promise.allSettled([r1, r2, r3]).then((values: PromiseSettledResult[]): void => { +Promise.allSettled([r1, r2, r3]).then((values): void => { if (values.length != 3) { console.log('Test failed. Expected a string array of length 3 but got length ' + values.length + '.'); return; diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllSettledRejectDeferred.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllSettledRejectDeferred.ets index e899cc8421f02cc2d5fdbaf1669a2b499adeeb2a..c2f3cd677f92446c0fdc428a190ad30f09229cf9 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllSettledRejectDeferred.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllSettledRejectDeferred.ets @@ -27,7 +27,7 @@ class Thenable implements PromiseLike { let error = new Error('abc'); let thenable = new Thenable(error); -Promise.allSettled([thenable]).then((values: PromiseSettledResult[]): void => { +Promise.allSettled([thenable]).then((values): void => { if (values.length != 1) { console.log('Test failed. Expected an array of length 1 but got length ' + values.length + '.'); return; diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllSettledResolve.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllSettledResolve.ets index 7deb06553bd09c8fa62fb5e7c4704831ba74f25b..16c8044c138eb61e5200d117e6f0a509b17a7a02 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllSettledResolve.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllSettledResolve.ets @@ -16,7 +16,7 @@ let p1 = Promise.resolve('abc'); let p2 = Promise.resolve('def'); let p3 = Promise.resolve('xyz'); -Promise.allSettled([p1, p2, p3]).then((values: PromiseSettledResult[]): void => { +Promise.allSettled([p1, p2, p3]).then((values): void => { if (values.length != 3) { console.log('Test failed. Expected a string array of length 3 but got length ' + values.length + '.'); return; diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllSettledThenableStatus.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllSettledThenableStatus.ets index 907151a948f35ff1868cc8b44699c25c61085256..107ff50d1e394fca3aadd4b0d8c6da6c3f3441b4 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllSettledThenableStatus.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAllSettledThenableStatus.ets @@ -34,7 +34,7 @@ class LateRejector implements PromiseLike { } let thenable: PromiseLike[] = [new Resolver(), new LateRejector()]; -Promise.allSettled(thenable).then((values:PromiseSettledResult[]): void => { +Promise.allSettled(thenable).then((values): void => { let v = (values[0] as PromiseFulfilledResult).value; if(v != 42) { console.log('Test failed. Expected 42, but got ' + v + '.'); diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyEmpty.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyEmpty.ets index fb286169bb1b0ed6b018812d85537746e0036a15..b1c3dadb141a1ee5a2859aa6140f812dd005a4fd 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyEmpty.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyEmpty.ets @@ -14,11 +14,11 @@ */ let array: Promise[] = []; -Promise.any(array).then((value: string): void => { +Promise.any(array).then((value): void => { console.log('Test failed. The promise should not be resolved.'); -}, (err: AggregateError): void => { - if (err.errors.length != 0) { - console.log('Test failed. Expected errors count 0 but got ' + err.errors.length + '.'); +}, (err): void => { + if ((err as AggregateError).errors.length != 0) { + console.log('Test failed. Expected errors count 0 but got ' + (err as AggregateError).errors.length + '.'); return; } console.log('Test passed.'); diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyPoisonedThen.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyPoisonedThen.ets index 7395a57e60747a85d34fa0089f441c8ca19c0f04..4edf1a433904509a5f1208bbb8bb2ca15f0ec7f1 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyPoisonedThen.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyPoisonedThen.ets @@ -27,14 +27,14 @@ class Thenable implements PromiseLike { let error = new Error(); let thenable = new Thenable(error); -Promise.any([thenable]).then((value: string): void => { +Promise.any([thenable]).then((value): void => { console.log('Test failed. The promise should not be resolved.'); -}, (err: AggregateError): void => { - if (err.errors.length != 1) { - console.log('Test failed. Expected errors count 1 but got ' + err.errors.length + '.'); +}, (err): void => { + if ((err as AggregateError).errors.length != 1) { + console.log('Test failed. Expected errors count 1 but got ' + (err as AggregateError).errors.length + '.'); return; } - if (err.errors[0] != error) { + if ((err as AggregateError).errors[0] != error) { console.log('Test failed. The promise should be rejected by the provided value.'); return; } diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyReject.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyReject.ets index 285e794718d50a332add500e1ac277180a95d940..639cd40adfb2aa385355a8c929e5be758beb9247 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyReject.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyReject.ets @@ -14,14 +14,14 @@ */ let error = new Error(); -Promise.any([Promise.reject(error)]).then((err: Error): void => { +Promise.any([Promise.reject(error)]).then((err): void => { console.log('Test failed. The promise should not be resolved.'); -}, (err: AggregateError): void => { - if (err.errors.length != 1) { - console.log('Test failed. Expected errors count 1 but got ' + err.errors.length + '.'); +}, (err): void => { + if ((err as AggregateError).errors.length != 1) { + console.log('Test failed. Expected errors count 1 but got ' + (err as AggregateError).errors.length + '.'); return; } - if (err.errors[0] != error) { + if ((err as AggregateError).errors[0] != error) { console.log('Test failed. The error should contain the specified value.'); return; } diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyRejectDeferred.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyRejectDeferred.ets index 239767c718fc8f5116aadbb3542d4ef265e9b13f..c629bc86900667e64280507c8dd835875ef7b5f3 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyRejectDeferred.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyRejectDeferred.ets @@ -23,14 +23,14 @@ class Thenable implements PromiseLike { } }; -Promise.any([new Thenable()]).then((values: Error): void => { +Promise.any([new Thenable()]).then((values): void => { console.log('Test failed. The promise should not be resolved.'); -}, (err: AggregateError): void => { - if (err.errors.length != 1) { - console.log('Test failed. Expected errors count 1 but got ' + err.errors.length + '.'); +}, (err): void => { + if ((err as AggregateError).errors.length != 1) { + console.log('Test failed. Expected errors count 1 but got ' + (err as AggregateError).errors.length + '.'); return; } - if (err.errors[0] != error) { + if ((err as AggregateError).errors[0] != error) { console.log('Test failed. The promise should be rejected by the specified value.'); return; } diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyRejectIgnored.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyRejectIgnored.ets index 58a4cf5a0df48fe4153a63419d4b79feb1c61e32..bae8cdc091592d3be9d63e309ea2fcc8e3d27490 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyRejectIgnored.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyRejectIgnored.ets @@ -33,7 +33,7 @@ class Reject implements PromiseLike { } let thenable: PromiseLike[] = [new Fulfill(), new Reject()]; -Promise.any(thenable).then((value: string): void => { +Promise.any(thenable).then((value): void => { if (value != 'abc') { console.log('Test failed. The promise should be resolved by the specified value.'); return; diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyRejectIgnoredDeferred.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyRejectIgnoredDeferred.ets index 1452d647a8d899fccb4de4c5a72d622bcbb97a1e..3dd1e64b29c172a5c5e6291bf42b530a547c8372 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyRejectIgnoredDeferred.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyRejectIgnoredDeferred.ets @@ -34,7 +34,7 @@ class Reject implements PromiseLike { let fulfill = new Fulfill(); let reject = new Reject(); let thenable: PromiseLike[] = [new Fulfill(), new Reject()]; -Promise.any(thenable).then((value: string): void => { +Promise.any(thenable).then((value): void => { if (value != 'abc') { console.log('Test failed. The promise should be resolved by the specified value.'); return; diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyRejectThenable.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyRejectThenable.ets index 2b9dc44ffd5b98840b139829c9a1d4687f02c955..f4c68205a46a28e4a085d52a998335d34149b92c 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyRejectThenable.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyRejectThenable.ets @@ -22,14 +22,14 @@ class Thenable implements PromiseLike { } } -Promise.any([new Thenable()]).then((value: Error): void => { +Promise.any([new Thenable()]).then((value): void => { console.log('Test failed. The promise should not be resolved.'); -}, (err: AggregateError): void => { - if (err.errors.length != 1) { - console.log('Test failed. Expected errors count 1 but got ' + err.errors.length + '.'); +}, (err): void => { + if ((err as AggregateError).errors.length != 1) { + console.log('Test failed. Expected errors count 1 but got ' + (err as AggregateError).errors.length + '.'); return; } - if (err.errors[0] != error) { + if ((err as AggregateError).errors[0] != error) { console.log('Test failed. The promise should be rejected by the specified value.'); return; } diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyResolve.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyResolve.ets index 6afbba37c0f6b8b63f18e56f4a58e6ea683c1ac8..703b8c5670ff4a4cfbadd7a2eb2a57a24fd213dc 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyResolve.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyResolve.ets @@ -12,12 +12,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -Promise.any(['a', 'b', 'c']).then((value: string): void => { +Promise.any(['a', 'b', 'c']).then((value): void => { if (value != 'a') { console.log('Test failed. Expected value \'a\' but got \'' + value + '\'.'); return; } console.log('Test passed.'); -}, (err: AggregateError): void => { +}, (err): void => { console.log('Test failed. The promise should not be rejected.'); }); diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyResolveLateRejectIgnored.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyResolveLateRejectIgnored.ets index c73de20adf9f7116a23a674b019faf1a97526113..81bd0d6c272f0d7eab241061ba6c3fb3ad9f93c6 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyResolveLateRejectIgnored.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnyResolveLateRejectIgnored.ets @@ -33,12 +33,12 @@ class LateReject implements PromiseLike { } let thenable: PromiseLike[] = [new Resolve(), new LateReject()]; -Promise.any(thenable).then((value: string): void => { +Promise.any(thenable).then((value): void => { if (value != 'abc') { console.log('Test failed. The promise should be resolve by the specified value.'); return; } console.log('Test passed.'); -}, (err: AggregateError): void => { +}, (err): void => { console.log('Test failed. The promise should not be rejected.'); }); diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnySequence4.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnySequence4.ets index a575a582217d222cdefb472cee27ed08615ae288..4a9f74d8c2b3b6419f856e205db2e369b65767c2 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnySequence4.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseAnySequence4.ets @@ -43,17 +43,17 @@ Promise.any([p1, p2]).then((): number => { sequence.push(5); checkSequence(sequence, 5); return 0; -}).then((value: number): void => {}, (err: AggregateError): void => { - if (err.errors.length != 2) { - console.log('Test failed. Expected number of errors 2, but got ' + err.errors.length); +}).then((value): void => {}, (err): void => { + if ((err as AggregateError).errors.length != 2) { + console.log('Test failed. Expected number of errors 2, but got ' + (err as AggregateError).errors.length); throw new Error('Test failed'); } - if (err.errors[0] != p1Err) { - console.log('Test failed. Expected the first error is \'abc\', but got ' + err.errors[0]); + if ((err as AggregateError).errors[0] != p1Err) { + console.log('Test failed. Expected the first error is \'abc\', but got ' + (err as AggregateError).errors[0]); throw new Error('Test failed'); } - if (err.errors[1] != p2Err) { - console.log('Test failed. Expected the first error is \'def\', but got ' + err.errors[1]); + if ((err as AggregateError).errors[1] != p2Err) { + console.log('Test failed. Expected the first error is \'def\', but got ' + (err as AggregateError).errors[1]); throw new Error('Test failed'); } console.log('Test passed.'); diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRacePoisonedThen.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRacePoisonedThen.ets index acd55416dc81d9fb7d4c733f1becb555975fd1a6..b24af3b9098c6b86b66f45ade9073deb7b68d4e9 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRacePoisonedThen.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRacePoisonedThen.ets @@ -27,7 +27,7 @@ class Thenable implements PromiseLike { let error = new Error(); let thenable = new Thenable(error); -Promise.race([thenable]).then((value: string): void => { +Promise.race([thenable]).then((value): void => { console.log('Test failed. The promise should not be resolved.'); }, (err: Error): void => { if (err != error) { diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRaceRejectDeferred.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRaceRejectDeferred.ets index f9ff31e66b4a4bd49e37bac8770c08a836f4f07b..1d48ae7be47b7fc5e294700488f3b3af50c50c89 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRaceRejectDeferred.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRaceRejectDeferred.ets @@ -27,7 +27,7 @@ class Thenable implements PromiseLike { }; let error = new Error('abc'); -Promise.race([new Thenable(error)]).then((values: string): void => { +Promise.race([new Thenable(error)]).then((values): void => { console.log('Test failed. The promise should not be resolved.'); }, (e: Error): void => { if (error !== e) { diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRaceRejectIgnoredDeferred.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRaceRejectIgnoredDeferred.ets index e5d5dc9cceef6adbea926aa7fb50fcb48239a6c9..bff34131591d9cded6cbee9279355c447bef022b 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRaceRejectIgnoredDeferred.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRaceRejectIgnoredDeferred.ets @@ -31,7 +31,7 @@ class Reject implements PromiseLike { } let thenable: PromiseLike[] = [new Fulfill(), new Reject()]; -Promise.race(thenable).then((value: string): void => { +Promise.race(thenable).then((value): void => { if (value != 'abc') { console.log('Test failed. The promise should be resolved by the specified value.'); return; diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRaceRejectThenable.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRaceRejectThenable.ets index 4a2699d045d33d510f70caec035581b90f0ecf41..5e926b03edc88b55014089678c6314d35d5e059c 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRaceRejectThenable.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRaceRejectThenable.ets @@ -25,7 +25,7 @@ class Thenable implements PromiseLike { } let error = new Error('abc'); -Promise.race([new Thenable(error)]).then((value: string): void => { +Promise.race([new Thenable(error)]).then((value): void => { console.log('Test failed. The promise should not be resolved.'); }, (err: Error): void => { if (err !== error) { diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRaceResolvePoisonedThen.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRaceResolvePoisonedThen.ets index 1e0b5d0ebd5392e6363d263baaa590e9167bc4ad..9ccb1d46a1b4ec7f8d9d6a3e148afdcc970de4d1 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRaceResolvePoisonedThen.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRaceResolvePoisonedThen.ets @@ -27,7 +27,7 @@ class Thenable implements PromiseLike { let error = new Error(); let thenable = new Thenable(error); -Promise.race([thenable]).then((value: string): void => { +Promise.race([thenable]).then((value): void => { console.log('Test failed. The promise should not be resolved.'); }, (err: Error): void => { if (err != error) { diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRaceResolveThenable.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRaceResolveThenable.ets index f366f5455a8224d461d46e7c737d98766d890d42..bd66f5e7f5b004c9d5b63a94e17c26fdb51bc143 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRaceResolveThenable.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRaceResolveThenable.ets @@ -22,7 +22,7 @@ class Thenable implements PromiseLike { }; let thenable = new Thenable(); -Promise.race([thenable]).then((value: string): void => { +Promise.race([thenable]).then((value): void => { if (value != 'abc') { console.log('Test failed. The promise should be resolved by the provided value.'); return; diff --git a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRaceSequence1.ets b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRaceSequence1.ets index 6c7e709f6aca0d5f6b94252d02a180361ff196f9..774eb6125cf2bd9e493ae62f1ae4b3d0bfbf5d3c 100644 --- a/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRaceSequence1.ets +++ b/static_core/plugins/ets/tests/ets_ts_subset/std/core/PromiseRaceSequence1.ets @@ -29,11 +29,11 @@ function checkSequence(actual: Array, expectedLength: number): void { let sequence = new Array(); let p1 = new Promise((resolve: (value: string) => void, reject: (err: Error) => void): void => {}); let p2 = Promise.resolve('abc'); -let p = Promise.race([p1, p2]); +let p = Promise.race([p1, p2]); sequence.push(1); -p.then((value: string): void => { +p.then((value): void => { if (value != 'abc') { console.log('Test failed. Expected value \'abc\', but got \'' + value + '\''); return; diff --git a/static_core/plugins/ets/tests/ets_warnings_tests/implicit_boxing_unboxing_tests/implicit_boxing_unboxing_1.ets b/static_core/plugins/ets/tests/ets_warnings_tests/implicit_boxing_unboxing_tests/implicit_boxing_unboxing_1.ets index 8f4bee5f92205992c2447a079c6f97e9222d941b..65d6f7479176ab009bb109f7c1a5038765a38d6d 100644 --- a/static_core/plugins/ets/tests/ets_warnings_tests/implicit_boxing_unboxing_tests/implicit_boxing_unboxing_1.ets +++ b/static_core/plugins/ets/tests/ets_warnings_tests/implicit_boxing_unboxing_tests/implicit_boxing_unboxing_1.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +/* #24986 class A { a(b : Int) : Int @@ -96,3 +96,4 @@ let i: Char = 15 as char let ni5 : Int = 5 as Int let nui5 : int = ni5 as int } +*/ \ No newline at end of file diff --git a/static_core/plugins/ets/tests/interop_js/tests/array/ts_to_ets/test_sts_array.ets b/static_core/plugins/ets/tests/interop_js/tests/array/ts_to_ets/test_sts_array.ets index 4cc0bd2304b64155f4649adb64d46887f06c76cc..4d55c31f033f7fb66a12580e32da22a79ec9b65a 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/array/ts_to_ets/test_sts_array.ets +++ b/static_core/plugins/ets/tests/interop_js/tests/array/ts_to_ets/test_sts_array.ets @@ -83,7 +83,7 @@ const concatenateReducer = (previousValue: string, currentValue: string, index: class A { style: string - currency: string + currency: string constructor(style: string, currency: string) { this.style = style this.currency = currency @@ -120,7 +120,7 @@ function testConcat(): boolean { } function testCopyWithin(): boolean { - return arrayCopyWithin1.copyWithin(1).toString() === "1,1,2,3" && arrayCopyWithin2.copyWithin(0, 2).toString() === "3,4,3,4" && arrayCopyWithin3.copyWithin(0, 1, 3).toString() === "2,3,3,4" + return arrayCopyWithin1.copyWithin(1).toString() === "1,1,2,3" && arrayCopyWithin2.copyWithin(0, 2).toString() === "3,4,3,4" && arrayCopyWithin3.copyWithin(0.0, 1, 3).toString() === "2,3,3,4" } function testEntries(): boolean { @@ -132,7 +132,7 @@ return !array.every(funcPredicate1) && array.every(funcPredicate2) } function testFill(): boolean { - return arrayFill.fill(8, 1, 3).toString() === "1,8,8,4" + return arrayFill.fill(8.0, 1.0, 3.0).toString() === "1,8,8,4" } function testFilter(): boolean { @@ -242,7 +242,7 @@ function testSort(): boolean { } function testSplice(): boolean { - return arraySplice1.splice(1).toString() === "2,3,4" && arraySplice3.splice(1, 1, 2).toString() === "2" && arraySplice4.splice(1, 2, 6, 7).toString() === "2,3" + return arraySplice1.splice(1).toString() === "2,3,4" && arraySplice3.splice(1.0, 1, 2).toString() === "2" && arraySplice4.splice(1.0, 2, 6, 7).toString() === "2,3" } function testToLocaleString(): boolean { @@ -258,7 +258,7 @@ function testToSorted(): boolean { } function testToSpliced(): boolean { - return array.toSpliced(1).toString() === "1" && array.toSpliced(1, 2).toString() === "1,4" && array.toSpliced(1, 2, 3).toString() === "1,3,4" && array.toSpliced(1, 2, 6, 7).toString() === "1,6,7,4" + return array.toSpliced(1).toString() === "1" && array.toSpliced(1, 2).toString() === "1,4" && array.toSpliced(1, 2, 3).toString() === "1,3,4" && array.toSpliced(1, 2, 6, 7).toString() === "1,6,7,4" } function testUnShift(): boolean { @@ -276,6 +276,6 @@ function testValues(): boolean { } function testWith(): boolean { - let a = array.with(1, 8) + let a = array.with(1.0, 8.0) return a.toString() === "1,8,3,4" } diff --git a/static_core/plugins/ets/tests/interop_js/tests/conversion_types/sts_to_js/conversion_types.ets b/static_core/plugins/ets/tests/interop_js/tests/conversion_types/sts_to_js/conversion_types.ets index 76d122361eb13cf8219692ba73a584f142a7be60..4c1641f8613ef1ea1bd8784fdbb01190035e1c47 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/conversion_types/sts_to_js/conversion_types.ets +++ b/static_core/plugins/ets/tests/interop_js/tests/conversion_types/sts_to_js/conversion_types.ets @@ -40,7 +40,7 @@ static { globStsLong = new Long(42 as long); globStsFloat = new Float(42.42 as float); globStsDouble = new Double(42.42 as double); - globStsChar = new Char('a'); + globStsChar = new Char(c'a'); globStsBoolean = new Boolean(true); globStsBigInt = new BigInt(42); } @@ -51,7 +51,7 @@ class DeferentIntTypes { num: int = 1; numb: number = 1; bigInt: BigInt = 1n; - fl: float = 1.1; + fl: float = 1.1f; intString: string = '1'; l: long = 1; doub: double = 1; @@ -60,7 +60,7 @@ class DeferentIntTypes { } class DeferentStringTypes { - ch: char = 'a'; + ch: char = c'a'; str: string = "hello"; lit: "one" | "two" = "one"; } diff --git a/static_core/plugins/ets/tests/interop_js/tests/conversion_types/ts_to_sts/conversion_array_int/conversion_array_int.ets b/static_core/plugins/ets/tests/interop_js/tests/conversion_types/ts_to_sts/conversion_array_int/conversion_array_int.ets index 94063b106ae346c9e27c06c8a74d50fc5be0051b..8609561f0b1d1d8401b8be6bf29871cd947f1ce3 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/conversion_types/ts_to_sts/conversion_array_int/conversion_array_int.ets +++ b/static_core/plugins/ets/tests/interop_js/tests/conversion_types/ts_to_sts/conversion_array_int/conversion_array_int.ets @@ -75,7 +75,7 @@ function checkConversionIntToArrayChar(): boolean { } function checkConversionBinaryToArrayInt(): boolean { - const val: FixedArray = [parseInt(tsBinary, systemBinary as int) as int]; + const val: FixedArray = [Double.toInt(parseInt(tsBinary, systemBinary as int))]; return typeof val[0] == 'number'; } @@ -87,25 +87,25 @@ function checkConversionBinaryToArrayNumber(): boolean { } function checkConversionBinaryToArrayFloat(): boolean { - const val: FixedArray = [parseInt(tsBinary, systemBinary as int) as float]; + const val: FixedArray = [Double.toFloat(parseInt(tsBinary, systemBinary as int))]; return typeof val[0] == 'number'; } function checkConversionBinaryToArrayByte(): boolean { - const val: FixedArray = [parseInt(tsBinary, systemBinary as int) as byte]; + const val: FixedArray = [Double.toByte(parseInt(tsBinary, systemBinary as int))]; return typeof val[0] == 'number'; } function checkConversionBinaryToArrayShort(): boolean { - const val: FixedArray = [parseInt(tsBinary, systemBinary as int) as short]; + const val: FixedArray = [Double.toShort(parseInt(tsBinary, systemBinary as int))]; return typeof val[0] == 'number'; } function checkConversionBinaryToArrayLong(): boolean { - const val: FixedArray = [parseInt(tsBinary, systemBinary as int) as long]; + const val: FixedArray = [Double.toLong(parseInt(tsBinary, systemBinary as int))]; return typeof val[0] == 'number'; } @@ -117,13 +117,13 @@ function checkConversionBinaryToArrayDouble(): boolean { } function checkConversionBinaryToArrayChar(): boolean { - const val: FixedArray = [parseInt(tsBinary, systemBinary as int) as char]; + const val: FixedArray = [Double.toChar(parseInt(tsBinary, systemBinary as int))]; return typeof val[0] == 'number'; } function checkConversionHexadecimalToArrayInt(): boolean { - const val: FixedArray = [parseInt(tsHexadecimal, systemHexadecimal as int) as int]; + const val: FixedArray = [Double.toInt(parseInt(tsHexadecimal, systemHexadecimal as int))]; return typeof val[0] == 'number'; } @@ -135,25 +135,25 @@ function checkConversionHexadecimalToArrayNumber(): boolean { } function checkConversionHexadecimalToArrayFloat(): boolean { - const val: FixedArray = [parseInt(tsHexadecimal, systemHexadecimal as int) as float]; + const val: FixedArray = [Double.toFloat(parseInt(tsHexadecimal, systemHexadecimal as int))]; return typeof val[0] == 'number'; } function checkConversionHexadecimalToArrayByte(): boolean { - const val: FixedArray = [parseInt(tsHexadecimal, systemHexadecimal as int) as byte]; + const val: FixedArray = [Double.toByte(parseInt(tsHexadecimal, systemHexadecimal as int))]; return typeof val[0] == 'number'; } function checkConversionHexadecimalToArrayShort(): boolean { - const val: FixedArray = [parseInt(tsHexadecimal, systemHexadecimal as int) as short]; + const val: FixedArray = [Double.toShort(parseInt(tsHexadecimal, systemHexadecimal as int))]; return typeof val[0] == 'number'; } function checkConversionHexadecimalToArrayLong(): boolean { - const val: FixedArray = [parseInt(tsHexadecimal, systemHexadecimal as int) as long]; + const val: FixedArray = [Double.toLong(parseInt(tsHexadecimal, systemHexadecimal as int))]; return typeof val[0] == 'number'; } @@ -165,13 +165,13 @@ function checkConversionHexadecimalToArrayDouble(): boolean { } function checkConversionHexadecimalToArrayChar(): boolean { - const val: FixedArray = [parseInt(tsHexadecimal, systemHexadecimal as int) as char]; + const val: FixedArray = [Double.toChar(parseInt(tsHexadecimal, systemHexadecimal as int))]; return typeof val[0] == 'number'; } function checkConversionIntStringToArrayInt(): boolean { - const val: FixedArray = [parseInt(tsIntString) as int]; + const val: FixedArray = [Double.toInt(parseInt(tsIntString))]; return typeof val[0] == 'number'; } @@ -183,25 +183,25 @@ function checkConversionIntStringToArrayNumber(): boolean { } function checkConversionIntStringToArrayFloat(): boolean { - const val: FixedArray = [parseInt(tsIntString) as float]; + const val: FixedArray = [Double.toFloat(parseInt(tsIntString))]; return typeof val[0] == 'number'; } function checkConversionIntStringToArrayByte(): boolean { - const val: FixedArray = [parseInt(tsIntString) as byte]; + const val: FixedArray = [Double.toByte(parseInt(tsIntString))]; return typeof val[0] == 'number'; } function checkConversionIntStringToArrayShort(): boolean { - const val: FixedArray = [parseInt(tsIntString) as short]; + const val: FixedArray = [Double.toShort(parseInt(tsIntString))]; return typeof val[0] == 'number'; } function checkConversionIntStringToArrayLong(): boolean { - const val: FixedArray = [parseInt(tsIntString) as long]; + const val: FixedArray = [Double.toLong(parseInt(tsIntString))]; return typeof val[0] == 'number'; } @@ -213,7 +213,7 @@ function checkConversionIntStringToArrayDouble(): boolean { } function checkConversionIntStringToArrayChar(): boolean { - const val: FixedArray = [parseInt(tsIntString) as char]; + const val: FixedArray = [Double.toChar(parseInt(tsIntString))]; return typeof val[0] == 'number'; } @@ -315,7 +315,7 @@ function checkConversionByteToArrayChar(): boolean { } function checkConversionBigIntToArrayInt(): boolean { - const val: FixedArray = [Number(tsBigInt) as int]; + const val: FixedArray = [Double.toInt(Number(tsBigInt))]; return typeof val[0] == 'number'; } @@ -327,25 +327,25 @@ function checkConversionBigIntToArrayNumber(): boolean { } function checkConversionBigIntToArrayFloat(): boolean { - const val: FixedArray = [Number(tsBigInt) as float]; + const val: FixedArray = [Double.toFloat(Number(tsBigInt))]; return typeof val[0] == 'number'; } function checkConversionBigIntToArrayByte(): boolean { - const val: FixedArray = [Number(tsBigInt) as byte]; + const val: FixedArray = [Double.toByte(Number(tsBigInt))]; return typeof val[0] == 'number'; } function checkConversionBigIntToArrayShort(): boolean { - const val: FixedArray = [Number(tsBigInt) as short]; + const val: FixedArray = [Double.toShort(Number(tsBigInt))]; return typeof val[0] == 'number'; } function checkConversionBigIntToArrayLong(): boolean { - const val: FixedArray = [Number(tsBigInt) as long]; + const val: FixedArray = [Double.toLong(Number(tsBigInt))]; return typeof val[0] == 'number'; } @@ -357,13 +357,13 @@ function checkConversionBigIntToArrayDouble(): boolean { } function checkConversionBigIntToArrayChar(): boolean { - const val: FixedArray = [Number(tsBigInt) as char]; + const val: FixedArray = [Double.toChar(Number(tsBigInt))]; return typeof val[0] == 'number'; } function checkConversionExponentialToArrayInt(): boolean { - const val: FixedArray = [parseInt(tsExponential) as int]; + const val: FixedArray = [Double.toInt(parseInt(tsExponential))]; return typeof val[0] == 'number'; } @@ -375,25 +375,25 @@ function checkConversionExponentialToArrayNumber(): boolean { } function checkConversionExponentialToArrayFloat(): boolean { - const val: FixedArray = [parseInt(tsExponential) as float]; + const val: FixedArray = [Double.toFloat(parseInt(tsExponential))]; return typeof val[0] == 'number'; } function checkConversionExponentialToArrayByte(): boolean { - const val: FixedArray = [parseInt(tsExponential) as byte]; + const val: FixedArray = [Double.toByte(parseInt(tsExponential))]; return typeof val[0] == 'number'; } function checkConversionExponentialToArrayShort(): boolean { - const val: FixedArray = [parseInt(tsExponential) as short]; + const val: FixedArray = [Double.toShort(parseInt(tsExponential))]; return typeof val[0] == 'number'; } function checkConversionExponentialToArrayLong(): boolean { - const val: FixedArray = [parseInt(tsExponential) as long]; + const val: FixedArray = [Double.toLong(parseInt(tsExponential))]; return typeof val[0] == 'number'; } @@ -405,7 +405,7 @@ function checkConversionExponentialToArrayDouble(): boolean { } function checkConversionExponentialToArrayChar(): boolean { - const val: FixedArray = [parseInt(tsExponential) as char]; + const val: FixedArray = [Double.toChar(parseInt(tsExponential))]; return typeof val[0] == 'number'; } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/interop_js/tests/conversion_types/ts_to_sts/conversion_big_int/conversion_big_int.ets b/static_core/plugins/ets/tests/interop_js/tests/conversion_types/ts_to_sts/conversion_big_int/conversion_big_int.ets index 7a8041e8e42c7d05f1a020e57ffb2d6fe4b24fea..f4569470bf17b0a8bb4470ae34dafb593f3f2be5 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/conversion_types/ts_to_sts/conversion_big_int/conversion_big_int.ets +++ b/static_core/plugins/ets/tests/interop_js/tests/conversion_types/ts_to_sts/conversion_big_int/conversion_big_int.ets @@ -26,7 +26,7 @@ function checkConversionBigIntToInt(): boolean { } function checkConversionBigIntToNumber(): boolean { - const val = Number(tsBigInt); + const val = Number(tsBigInt).toDouble(); return typeof val == 'number'; } @@ -56,7 +56,7 @@ function checkConversionBigIntToLong(): boolean { } function checkConversionBigIntToDouble(): boolean { - const val = Number(tsBigInt); + const val = Number(tsBigInt).toDouble(); return typeof val == 'number'; } diff --git a/static_core/plugins/ets/tests/interop_js/tests/conversion_types/ts_to_sts/conversion_binary/conversion_binary.ets b/static_core/plugins/ets/tests/interop_js/tests/conversion_types/ts_to_sts/conversion_binary/conversion_binary.ets index e79a754bb58cf9b1f601dc9a5816a8d7a692398a..d9f9bb43f966f7ebfdf71717ec0c44760c293cfc 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/conversion_types/ts_to_sts/conversion_binary/conversion_binary.ets +++ b/static_core/plugins/ets/tests/interop_js/tests/conversion_types/ts_to_sts/conversion_binary/conversion_binary.ets @@ -22,7 +22,7 @@ function checkConversionBinaryToInt(): boolean { } function checkConversionBinaryToNumber(): boolean { - const val = parseInt(tsBinary, systemBinary as int); + const val = parseInt(tsBinary, systemBinary as int).toDouble(); return typeof val == 'number'; } @@ -52,7 +52,7 @@ function checkConversionBinaryToLong(): boolean { } function checkConversionBinaryToDouble(): boolean { - const val = parseInt(tsBinary, systemBinary as int); + const val = parseInt(tsBinary, systemBinary as int).toDouble(); return typeof val == 'number'; } diff --git a/static_core/plugins/ets/tests/interop_js/tests/conversion_types/ts_to_sts/conversion_exponential/conversion_exponential.ets b/static_core/plugins/ets/tests/interop_js/tests/conversion_types/ts_to_sts/conversion_exponential/conversion_exponential.ets index 3149d43b55b88418b2b331346c35685e62b26a00..7c9c32294b8ee36019505ad6fc4f971a0c7ff770 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/conversion_types/ts_to_sts/conversion_exponential/conversion_exponential.ets +++ b/static_core/plugins/ets/tests/interop_js/tests/conversion_types/ts_to_sts/conversion_exponential/conversion_exponential.ets @@ -22,7 +22,7 @@ function checkConversionExponentialToInt(): boolean { } function checkConversionExponentialToNumber(): boolean { - const val = parseInt(tsExponential); + const val = parseInt(tsExponential).toDouble(); return typeof val == 'number'; } @@ -52,7 +52,7 @@ function checkConversionExponentialToLong(): boolean { } function checkConversionExponentialToDouble(): boolean { - const val = parseInt(tsExponential); + const val = parseInt(tsExponential).toDouble(); return typeof val == 'number'; } diff --git a/static_core/plugins/ets/tests/interop_js/tests/conversion_types/ts_to_sts/conversion_hexadecimal/conversion_hexadecimal.ets b/static_core/plugins/ets/tests/interop_js/tests/conversion_types/ts_to_sts/conversion_hexadecimal/conversion_hexadecimal.ets index 9c6c8ebe8e0fea7497a356c247ca713efb29b486..b5367380708137c02cebf35162bad6bef54cb7a5 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/conversion_types/ts_to_sts/conversion_hexadecimal/conversion_hexadecimal.ets +++ b/static_core/plugins/ets/tests/interop_js/tests/conversion_types/ts_to_sts/conversion_hexadecimal/conversion_hexadecimal.ets @@ -22,7 +22,7 @@ function checkConversionHexadecimalToInt(): boolean { } function checkConversionHexadecimalToNumber(): boolean { - const val = parseInt(tsHexadecimal, systemHexadecimal as int); + const val = parseInt(tsHexadecimal, systemHexadecimal as int).toDouble(); return typeof val == 'number'; } @@ -52,7 +52,7 @@ function checkConversionHexadecimalToLong(): boolean { } function checkConversionHexadecimalToDouble(): boolean { - const val = parseInt(tsHexadecimal, systemHexadecimal as int); + const val = parseInt(tsHexadecimal, systemHexadecimal as int).toDouble(); return typeof val == 'number'; } diff --git a/static_core/plugins/ets/tests/interop_js/tests/conversion_types/ts_to_sts/conversion_string_to_int/conversion_string_to_int.ets b/static_core/plugins/ets/tests/interop_js/tests/conversion_types/ts_to_sts/conversion_string_to_int/conversion_string_to_int.ets index d6f5e2e2cb7dfbcca32c61b1f7e252843a9d8710..c301834ce0283f0e22dbeac0709da12e01b1ebb0 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/conversion_types/ts_to_sts/conversion_string_to_int/conversion_string_to_int.ets +++ b/static_core/plugins/ets/tests/interop_js/tests/conversion_types/ts_to_sts/conversion_string_to_int/conversion_string_to_int.ets @@ -22,7 +22,7 @@ function checkConversionStringToInt(): boolean { } function checkConversionStringToNumber(): boolean { - const val = parseInt(tsIntString); + const val = parseInt(tsIntString).toDouble(); return typeof val == 'number'; } @@ -52,7 +52,7 @@ function checkConversionStringToLong(): boolean { } function checkConversionStringToDouble(): boolean { - const val = parseInt(tsIntString); + const val = parseInt(tsIntString).toDouble(); return typeof val == 'number'; } diff --git a/static_core/plugins/ets/tests/interop_js/tests/date/ts_to_ets/test_date.ets b/static_core/plugins/ets/tests/interop_js/tests/date/ts_to_ets/test_date.ets index 747de96d930c74fdf6474a756bf73c0bccfe2223..f16ea7c985defc40157102407621756beb30087e 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/date/ts_to_ets/test_date.ets +++ b/static_core/plugins/ets/tests/interop_js/tests/date/ts_to_ets/test_date.ets @@ -31,35 +31,35 @@ function funDateTypeOf(val: Date) { } function funDateGetFullYear(val: Date) { - return val.getFullYear() === 2025; + return val.getUTCFullYear() === 2025; } function funDateGetMonth(val: Date) { - return val.getMonth() === 3; + return val.getUTCMonth() === 2; } function funDateGetDate(val: Date) { - return val.getDate() === 1; + return val.getUTCDate() === 1; } function funDateGetDay(val: Date) { - return val.getDay() === 6; + return val.getUTCDay() === 6; } function funDateGetHours(val: Date) { - return val.getHours() === 1; + return val.getUTCHours() === 1; } function funDateGetMinutes(val: Date) { - return val.getMinutes() === 2; + return val.getUTCMinutes() === 2; } function funDateGetSeconds(val: Date) { - return val.getSeconds() === 3; + return val.getUTCSeconds() === 3; } function funDateGetMilliseconds(val: Date) { - return val.getMilliseconds() === 0; + return val.getUTCMilliseconds() === 0; } function funDateToISOString(val: Date) { diff --git a/static_core/plugins/ets/tests/interop_js/tests/declgen_ets2ts/basic_var/lib.ets b/static_core/plugins/ets/tests/interop_js/tests/declgen_ets2ts/basic_var/lib.ets index 6830da489e473704bd8e8ca3bd3ab49ec39a5eb0..e7a063df27f52c34af04213896c16bceeced2279 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/declgen_ets2ts/basic_var/lib.ets +++ b/static_core/plugins/ets/tests/interop_js/tests/declgen_ets2ts/basic_var/lib.ets @@ -33,7 +33,7 @@ export const d: int = 1 export const e: long = 1 export const f: float = 1 export const g: double = 1 -export const h: char = "1" +export const h: char = c'1' export const i: boolean = true export const j: string = "1" export const k: bigint = 1n @@ -56,4 +56,4 @@ export type Greeting = "Hello" export let a2: "Hello" = "Hello" export let b2: Greeting = "Hello" -export let a3: Record; \ No newline at end of file +export let a3: Record; diff --git a/static_core/plugins/ets/tests/interop_js/tests/declgen_ets2ts/fields/lib.ets b/static_core/plugins/ets/tests/interop_js/tests/declgen_ets2ts/fields/lib.ets index 1478c7c36e724b39e63e33a4d672b53d92ef397e..8977a10500b2cf639f403b56828736b9d2eefd93 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/declgen_ets2ts/fields/lib.ets +++ b/static_core/plugins/ets/tests/interop_js/tests/declgen_ets2ts/fields/lib.ets @@ -15,7 +15,7 @@ export class Fields { readonly readonlyBoolean_: boolean = true; - public static staticFloat_: float = 0.0; + public static staticFloat_: float = 0.0f; public number_: number = 2.2; public Number_: Number = 3.3; public double_: double = 4.4; @@ -30,4 +30,4 @@ export class Fields { uint32Array_: Uint32Array = new Uint32Array(); public cb = (a: number = 1, b: number = 2, c: number = 3) => {}; }; -Fields.staticFloat_ = 1.1; +Fields.staticFloat_ = 1.1f; diff --git a/static_core/plugins/ets/tests/interop_js/tests/declgen_ets2ts/imports/lib1.expected b/static_core/plugins/ets/tests/interop_js/tests/declgen_ets2ts/imports/lib1.expected index b16c2262dec65bcd1ce23881f1d7fa889eb23134..494b14054b0527d21c18328cc79cf830c413ed04 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/declgen_ets2ts/imports/lib1.expected +++ b/static_core/plugins/ets/tests/interop_js/tests/declgen_ets2ts/imports/lib1.expected @@ -13,7 +13,7 @@ * limitations under the License. */ import * as GG from "./lib2"; -import { Lib2Class, Lib2Class2, EC1 } from "./lib2"; +import { Lib2Class, Lib2Class2, IntAlias, EC1 } from "./lib2"; import { B } from "./lib2"; import { C, D } from "./lib2"; import { E as EE, F } from "./lib2"; @@ -39,8 +39,8 @@ export declare class C1 { public set o1(value: Lib2Class); public get o2(): Lib2Class2; public set o2(value: Lib2Class2); - public get v1(): number; - public set v1(value: number); + public get v1(): IntAlias; + public set v1(value: IntAlias); } export declare class C2 { public get a(): EC1; diff --git a/static_core/plugins/ets/tests/interop_js/tests/generic_call_params/sts_to_ts/generic_call_params.ets b/static_core/plugins/ets/tests/interop_js/tests/generic_call_params/sts_to_ts/generic_call_params.ets index b0888415eaa4330dcbda9a87abeb50910745c447..ce3e4b47489ab86c19eb0cf6caac6a3c73dd49f7 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/generic_call_params/sts_to_ts/generic_call_params.ets +++ b/static_core/plugins/ets/tests/interop_js/tests/generic_call_params/sts_to_ts/generic_call_params.ets @@ -75,10 +75,10 @@ function applyFunctionGenericArray(values: FixedArray, func: (accumulator: return result; } -function applyFunctionGenericArrayCallFromSts(array: FixedArray): int { - - return applyFunctionGenericArray(array, add); -} +// See #25111. FixedArray to FixedArray assignability. +// function applyFunctionGenericArrayCallFromSts(array: FixedArray): int { +// return applyFunctionGenericArray(array, add); +// } // NOTE: issue (18007) primitive constrain // type GNumber = T; diff --git a/static_core/plugins/ets/tests/interop_js/tests/hybridgref/ets_to_ts/ets_hybridgref.ets b/static_core/plugins/ets/tests/interop_js/tests/hybridgref/ets_to_ts/ets_hybridgref.ets index 900fa786588e05e67281acdd83b71103f656fe83..c6b4dd6be902c830faafd4e820ad10f289a4c6be 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/hybridgref/ets_to_ts/ets_hybridgref.ets +++ b/static_core/plugins/ets/tests/interop_js/tests/hybridgref/ets_to_ts/ets_hybridgref.ets @@ -19,7 +19,7 @@ type refType = Object | ESValue; native function saveHybridGref(ref: refType):void; export function etsSaveNativeGrefChar(): void { - let value : char = 'A' + let value : char = c'A' let ref = new Char(value); saveHybridGref(ref); } diff --git a/static_core/plugins/ets/tests/interop_js/tests/indexed_type/indexed_type.ets b/static_core/plugins/ets/tests/interop_js/tests/indexed_type/indexed_type.ets index ac8f3afb09a6a477479f3d81224ff49e3c8b0a8d..a14e2021e4f452d0339366c3ce9b9b4cd323d34f 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/indexed_type/indexed_type.ets +++ b/static_core/plugins/ets/tests/interop_js/tests/indexed_type/indexed_type.ets @@ -30,7 +30,7 @@ function changeArrValueByIndex():boolean{ function checkLengthArr():boolean{ const jsArray:FixedArray = getArray(arr) as FixedArray; - return jsArray.length as number == arr.length + return jsArray.length as number == arr.length.toDouble() } function checkAllArrValue():boolean{ const jsArray:FixedArray = getArray(arr) as FixedArray; @@ -50,7 +50,7 @@ function changeCustomArrValueByIndex():boolean{ } function checkLengthCustomArr():boolean{ const jsArray:FixedArray = returnCustomArray(arr); - return jsArray.length as number == arr.length; + return jsArray.length as number == arr.length.toDouble(); } function checkAllCustomArrValue():boolean{ diff --git a/static_core/plugins/ets/tests/interop_js/tests/interfaces/interface_method_returns_value/js_interface/test.ets b/static_core/plugins/ets/tests/interop_js/tests/interfaces/interface_method_returns_value/js_interface/test.ets index b4c493b18320536f914f87f8706e74165bdfbd25..17da1c6eb6b2578a45db888be231c280015116b2 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/interfaces/interface_method_returns_value/js_interface/test.ets +++ b/static_core/plugins/ets/tests/interop_js/tests/interfaces/interface_method_returns_value/js_interface/test.ets @@ -62,14 +62,16 @@ function type_imported__returnBoolean(){ return typeof getterFn() == "object" && (getterFn() as boolean) == true && (getterFn() as boolean) != false; } +// NOTE: this test uses JS integer value which is longer than 32 bits function type_imported__returnInteger(){ const getterFn: TFunctionReturnsNumber = genericInterfaceImplementation.getInt as TFunctionReturnsNumber; return typeof getterFn() == "object" && (getterFn() as int) > 0 && (getterFn() as int) / 2 == Double.toInt((getterFn() as int) * 0.5); } +// NOTE: this test uses JS integer value which is longer than 32 bit function type_imported__returnNegativeInteger(){ const getterFn: TFunctionReturnsNumber = genericInterfaceImplementation.getNegativeInt; - return typeof getterFn() == "object" && (getterFn() as int) < 0 && (getterFn() as int) * -1 > 0; + return typeof getterFn() == "object" && (getterFn() as long) < 0 && (getterFn() as long) * -1 > 0; } diff --git a/static_core/plugins/ets/tests/interop_js/tests/number_subtypes/number_subtypes.rb b/static_core/plugins/ets/tests/interop_js/tests/number_subtypes/number_subtypes.rb index 701b17b6bf402455de92851536b292baa10a4ab0..0fa1708b90038e2b79a982b9148f8314f6057f82 100755 --- a/static_core/plugins/ets/tests/interop_js/tests/number_subtypes/number_subtypes.rb +++ b/static_core/plugins/ets/tests/interop_js/tests/number_subtypes/number_subtypes.rb @@ -13,8 +13,8 @@ # limitations under the License. class NumberTypeDescription - def initialize(name, min, max, sum) - @name, @min, @max, @sum = name, min, max, sum + def initialize(name, min, max, sum, suffix) + @name, @min, @max, @sum, @suffix = name, min, max, sum, suffix end def getName @@ -32,20 +32,24 @@ class NumberTypeDescription def getSum @sum end + + def getSuffix + @suffix + end end @integral_primitives = [ - NumberTypeDescription.new("byte", -128, 127, -128 + 127), - NumberTypeDescription.new("short", -32768, 32767, -32768 + 32767), - NumberTypeDescription.new("int", -2147483648, 2147483647, -2147483648 + 2147483647), + NumberTypeDescription.new("byte", -128, 127, -128 + 127, ""), + NumberTypeDescription.new("short", -32768, 32767, -32768 + 32767, ""), + NumberTypeDescription.new("int", -2147483648, 2147483647, -2147483648 + 2147483647, ""), # double-long precision loss # NumberTypeDescription.new("long", -9223372036854775808, 9223372036854775, 0), - NumberTypeDescription.new("long", -9223372036854775, 9223372036854775, -9223372036854775 + 9223372036854775), + NumberTypeDescription.new("long", -9223372036854775, 9223372036854775, -9223372036854775 + 9223372036854775, ""), # char will map to string when pass to dynamic world # NumberTypeDescription.new("char", 0, 65535, 0 + 65535), ] @float_primitives = [ - NumberTypeDescription.new("float", 0.111, 2.71, 0.111 + 2.71), - NumberTypeDescription.new("double", 0.01, 3.14, 0.01 + 3.14), + NumberTypeDescription.new("float", 0.111, 2.71, 0.111 + 2.71, "f"), + NumberTypeDescription.new("double", 0.01, 3.14, 0.01 + 3.14, ""), ] diff --git a/static_core/plugins/ets/tests/interop_js/tests/number_subtypes/ts_to_sts/number_subtypes.ets.erb b/static_core/plugins/ets/tests/interop_js/tests/number_subtypes/ts_to_sts/number_subtypes.ets.erb index a3de4f053824348a065e7cb95753399db90fda7b..bc4f1584e4646ef3440c6e1437a7af2af6de26f2 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/number_subtypes/ts_to_sts/number_subtypes.ets.erb +++ b/static_core/plugins/ets/tests/interop_js/tests/number_subtypes/ts_to_sts/number_subtypes.ets.erb @@ -33,8 +33,8 @@ class jsnew { % @integral_primitives.each do |primitive| function jscall<%= primitive.getName.capitalize() %>(): int { - let v0: <%= primitive.getName.capitalize() %> = <%= primitive.getMin() %>; - let v1: <%= primitive.getName.capitalize() %> = <%= primitive.getMax() %>; + let v0: <%= primitive.getName.capitalize() %> = <%= primitive.getMin() %><%= primitive.getSuffix() %>; + let v1: <%= primitive.getName.capitalize() %> = <%= primitive.getMax() %><%= primitive.getSuffix() %>; let res = jscall.num$(jsvars.m, ".evaluateNumber", v0, v1); if (res == <%= primitive.getSum() %>) { return 0; @@ -44,8 +44,8 @@ function jscall<%= primitive.getName.capitalize() %>(): int { } function jsnewGetProperty<%= primitive.getName.capitalize() %>(): int { - let v0: <%= primitive.getName.capitalize() %> = <%= primitive.getMin() %>; - let v1: <%= primitive.getName.capitalize() %> = <%= primitive.getMax() %>;; + let v0: <%= primitive.getName.capitalize() %> = <%= primitive.getMin() %><%= primitive.getSuffix() %>; + let v1: <%= primitive.getName.capitalize() %> = <%= primitive.getMax() %><%= primitive.getSuffix() %>;; let res_obj = jsnew.$(jsvars.m, ".ExampleClass", v0, v1); let res_get_v0 = JSRuntime.getPropertyDouble(res_obj, "v0"); let res_get_v1 = JSRuntime.getPropertyDouble(res_obj, "v1"); @@ -58,8 +58,8 @@ function jsnewGetProperty<%= primitive.getName.capitalize() %>(): int { } function jsnewSetProperty<%= primitive.getName.capitalize() %>(): int { - let v0: <%= primitive.getName.capitalize() %> = <%= primitive.getMin() %>; - let v1: <%= primitive.getName.capitalize() %> = <%= primitive.getMax() %>;; + let v0: <%= primitive.getName.capitalize() %> = <%= primitive.getMin() %><%= primitive.getSuffix() %>; + let v1: <%= primitive.getName.capitalize() %> = <%= primitive.getMax() %><%= primitive.getSuffix() %>;; let res_obj = jsnew.$(jsvars.m, ".ClassWithEmptyConstructor"); JSRuntime.setPropertyDouble(res_obj, "v0", v0); JSRuntime.setPropertyDouble(res_obj, "v1", v1); @@ -80,8 +80,8 @@ function jsnewSetProperty<%= primitive.getName.capitalize() %>(): int { } function jscallStaticMethod<%= primitive.getName.capitalize() %>(): int { - let v0: <%= primitive.getName %> = <%= primitive.getMin() %>; - let v1: <%= primitive.getName %> = <%= primitive.getMax() %>; + let v0: <%= primitive.getName %> = <%= primitive.getMin() %><%= primitive.getSuffix() %>; + let v1: <%= primitive.getName %> = <%= primitive.getMax() %><%= primitive.getSuffix() %>; let res = jscall.num$(jsvars.m, ".ExampleClass.evaluateNumber", v0, v1); if (res == <%= primitive.getSum() %>) { return 0; @@ -94,8 +94,8 @@ function jscallStaticMethod<%= primitive.getName.capitalize() %>(): int { % @float_primitives.each do |primitive| function jscall<%= primitive.getName.capitalize() %>(): int { - let v0: <%= primitive.getName %> = <%= primitive.getMin() %>; - let v1: <%= primitive.getName %> = <%= primitive.getMax() %>; + let v0: <%= primitive.getName %> = <%= primitive.getMin() %><%= primitive.getSuffix() %>; + let v1: <%= primitive.getName %> = <%= primitive.getMax() %><%= primitive.getSuffix() %>; let res = jscall.num$(jsvars.m, ".ExampleClass.evaluateNumber", v0, v1); if (abs(res - <%= primitive.getSum() %>) < 0.000001) { return 0; @@ -105,8 +105,8 @@ function jscall<%= primitive.getName.capitalize() %>(): int { } function jsnewGetProperty<%= primitive.getName.capitalize() %>(): int { - let v0: <%= primitive.getName %> = <%= primitive.getMin() %>; - let v1: <%= primitive.getName %> = <%= primitive.getMax() %>;; + let v0: <%= primitive.getName %> = <%= primitive.getMin() %><%= primitive.getSuffix() %>; + let v1: <%= primitive.getName %> = <%= primitive.getMax() %><%= primitive.getSuffix() %>;; let res_obj = jsnew.$(jsvars.m, ".ExampleClass", v0, v1); let res_get_v0 = JSRuntime.getPropertyDouble(res_obj, "v0"); let res_get_v1 = JSRuntime.getPropertyDouble(res_obj, "v1"); @@ -120,8 +120,8 @@ function jsnewGetProperty<%= primitive.getName.capitalize() %>(): int { function jsnewSetProperty<%= primitive.getName.capitalize() %>(): int { let v0: <%= primitive.getName - %> = <%= primitive.getMin() %>; - let v1: <%= primitive.getName %> = <%= primitive.getMax() %>;; + %> = <%= primitive.getMin() %><%= primitive.getSuffix() %>; + let v1: <%= primitive.getName %> = <%= primitive.getMax() %><%= primitive.getSuffix() %>;; let res_obj = jsnew.$(jsvars.m, ".ClassWithEmptyConstructor"); JSRuntime.setPropertyDouble(res_obj, "v0", v0); JSRuntime.setPropertyDouble(res_obj, "v1", v1); @@ -136,8 +136,8 @@ function jsnewSetProperty<%= primitive.getName.capitalize() %>(): int { } function jscallStaticMethod<%= primitive.getName.capitalize() %>(): int { - let v0: <%= primitive.getName %> = <%= primitive.getMin() %>; - let v1: <%= primitive.getName %> = <%= primitive.getMax() %>; + let v0: <%= primitive.getName %> = <%= primitive.getMin() %><%= primitive.getSuffix() %>; + let v1: <%= primitive.getName %> = <%= primitive.getMax() %><%= primitive.getSuffix() %>; let res = jscall.num$(jsvars.m, ".ExampleClass.evaluateNumber", v0, v1); if (abs(res - <%= primitive.getSum() %>) < 0.000001) { return 0; diff --git a/static_core/plugins/ets/tests/interop_js/tests/number_subtypes/ts_to_sts_frontend/number_subtypes_frontend.ets.erb b/static_core/plugins/ets/tests/interop_js/tests/number_subtypes/ts_to_sts_frontend/number_subtypes_frontend.ets.erb index e406fd998ee1f31c5de0c28b87b57ac6c4215cef..0960c002f95c7915c267bfd06da9b332dd1812c6 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/number_subtypes/ts_to_sts_frontend/number_subtypes_frontend.ets.erb +++ b/static_core/plugins/ets/tests/interop_js/tests/number_subtypes/ts_to_sts_frontend/number_subtypes_frontend.ets.erb @@ -57,8 +57,8 @@ import { % @integral_primitives.each do |primitive| function jscall<%= primitive.getName.capitalize() %>(): int { - let v0: <%= primitive.getName %> = <%= primitive.getMin() %>; - let v1: <%= primitive.getName %> = <%= primitive.getMax() %>; + let v0: <%= primitive.getName %> = <%= primitive.getMin() %><%= primitive.getSuffix() %>; + let v1: <%= primitive.getName %> = <%= primitive.getMax() %><%= primitive.getSuffix() %>; let res = evaluateNumber(v0, v1) as double; if (res == <%= primitive.getSum() %>) { return 0; @@ -68,8 +68,8 @@ function jscall<%= primitive.getName.capitalize() %>(): int { } function jsnewGetProperty<%= primitive.getName.capitalize() %>(): int { - let v0: <%= primitive.getName %> = <%= primitive.getMin() %>; - let v1: <%= primitive.getName %> = <%= primitive.getMax() %>; + let v0: <%= primitive.getName %> = <%= primitive.getMin() %><%= primitive.getSuffix() %>; + let v1: <%= primitive.getName %> = <%= primitive.getMax() %><%= primitive.getSuffix() %>; let res_obj = new ExampleClass(v0, v1); let res_get_v0 = res_obj.v0 as double; let res_get_v1 = res_obj.v1 as double; @@ -82,8 +82,8 @@ function jsnewGetProperty<%= primitive.getName.capitalize() %>(): int { } function jsnewSetProperty<%= primitive.getName.capitalize() %>(): int { - let v0: <%= primitive.getName %> = <%= primitive.getMin() %>; - let v1: <%= primitive.getName %> = <%= primitive.getMax() %>; + let v0: <%= primitive.getName %> = <%= primitive.getMin() %><%= primitive.getSuffix() %>; + let v1: <%= primitive.getName %> = <%= primitive.getMax() %><%= primitive.getSuffix() %>; let res_obj = new ClassWithEmptyConstructor(); res_obj.v0 = v0; res_obj.v1 = v1; @@ -105,8 +105,8 @@ function jsnewSetProperty<%= primitive.getName.capitalize() %>(): int { } function jscallStaticMethod<%= primitive.getName.capitalize() %>(): int { - let v0: <%= primitive.getName %> = <%= primitive.getMin() %>; - let v1: <%= primitive.getName %> = <%= primitive.getMax() %>; + let v0: <%= primitive.getName %> = <%= primitive.getMin() %><%= primitive.getSuffix() %>; + let v1: <%= primitive.getName %> = <%= primitive.getMax() %><%= primitive.getSuffix() %>; let res = ExampleClass.evaluateNumber(v0, v1) as double; if (res == <%= primitive.getSum() %>) { return 0; @@ -119,8 +119,8 @@ function jscallStaticMethod<%= primitive.getName.capitalize() %>(): int { % @float_primitives.each do |primitive| function jscall<%= primitive.getName.capitalize() %>(): int { - let v0: <%= primitive.getName %> = <%= primitive.getMin() %>; - let v1: <%= primitive.getName %> = <%= primitive.getMax() %>; + let v0: <%= primitive.getName %> = <%= primitive.getMin() %><%= primitive.getSuffix() %>; + let v1: <%= primitive.getName %> = <%= primitive.getMax() %><%= primitive.getSuffix() %>; let res = ExampleClass.evaluateNumber(v0, v1) as double; if (abs(res - <%= primitive.getSum() %>) < 0.000001) { return 0; @@ -130,8 +130,8 @@ function jscall<%= primitive.getName.capitalize() %>(): int { } function jsnewGetProperty<%= primitive.getName.capitalize() %>(): int { - let v0: <%= primitive.getName %> = <%= primitive.getMin() %>; - let v1: <%= primitive.getName %> = <%= primitive.getMax() %>; + let v0: <%= primitive.getName %> = <%= primitive.getMin() %><%= primitive.getSuffix() %>; + let v1: <%= primitive.getName %> = <%= primitive.getMax() %><%= primitive.getSuffix() %>; let res_obj = new ExampleClass(v0, v1); let res_get_v0 = res_obj.v0 as double; let res_get_v1 = res_obj.v1 as double; @@ -144,8 +144,8 @@ function jsnewGetProperty<%= primitive.getName.capitalize() %>(): int { } function jsnewSetProperty<%= primitive.getName.capitalize() %>(): int { - let v0: <%= primitive.getName %> = <%= primitive.getMin() %>; - let v1: <%= primitive.getName %> = <%= primitive.getMax() %>; + let v0: <%= primitive.getName %> = <%= primitive.getMin() %><%= primitive.getSuffix() %>; + let v1: <%= primitive.getName %> = <%= primitive.getMax() %><%= primitive.getSuffix() %>; let res_obj = new ClassWithEmptyConstructor(); res_obj.v0 = v0; res_obj.v1 = v1; @@ -160,8 +160,8 @@ function jsnewSetProperty<%= primitive.getName.capitalize() %>(): int { } function jscallStaticMethod<%= primitive.getName.capitalize() %>(): int { - let v0: <%= primitive.getName %> = <%= primitive.getMin() %>; - let v1: <%= primitive.getName %> = <%= primitive.getMax() %>; + let v0: <%= primitive.getName %> = <%= primitive.getMin() %><%= primitive.getSuffix() %>; + let v1: <%= primitive.getName %> = <%= primitive.getMax() %><%= primitive.getSuffix() %>; let res = ExampleClass.evaluateNumber(v0, v1) as double; if (abs(res - <%= primitive.getSum() %>) < 0.000001) { return 0; diff --git a/static_core/plugins/ets/tests/interop_js/tests/promise/promise_tests.ets b/static_core/plugins/ets/tests/interop_js/tests/promise/promise_tests.ets index 1a325b63b75c42f956025da265166bc95ff70bcf..54c025f8fddfb255102ea05edcbd11bf073b6e39 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/promise/promise_tests.ets +++ b/static_core/plugins/ets/tests/interop_js/tests/promise/promise_tests.ets @@ -478,7 +478,7 @@ async function testAsyncLong(): Promise { } async function testAsyncFloat(): Promise { - let x: float = 3.14; + let x: float = 3.14f; return x; } 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 5234c757b18055537f5d57f3de2f5f01d22f178b..94fc769a9b9e8a95462a3becce1f3af35870066c 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 @@ -66,7 +66,7 @@ function functionReturnBoxedDouble(): Double { } function functionReturnBoxedChar(): Char { - let stsChar: Char = new Char('a'); + let stsChar: Char = new Char(c'a'); return stsChar; } 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 76fb2b0949bee9d8c02101b094b45742e604a31f..7765674202e617c4bb62bd6ef6faa1f833ede102 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 @@ -30,7 +30,6 @@ import { singleRequired, } from "decl_js" - function testOptionals() { // #22991 // let x = optionalCall(123, 321, 5) diff --git a/static_core/plugins/ets/tests/interop_js/tests/test_esvalue2/esvalue_def_test.ets b/static_core/plugins/ets/tests/interop_js/tests/test_esvalue2/esvalue_def_test.ets index ccb6b59562b804910f31cc7cb61f76aa8aa1dc9d..6b2dced0d34d8699b3d78c840bb4d95925e40321 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/test_esvalue2/esvalue_def_test.ets +++ b/static_core/plugins/ets/tests/interop_js/tests/test_esvalue2/esvalue_def_test.ets @@ -298,11 +298,11 @@ function checkSetPropertyByIndex(): boolean { // setProperty(property: ESValue, value: ESValue): void function checkSetProperty(): boolean { - let value = ESValue.wrapNumber(5); + let value = ESValue.wrapNumber(8); let property = ESValue.wrapString("property1"); jsObjectA.setProperty(property, value); let val = jsObjectA.getProperty(property); - return val.toNumber() == 5; + return val.toNumber() == 8; } // hasProperty(property: ESValue): boolean diff --git a/static_core/plugins/ets/tests/mock/AccessingObjectsFieldsTest.ets b/static_core/plugins/ets/tests/mock/AccessingObjectsFieldsTest.ets index 36cc5850c32386fe019c4e7fa10abdfffc91c094..2e470fb29d9407904a5205923b4016dfae88b63f 100644 --- a/static_core/plugins/ets/tests/mock/AccessingObjectsFieldsTest.ets +++ b/static_core/plugins/ets/tests/mock/AccessingObjectsFieldsTest.ets @@ -38,7 +38,7 @@ class F { this.member3 = 4; this.member4 = 5; this.member5 = 6; - this.member6 = 7.0; + this.member6 = 7.0f; this.member7 = 8.0; this.member8 = new A; } diff --git a/static_core/plugins/ets/tests/mock/CallingMethodsTest.ets b/static_core/plugins/ets/tests/mock/CallingMethodsTest.ets index a06f713d0b6ff20ec4f16b053e8236238bf01183..16638bc6c183a36c970062fb5c70edb379dac688 100644 --- a/static_core/plugins/ets/tests/mock/CallingMethodsTest.ets +++ b/static_core/plugins/ets/tests/mock/CallingMethodsTest.ets @@ -60,7 +60,7 @@ class C { public float_method(a: float, b: int): float { - return 0.0; + return 0.0f; } public double_method(a: double, b: int): double @@ -118,7 +118,7 @@ final class D extends C { public override float_method(a: float, b: int): float { - return 1.0; + return 1.0f; } public override double_method(a: double, b: int): double diff --git a/static_core/plugins/ets/tests/mock/FinalFieldNativeTest.ets b/static_core/plugins/ets/tests/mock/FinalFieldNativeTest.ets index 1677e6d15dbb27abc7fefac787c4bc6e47f6ae5f..9f3ed50cdd627d092cdc67d5e7b0c83b0ed145e4 100644 --- a/static_core/plugins/ets/tests/mock/FinalFieldNativeTest.ets +++ b/static_core/plugins/ets/tests/mock/FinalFieldNativeTest.ets @@ -20,7 +20,7 @@ class FinalFieldNativeTest { public static char_value_final: char = 32767; public static int_value_final: int = 65536; public static long_value_final: long = 4294967296; - public static float_value_final: float = 1.0; + public static float_value_final: float = 1.0f; public static double_value_final: double = 2.0; public static string_value_final: String = "abc"; -} \ No newline at end of file +} diff --git a/static_core/plugins/ets/tests/native/array_buffer/ManagedTest.ets b/static_core/plugins/ets/tests/native/array_buffer/ManagedTest.ets index 7e0439ba7c44c69cc4803c26488ca61e2fcc9988..79f6c4e416572c27d6a3e78e5a09bbe3b5bbe8ec 100644 --- a/static_core/plugins/ets/tests/native/array_buffer/ManagedTest.ets +++ b/static_core/plugins/ets/tests/native/array_buffer/ManagedTest.ets @@ -24,11 +24,11 @@ export function createSlicedArrayBuffer(buff: ArrayBuffer, begin: int, end: int) } export function getLength(buff: ArrayBuffer): int { - return buff.byteLength as int; + return buff.byteLength.toInt(); } export function getByte(buff: ArrayBuffer, idx: int): int { - return buff.at(idx) as int; + return buff.at(idx).toInt(); } export function setByte(buff: ArrayBuffer, idx: int, val: byte): int { diff --git a/static_core/plugins/ets/tests/runtime/types/typed_arrays_test.cpp b/static_core/plugins/ets/tests/runtime/types/typed_arrays_test.cpp index 1a149e5a18b266a255398b4a165e6448292898a0..f53cb21e43eef68493c6408f3b7e55cea84a007b 100644 --- a/static_core/plugins/ets/tests/runtime/types/typed_arrays_test.cpp +++ b/static_core/plugins/ets/tests/runtime/types/typed_arrays_test.cpp @@ -19,6 +19,7 @@ #include "types/ets_class.h" #include "types/ets_arraybuffer.h" +#include "types/ets_typed_arrays.h" #include "tests/runtime/types/ets_test_mirror_classes.h" #include "cross_values.h" diff --git a/static_core/plugins/ets/tests/stdlib-templates/escompat/escompat_Array_methods.ets b/static_core/plugins/ets/tests/stdlib-templates/escompat/escompat_Array_methods.ets index 534a1b6b381fb38e2a9a5f130780385a9e81e0f6..08031d0955216eb1e78f20ba14b31544f732b3d6 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/escompat/escompat_Array_methods.ets +++ b/static_core/plugins/ets/tests/stdlib-templates/escompat/escompat_Array_methods.ets @@ -159,7 +159,7 @@ function testReverse(): int { let l = src.length for (let i = 0; i < l; i++) { - if (src.at(i as int) == source[l-i-1 as int]) continue + if (src.at(i.toInt()) == source[l-i-1]) continue console.println("Bad data after reverse") return FAILURE } @@ -174,7 +174,7 @@ function testToReversed(): int { let l = reversed.length for (let i = 0; i < l; i++) { - if (reversed.at(i as int) == source[l-i-1 as int]) continue + if (reversed.at(i.toInt()) == source[l-i-1]) continue console.println("Bad data after reverse") return FAILURE } diff --git a/static_core/plugins/ets/tests/stdlib-templates/escompat/escompat_Array_modifications.ets b/static_core/plugins/ets/tests/stdlib-templates/escompat/escompat_Array_modifications.ets index ec33d6f156941cabe129ec98117c105820443aaf..980969c71a7a9aa49474dff30c9f7214297a92bb 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/escompat/escompat_Array_modifications.ets +++ b/static_core/plugins/ets/tests/stdlib-templates/escompat/escompat_Array_modifications.ets @@ -98,7 +98,7 @@ function testPop(): int { return FAILURE } - if (popped != source[length as int] as Object) { + if (popped != source[length] as Object) { console.println("Unexpected value returned at pop") return FAILURE } diff --git a/static_core/plugins/ets/tests/stdlib-templates/escompat/escompat_Array_single.ets b/static_core/plugins/ets/tests/stdlib-templates/escompat/escompat_Array_single.ets index a25b5acbee193aaf008bc8f906a4754e3397555e..e852b8260fc1f3c481e749716f99c3e5e8924945 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/escompat/escompat_Array_single.ets +++ b/static_core/plugins/ets/tests/stdlib-templates/escompat/escompat_Array_single.ets @@ -39,7 +39,7 @@ function testCreateFromString(): int { for(let i: int = 0; i < src.length; i++) { let cc: char = src.charAt(i); - let ac: char = (test[i] as Object as String).charAt(0); + let ac: char = test[i].charAt(0); if(ac == cc) continue; console.println("Array data mismatch"); return 1; @@ -58,7 +58,7 @@ function testCreateFromString1(): int { let exp: String = "hello"; for (let i: int = 0; i < exp.length; i++) { - let tmp: String = test[i] as Object as String; // <- verifier fails otherwise + let tmp: String = test[i]; // <- verifier fails otherwise let ac: char = tmp.charAt(0); let cc: char = exp.charAt(i); @@ -71,13 +71,13 @@ function testCreateFromString1(): int { function testCreateFromString2(): int { let src: String = "Hello"; - let test = Array.from(src, (v: String, k: number): Int => { return k as Int; }); + let test = Array.from(src, (v: String, k: number): Int => { return k.toInt(); }); if(test.length != src.length) { console.println("Array size mismatch"); return 1; } for(let i: int = 0; i < src.length; i++) { - let av: Int = test[i] as Object as Int; // <- verifier fails otherwise + let av: Int = (test[i] as Object) as Int; // <- verifier fails otherwise if(av == i) continue; console.println("Array data mismatch"); return 1; @@ -97,7 +97,7 @@ function testFiltered(): int { } for(let i: int = 0; i < exp.length; i++) { - let ac: char = (test[i] as Object as String).charAt(0); + let ac: char = test[i].charAt(0); let cc: char = exp.charAt(i); if(ac == cc) continue; diff --git a/static_core/plugins/ets/tests/stdlib-templates/regression/list.issue14385.yaml b/static_core/plugins/ets/tests/stdlib-templates/regression/list.issue14385.yaml index eaf2b518dd19134610860b9ec98b98313568fe1c..3e82c1b2503f93b176783e722f1a3fb8292573c9 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/regression/list.issue14385.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/regression/list.issue14385.yaml @@ -29,7 +29,7 @@ } - { "type": "float", - "value": 42.0 + "value": 42.0f } - { "type": "double", diff --git a/static_core/plugins/ets/tests/stdlib-templates/spec/expressions/compound_assignment_01.ets b/static_core/plugins/ets/tests/stdlib-templates/spec/expressions/compound_assignment_01.ets index e97c1d746ca06d3ad558c89937f2cd1fa2b93dba..2aa32a3305f63105c905bcb850a1e0e6adf6cc66 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/spec/expressions/compound_assignment_01.ets +++ b/static_core/plugins/ets/tests/stdlib-templates/spec/expressions/compound_assignment_01.ets @@ -16,7 +16,7 @@ {% for item in compound_assignment_01 %} /*--- -desc: {function: {{.item.type1}}_{{.item.op_name}}_{{.item.type2}}} +desc: {function: {{.item.type1|lower}}_{{.item.op_name}}_{{.item.type2|lower}}} tags: [] ---*/ @@ -30,8 +30,10 @@ function foo(count: {{.item.type2}}): EasingCurve { } function main(): void { - let curve: EasingCurve = foo({{.item.value2}} as {{.item.type2}}) - let value = curve({{.item.value1}} as {{.item.type1}}) + let val1: {{.item.type2}} = {{.item.value2}} + let val2: {{.item.type1}} = {{.item.value1}} + let curve: EasingCurve = foo(val1) + let value = curve(val2) assertEQ(value {{.item.casting}}, {{.item.result}}, "value = " + value) } diff --git a/static_core/plugins/ets/tests/stdlib-templates/spec/expressions/compound_assignment_02.ets b/static_core/plugins/ets/tests/stdlib-templates/spec/expressions/compound_assignment_02.ets index 4634dd163ec8a7ba1d6269afa7029c3ffbbc5c45..8b40cc09db12ebb4ef275f08ab1d7d433f743650 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/spec/expressions/compound_assignment_02.ets +++ b/static_core/plugins/ets/tests/stdlib-templates/spec/expressions/compound_assignment_02.ets @@ -16,13 +16,13 @@ {% for item in compound_assignment_01 %} /*--- -desc: {function: only_main_{{.item.type1}}_{{.item.op_name}}_{{.item.type2}}} +desc: {function: only_main_{{.item.type1|lower}}_{{.item.op_name}}_{{.item.type2|lower}}} tags: [] ---*/ function main(): void { - let count: {{.item.type2}} = {{.item.value2}} as {{.item.type2}} - let value: {{.item.type1}} = {{.item.value1}} as {{.item.type1}} + let count: {{.item.type2}} = {{.item.value2}} + let value: {{.item.type1}} = {{.item.value1}} value {{.item.operation}}= count assertEQ(value {{.item.casting}}, {{.item.result}}, "value = " + value) } diff --git a/static_core/plugins/ets/tests/stdlib-templates/spec/expressions/compound_assignment_03.ets b/static_core/plugins/ets/tests/stdlib-templates/spec/expressions/compound_assignment_03.ets index 53223ddf33569a14abe8a8b0269f111aa6d38d84..6beecc6fa30d5b61c71174ad19ec7ff23109f95d 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/spec/expressions/compound_assignment_03.ets +++ b/static_core/plugins/ets/tests/stdlib-templates/spec/expressions/compound_assignment_03.ets @@ -16,7 +16,7 @@ {% for item in compound_assignment_01 %} /*--- -desc: {function: simple_assign_{{.item.type1}}_{{.item.op_name}}_{{.item.type2}}} +desc: {function: simple_assign_{{.item.type1|lower}}_{{.item.op_name}}_{{.item.type2|lower}}} tags: [] ---*/ @@ -24,7 +24,7 @@ type EasingCurve = (value: {{.item.type1}}) => {{.item.type1}} function foo(count: {{.item.type2}}): EasingCurve { return (value: {{.item.type1}}) => { - value = (value {{.item.operation}} count) as {{.item.type1}} + value = (value {{.item.operation}} count).to{{.item.type1}}() return value } } diff --git a/static_core/plugins/ets/tests/stdlib-templates/spec/expressions/compound_assignment_04.ets b/static_core/plugins/ets/tests/stdlib-templates/spec/expressions/compound_assignment_04.ets index 734f7a52020b753456cbefcef446bbfb4b84286a..9e279d8d8103f2a45c428524c153f1e6ff974fdb 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/spec/expressions/compound_assignment_04.ets +++ b/static_core/plugins/ets/tests/stdlib-templates/spec/expressions/compound_assignment_04.ets @@ -16,15 +16,15 @@ {% for item in compound_assignment_01 %} /*--- -desc: {function: only_main_simple_{{.item.type1}}_{{.item.op_name}}_{{.item.type2}}} +desc: {function: only_main_simple_{{.item.type1|lower}}_{{.item.op_name}}_{{.item.type2|lower}}} tags: [] ---*/ function main(): void { - let count: {{.item.type2}} = {{.item.value2}} as {{.item.type2}} - let value: {{.item.type1}} = {{.item.value1}} as {{.item.type1}} - value = (value {{.item.operation}} count) as {{.item.type1}} - assertEQ(value {{.item.casting}}, {{.item.result}}, "value = " + value) + let count: {{.item.type2}} = {{.item.value2}} + let value: {{.item.type1}} = {{.item.value1}} + value = (value {{.item.operation}} count).to{{.item.type1}}() + assertEQ(value{{.item.casting}}, {{.item.result}}, "value = " + value) } {%- endfor %} diff --git a/static_core/plugins/ets/tests/stdlib-templates/spec/expressions/list.compound_assignment_01.yaml b/static_core/plugins/ets/tests/stdlib-templates/spec/expressions/list.compound_assignment_01.yaml index e16577d56897796e57bbea8c55801473fa2f9877..bd1b1b23d46e7dfb5becccfa032cd2efb964a5ca 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/spec/expressions/list.compound_assignment_01.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/spec/expressions/list.compound_assignment_01.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 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 @@ -11,351 +11,260 @@ # See the License for the specific language governing permissions and # limitations under the License. -# (mult) XXX to float +# (mult) XXX to Float - { - type1: "float", value1: "10.0", - type2: "float", value2: "2.3", + type1: "Float", value1: "10.0f", + type2: "Float", value2: "2.3f", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "23" } - { - type1: "double", value1: "10.0", - type2: "float", value2: "2.3", + type1: "Double", value1: "10.0", + type2: "Float", value2: "2.3f", operation: "*", op_name: "mult", result: "22.999999523162842" } - { - type1: "number", value1: "10.0", - type2: "float", value2: "2.3", + type1: "Long", value1: "10", + type2: "Float", value2: "2.3f", operation: "*", op_name: "mult", - result: "22.999999523162842" - } -- { - type1: "long", value1: "10", - type2: "float", value2: "2.3", - operation: "*", op_name: "mult", - casting: "as int", - result: "23" - } -- { - type1: "int", value1: "10", - type2: "float", value2: "2.3", - operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "23" } - { - type1: "short", value1: "10", - type2: "float", value2: "2.3", + type1: "Int", value1: "10", + type2: "Float", value2: "2.3f", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "23" } - { - type1: "byte", value1: "10", - type2: "float", value2: "2.3", + type1: "Short", value1: "10", + type2: "Float", value2: "2.3f", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "23" } -# (mult) XXX to double - { - type1: "float", value1: "10.0", - type2: "double", value2: "2.3", + type1: "Byte", value1: "10", + type2: "Float", value2: "2.3f", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "23" } +# (mult) XXX to Double - { - type1: "double", value1: "10.0", - type2: "double", value2: "2.3", + type1: "Float", value1: "10.0f", + type2: "Double", value2: "2.3", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "23" } - { - type1: "number", value1: "10.0", - type2: "double", value2: "2.3", + type1: "Double", value1: "10.0", + type2: "Double", value2: "2.3", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "23" } - { - type1: "long", value1: "10", - type2: "double", value2: "2.3", + type1: "Long", value1: "10", + type2: "Double", value2: "2.3", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "23" } - { - type1: "int", value1: "10", - type2: "double", value2: "2.3", + type1: "Int", value1: "10", + type2: "Double", value2: "2.3", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "23" } - { - type1: "short", value1: "10", - type2: "double", value2: "2.3", + type1: "Short", value1: "10", + type2: "Double", value2: "2.3", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "23" } - { - type1: "byte", value1: "10", - type2: "double", value2: "2.3", + type1: "Byte", value1: "10", + type2: "Double", value2: "2.3", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "23" } -# (mult) XXX to long +# (mult) XXX to Long - { - type1: "float", value1: "10.0", - type2: "long", value2: "23", + type1: "Float", value1: "10.0f", + type2: "Long", value2: "23", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "230" } - { - type1: "double", value1: "10.0", - type2: "long", value2: "23", + type1: "Double", value1: "10.0", + type2: "Long", value2: "23", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "230" } - { - type1: "number", value1: "10.0", - type2: "long", value2: "23", + type1: "Long", value1: "10", + type2: "Long", value2: "23", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "230" } - { - type1: "long", value1: "10", - type2: "long", value2: "23", + type1: "Int", value1: "10", + type2: "Long", value2: "23", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "230" } - { - type1: "int", value1: "10", - type2: "long", value2: "23", + type1: "Short", value1: "10", + type2: "Long", value2: "23", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "230" } - { - type1: "short", value1: "10", - type2: "long", value2: "23", + type1: "Byte", value1: "4", + type2: "Long", value2: "23", operation: "*", op_name: "mult", - casting: "as int", - result: "230" - } -- { - type1: "byte", value1: "4", - type2: "long", value2: "23", - operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "92" } -# (mult) XXX to int -- { - type1: "float", value1: "10.0", - type2: "int", value2: "23", - operation: "*", op_name: "mult", - casting: "as int", - result: "230" -} +# (mult) XXX to Int - { - type1: "double", value1: "10.0", - type2: "int", value2: "23", + type1: "Float", value1: "10.0f", + type2: "Int", value2: "23", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "230" -} + } - { - type1: "number", value1: "10.0", - type2: "int", value2: "23", + type1: "Double", value1: "10.0", + type2: "Int", value2: "23", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "230" -} + } - { - type1: "long", value1: "10", - type2: "int", value2: "23", + type1: "Long", value1: "10", + type2: "Int", value2: "23", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "230" -} + } - { - type1: "int", value1: "10", - type2: "int", value2: "23", + type1: "Int", value1: "10", + type2: "Int", value2: "23", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "230" -} + } - { - type1: "short", value1: "10", - type2: "int", value2: "23", + type1: "Short", value1: "10", + type2: "Int", value2: "23", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "230" -} + } - { - type1: "byte", value1: "4", - type2: "int", value2: "23", + type1: "Byte", value1: "4", + type2: "Int", value2: "23", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "92" -} -# (mult) XXX to short -- { - type1: "float", value1: "10.0", - type2: "short", value2: "23", - operation: "*", op_name: "mult", - casting: "as int", - result: "230" -} + } +# (mult) XXX to Short - { - type1: "double", value1: "10.0", - type2: "short", value2: "23", + type1: "Float", value1: "10.0f", + type2: "Short", value2: "23", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "230" -} + } - { - type1: "number", value1: "10.0", - type2: "short", value2: "23", + type1: "Double", value1: "10.0", + type2: "Short", value2: "23", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "230" -} + } - { - type1: "long", value1: "10", - type2: "short", value2: "23", + type1: "Long", value1: "10", + type2: "Short", value2: "23", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "230" -} + } - { - type1: "int", value1: "10", - type2: "short", value2: "23", + type1: "Int", value1: "10", + type2: "Short", value2: "23", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "230" -} + } - { - type1: "short", value1: "10", - type2: "short", value2: "23", + type1: "Short", value1: "10", + type2: "Short", value2: "23", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "230" -} + } - { - type1: "byte", value1: "4", - type2: "short", value2: "23", + type1: "Byte", value1: "4", + type2: "Short", value2: "23", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "92" -} -# (mult) XXX to byte -- { - type1: "float", value1: "10.0", - type2: "byte", value2: "4", - operation: "*", op_name: "mult", - casting: "as int", - result: "40" -} + } +# (mult) XXX to Byte - { - type1: "double", value1: "10.0", - type2: "byte", value2: "4", + type1: "Float", value1: "10.0f", + type2: "Byte", value2: "4", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "40" -} + } - { - type1: "number", value1: "10.0", - type2: "byte", value2: "4", + type1: "Double", value1: "10.0", + type2: "Byte", value2: "4", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "40" -} + } - { - type1: "long", value1: "10", - type2: "byte", value2: "4", + type1: "Long", value1: "10", + type2: "Byte", value2: "4", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "40" -} + } - { - type1: "int", value1: "10", - type2: "byte", value2: "4", + type1: "Int", value1: "10", + type2: "Byte", value2: "4", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "40" -} + } - { - type1: "short", value1: "10", - type2: "byte", value2: "4", + type1: "Short", value1: "10", + type2: "Byte", value2: "4", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "40" -} + } - { - type1: "byte", value1: "4", - type2: "byte", value2: "4", + type1: "Byte", value1: "4", + type2: "Byte", value2: "4", operation: "*", op_name: "mult", - casting: "as int", + casting: ".toInt()", result: "16" -} -# (mult) XXX to number -- { - type1: "float", value1: "10.0", - type2: "number", value2: "2.3", - operation: "*", op_name: "mult", - casting: "as int", - result: "23" -} -- { - type1: "double", value1: "10.0", - type2: "number", value2: "2.3", - operation: "*", op_name: "mult", - casting: "as int", - result: "23" -} -- { - type1: "number", value1: "10.0", - type2: "number", value2: "2.3", - operation: "*", op_name: "mult", - casting: "as int", - result: "23" -} -- { - type1: "long", value1: "10", - type2: "number", value2: "2.3", - operation: "*", op_name: "mult", - casting: "as int", - result: "23" -} -- { - type1: "int", value1: "10", - type2: "number", value2: "2.3", - operation: "*", op_name: "mult", - casting: "as int", - result: "23" -} -- { - type1: "short", value1: "10", - type2: "number", value2: "2.3", - operation: "*", op_name: "mult", - casting: "as int", - result: "23" -} -- { - type1: "byte", value1: "10", - type2: "number", value2: "2.3", - operation: "*", op_name: "mult", - casting: "as int", - result: "23" -} + } diff --git a/static_core/plugins/ets/tests/stdlib-templates/spec/generic/issue14700.ets b/static_core/plugins/ets/tests/stdlib-templates/spec/generic/issue14700.ets index ab751f4399be31ed2a75c8205874a38712accba1..482bcb1480cec93fb2c45273256a81fe07405470 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/spec/generic/issue14700.ets +++ b/static_core/plugins/ets/tests/stdlib-templates/spec/generic/issue14700.ets @@ -35,7 +35,7 @@ export final class ArrayBackedConstructor { this(); } - public static readonly BYTES_PER_ELEMENT: number = 1; + public static readonly BYTES_PER_ELEMENT: int = 1; public constructor() { this(new TestArrayBuffer(0), 0, 0); diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_concat.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_concat.yaml index a8d4531f1d00dc629c22bf4d23c5a2b5c9185b88..6df046b36b3410fcf546b07da6213d07e437215b 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_concat.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_concat.yaml @@ -148,19 +148,19 @@ method_throws: "false", method_test_index_data: { - test1: { first: "[1.0]", second: "[2.0]" }, - test2: { first: "[127.0, -128.0]", second: "[-128.0, 127.0]", }, + test1: { first: "[1.0f]", second: "[2.0f]" }, + test2: { first: "[127.0f, -128.0f]", second: "[-128.0f, 127.0f]", }, test3: { first: "[]", second: "[]" }, - test4: { first: "[111.0, 99.0]", second: "[]" }, - test5: { first: "[]", second: "[33.0, 66.0, 33.0]",}, + test4: { first: "[111.0f, 99.0f]", second: "[]" }, + test5: { first: "[]", second: "[33.0f, 66.0f, 33.0f]",}, }, method_expected_data: { - test1: "[1.0, 2.0]", - test2: "[127.0, -128.0, -128.0, 127.0]", + test1: "[1.0f, 2.0f]", + test2: "[127.0f, -128.0f, -128.0f, 127.0f]", test3: "[]", - test4: "[111.0, 99.0]", - test5: "[33.0, 66.0, 33.0]", + test4: "[111.0f, 99.0f]", + test5: "[33.0f, 66.0f, 33.0f]", }, } - { @@ -198,18 +198,18 @@ method_throws: "false", method_test_index_data: { - test1: { first: "['a']", second: "['z']" }, - test2: { first: "['a', 'b']", second: "['y', 'z']" }, + test1: { first: "[c'a']", second: "[c'z']" }, + test2: { first: "[c'a', c'b']", second: "[c'y', c'z']" }, test3: { first: "[]", second: "[]" }, - test4: { first: "['x', 'y']", second: "[]" }, - test5: { first: "[]", second: "['x', 'y', 'z']" }, + test4: { first: "[c'x', c'y']", second: "[]" }, + test5: { first: "[]", second: "[c'x', c'y', c'z']" }, }, method_expected_data: { - test1: "['a', 'z']", - test2: "['a', 'b', 'y', 'z']", + test1: "[c'a', c'z']", + test2: "[c'a', c'b', c'y', c'z']", test3: "[]", - test4: "['x', 'y']", - test5: "['x', 'y', 'z']", + test4: "[c'x', c'y']", + test5: "[c'x', c'y', c'z']", }, } diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_copyOf.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_copyOf.yaml index 76bc7eb827708f838c67985b3caca4f36a91fb02..cda257c42cd0e54391924747b27a6d49849bd9ab 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_copyOf.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_copyOf.yaml @@ -310,7 +310,7 @@ }, test5: { - arr: "[0.1, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.77, 8.88, 9.99, 10.10101, 11.11111, 12.1212, 13.1313, 14.1414, 15.1515]", + arr: "[0.1f, 1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.77f, 8.88f, 9.99f, 10.10101f, 11.11111f, 12.1212f, 13.1313f, 14.1414f, 15.1515f]", startIndex: 0, endIndex: arr.length, }, @@ -327,7 +327,7 @@ test2: "[10, 11, 12, 13, 14]", test3: "[2, 3, 4]", test4: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - test5: "[0.1, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.77, 8.88, 9.99, 10.10101, 11.11111, 12.1212, 13.1313, 14.1414, 15.1515]", + test5: "[0.1f, 1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.77f, 8.88f, 9.99f, 10.10101f, 11.11111f, 12.1212f, 13.1313f, 14.1414f, 15.1515f]", test6: "[]" }, } diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_copyOf_2.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_copyOf_2.yaml index 5b5c687874f446fce70309b0dab324fc1f16267a..855071fbc53ed719518fad5223cfebd34d117ed6 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_copyOf_2.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_copyOf_2.yaml @@ -321,7 +321,7 @@ }, test6: { - arr: "[0.1, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.77, 8.88, 9.99, 10.10101, 11.11111, 12.1212, 13.1313, 14.1414, 15.1515]", + arr: "[0.1f, 1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.77f, 8.88f, 9.99f, 10.10101f, 11.11111f, 12.1212f, 13.1313f, 14.1414f, 15.1515f]", startIndex: 0, }, test7: @@ -338,7 +338,7 @@ test3: "[8, 9, 10, 11, 12, 13, 14, 15]", test4: "[14, 15]", test5: "[15]", - test6: "[0.1, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.77, 8.88, 9.99, 10.10101, 11.11111, 12.1212, 13.1313, 14.1414, 15.1515]", + test6: "[0.1f, 1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.77f, 8.88f, 9.99f, 10.10101f, 11.11111f, 12.1212f, 13.1313f, 14.1414f, 15.1515f]", test7: "[]" }, } diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_copyOf_3.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_copyOf_3.yaml index 920425bb87c2eaecef4d416e990fab6545c55732..a0cf56f78a9a3418188cd1fd8a938106da03cc99 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_copyOf_3.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_copyOf_3.yaml @@ -186,7 +186,7 @@ }, test3: { - arr: "[0.1, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.77, 8.88, 9.99, 10.10101, 11.11111, 12.1212, 13.1313, 14.1414, 15.1515]", + arr: "[0.1f, 1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.77f, 8.88f, 9.99f, 10.10101f, 11.11111f, 12.1212f, 13.1313f, 14.1414f, 15.1515f]", }, test4: { @@ -197,7 +197,7 @@ { test1: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", test2: "[0]", - test3: "[0.1, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.77, 8.88, 9.99, 10.10101, 11.11111, 12.1212, 13.1313, 14.1414, 15.1515]", + test3: "[0.1f, 1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.77f, 8.88f, 9.99f, 10.10101f, 11.11111f, 12.1212f, 13.1313f, 14.1414f, 15.1515f]", test4: "[]" }, } diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_foreach.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_foreach.yaml index d0214f82dfbffc18d28f35bd8f00c45b3cf04a5a..676c8a128062c9ba9286280e76de8746331dd794 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_foreach.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_foreach.yaml @@ -25,12 +25,12 @@ test1: { arr: "[false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]", - fn: '(value:boolean,index:number,self:FixedArray): void => {self[index as int] = !value}', + fn: '(value:boolean,index:number,self:FixedArray): void => {self[index.toInt()] = !value}', }, test2: { arr: "[]", - fn: '(value:boolean,index:number,self:FixedArray): void => {self[index as int] = !value}', + fn: '(value:boolean,index:number,self:FixedArray): void => {self[index.toInt()] = !value}', }, }, @@ -54,17 +54,17 @@ test1: { arr: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:byte,index:number,self:FixedArray): void => {self[index as int] = ((value * 2) as byte)}', + fn: '(value:byte,index:number,self:FixedArray): void => {self[index.toInt()] = ((value * 2).toByte())}', }, test2: { arr: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:byte,index:number,self:FixedArray): void => {self[index as int] = ((value + index as int) as byte)}', + fn: '(value:byte,index:number,self:FixedArray): void => {self[index.toInt()] = ((value + index.toInt()).toByte())}', }, test3: { arr: "[]", - fn: '(value:byte,index:number,self:FixedArray): void => {self[index as int] = ((value + index as int) as byte)}', + fn: '(value:byte,index:number,self:FixedArray): void => {self[index.toInt()] = ((value + index.toInt()).toByte())}', }, }, method_expected_data: @@ -88,17 +88,17 @@ test1: { arr: "[0 ,1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:short,index:number,self:FixedArray): void => {self[index as int] = ((value * 2) as short)}', + fn: '(value:short,index:number,self:FixedArray): void => {self[index.toInt()] = ((value * 2).toShort())}', }, test2: { arr: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:short,index:number,self:FixedArray): void => {self[index as int] = ((value + index as int) as short)}', + fn: '(value:short,index:number,self:FixedArray): void => {self[index.toInt()] = ((value + index.toInt()).toShort())}', }, test3: { arr: "[]", - fn: '(value:short,index:number,self:FixedArray): void => {self[index as int] = ((value + index as int) as short)}', + fn: '(value:short,index:number,self:FixedArray): void => {self[index.toInt()] = ((value + index.toInt()).toShort())}', }, }, method_expected_data: @@ -122,17 +122,17 @@ test1: { arr: "[0 ,1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:int,index:number,self:FixedArray): void => {self[index as int] = value * 2}', + fn: '(value:int,index:number,self:FixedArray): void => {self[index.toInt()] = value * 2}', }, test2: { arr: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:int,index:number,self:FixedArray): void => {self[index as int] = value + index as int}', + fn: '(value:int,index:number,self:FixedArray): void => {self[index.toInt()] = value + index.toInt()}', }, test3: { arr: "[]", - fn: '(value:int,index:number,self:FixedArray): void => {self[index as int] = value + index as int}', + fn: '(value:int,index:number,self:FixedArray): void => {self[index.toInt()] = value + index.toInt()}', }, }, method_expected_data: @@ -156,17 +156,17 @@ test1: { arr: "[0 ,1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:long,index:number,self:FixedArray): void => {self[index as int] = value * 2}', + fn: '(value:long,index:number,self:FixedArray): void => {self[index.toInt()] = value * 2}', }, test2: { arr: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:long,index:number,self:FixedArray): void => {self[index as int] = value + index as int}', + fn: '(value:long,index:number,self:FixedArray): void => {self[index.toInt()] = value + index.toInt()}', }, test3: { arr: "[]", - fn: '(value:long,index:number,self:FixedArray): void => {self[index as int] = value + index as int}', + fn: '(value:long,index:number,self:FixedArray): void => {self[index.toInt()] = value + index.toInt()}', }, }, method_expected_data: @@ -190,17 +190,17 @@ test1: { arr: "[0 ,1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:float,index:number,self:FixedArray): void => {self[index as int] = value * 2}', + fn: '(value:float,index:number,self:FixedArray): void => {self[index.toInt()] = value * 2}', }, test2: { arr: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:float,index:number,self:FixedArray): void => {self[index as int] = value + index as int}', + fn: '(value:float,index:number,self:FixedArray): void => {self[index.toInt()] = value + index.toInt()}', }, test3: { arr: "[]", - fn: '(value:float,index:number,self:FixedArray): void => {self[index as int] = value + index as int}', + fn: '(value:float,index:number,self:FixedArray): void => {self[index.toInt()] = value + index.toInt()}', }, }, method_expected_data: @@ -224,17 +224,17 @@ test1: { arr: "[0 ,1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:double,index:number,self:FixedArray): void => {self[index as int] = value * 2}', + fn: '(value:double,index:number,self:FixedArray): void => {self[index.toInt()] = value * 2}', }, test2: { arr: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:double,index:number,self:FixedArray): void => {self[index as int] = value + index as int}', + fn: '(value:double,index:number,self:FixedArray): void => {self[index.toInt()] = value + index.toInt()}', }, test3: { arr: "[]", - fn: '(value:double,index:number,self:FixedArray): void => {self[index as int] = value + index as int}', + fn: '(value:double,index:number,self:FixedArray): void => {self[index.toInt()] = value + index.toInt()}', }, }, method_expected_data: @@ -258,17 +258,17 @@ test1: { arr: "[0 ,1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:char,index:number,self:FixedArray): void => {self[index as int] = value * 2}', + fn: '(value:char,index:number,self:FixedArray): void => {self[index.toInt()] = value * 2}', }, test2: { arr: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:char,index:number,self:FixedArray): void => {self[index as int] = value + index as int}', + fn: '(value:char,index:number,self:FixedArray): void => {self[index.toInt()] = value + index.toInt()}', }, test3: { arr: "[]", - fn: '(value:char,index:number,self:FixedArray): void => {self[index as int] = value + index as int}', + fn: '(value:char,index:number,self:FixedArray): void => {self[index.toInt()] = value + index.toInt()}', }, }, method_expected_data: diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_foreach_2.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_foreach_2.yaml index 21907416fcbe3e7078829c690aebb634198bccfd..5d2ba8e85a5ab8b9e968eeb9d24d599952c2b2c4 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_foreach_2.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_foreach_2.yaml @@ -53,12 +53,12 @@ test1: { arr: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:byte): void => {((value * 2) as byte)}', + fn: '(value:byte): void => {((value * 2).toByte())}', }, test2: { arr: "[]", - fn: '(value:byte): void => {((value * 2) as byte)}', + fn: '(value:byte): void => {((value * 2).toByte())}', }, }, method_expected_data: { @@ -80,12 +80,12 @@ test1: { arr: "[0 ,1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:short): void => {((value * 2) as short)}', + fn: '(value:short): void => {((value * 2).toShort())}', }, test2: { arr: "[]", - fn: '(value:short): void => {((value * 2) as short)}', + fn: '(value:short): void => {((value * 2).toShort())}', }, }, method_expected_data: diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_includes.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_includes.yaml index 8ac47364f8fc76de80fa49458cd076e0d59046f5..1be3fb8fa8248bfcd26cf6095dd0793cf2429120 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_includes.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_includes.yaml @@ -344,53 +344,53 @@ { test1: { - arr: "[120.0, 100.0, 99.0, 21.0]", - key: 33.0, + arr: "[120.0f, 100.0f, 99.0f, 21.0f]", + key: 33.0f, }, test2: { - arr: "[33.0, 120.0, 121.0, 99.0, 77.0, 33.0, 33.0]", - key: 33.0, + arr: "[33.0f, 120.0f, 121.0f, 99.0f, 77.0f, 33.0f, 33.0f]", + key: 33.0f, }, test3: { - arr: "[121.0, 122.0, 34.0, 35.0, 45.0, 33.0]", - key: 33.0, + arr: "[121.0f, 122.0f, 34.0f, 35.0f, 45.0f, 33.0f]", + key: 33.0f, }, test4: { - arr: "[121.0, 33.0, 77.0, 33.0, 45.0, 44.0]", - key: 33.0, + arr: "[121.0f, 33.0f, 77.0f, 33.0f, 45.0f, 44.0f]", + key: 33.0f, }, test5: { - arr: "[121.121, -33.33, 77.77, 33.33, 45.45, 44.44]", - key: -33.33, + arr: "[121.121f, -33.33f, 77.77f, 33.33f, 45.45f, 44.44f]", + key: -33.33f, }, test6: { - arr: "[121.121, -33.33, 77.77, 33.33, 45.45, 44.44]", - key: -35.34, + arr: "[121.121f, -33.33f, 77.77f, 33.33f, 45.45f, 44.44f]", + key: -35.34f, }, test7: { - arr: "[121.121, -33.33, 77.77, 33.33, 45.45, 44.44]", - key: 0, + arr: "[121.121f, -33.33f, 77.77f, 33.33f, 45.45f, 44.44f]", + key: 0f, }, test8: { - arr: "[121.121, -33.33, 77.77, 0, 45.45, 44.44]", - key: 0, + arr: "[121.121f, -33.33f, 77.77f, 0f, 45.45f, 44.44f]", + key: 0f, }, test9: { - arr: "[121.121, -33.33, 77.77, -0.0, 45.45, 44.44]", - key: -0.0, + arr: "[121.121f, -33.33f, 77.77f, -0.0f, 45.45f, 44.44f]", + key: -0.0f, }, test10: { arr: "[]", - key: 333.0, + key: 333.0f, }, }, method_expected_data: diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_indexOf_2.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_indexOf_2.yaml index fce5db67e032bc732de412234c648dea79566346..0e34b5ac40ab37b87b466f2a25cf042228e637fd 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_indexOf_2.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_indexOf_2.yaml @@ -345,53 +345,53 @@ { test1: { - arr: "[120.0, 100.0, 99.0, 21.0]", - key: 33.0, + arr: "[120.0f, 100.0f, 99.0f, 21.0f]", + key: 33.0f, }, test2: { - arr: "[33.0, 120.0, 121.0, 99.0, 77.0, 33.0, 33.0]", - key: 33.0, + arr: "[33.0f, 120.0f, 121.0f, 99.0f, 77.0f, 33.0f, 33.0f]", + key: 33.0f, }, test3: { - arr: "[121.0, 122.0, 34.0, 35.0, 45.0, 33.0]", - key: 33.0, + arr: "[121.0f, 122.0f, 34.0f, 35.0f, 45.0f, 33.0f]", + key: 33.0f, }, test4: { - arr: "[121.0, 33.0, 77.0, 33.0, 45.0, 44.0]", - key: 33.0, + arr: "[121.0f, 33.0f, 77.0f, 33.0f, 45.0f, 44.0f]", + key: 33.0f, }, test5: { - arr: "[121.121, -33.33, 77.77, 33.44, 45.45, 44.44]", - key: -33.33, + arr: "[121.121f, -33.33f, 77.77f, 33.44f, 45.45f, 44.44f]", + key: -33.33f, }, test6: { - arr: "[121.121, -33.33, 77.77, 33.33, 45.45, 44.44]", - key: -35.35, + arr: "[121.121f, -33.33f, 77.77f, 33.33f, 45.45f, 44.44f]", + key: -35.35f, }, test7: { - arr: "[121.121, -33.33, 77.77, 33.33, 45.45, 44.44]", - key: 0, + arr: "[121.121f, -33.33f, 77.77f, 33.33f, 45.45f, 44.44f]", + key: 0f, }, test8: { - arr: "[121.121, -33.33, 77.77, 0, 45.45, 44.44]", - key: 0, + arr: "[121.121f, -33.33f, 77.77f, 0f, 45.45f, 44.44f]", + key: 0f, }, test9: { - arr: "[121.121, -33.33, 77.77, -0.0, 45.45, 44.44]", - key: -0.0, + arr: "[121.121f, -33.33f, 77.77f, -0.0f, 45.45f, 44.44f]", + key: -0.0f, }, test10: { arr: "[]", - key: 1, + key: 1f, }, }, method_expected_data: diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_join.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_join.yaml index d8c1b8193514914d504a26f80eed1436d8bcea9e..c70383d8fb3f2f769cd602549a7d2b5dbac5f00f 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_join.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_join.yaml @@ -173,22 +173,22 @@ { test1: { - arr: "[1.1, 22.1, 33.1, 44.1, 55.1, 66.1, 77.1, 88.1, 99.1]", + arr: "[1.1f, 22.1f, 33.1f, 44.1f, 55.1f, 66.1f, 77.1f, 88.1f, 99.1f]", delimiter: '""', }, test2: { - arr: "[1.1, 22.1, 33.1, 44.1, 55.1, 66.1, 77.1, 88.1, 99.1]", + arr: "[1.1f, 22.1f, 33.1f, 44.1f, 55.1f, 66.1f, 77.1f, 88.1f, 99.1f]", delimiter: '" "', }, test3: { - arr: "[1.1, 22.1, 33.1, 44.1, 55.1, 66.1, 77.1, 88.1, 99.1]", + arr: "[1.1f, 22.1f, 33.1f, 44.1f, 55.1f, 66.1f, 77.1f, 88.1f, 99.1f]", delimiter: '"------"', }, test4: { - arr: "[1.1, 22.1, 33.1, 44.1, 55.1, 66.1, 77.1, 88.1, 99.1]", + arr: "[1.1f, 22.1f, 33.1f, 44.1f, 55.1f, 66.1f, 77.1f, 88.1f, 99.1f]", delimiter: '","', }, test5: {arr: "[]", delimiter: '","'}, diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_lowerBoundSearch.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_lowerBoundSearch.yaml index e3ab0c8bb9ee818bd4a2318754b385dfb4e94878..4001b3eb74cf7caa89fbae5e755e0673372cd6dd 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_lowerBoundSearch.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_lowerBoundSearch.yaml @@ -382,56 +382,56 @@ { test10: { - arr: "[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]", + arr: "[0f,1f,2f,3f,4f,5f,6f,7f,8f,9f,10f,11f,12f,13f,14f,15f]", key: 7, startIndex: 4, endIndex: 12, }, test20: { - arr: "[0,1,2,3,4,5,6,7,7,7,7,7,12,13,14,15]", + arr: "[0f,1f,2f,3f,4f,5f,6f,7f,7f,7f,7f,7f,12f,13f,14f,15f]", key: 7, startIndex: 4, endIndex: 12, }, test30: { - arr: "[7,7,7,7,7,8,9,10,11,12,13,14,15,16,17,18]", + arr: "[7f,7f,7f,7f,7f,8f,9f,10f,11f,12f,13f,14f,15f,16f,17f,18f]", key: 7, startIndex: 0, endIndex: 8, }, test40: { - arr: "[0,1,2,3,4,5,6,7,7,7,7,7,7,7,7,7]", + arr: "[0f,1f,2f,3f,4f,5f,6f,7f,7f,7f,7f,7f,7f,7f,7f,7f]", key: 7, startIndex: 6, endIndex: 16, }, test50: { - arr: "[0,1,2,3,4,5,6,8,9,10,11,12,13,14,15,16]", + arr: "[0f,1f,2f,3f,4f,5f,6f,8f,9f,10f,11f,12f,13f,14f,15f,16f]", key: 7, startIndex: 4, endIndex: 12, }, test60: { - arr: "[8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]", + arr: "[8f,9f,10f,11f,12f,13f,14f,15f,16f,17f,18f,19f,20f,21f,22f,23f]", key: 7, startIndex: 0, endIndex: 10, }, test70: { - arr: "[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]", + arr: "[0f,1f,2f,3f,4f,5f,6f,7f,8f,9f,10f,11f,12f,13f,14f,15f]", key: 16, startIndex: 10, endIndex: 16, }, test80: { - arr: "[0,1,2,3,4,5,6,7,7,7,7,7,12,13,14]", + arr: "[0f,1f,2f,3f,4f,5f,6f,7f,7f,7f,7f,7f,12f,13f,14f]", key: 7, startIndex: 7, endIndex: 11, diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_lowerBoundSearch_2.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_lowerBoundSearch_2.yaml index ee9d89f218eea49ec8f756612eb515c8428fda20..55f0dd4e36c83a11b5f75ecfb1e1c3b8962278c6 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_lowerBoundSearch_2.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_lowerBoundSearch_2.yaml @@ -307,38 +307,38 @@ { test10: { - arr: "[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]", + arr: "[0f,1f,2f,3f,4f,5f,6f,7f,8f,9f,10f,11f,12f,13f,14f,15f]", key: 7, }, test20: { - arr: "[0,1,2,3,4,5,6,7,7,7,7,7,12,13,14,15]", + arr: "[0f,1f,2f,3f,4f,5f,6f,7f,7f,7f,7f,7f,12f,13f,14f,15f]", key: 7, }, test30: { - arr: "[7,7,7,7,7,8,9,10,11,12,13,14,15,16,17,18]", + arr: "[7f,7f,7f,7f,7f,8f,9f,10f,11f,12f,13f,14f,15f,16f,17f,18f]", key: 7, }, test40: { - arr: "[0,1,2,3,4,5,6,7,7,7,7,7,7,7,7.7]", + arr: "[0f,1f,2f,3f,4f,5f,6f,7f,7f,7f,7f,7f,7f,7f,7.7f]", key: 7, }, test50: { - arr: "[0,1,2,3,4,5,6,8,9,10,11,12,13,14,15,16]", + arr: "[0f,1f,2f,3f,4f,5f,6f,8f,9f,10f,11f,12f,13f,14f,15f,16f]", key: 7, }, test60: { - arr: "[8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]", + arr: "[8f,9f,10f,11f,12f,13f,14f,15f,16f,17f,18f,19f,20f,21f,22f,23f]", key: 7, }, test70: { - arr: "[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]", + arr: "[0f,1f,2f,3f,4f,5f,6f,7f,8f,9f,10f,11f,12f,13f,14f,15f]", key: 16, }, }, diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_map.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_map.yaml index faedf8dcb4ee3ec5392c3c2fb553ccb8ce474778..ef65b47ba42f06b147b56b00e4d900fd57b99d63 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_map.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_map.yaml @@ -51,17 +51,17 @@ test1: { arr: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:byte,index:number,self:FixedArray): byte => {return ((value * 2) as byte)}', + fn: '(value:byte,index:number,self:FixedArray): byte => {return ((value * 2).toByte())}', }, test2: { arr: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:byte,index:number,self:FixedArray): byte => {return ((value + index) as byte)}', + fn: '(value:byte,index:number,self:FixedArray): byte => {return ((value + index).toByte())}', }, test3: { arr: "[]", - fn: '(value:byte,index:number,self:FixedArray): byte => {return ((value + index) as byte)}', + fn: '(value:byte,index:number,self:FixedArray): byte => {return ((value + index).toByte())}', }, }, method_expected_data: @@ -84,17 +84,17 @@ test1: { arr: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:short,index:number,self:FixedArray): short => {return ((value * 2) as short)}', + fn: '(value:short,index:number,self:FixedArray): short => {return ((value * 2).toShort())}', }, test2: { arr: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:short,index:number,self:FixedArray): short => {return ((value + index) as short)}', + fn: '(value:short,index:number,self:FixedArray): short => {return ((value + index).toShort())}', }, test3: { arr: "[]", - fn: '(value:short,index:number,self:FixedArray): short => {return ((value + index) as short)}', + fn: '(value:short,index:number,self:FixedArray): short => {return ((value + index).toShort())}', }, }, method_expected_data: @@ -122,12 +122,12 @@ test2: { arr: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:int,index:number,self:FixedArray): int => {return (value + index) as int}', + fn: '(value:int,index:number,self:FixedArray): int => {return (value + index).toInt()}', }, test3: { arr: "[]", - fn: '(value:int,index:number,self:FixedArray): int => {return (value + index) as int}', + fn: '(value:int,index:number,self:FixedArray): int => {return (value + index).toInt()}', }, }, @@ -156,12 +156,12 @@ test2: { arr: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:long,index:number,self:FixedArray): long => {return (value + index) as long}', + fn: '(value:long,index:number,self:FixedArray): long => {return (value + index).toLong()}', }, test3: { arr: "[]", - fn: '(value:long,index:number,self:FixedArray): long => {return (value + index) as long}', + fn: '(value:long,index:number,self:FixedArray): long => {return (value + index).toLong()}', }, }, @@ -190,12 +190,12 @@ test2: { arr: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:float,index:number,self:FixedArray): float => {return (value + index) as float}', + fn: '(value:float,index:number,self:FixedArray): float => {return (value + index).toFloat()}', }, test3: { arr: "[]", - fn: '(value:float,index:number,self:FixedArray): float => {return (value + index) as float}', + fn: '(value:float,index:number,self:FixedArray): float => {return (value + index).toFloat()}', }, }, @@ -252,17 +252,17 @@ test1: { arr: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:char,index:number,self:FixedArray): char => {return ((value * 2) as char)}', + fn: '(value:char,index:number,self:FixedArray): char => {return ((value * 2).toChar())}', }, test2: { arr: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:char,index:number,self:FixedArray): char => {return ((value + index) as char)}', + fn: '(value:char,index:number,self:FixedArray): char => {return ((value + index).toChar())}', }, test3: { arr: "[]", - fn: '(value:char,index:number,self:FixedArray): char => {return ((value + index) as char)}', + fn: '(value:char,index:number,self:FixedArray): char => {return ((value + index).toChar())}', }, }, method_expected_data: diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_map_2.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_map_2.yaml index 65d76dc4ac2b53d428edf0dfb32947d5a1a54dec..1d446846a7b268133eb843e0dd415a5dcf450dbf 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_map_2.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_map_2.yaml @@ -52,12 +52,12 @@ test1: { arr: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:byte): byte => {return (value * 2) as byte}', + fn: '(value:byte): byte => {return (value * 2).toByte()}', }, test2: { arr: "[]", - fn: '(value:byte): byte => {return (value * 2) as byte}', + fn: '(value:byte): byte => {return (value * 2).toByte()}', }, }, method_expected_data: @@ -79,12 +79,12 @@ test1: { arr: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:short): short => {return ((value * 2) as short)}', + fn: '(value:short): short => {return ((value * 2).toShort())}', }, test2: { arr: "[]", - fn: '(value:short): short => {return ((value * 2) as short)}', + fn: '(value:short): short => {return ((value * 2).toShort())}', }, }, method_expected_data: @@ -214,12 +214,12 @@ test1: { arr: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]", - fn: '(value:char): char => {return ((value * 2) as char)}', + fn: '(value:char): char => {return ((value * 2).toChar())}', }, test2: { arr: "[]", - fn: '(value:char): char => {return ((value * 2) as char)}', + fn: '(value:char): char => {return ((value * 2).toChar())}', }, }, method_expected_data: diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_reverse.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_reverse.yaml index 9e130fc56c6638a88392b9fc85ac5c2db0104bfd..578b968c84892ae5336777c20c8de77b4edf5b10 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_reverse.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_reverse.yaml @@ -142,16 +142,16 @@ method_throws: "false", method_test_index_data: { - test1: { arr: "[1.0 as float]" }, - test2: { arr: "[1.0 as float, 2.0 as float]" }, - test3: { arr: "[1.0 as float, 2.0 as float, 3.0 as float]" }, + test1: { arr: "[1.0f]" }, + test2: { arr: "[1.0f, 2.0f]" }, + test3: { arr: "[1.0f, 2.0f, 3.0f]" }, test4: { arr: "[]" }, }, method_expected_data: { - test1: "[1.0 as float]", - test2: "[2.0 as float, 1.0 as float]", - test3: "[3.0 as float, 2.0 as float, 1.0 as float]", + test1: "[1.0f]", + test2: "[2.0f, 1.0f]", + test3: "[3.0f, 2.0f, 1.0f]", test4: "[]", }, } diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_sort.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_sort.yaml index 722a9961316942bb2cf9a39ad0a6f50a6263e39a..635a32ed414fe201a15045a88de8a01ddff663f0 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_sort.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_sort.yaml @@ -338,37 +338,37 @@ { test1: { - arr: "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]", + arr: "[0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f]", startIndex: 0, endIndex: 4, }, test2: { - arr: "[4.0, 3.0, 2.0, 1.0, 0.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]", + arr: "[4.0f, 3.0f, 2.0f, 1.0f, 0.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f]", startIndex: 0, endIndex: 5, }, test3: { - arr: "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 9.0, 8.0, 7.0, 6.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]", + arr: "[0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 9.0f, 8.0f, 7.0f, 6.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f]", startIndex: 6, endIndex: 10, }, test4: { - arr: "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 16.0, 15.0, 14.0, 13.0]", + arr: "[0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 16.0f, 15.0f, 14.0f, 13.0f]", startIndex: 12, endIndex: arr.length, }, test5: { - arr: "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 11.0, 10.0, 12.0, 13.0, 14.0, 15.0, 16.0]", + arr: "[0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 11.0f, 10.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f]", startIndex: 10, endIndex: 12, }, test6: { - arr: "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 11.0, 10.0, 12.0, 13.0, 14.0, 15.0, 16.0]", + arr: "[0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 11.0f, 10.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f]", startIndex: 0, endIndex: 14, }, @@ -382,13 +382,13 @@ }, method_expected_data: { - test1: "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]", - test2: "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]", - test3: "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]", - test4: "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]", - test5: "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]", - test6: "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]", - test7: "[0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 3.0, 5.0, 6.0, 8.0, 9.0, 11.0, 12.0, 1.0, 1.0, 1.0 ]", + test1: "[0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f]", + test2: "[0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f]", + test3: "[0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f]", + test4: "[0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f]", + test5: "[0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f]", + test6: "[0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f]", + test7: "[0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f, 3.0f, 5.0f, 6.0f, 8.0f, 9.0f, 11.0f, 12.0f, 1.0f, 1.0f, 1.0f ]", }, } - { diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_sort_2.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_sort_2.yaml index fb8547f6f7819579e5f22d89aadc5b9e80759297..f31d8faa189b88b8fdb019c857084e0dbe8a56dd 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_sort_2.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_array_sort_2.yaml @@ -289,31 +289,31 @@ { test1: { - arr: "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]", + arr: "[0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f]", }, test2: { - arr: "[4.0, 3.0, 2.0, 1.0, 0.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]", + arr: "[4.0f, 3.0f, 2.0f, 1.0f, 0.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f]", }, test3: { - arr: "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 9.0, 8.0, 7.0, 6.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]", + arr: "[0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 9.0f, 8.0f, 7.0f, 6.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f]", }, test4: { - arr: "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 16.0, 15.0, 14.0, 13.0]", + arr: "[0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 16.0f, 15.0f, 14.0f, 13.0f]", }, test5: { - arr: "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 11.0, 10.0, 12.0, 13.0, 14.0, 15.0, 16.0]", + arr: "[0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 11.0f, 10.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f]", }, test6: { - arr: "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 11.0, 10.0, 12.0, 13.0, 14.0, 15.0, 16.0]", + arr: "[0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 11.0f, 10.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f]", }, test7: { - arr: "[0.0, 1.0, 2.0, 3.0, 1.0, 5.0, 6.0, 1.0, 8.0, 9.0, 11.0, 1.0, 12.0, 1.0, 1.0, 1.0, 1.0]", + arr: "[0.0f, 1.0f, 2.0f, 3.0f, 1.0f, 5.0f, 6.0f, 1.0f, 8.0f, 9.0f, 11.0f, 1.0f, 12.0f, 1.0f, 1.0f, 1.0f, 1.0f]", }, test8: { @@ -322,13 +322,13 @@ }, method_expected_data: { - test1: "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]", - test2: "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]", - test3: "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]", - test4: "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]", - test5: "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]", - test6: "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]", - test7: "[0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 3.0, 5.0, 6.0, 8.0, 9.0, 11.0, 12.0]", + test1: "[0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f]", + test2: "[0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f]", + test3: "[0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f]", + test4: "[0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f]", + test5: "[0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f]", + test6: "[0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f]", + test7: "[0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f, 3.0f, 5.0f, 6.0f, 8.0f, 9.0f, 11.0f, 12.0f]", test8: "[]" }, } diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_byte_instance.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_byte_instance.yaml index a99f48102b157e1342f3792a28820424add0a620..57340baaa184a6b4c1541d92d5911c5e03fd8443 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_byte_instance.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_byte_instance.yaml @@ -15,105 +15,105 @@ method_name: unboxed, object_type: Byte, init_object_data_type: "FixedArray", - init_object_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE as byte, Byte.MAX_VALUE as byte]", + init_object_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE.toByte(), Byte.MAX_VALUE.toByte()]", param_init_data_types: {} , param_types: {}, method_return_type: byte, expected_data_item_type: byte, expected_data_type: "FixedArray", param_list: {}, - expected_test_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE as byte, Byte.MAX_VALUE as byte]", + expected_test_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE.toByte(), Byte.MAX_VALUE.toByte()]", verify_test_result_function: comparePrimitiveValue, } - { method_name: toByte, object_type: Byte, init_object_data_type: "FixedArray", - init_object_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE as byte, Byte.MAX_VALUE as byte]", + init_object_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE.toByte(), Byte.MAX_VALUE.toByte()]", param_init_data_types: {} , param_types: {}, method_return_type: byte, expected_data_item_type: byte, expected_data_type: "FixedArray", param_list: {}, - expected_test_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE as byte, Byte.MAX_VALUE as byte]", + expected_test_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE.toByte(), Byte.MAX_VALUE.toByte()]", verify_test_result_function: comparePrimitiveValue, } - { method_name: toShort, object_type: Byte, init_object_data_type: "FixedArray", - init_object_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE as byte, Byte.MAX_VALUE as byte]", + init_object_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE.toByte(), Byte.MAX_VALUE.toByte()]", param_init_data_types: {} , param_types: {}, method_return_type: short, expected_data_item_type: short, expected_data_type: "FixedArray", param_list: {}, - expected_test_data: "[0 as short, 1 as short, Byte.MIN_VALUE as short, Byte.MAX_VALUE as short]", + expected_test_data: "[0 as short, 1 as short, Byte.MIN_VALUE.toShort(), Byte.MAX_VALUE.toShort()]", verify_test_result_function: comparePrimitiveValue, } - { method_name: toInt, object_type: Byte, init_object_data_type: "FixedArray", - init_object_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE as byte, Byte.MAX_VALUE as byte]", + init_object_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE.toByte(), Byte.MAX_VALUE.toByte()]", param_init_data_types: {} , param_types: {}, method_return_type: int, expected_data_item_type: int, expected_data_type: "FixedArray", param_list: {}, - expected_test_data: "[0 as int, 1 as int, Byte.MIN_VALUE as int, Byte.MAX_VALUE as int]", + expected_test_data: "[0 as int, 1 as int, Byte.MIN_VALUE.toInt(), Byte.MAX_VALUE.toInt()]", verify_test_result_function: comparePrimitiveValue, } - { method_name: toLong, object_type: Byte, init_object_data_type: "FixedArray", - init_object_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE as byte, Byte.MAX_VALUE as byte]", + init_object_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE.toByte(), Byte.MAX_VALUE.toByte()]", param_init_data_types: {} , param_types: {}, method_return_type: long, expected_data_item_type: long, expected_data_type: "FixedArray", param_list: {}, - expected_test_data: "[0 as long, 1 as long, Byte.MIN_VALUE as long, Byte.MAX_VALUE as long]", + expected_test_data: "[0 as long, 1 as long, Byte.MIN_VALUE.toLong(), Byte.MAX_VALUE.toLong()]", verify_test_result_function: comparePrimitiveValue, } - { method_name: toFloat, object_type: Byte, init_object_data_type: "FixedArray", - init_object_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE as byte, Byte.MAX_VALUE as byte]", + init_object_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE.toByte(), Byte.MAX_VALUE.toByte()]", param_init_data_types: {} , param_types: {}, method_return_type: float, expected_data_item_type: float, expected_data_type: "FixedArray", param_list: {}, - expected_test_data: "[0 as float, 1 as float, Byte.MIN_VALUE as float, Byte.MAX_VALUE as float]", + expected_test_data: "[0 as float, 1 as float, Byte.MIN_VALUE.toFloat(), Byte.MAX_VALUE.toFloat()]", verify_test_result_function: compareFloatPointValue } - { method_name: toDouble, object_type: Byte, init_object_data_type: "FixedArray", - init_object_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE as byte, Byte.MAX_VALUE as byte]", + init_object_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE.toByte(), Byte.MAX_VALUE.toByte()]", param_init_data_types: {} , param_types: {}, method_return_type: double, expected_data_item_type: double, expected_data_type: "FixedArray", param_list: {}, - expected_test_data: "[0 as double, 1 as double, Byte.MIN_VALUE as double, Byte.MAX_VALUE as double]", + expected_test_data: "[0 as double, 1 as double, Byte.MIN_VALUE.toDouble(), Byte.MAX_VALUE.toDouble()]", verify_test_result_function: compareFloatPointValue } - { method_name: toString, object_type: Byte, init_object_data_type: "FixedArray", - init_object_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE as byte, Byte.MAX_VALUE as byte]", + init_object_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE.toByte(), Byte.MAX_VALUE.toByte()]", param_init_data_types: {} , param_types: {}, method_return_type: String, diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_constructor.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_constructor.yaml index dd03b228b9fd89e75a0ffc510c64c45605dd6749..50aeb38db133c8c31a22dfad88e51a0c2aaf3713 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_constructor.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_constructor.yaml @@ -36,12 +36,12 @@ init_object_default: yes, init_object_copy_constructor: yes, init_object_data_types: {"param1":"FixedArray"}, - init_object_param_list: {"param1" : "[125 as int, (-125) as int, Int.MAX_VALUE as int, Int.MIN_VALUE, 0 as int]"}, + init_object_param_list: {"param1" : "[125 as int, (-125) as int, Int.MAX_VALUE.toInt(), Int.MIN_VALUE, 0 as int]"}, init_object_param_types: {"param1": int}, init_object_param_nature: {"param1": primitive}, expected_data_item_type: int, expected_data_type: "FixedArray", - expected_test_data: "[125 as int, (-125) as int, Int.MAX_VALUE as int, Int.MIN_VALUE as int, 0 as int]", + expected_test_data: "[125 as int, (-125) as int, Int.MAX_VALUE.toInt(), Int.MIN_VALUE.toInt(), 0 as int]", expected_default_data_type: int, expected_default_test_data: 0 as int, verify_test_result_function: compareWrapperObjectValue, @@ -53,12 +53,12 @@ init_object_default: yes, init_object_copy_constructor: yes, init_object_data_types: {"param1":"FixedArray"}, - init_object_param_list: {"param1" : "[125 as short, (-125) as short, Short.MAX_VALUE as short, Short.MIN_VALUE as short, 0 as short]"}, + init_object_param_list: {"param1" : "[125 as short, (-125) as short, Short.MAX_VALUE.toShort(), Short.MIN_VALUE.toShort(), 0 as short]"}, init_object_param_types: {"param1": short}, init_object_param_nature: {"param1": primitive}, expected_data_item_type: short, expected_data_type: "FixedArray", - expected_test_data: "[125 as short, (-125) as short, Short.MAX_VALUE as short, Short.MIN_VALUE as short, 0 as short]", + expected_test_data: "[125 as short, (-125) as short, Short.MAX_VALUE.toShort(), Short.MIN_VALUE.toShort(), 0 as short]", expected_default_data_type: short, expected_default_test_data: 0 as short, verify_test_result_function: compareWrapperObjectValue, @@ -70,12 +70,12 @@ init_object_default: yes, init_object_copy_constructor: yes, init_object_data_types: {"param1":"FixedArray"}, - init_object_param_list: {"param1" : "[125 as byte, (-125) as byte, Byte.MAX_VALUE as byte, Byte.MIN_VALUE as byte, 0 as byte]"}, + init_object_param_list: {"param1" : "[125 as byte, (-125) as byte, Byte.MAX_VALUE.toByte(), Byte.MIN_VALUE.toByte(), 0 as byte]"}, init_object_param_types: {"param1": byte}, init_object_param_nature: {"param1": primitive}, expected_data_item_type: byte, expected_data_type: "FixedArray", - expected_test_data: "[125 as byte, (-125) as byte, Byte.MAX_VALUE as byte, Byte.MIN_VALUE as byte, 0 as byte]", + expected_test_data: "[125 as byte, (-125) as byte, Byte.MAX_VALUE.toByte(), Byte.MIN_VALUE.toByte(), 0 as byte]", expected_default_data_type: byte, expected_default_test_data: 0 as byte, verify_test_result_function: compareWrapperObjectValue, @@ -121,14 +121,14 @@ init_object_default: yes, init_object_copy_constructor: yes, init_object_data_types: {"param1":"FixedArray"}, - init_object_param_list: {"param1" : "[125.0 as float, (-125.0) as float, PI as float, E as float, 0.0 as float]"}, + init_object_param_list: {"param1" : "[125.0f, -125.0f, PI.toFloat(), E.toFloat(), 0.0f]"}, init_object_param_types: {"param1": float}, init_object_param_nature: {"param1": primitive}, expected_data_item_type: float, expected_data_type: "FixedArray", - expected_test_data: "[125.0 as float, (-125.0) as float, PI as float, E as float, 0.0 as float]", + expected_test_data: "[125.0f, -125.0f, PI.toFloat(), E.toFloat(), 0.0f]", expected_default_data_type: float, - expected_default_test_data: 0.0 as float, + expected_default_test_data: 0.0f, verify_test_result_function: compareWrapperObjectValue, } - { diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_double_instance.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_double_instance.yaml index 892632b539ea2ff534cb367289b3ee9a90f13dde..c6f9f785a935617214bad96301f104699e325f5c 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_double_instance.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_double_instance.yaml @@ -21,9 +21,9 @@ param_types: {}, param_list: {}, method_return_type: double, - init_object_data: "[0 as double, 1 as double, Byte.MIN_VALUE as double, Byte.MAX_VALUE as double]", + init_object_data: "[0 as double, 1 as double, Byte.MIN_VALUE.toDouble(), Byte.MAX_VALUE.toDouble()]", expected_data_type: "FixedArray", - expected_test_data: "[0 as double, 1 as double, Byte.MIN_VALUE as double, Byte.MAX_VALUE as double]", + expected_test_data: "[0 as double, 1 as double, Byte.MIN_VALUE.toDouble(), Byte.MAX_VALUE.toDouble()]", verify_test_result_function: compareFloatPointValue } - { @@ -36,9 +36,9 @@ param_types: {}, param_list: {}, method_return_type: byte, - init_object_data: "[0 as double, 1 as double, Byte.MIN_VALUE as double, Byte.MAX_VALUE as double]", + init_object_data: "[0 as double, 1 as double, Byte.MIN_VALUE.toDouble(), Byte.MAX_VALUE.toDouble()]", expected_data_type: "FixedArray", - expected_test_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE as byte, Byte.MAX_VALUE as byte]", + expected_test_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE.toByte(), Byte.MAX_VALUE.toByte()]", verify_test_result_function: comparePrimitiveValue } - { @@ -51,9 +51,9 @@ param_types: {}, param_list: {}, method_return_type: short, - init_object_data: "[0 as double, 1 as double, Short.MIN_VALUE as byte, Short.MAX_VALUE as byte]", + init_object_data: "[0 as double, 1 as double, Short.MIN_VALUE.toByte(), Short.MAX_VALUE.toByte()]", expected_data_type: "FixedArray", - expected_test_data: "[0 as short, 1 as short, Short.MIN_VALUE as byte, Short.MAX_VALUE as byte]", + expected_test_data: "[0 as short, 1 as short, Short.MIN_VALUE.toByte(), Short.MAX_VALUE.toByte()]", verify_test_result_function: comparePrimitiveValue } - { @@ -66,9 +66,9 @@ param_types: {}, param_list: {}, method_return_type: int, - init_object_data: "[0 as double, 1 as double, Int.MIN_VALUE as double, Int.MAX_VALUE as double]", + init_object_data: "[0 as double, 1 as double, Int.MIN_VALUE.toDouble(), Int.MAX_VALUE.toDouble()]", expected_data_type: "FixedArray", - expected_test_data: "[0 as int, 1 as int, Int.MIN_VALUE as int, Int.MAX_VALUE as int]", + expected_test_data: "[0 as int, 1 as int, Int.MIN_VALUE.toInt(), Int.MAX_VALUE.toInt()]", verify_test_result_function: comparePrimitiveValue } - { @@ -81,9 +81,9 @@ param_types: {}, param_list: {}, method_return_type: long, - init_object_data: "[0 as double, 1 as double, Long.MIN_VALUE as double, Long.MAX_VALUE as double]", + init_object_data: "[0 as double, 1 as double, Long.MIN_VALUE.toDouble(), Long.MAX_VALUE.toDouble()]", expected_data_type: "FixedArray", - expected_test_data: "[0 as long, 1 as long, Long.MIN_VALUE as long, Long.MAX_VALUE as long]", + expected_test_data: "[0 as long, 1 as long, Long.MIN_VALUE.toLong(), Long.MAX_VALUE.toLong()]", verify_test_result_function: comparePrimitiveValue } - { @@ -95,9 +95,9 @@ param_types: {}, param_list: {}, method_return_type: float, - init_object_data: "[0 as byte, 1 as byte, Double.MIN_VALUE as float, Double.MAX_VALUE as float]", + init_object_data: "[0 as byte, 1 as byte, Double.MIN_VALUE.toFloat(), Double.MAX_VALUE.toFloat()]", expected_data_type: "FixedArray", - expected_test_data: "[0 as float, 1 as float, Double.MIN_VALUE as float, Double.MAX_VALUE as float]", + expected_test_data: "[0f, 1f, Double.MIN_VALUE.toFloat(), Double.MAX_VALUE.toFloat()]", verify_test_result_function: compareFloatPointValue } - { @@ -110,9 +110,9 @@ param_types: {}, param_list: {}, method_return_type: double, - init_object_data: "[0 as double, 1 as double, Double.MIN_VALUE as double, Double.MAX_VALUE as double]", + init_object_data: "[0 as double, 1 as double, Double.MIN_VALUE.toDouble(), Double.MAX_VALUE.toDouble()]", expected_data_type: "FixedArray", - expected_test_data: "[0 as double, 1 as double, Double.MIN_VALUE as double, Double.MAX_VALUE as double]", + expected_test_data: "[0 as double, 1 as double, Double.MIN_VALUE.toDouble(), Double.MAX_VALUE.toDouble()]", verify_test_result_function: compareFloatPointValue } - { @@ -125,7 +125,7 @@ param_types: {}, param_list: {}, method_return_type: String, - init_object_data: "[0 as double, 1 as double, Double.MIN_VALUE as double, Double.MAX_VALUE as double, Double.NaN, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.EPSILON, 0.34567423843258427, Int.MAX_VALUE as double, -0.0]", + init_object_data: "[0 as double, 1 as double, Double.MIN_VALUE.toDouble(), Double.MAX_VALUE.toDouble(), Double.NaN, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.EPSILON, 0.34567423843258427, Int.MAX_VALUE.toDouble(), -0.0]", expected_data_type: "FixedArray", expected_test_data: '["0", "1", "5e-324", "1.7976931348623157e+308", "NaN", "Infinity", "-Infinity", "2.220446049250313e-16", "0.34567423843258427", "2147483647", "0"]', verify_test_result_function: compareStringTrivial @@ -177,7 +177,7 @@ param_types: {}, param_list: {}, method_return_type: int, - init_object_data: "[0 as double, 1 as double, Byte.MIN_VALUE as double, Byte.MAX_VALUE as double]", + init_object_data: "[0 as double, 1 as double, Byte.MIN_VALUE.toDouble(), Byte.MAX_VALUE.toDouble()]", expected_data_type: "FixedArray", expected_test_data: '[0 as int, 1 as int, -128 as int, 127 as int]', verify_test_result_function: comparePrimitiveValue diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_double_static.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_double_static.yaml index fcc8b7bd0cc15dee7fe2e5d5ec16cb1f612e7213..c1f24e4decc7c99b75b1937992958fad7ff95a0b 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_double_static.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_double_static.yaml @@ -17,11 +17,11 @@ param_init_data_types: {"param1":"FixedArray"} , param_types: {"param1":Double}, param_nature: {"param1": object}, - param_list: {"param1": "[(-1) as double, 0 as double, 1 as double, Byte.MAX_VALUE as double, Byte.MIN_VALUE as double]"}, + param_list: {"param1": "[(-1) as double, 0 as double, 1 as double, Byte.MAX_VALUE.toDouble(), Byte.MIN_VALUE.toDouble()]"}, method_return_type: Double, expected_data_item_type: double, expected_data_type: "FixedArray", - expected_test_data: "[(-1) as double, 0 as double, 1 as double, Byte.MAX_VALUE as double, Byte.MIN_VALUE as double]", + expected_test_data: "[(-1) as double, 0 as double, 1 as double, Byte.MAX_VALUE.toDouble(), Byte.MIN_VALUE.toDouble()]", verify_test_result_function: compareWrapperObjectValue } diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_float_instance.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_float_instance.yaml index 5318c2c10a01583d1dc5b704be35dc74da5f54ed..ebb0661524baca9897549cff24732d51a479f4e1 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_float_instance.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_float_instance.yaml @@ -20,9 +20,9 @@ param_types: {}, param_list: {}, method_return_type: float, - init_object_data: "[0.0 as float, 1.0 as float, Float.MIN_VALUE as float, Float.MAX_VALUE as float]", + init_object_data: "[0.0f, 1.0f, Float.MIN_VALUE, Float.MAX_VALUE]", expected_data_type: "FixedArray", - expected_test_data: "[0.0 as float, 1.0 as float, Float.MIN_VALUE as float, Float.MAX_VALUE as float]", + expected_test_data: "[0.0f, 1.0f, Float.MIN_VALUE, Float.MAX_VALUE]", verify_test_result_function: compareFloatPointValue } - { @@ -34,9 +34,9 @@ param_types: {}, param_list: {}, method_return_type: byte, - init_object_data: "[0.0 as float, 1.0 as float, Byte.MIN_VALUE as byte, Byte.MAX_VALUE as byte]", + init_object_data: "[0.0f, 1.0f, Byte.MIN_VALUE.toByte(), Byte.MAX_VALUE.toByte()]", expected_data_type: "FixedArray", - expected_test_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE as byte, Byte.MAX_VALUE as byte]", + expected_test_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE.toByte(), Byte.MAX_VALUE.toByte()]", verify_test_result_function: comparePrimitiveValue } - { @@ -48,9 +48,9 @@ param_types: {}, param_list: {}, method_return_type: short, - init_object_data: "[0.0 as float, 1.0 as byte, Short.MIN_VALUE as short, Short.MAX_VALUE as short]", + init_object_data: "[0.0f, 1 as byte, Short.MIN_VALUE.toShort(), Short.MAX_VALUE.toShort()]", expected_data_type: "FixedArray", - expected_test_data: "[0 as short, 1 as short, Short.MIN_VALUE as short, Short.MAX_VALUE as short]", + expected_test_data: "[0 as short, 1 as short, Short.MIN_VALUE.toShort(), Short.MAX_VALUE.toShort()]", verify_test_result_function: comparePrimitiveValue } - { @@ -62,9 +62,9 @@ param_types: {}, param_list: {}, method_return_type: int, - init_object_data: "[0.0 as float, 1.0 as float, Int.MIN_VALUE as float, Int.MAX_VALUE as float]", + init_object_data: "[0.0f, 1.0f, Int.MIN_VALUE.toFloat(), Int.MAX_VALUE.toFloat()]", expected_data_type: "FixedArray", - expected_test_data: "[0 as int, 1 as int, Int.MIN_VALUE as int, Int.MAX_VALUE as int]", + expected_test_data: "[0 as int, 1 as int, Int.MIN_VALUE.toInt(), Int.MAX_VALUE.toInt()]", verify_test_result_function: comparePrimitiveValue } - { @@ -76,9 +76,9 @@ param_init_data_types: {}, param_types: {}, param_list: {}, - init_object_data: "[0.0 as float, 1.0 as float, Long.MIN_VALUE as float, Long.MAX_VALUE as float]", + init_object_data: "[0.0f, 1.0f, Long.MIN_VALUE.toFloat(), Long.MAX_VALUE.toFloat()]", expected_data_type: "FixedArray", - expected_test_data: "[0 as long, 1 as long, Long.MIN_VALUE as long, Long.MAX_VALUE as long]", + expected_test_data: "[0 as long, 1 as long, Long.MIN_VALUE.toLong(), Long.MAX_VALUE.toLong()]", verify_test_result_function: comparePrimitiveValue } - { @@ -90,9 +90,9 @@ param_types: {}, param_list: {}, method_return_type: float, - init_object_data: "[0 as byte, 1 as byte, Float.MIN_VALUE as byte, Float.MAX_VALUE as byte]", + init_object_data: "[0 as byte, 1 as byte, Float.MIN_VALUE.toByte(), Float.MAX_VALUE.toByte()]", expected_data_type: "FixedArray", - expected_test_data: "[0 as float, 1 as float, Float.MIN_VALUE as byte, Float.MAX_VALUE as byte]", + expected_test_data: "[0f, 1f, Float.MIN_VALUE.toByte(), Float.MAX_VALUE.toByte()]", verify_test_result_function: compareFloatPointValue } - { @@ -104,9 +104,9 @@ param_types: {}, param_list: {}, method_return_type: double, - init_object_data: "[0.0 as float, 1.0 as float, Float.MIN_VALUE as float, Float.MAX_VALUE as float]", + init_object_data: "[0.0f, 1.0f, Float.MIN_VALUE, Float.MAX_VALUE]", expected_data_type: "FixedArray", - expected_test_data: "[0.0 as double, 1.0 as double, Float.MIN_VALUE as double, Float.MAX_VALUE as double]", + expected_test_data: "[0.0 as double, 1.0 as double, Float.MIN_VALUE.toDouble(), Float.MAX_VALUE.toDouble()]", verify_test_result_function: compareFloatPointValue } - { @@ -118,7 +118,7 @@ param_types: {}, param_list: {}, method_return_type: String, - init_object_data: "[0.0 as float, 1.0 as float, Float.MIN_VALUE as float, Float.MAX_VALUE as float]", + init_object_data: "[0.0f, 1.0f, Float.MIN_VALUE, Float.MAX_VALUE]", expected_data_type: "FixedArray", expected_test_data: '["0", "1", "1e-45", "3.4028235e+38"]', verify_test_result_function: compareStringTrivial @@ -132,9 +132,9 @@ param_types: {}, param_list: {}, method_return_type: int, - init_object_data: "[0 as float, 1 as float, Int.MIN_VALUE as float, Int.MAX_VALUE as float]", + init_object_data: "[0f, 1f, Int.MIN_VALUE.toFloat(), Int.MAX_VALUE.toFloat()]", expected_data_type: "FixedArray", - expected_test_data: '[0 as int, 1 as int, Int.MIN_VALUE as int, Int.MAX_VALUE as int]', + expected_test_data: '[0 as int, 1 as int, Int.MIN_VALUE.toInt(), Int.MAX_VALUE.toInt()]', verify_test_result_function: comparePrimitiveValue } - { @@ -142,16 +142,16 @@ object_type: Float, init_object_data_type: "FixedArray", init_object_type: float, - init_object_data: "[0 as float, 1 as float, (-1) as float]", + init_object_data: "[0f, 1f, -1f]", param_init_data_types: {"param1": "FixedArray"}, param_types: {"param1": Float}, - param_list: {"param1": "[0 as float, 1 as float, (-1) as float]"}, + param_list: {"param1": "[0f, 1f, -1f]"}, param_nature: {"param1": object}, method_return_type: Float, expected_data_item_type: float, expected_data_type: "FixedArray", - expected_test_data: "[0 as float, 2 as float, (-2) as float]", + expected_test_data: "[0f, 2f, -2f]", verify_test_result_function: compareWrapperObjectValue, } - { @@ -159,16 +159,16 @@ object_type: Float, init_object_data_type: "FixedArray", init_object_type: float, - init_object_data: "[0 as float, 1 as float, (-1) as float]", + init_object_data: "[0f, 1f, -1f]", param_init_data_types: {"param1": "FixedArray"}, param_types: {"param1": Float}, - param_list: {"param1": "[0 as float, 1 as float, (-1) as float]"}, + param_list: {"param1": "[0f, 1f, -1f]"}, param_nature: {"param1": object}, method_return_type: Float, expected_data_item_type: float, expected_data_type: "FixedArray", - expected_test_data: "[0 as float, 0 as float, 0 as float]", + expected_test_data: "[0f, 0f, 0f]", verify_test_result_function: compareWrapperObjectValue, } - { @@ -176,16 +176,16 @@ object_type: Float, init_object_data_type: "FixedArray", init_object_type: float, - init_object_data: "[0 as float, 1 as float, (-1) as float, 1 as float]", + init_object_data: "[0f, 1f, -1f, 1f]", param_init_data_types: {"param1": "FixedArray"}, param_types: {"param1": Float}, - param_list: {"param1": "[0 as float, 1 as float, (-1) as float, (-1) as float]"}, + param_list: {"param1": "[0f, 1f, -1f, -1f]"}, param_nature: {"param1": object}, method_return_type: Float, expected_data_item_type: float, expected_data_type: "FixedArray", - expected_test_data: "[0 as float, 1 as float, 1 as float, (-1) as float]", + expected_test_data: "[0f, 1f, 1f, -1f]", verify_test_result_function: compareWrapperObjectValue, } - { @@ -193,15 +193,15 @@ object_type: Float, init_object_data_type: "FixedArray", init_object_type: float, - init_object_data: "[0 as float, 1 as float, (-1) as float, 1 as float]", + init_object_data: "[0f, 1f, -1f, 1f]", param_init_data_types: {"param1": "FixedArray"}, param_types: {"param1": Float}, - param_list: {"param1": "[1 as float, 1 as float, (-1) as float, (-1) as float]"}, + param_list: {"param1": "[1f, 1f, -1f, -1f]"}, param_nature: {"param1": object}, method_return_type: Float, expected_data_item_type: float, expected_data_type: "FixedArray", - expected_test_data: "[0 as float, 1 as float, 1 as float, (-1) as float]", + expected_test_data: "[0f, 1f, 1f, -1]", verify_test_result_function: compareWrapperObjectValue, } - { @@ -209,9 +209,9 @@ object_type: Float, init_object_data_type: "FixedArray", init_object_type: float, - init_object_data: "[126 as float, (-128) as float, 126 as float, (-128) as float, 126 as float, (-128) as float, 126 as float, (-128) as float, 126 as float, (-128) as float]", + init_object_data: "[126f, -128f, 126f, -128f, 126f, -128f, 126f, -128f, 126f, -128f]", - param_list: {"param1" : "[125 as float, 125 as float, 126 as float, 126 as float, 127 as float, 127 as float, (-127) as float, (-127) as float, (-128) as float, (-128) as float]"}, + param_list: {"param1" : "[125f, 125f, 126f, 126f, 127f, 127f, -127f, -127f, -128f, -128f]"}, param_init_data_types: {"param1": "FixedArray"} , param_types: {"param1": Float}, param_nature: {"param1": object}, @@ -230,9 +230,9 @@ object_type: Float, init_object_data_type: "FixedArray", init_object_type: float, - init_object_data: "[126 as float, (-128) as float, 126 as float, (-128) as float, 126 as float, (-128) as float, 126 as float, (-128) as float, 126 as float, (-128) as float]", + init_object_data: "[126f, -128f, 126f, -128f, 126f, -128f, 126f, -128f, 126f, -128f]", - param_list: {"param1" : "[125 as float, 125 as float, 126 as float, 126 as float, 127 as float, 127 as float, (-127) as float, (-127) as float, (-128) as float, (-128) as float]"}, + param_list: {"param1" : "[125f, 125f, 126f, 126f, 127f, 127f, -127f, -127f, -128f, -128f]"}, param_init_data_types: {"param1": "FixedArray"} , param_types: {"param1": Float}, param_nature: {"param1": object}, @@ -251,9 +251,9 @@ object_type: Float, init_object_data_type: "FixedArray", init_object_type: float, - init_object_data: "[126 as float, (-128) as float, 126 as float, (-128) as float, 126 as float, (-128) as float, 126 as float, (-128) as float, 126 as float, (-128) as float]", + init_object_data: "[126f, -128f, 126f, -128f, 126f, -128f, 126f, -128f, 126f, -128f]", - param_list: {"param1" : "[125 as float, 125 as float, 126 as float, 126 as float, 127 as float, 127 as float, (-127) as float, (-127) as float, (-128) as float, (-128) as float]"}, + param_list: {"param1" : "[125f, 125f, 126f, 126f, 127f, 127f, -127f, -127f, -128f, -128f]"}, param_init_data_types: {"param1": "FixedArray"} , param_types: {"param1": Float}, param_nature: {"param1": object}, @@ -272,9 +272,9 @@ object_type: Float, init_object_data_type: "FixedArray", init_object_type: float, - init_object_data: "[126 as float, (-128) as float, 126 as float, (-128) as float, 126 as float, (-128) as float, 126 as float, (-128) as float, 126 as float, (-128) as float]", + init_object_data: "[126f, -128f, 126f, -128f, 126f, -128f, 126f, -128f, 126f, -128f]", - param_list: {"param1" : "[125 as float, 125 as float, 126 as float, 126 as float, 127 as float, 127 as float, (-127) as float, (-127) as float, (-128) as float, (-128) as float]"}, + param_list: {"param1" : "[125f, 125f, 126f, 126f, 127f, 127f, -127f, -127f, -128f, -128f]"}, param_init_data_types: {"param1": "FixedArray"} , param_types: {"param1": Float}, param_nature: {"param1": object}, @@ -293,9 +293,9 @@ object_type: Float, init_object_data_type: "FixedArray", init_object_type: float, - init_object_data: "[126 as float, (-128) as float, 126 as float, (-128) as float, 126 as float, (-128) as float, 126 as float, (-128) as float, 126 as float, (-128) as float]", + init_object_data: "[126f, -128f, 126f, -128f, 126f, -128f, 126f, -128f, 126f, -128f]", - param_list: {"param1" : "[125 as float, 125 as float, 126 as float, 126 as float, 127 as float, 127 as float, (-127) as float, (-127) as float, (-128) as float, (-128) as float]"}, + param_list: {"param1" : "[125f, 125f, 126f, 126f, 127f, 127f, -127f, -127f, -128f, -128f]"}, param_init_data_types: {"param1": "FixedArray"} , param_types: {"param1": Float}, param_nature: {"param1": object}, @@ -314,9 +314,9 @@ object_type: Float, init_object_data_type: "FixedArray", init_object_type: float, - init_object_data: "[126 as float, (-128) as float, 126 as float, (-128) as float]", + init_object_data: "[126f, -128f, 126f, -128f]", - param_list: {"param1" : "[125 as float, (-128) as float, 127 as float, (-128) as float]"}, + param_list: {"param1" : "[125f, -128f, 127f, -128f]"}, param_init_data_types: {"param1": "FixedArray"} , param_types: {"param1": Float}, param_nature: {"param1": object}, @@ -336,7 +336,7 @@ object_type: Float, init_object_data_type: "FixedArray", init_object_type: float, - init_object_data: "[(-1) as float, 0 as float, 1 as float, Float.MAX_SAFE_INTEGER, Float.MAX_SAFE_INTEGER + 1, 12.5 as float, -Float.MAX_SAFE_INTEGER, (-Float.MAX_SAFE_INTEGER - 1)]", + init_object_data: "[-1f, 0f, 1f, Float.MAX_SAFE_INTEGER, Float.MAX_SAFE_INTEGER + 1, 12.5f, -Float.MAX_SAFE_INTEGER, (-Float.MAX_SAFE_INTEGER - 1)]", param_list: {}, param_init_data_types: {}, diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_float_static.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_float_static.yaml index 8af47bc30508b3317c2d26ac8698b7ee92b36572..d85fbee9a1ed6ba25256155cfa2fa7db4dc1c466 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_float_static.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_float_static.yaml @@ -17,12 +17,12 @@ param_init_data_types: {"param1":"FixedArray"} , param_types: {"param1":Float}, param_nature: {"param1": object}, - param_list: {"param1": "[(-1) as float, 0 as float, 1 as float, Float.MAX_VALUE as float, Float.MIN_VALUE as float]"}, + param_list: {"param1": "[-1f, 0f, 1f, Float.MAX_VALUE.toFloat(), Float.MIN_VALUE.toFloat()]"}, method_return_type: Float, expected_data_item_type: Float, expected_data_type: "FixedArray", - expected_test_data: "[(-1) as float, 0 as float, 1 as float, Float.MAX_VALUE as float, Float.MIN_VALUE as float]", + expected_test_data: "[-1f, 0f, 1f, Float.MAX_VALUE.toFloat(), Float.MIN_VALUE.toFloat()]", verify_test_result_function: compareWrapperObjectValue, } - { @@ -31,7 +31,7 @@ param_init_data_types: {"param1":"FixedArray"}, param_types: {"param1":Float}, param_nature: {"param1": object}, - param_list: {"param1": "[(-1) as float, 0 as float, 1 as float, Float.MAX_SAFE_INTEGER, Float.MAX_SAFE_INTEGER + 1, 12.5 as float, -Float.MAX_SAFE_INTEGER, (-Float.MAX_SAFE_INTEGER - 1)]"}, + param_list: {"param1": "[-1f, 0f, 1f, Float.MAX_SAFE_INTEGER, Float.MAX_SAFE_INTEGER + 1, 12.5f, -Float.MAX_SAFE_INTEGER, (-Float.MAX_SAFE_INTEGER - 1)]"}, method_return_type: boolean, expected_data_item_type: boolean, expected_data_type: "FixedArray", diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_int_instance.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_int_instance.yaml index 7df3fd9ed23830486e0d3cd0702d0fb54c257180..ec75338ec7be04aa0db1dbb84b14615679fd0663 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_int_instance.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_int_instance.yaml @@ -15,105 +15,105 @@ method_name: unboxed, object_type: Int, init_object_data_type: "FixedArray", - init_object_data: "[0 as int, 1 as int, Int.MIN_VALUE as int, Int.MAX_VALUE as int]", + init_object_data: "[0 as int, 1 as int, Int.MIN_VALUE.toInt(), Int.MAX_VALUE.toInt()]", param_init_data_types: {} , param_types: {}, method_return_type: int, expected_data_item_type: int, expected_data_type: "FixedArray", param_list: {}, - expected_test_data: "[0 as int, 1 as int, Int.MIN_VALUE as int, Int.MAX_VALUE as int]", + expected_test_data: "[0 as int, 1 as int, Int.MIN_VALUE.toInt(), Int.MAX_VALUE.toInt()]", verify_test_result_function: comparePrimitiveValue, } - { method_name: toByte, object_type: Int, init_object_data_type: "FixedArray", - init_object_data: "[0 as int, 1 as int, Byte.MIN_VALUE as int, Byte.MAX_VALUE as int]", + init_object_data: "[0 as int, 1 as int, Byte.MIN_VALUE.toInt(), Byte.MAX_VALUE.toInt()]", param_init_data_types: {} , param_types: {}, method_return_type: byte, expected_data_item_type: byte, expected_data_type: "FixedArray", param_list: {}, - expected_test_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE as byte, Byte.MAX_VALUE as byte]", + expected_test_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE.toByte(), Byte.MAX_VALUE.toByte()]", verify_test_result_function: comparePrimitiveValue, } - { method_name: toShort, object_type: Int, init_object_data_type: "FixedArray", - init_object_data: "[0 as int, 1 as int, Short.MIN_VALUE as int, Short.MAX_VALUE as int]", + init_object_data: "[0 as int, 1 as int, Short.MIN_VALUE.toInt(), Short.MAX_VALUE.toInt()]", param_init_data_types: {} , param_types: {}, method_return_type: short, expected_data_item_type: short, expected_data_type: "FixedArray", param_list: {}, - expected_test_data: "[0 as short, 1 as short, Short.MIN_VALUE as short, Short.MAX_VALUE as short]", + expected_test_data: "[0 as short, 1 as short, Short.MIN_VALUE.toShort(), Short.MAX_VALUE.toShort()]", verify_test_result_function: comparePrimitiveValue, } - { method_name: toInt, object_type: Int, init_object_data_type: "FixedArray", - init_object_data: "[0 as int, 1 as int, Int.MIN_VALUE as int, Int.MAX_VALUE as int]", + init_object_data: "[0 as int, 1 as int, Int.MIN_VALUE.toInt(), Int.MAX_VALUE.toInt()]", param_init_data_types: {} , param_types: {}, method_return_type: int, expected_data_item_type: int, expected_data_type: "FixedArray", param_list: {}, - expected_test_data: "[0 as int, 1 as int, Int.MIN_VALUE as int, Int.MAX_VALUE as int]", + expected_test_data: "[0 as int, 1 as int, Int.MIN_VALUE.toInt(), Int.MAX_VALUE.toInt()]", verify_test_result_function: comparePrimitiveValue, } - { method_name: toLong, object_type: Int, init_object_data_type: "FixedArray", - init_object_data: "[0 as int, 1 as int, Int.MIN_VALUE as int, Int.MAX_VALUE as int]", + init_object_data: "[0 as int, 1 as int, Int.MIN_VALUE.toInt(), Int.MAX_VALUE.toInt()]", param_init_data_types: {} , param_types: {}, method_return_type: long, expected_data_item_type: long, expected_data_type: "FixedArray", param_list: {}, - expected_test_data: "[0 as long, 1 as long, Int.MIN_VALUE as long, Int.MAX_VALUE as long]", + expected_test_data: "[0 as long, 1 as long, Int.MIN_VALUE.toLong(), Int.MAX_VALUE.toLong()]", verify_test_result_function: comparePrimitiveValue, } - { method_name: toFloat, object_type: Int, init_object_data_type: "FixedArray", - init_object_data: "[0 as int, 1 as int, Int.MIN_VALUE as int, Int.MAX_VALUE as int]", + init_object_data: "[0 as int, 1 as int, Int.MIN_VALUE.toInt(), Int.MAX_VALUE.toInt()]", param_init_data_types: {} , param_types: {}, method_return_type: float, expected_data_item_type: float, expected_data_type: "FixedArray", param_list: {}, - expected_test_data: "[0 as float, 1 as float, Int.MIN_VALUE as float, Int.MAX_VALUE as float]", + expected_test_data: "[0 as float, 1 as float, Int.MIN_VALUE.toFloat(), Int.MAX_VALUE.toFloat()]", verify_test_result_function: compareFloatPointValue } - { method_name: toDouble, object_type: Int, init_object_data_type: "FixedArray", - init_object_data: "[0 as int, 1 as int, Int.MIN_VALUE as int, Int.MAX_VALUE as int]", + init_object_data: "[0 as int, 1 as int, Int.MIN_VALUE.toInt(), Int.MAX_VALUE.toInt()]", param_init_data_types: {} , param_types: {}, method_return_type: double, expected_data_item_type: double, expected_data_type: "FixedArray", param_list: {}, - expected_test_data: "[0 as double, 1 as double, Int.MIN_VALUE as double, Int.MAX_VALUE as double]", + expected_test_data: "[0 as double, 1 as double, Int.MIN_VALUE.toDouble(), Int.MAX_VALUE.toDouble()]", verify_test_result_function: compareFloatPointValue } - { method_name: toString, object_type: Int, init_object_data_type: "FixedArray", - init_object_data: "[0 as int, 1 as int, Int.MIN_VALUE as int, Int.MAX_VALUE as int]", + init_object_data: "[0 as int, 1 as int, Int.MIN_VALUE.toInt(), Int.MAX_VALUE.toInt()]", param_init_data_types: {} , param_types: {}, method_return_type: String, diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_long_instance.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_long_instance.yaml index 29b0c25c555ea2f92a11bff47da94fbbb78d123b..35c815217ed6d5c503757c1d6704583878cc1a91 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_long_instance.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_long_instance.yaml @@ -21,9 +21,9 @@ param_types: {}, param_list: {}, method_return_type: long, - init_object_data: "[0 as long, 1 as int, -1 as int, Long.MIN_VALUE as long, Long.MAX_VALUE as long]", + init_object_data: "[0 as long, 1 as int, -1 as int, Long.MIN_VALUE.toLong(), Long.MAX_VALUE.toLong()]", expected_data_type: "FixedArray", - expected_test_data: "[0 as long, 1 as long, -1 as long, Long.MIN_VALUE as long, Long.MAX_VALUE as long]", + expected_test_data: "[0 as long, 1 as long, -1 as long, Long.MIN_VALUE.toLong(), Long.MAX_VALUE.toLong()]", verify_test_result_function: comparePrimitiveValue } @@ -38,9 +38,9 @@ param_types: {}, param_list: {}, method_return_type: byte, - init_object_data: "[0 as long, 1 as long, Byte.MIN_VALUE as long, Byte.MAX_VALUE as long]", + init_object_data: "[0 as long, 1 as long, Byte.MIN_VALUE.toLong(), Byte.MAX_VALUE.toLong()]", expected_data_type: "FixedArray", - expected_test_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE as byte, Byte.MAX_VALUE as byte]", + expected_test_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE.toByte(), Byte.MAX_VALUE.toByte()]", verify_test_result_function: comparePrimitiveValue } - { @@ -53,9 +53,9 @@ param_types: {}, param_list: {}, method_return_type: short, - init_object_data: "[0 as long, 1 as long, Short.MIN_VALUE as long, Short.MAX_VALUE as long]", + init_object_data: "[0 as long, 1 as long, Short.MIN_VALUE.toLong(), Short.MAX_VALUE.toLong()]", expected_data_type: "FixedArray", - expected_test_data: "[0 as short, 1 as short, Short.MIN_VALUE as short, Short.MAX_VALUE as short]", + expected_test_data: "[0 as short, 1 as short, Short.MIN_VALUE.toShort(), Short.MAX_VALUE.toShort()]", verify_test_result_function: comparePrimitiveValue } - { @@ -68,9 +68,9 @@ param_types: {}, param_list: {}, method_return_type: int, - init_object_data: "[0 as long, 1 as long, -1 as long, Int.MIN_VALUE as long, Int.MAX_VALUE as long]", + init_object_data: "[0 as long, 1 as long, -1 as long, Int.MIN_VALUE.toLong(), Int.MAX_VALUE.toLong()]", expected_data_type: "FixedArray", - expected_test_data: "[0 as int, 1 as int, -1 as int, Int.MIN_VALUE as int, Int.MAX_VALUE as int]", + expected_test_data: "[0 as int, 1 as int, -1 as int, Int.MIN_VALUE.toInt(), Int.MAX_VALUE.toInt()]", verify_test_result_function: comparePrimitiveValue } - { @@ -83,9 +83,9 @@ param_types: {}, param_list: {}, method_return_type: long, - init_object_data: "[0 as long, 1 as long, -1 as long, Long.MIN_VALUE as long, Long.MAX_VALUE as long]", + init_object_data: "[0 as long, 1 as long, -1 as long, Long.MIN_VALUE.toLong(), Long.MAX_VALUE.toLong()]", expected_data_type: "FixedArray", - expected_test_data: "[0 as long, 1 as long, -1 as long, Long.MIN_VALUE as long, Long.MAX_VALUE as long]", + expected_test_data: "[0 as long, 1 as long, -1 as long, Long.MIN_VALUE.toLong(), Long.MAX_VALUE.toLong()]", verify_test_result_function: comparePrimitiveValue } - { @@ -98,9 +98,9 @@ param_types: {}, param_list: {}, method_return_type: float, - init_object_data: "[0 as long, 1 as long, -1 as long, Long.MIN_VALUE as long, Long.MAX_VALUE as long]", + init_object_data: "[0 as long, 1 as long, -1 as long, Long.MIN_VALUE.toLong(), Long.MAX_VALUE.toLong()]", expected_data_type: "FixedArray", - expected_test_data: "[0 as float, 1 as float, -1 as float, Long.MIN_VALUE as float, Long.MAX_VALUE as float]", + expected_test_data: "[0 as float, 1 as float, -1 as float, Long.MIN_VALUE.toFloat(), Long.MAX_VALUE.toFloat()]", verify_test_result_function: compareFloatPointValue } - { @@ -113,9 +113,9 @@ param_types: {}, param_list: {}, method_return_type: double, - init_object_data: "[0 as long, 1 as long, -1 as long, Long.MIN_VALUE as long, Long.MAX_VALUE as long]", + init_object_data: "[0 as long, 1 as long, -1 as long, Long.MIN_VALUE.toLong(), Long.MAX_VALUE.toLong()]", expected_data_type: "FixedArray", - expected_test_data: "[0 as double, 1 as double, -1 as double, Long.MIN_VALUE as double, Long.MAX_VALUE as double]", + expected_test_data: "[0 as double, 1 as double, -1 as double, Long.MIN_VALUE.toDouble(), Long.MAX_VALUE.toDouble()]", verify_test_result_function: compareFloatPointValue } - { @@ -128,9 +128,9 @@ param_types: {}, param_list: {}, method_return_type: int, - init_object_data: "[0 as long, 1 as long, -1 as long, Int.MIN_VALUE as long, Int.MAX_VALUE as long]", + init_object_data: "[0 as long, 1 as long, -1 as long, Int.MIN_VALUE.toLong(), Int.MAX_VALUE.toLong()]", expected_data_type: "FixedArray", - expected_test_data: '[0 as int, 1 as int, -1 as int, Int.MIN_VALUE as int, Int.MAX_VALUE as int]', + expected_test_data: '[0 as int, 1 as int, -1 as int, Int.MIN_VALUE.toInt(), Int.MAX_VALUE.toInt()]', verify_test_result_function: comparePrimitiveValue } - { @@ -143,7 +143,7 @@ param_types: {}, param_list: {}, method_return_type: String, - init_object_data: "[0 as long, 1 as long, -1 as long, Long.MIN_VALUE as long, Long.MAX_VALUE as long]", + init_object_data: "[0 as long, 1 as long, -1 as long, Long.MIN_VALUE.toLong(), Long.MAX_VALUE.toLong()]", expected_data_type: "FixedArray", expected_test_data: '["0", "1", "-1", "-9223372036854775808", "9223372036854775807"]', verify_test_result_function: compareStringTrivial diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_short_instance.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_short_instance.yaml index 38244144efef70a539d038d98882440b98b9cd09..e2b39599af0e2017c6013cedaba406e71d66031d 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_short_instance.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_short_instance.yaml @@ -15,105 +15,105 @@ method_name: unboxed, object_type: Short, init_object_data_type: "FixedArray", - init_object_data: "[0 as short, 1 as short, Short.MIN_VALUE as short, Short.MAX_VALUE as short]", + init_object_data: "[0 as short, 1 as short, Short.MIN_VALUE.toShort(), Short.MAX_VALUE.toShort()]", param_init_data_types: {} , param_types: {}, method_return_type: short, expected_data_item_type: short, expected_data_type: "FixedArray", param_list: {}, - expected_test_data: "[0 as short, 1 as short, Short.MIN_VALUE as short, Short.MAX_VALUE as short]", + expected_test_data: "[0 as short, 1 as short, Short.MIN_VALUE.toShort(), Short.MAX_VALUE.toShort()]", verify_test_result_function: comparePrimitiveValue, } - { method_name: toByte, object_type: Short, init_object_data_type: "FixedArray", - init_object_data: "[0 as short, 1 as short, Byte.MIN_VALUE as short, Byte.MAX_VALUE as short]", + init_object_data: "[0 as short, 1 as short, Byte.MIN_VALUE.toShort(), Byte.MAX_VALUE.toShort()]", param_init_data_types: {} , param_types: {}, method_return_type: byte, expected_data_item_type: byte, expected_data_type: "FixedArray", param_list: {}, - expected_test_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE as byte, Byte.MAX_VALUE as byte]", + expected_test_data: "[0 as byte, 1 as byte, Byte.MIN_VALUE.toByte(), Byte.MAX_VALUE.toByte()]", verify_test_result_function: comparePrimitiveValue, } - { method_name: toShort, object_type: Short, init_object_data_type: "FixedArray", - init_object_data: "[0 as short, 1 as short, Short.MIN_VALUE as short, Short.MAX_VALUE as short]", + init_object_data: "[0 as short, 1 as short, Short.MIN_VALUE.toShort(), Short.MAX_VALUE.toShort()]", param_init_data_types: {} , param_types: {}, method_return_type: short, expected_data_item_type: short, expected_data_type: "FixedArray", param_list: {}, - expected_test_data: "[0 as short, 1 as short, Short.MIN_VALUE as short, Short.MAX_VALUE as short]", + expected_test_data: "[0 as short, 1 as short, Short.MIN_VALUE.toShort(), Short.MAX_VALUE.toShort()]", verify_test_result_function: comparePrimitiveValue, } - { method_name: toInt, object_type: Short, init_object_data_type: "FixedArray", - init_object_data: "[0 as short, 1 as short, Short.MIN_VALUE as short, Short.MAX_VALUE as short]", + init_object_data: "[0 as short, 1 as short, Short.MIN_VALUE.toShort(), Short.MAX_VALUE.toShort()]", param_init_data_types: {} , param_types: {}, method_return_type: int, expected_data_item_type: int, expected_data_type: "FixedArray", param_list: {}, - expected_test_data: "[0 as int, 1 as int, Short.MIN_VALUE as int, Short.MAX_VALUE as int]", + expected_test_data: "[0 as int, 1 as int, Short.MIN_VALUE.toInt(), Short.MAX_VALUE.toInt()]", verify_test_result_function: comparePrimitiveValue, } - { method_name: toLong, object_type: Short, init_object_data_type: "FixedArray", - init_object_data: "[0 as short, 1 as short, Short.MIN_VALUE as short, Short.MAX_VALUE as short]", + init_object_data: "[0 as short, 1 as short, Short.MIN_VALUE.toShort(), Short.MAX_VALUE.toShort()]", param_init_data_types: {} , param_types: {}, method_return_type: long, expected_data_item_type: long, expected_data_type: "FixedArray", param_list: {}, - expected_test_data: "[0 as long, 1 as long, Short.MIN_VALUE as long, Short.MAX_VALUE as long]", + expected_test_data: "[0 as long, 1 as long, Short.MIN_VALUE.toLong(), Short.MAX_VALUE.toLong()]", verify_test_result_function: comparePrimitiveValue, } - { method_name: toFloat, object_type: Short, init_object_data_type: "FixedArray", - init_object_data: "[0 as short, 1 as short, Short.MIN_VALUE as short, Short.MAX_VALUE as short]", + init_object_data: "[0 as short, 1 as short, Short.MIN_VALUE.toShort(), Short.MAX_VALUE.toShort()]", param_init_data_types: {} , param_types: {}, method_return_type: float, expected_data_item_type: float, expected_data_type: "FixedArray", param_list: {}, - expected_test_data: "[0 as float, 1 as float, Short.MIN_VALUE as float, Short.MAX_VALUE as float]", + expected_test_data: "[0 as float, 1 as float, Short.MIN_VALUE.toFloat(), Short.MAX_VALUE.toFloat()]", verify_test_result_function: compareFloatPointValue } - { method_name: toDouble, object_type: Short, init_object_data_type: "FixedArray", - init_object_data: "[0 as short, 1 as short, Short.MIN_VALUE as short, Short.MAX_VALUE as short]", + init_object_data: "[0 as short, 1 as short, Short.MIN_VALUE.toShort(), Short.MAX_VALUE.toShort()]", param_init_data_types: {} , param_types: {}, method_return_type: double, expected_data_item_type: double, expected_data_type: "FixedArray", param_list: {}, - expected_test_data: "[0 as double, 1 as double, Short.MIN_VALUE as double, Short.MAX_VALUE as double]", + expected_test_data: "[0 as double, 1 as double, Short.MIN_VALUE.toDouble(), Short.MAX_VALUE.toDouble()]", verify_test_result_function: compareFloatPointValue } - { method_name: toString, object_type: Short, init_object_data_type: "FixedArray", - init_object_data: "[0 as short, 1 as short, Short.MIN_VALUE as short, Short.MAX_VALUE as short]", + init_object_data: "[0 as short, 1 as short, Short.MIN_VALUE.toShort(), Short.MAX_VALUE.toShort()]", param_init_data_types: {} , param_types: {}, method_return_type: String, diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_string_instance.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_string_instance.yaml index 82a995f9d298c258e08cf80b7c732bb63419d976..8f1ecc3095adf136e4de866f5197b4ca420d5590 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_string_instance.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_string_instance.yaml @@ -21,7 +21,7 @@ param_init_data_types: {}, param_types: {}, param_list: {}, - method_return_type: int, + method_return_type: Int, expected_data_type: "FixedArray", expected_test_data: "[0, 4, 4, 8, 4, 8]", verify_test_result_function: comparePrimitiveValue @@ -306,7 +306,7 @@ param_types: {"param1": String}, param_nature: {"param1": primitive}, param_list: {"param1": '["abcd", "hjkl", "abcd", "hjkl"]'}, - method_return_type: int, + method_return_type: Int, expected_data_item_type: int, expected_data_type: "FixedArray", @@ -402,7 +402,7 @@ param_nature: {"param1": primitive}, param_list: {"param1": "[c'a', c'к', c'世', c'世', c'a', c'к']"}, - method_return_type: double, + method_return_type: Double, expected_data_item_type: double, expected_data_type: "FixedArray", @@ -484,7 +484,7 @@ param_nature: {"param1": primitive}, param_list: {"param1": '["bcd", "xyz", "", "", "a"]'}, - method_return_type: double, + method_return_type: Double, expected_data_item_type: double, expected_data_type: "FixedArray", @@ -504,7 +504,7 @@ param_nature: {"param1": primitive}, param_list: {"param1": "[c'g', c'к', c'界', c'界', c'g', c'к']"}, - method_return_type: double, + method_return_type: Double, expected_data_item_type: double, expected_data_type: "FixedArray", @@ -524,7 +524,7 @@ param_nature: {"param1": primitive}, param_list: {"param1": '["bcd", "xyz"]'}, - method_return_type: double, + method_return_type: Double, expected_data_item_type: double, expected_data_type: "FixedArray", @@ -784,7 +784,7 @@ param_types: {"param1": String, "param2": int}, param_nature: {"param1": primitive, "param2": primitive}, param_list: {"param1": '["ab", "ab", "ab", "ab", "ijk", "ijk", "ijk", "ijk", "ijk", "ijk", "", "", ""]', "param2": "[0, 2, 8, 12, 0, 2, 8, 12, 23, -2, -2, 22, 23]"}, - method_return_type: double, + method_return_type: Double, expected_data_type: "FixedArray", expected_test_data: "[0, 11, 11, -1, 8, 8, 8, 19, -1, 8, 0, 22, 22]", @@ -803,7 +803,7 @@ param_types: {"param1": String, "param2": number}, param_nature: {"param1": primitive, "param2": primitive}, param_list: {"param1": '["ab", "ab", "ab", "ab", "ijk", "ijk", "ijk", "ijk", "ijk", "ijk", "", "", ""]', "param2": "[0, 2.9, 8, 12.4, 0, 2.8, 8, 12.04, 23, -2, -2, 22, 23.5]"}, - method_return_type: double, + method_return_type: Double, expected_data_type: "FixedArray", expected_test_data: "[0, 11, 11, -1, 8, 8, 8, 19, -1, 8, 0, 22, 22]", @@ -824,7 +824,7 @@ param_nature: {"param1": primitive, "param2": primitive}, param_list: {"param1": "[c'a', c'a', c'a', c'h', c'h', c'h', c'h', c'h', c'c', c'c', c'c']", "param2": "[0, 2, 8, 0, 2, 8, 14, 15, 0, 2, 8]"}, - method_return_type: double, + method_return_type: Double, expected_data_type: "FixedArray", expected_test_data: "[0, -1, -1, 6, 6, 13, -1, -1, 2, 2, 8]", @@ -846,7 +846,7 @@ param_types: {"param1": String, "param2": int}, param_nature: {"param1": primitive, "param2": primitive}, param_list: {"param1": '["ab", "ab", "ab", "ab", "ijk", "ijk", "ijk", "ijk", "ijk", "ijkl", "eabc", "", "", "", ""]', "param2": "[4, 14, 100, -1, 8, 15, 18, 19, 40, 40, 40, 28, 22, 14, -5]"}, - method_return_type: double, + method_return_type: Double, expected_data_type: "FixedArray", expected_test_data: "[0, 11, 11, 0, 8, 8, 8, 19, 19, -1, -1, 22, 22, 14, 0]", @@ -887,7 +887,7 @@ param_nature: {"param1": primitive, "param2": primitive}, param_list: {"param1": "[c'a', c'a', c'a', c'h', c'h', c'h', c'h', c'c', c'c', c'c']", "param2": "[0, 5, -3, 5, 6, 12, 13, 3, 2, 8]"}, - method_return_type: double, + method_return_type: Double, expected_data_type: "FixedArray", expected_test_data: "[0, 0, -1, -1, 6, 6, 13, 2, 2, 8]", @@ -1237,7 +1237,7 @@ param_init_data_types: {inputs: "FixedArray"}, param_list: {inputs: '[0, 0]'}, - method_return_type: int, + method_return_type: Int, expected_test_data_item_type: int, expected_data_type: "FixedArray", expected_test_data: '[67, 1050]', @@ -1878,7 +1878,7 @@ param_types: {"param1": String}, param_nature: {"param1": object }, param_list: {"param1": '["ab", "ab", "ab", "ab", "ijk", "ijk", "ijk", "ijk", "ijk", "ijk", "", "", ""]'}, - method_return_type: double, + method_return_type: Double, expected_data_type: "FixedArray", expected_test_data: "[0 as double, 0 as double, 0 as double, 0 as double, 8 as double, 8 as double, 8 as double, 8 as double, 8 as double, 8 as double, 0 as double, 0 as double, 0 as double]", diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_stringbuilder_instance.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_stringbuilder_instance.yaml index 377cc4beca587343dfa88d6d5a46b7a28791ac8a..c67c6a89e187da603cf9c59a6f675e0fabb00e73 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_stringbuilder_instance.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_stringbuilder_instance.yaml @@ -127,7 +127,7 @@ init_object_data_type: "FixedArray", init_object_type: String, init_object_data: '["", "", "abcd", "abcd"]', - param_list: {"param1": "[E as float, (-E) as float, E as float, (-E) as float]"}, + param_list: {"param1": "[E.toFloat(), (-E).toFloat(), E.toFloat(), (-E).toFloat()]"}, param_types: {"param1": float}, param_nature: {"param1": "primitive"}, param_init_data_types: {"param1" : "FixedArray"}, diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_stringbuilder_static.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_stringbuilder_static.yaml index 1a83e36e005324cac5115e5db4e328c7b7c3dfb3..18282c199a56e1b65a4abd499336ff9e5d0790f5 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_stringbuilder_static.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_stringbuilder_static.yaml @@ -98,7 +98,7 @@ method_return_type: String, expected_data_item_type: String, expected_data_type: "FixedArray", - param_list: {"param1": "[E as float, (-E) as float, 0.0 as float]"}, + param_list: {"param1": "[E.toFloat(), (-E).toFloat(), 0.0.toFloat()]"}, expected_test_data: '["2.7182817", "-2.7182817", "0"]', verify_test_result_function: compareStringTrivial, } diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_type_numeric_type.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_type_numeric_type.yaml index 69b58c54a083c0d7c2dc0b5fb2babe19e42dcdf7..c53a7db6df2c707b6e4bb901812b0bb00e75d713 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_type_numeric_type.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_type_numeric_type.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 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 @@ -20,7 +20,7 @@ short: "0", int: "0", long: "0", - float: "0.0", + float: "0.0f", double: "0.0", Char: "new Char()", Boolean: "new Boolean()", diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_typedarrays_function1.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_typedarrays_function1.yaml index 6d1ec7a6f2615ea5dc9eff784d62860dfe5b87ae..01df038d107efe594bf814e85ddf76f839ac8b3d 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_typedarrays_function1.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_typedarrays_function1.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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,29 +16,29 @@ type: "number", primitiveType: "byte", elementType: "byte", - cast2primitive: " as byte", + cast2primitive: ".toByte()", create: "", primitiveSizeBytes: 1, - data: "[Byte.MIN_VALUE as byte, -120 as byte, -77 as byte, -1 as byte, 0 as byte, 1 as byte, 77 as byte, 120 as byte, Byte.MAX_VALUE as byte]", - abnormalData: "[Byte.MIN_VALUE -2 as byte, Byte.MIN_VALUE -1 as byte, Byte.MAX_VALUE + 1 as byte, Byte.MAX_VALUE + 2 as byte]" + data: "[Byte.MIN_VALUE, -120 as byte, -77 as byte, -1 as byte, 0 as byte, 1 as byte, 77 as byte, 120 as byte, Byte.MAX_VALUE]", + abnormalData: "[(Byte.MIN_VALUE - 2).toByte(), (Byte.MIN_VALUE - 1).toByte(), (Byte.MAX_VALUE + 1).toByte(), (Byte.MAX_VALUE + 2).toByte()]" } - { objectType: "Int16Array", type: "number", primitiveType: "short", elementType: "short", - cast2primitive: " as short", + cast2primitive: ".toShort()", create: "", primitiveSizeBytes: 2, - data: "[Short.MIN_VALUE as short, -12345 as short, -777 as short, -1 as short, 0 as short, 1 as short, 777 as short, 12345 as short, Short.MAX_VALUE as short]", - abnormalData: "[Short.MIN_VALUE - 2 as short, Short.MIN_VALUE - 1 as short, Short.MAX_VALUE + 1 as short, Short.MAX_VALUE + 2 as short]" + data: "[Short.MIN_VALUE, -12345 as short, -777 as short, -1 as short, 0 as short, 1 as short, 777 as short, 12345 as short, Short.MAX_VALUE as short]", + abnormalData: "[(Short.MIN_VALUE - 2).toShort(), (Short.MIN_VALUE - 1).toShort(), (Short.MAX_VALUE + 1).toShort(), (Short.MAX_VALUE + 2).toShort()]" } - { objectType: "Int32Array", type: "number", primitiveType: "int", elementType: "int", - cast2primitive: " as int", + cast2primitive: ".toInt()", create: "", primitiveSizeBytes: 4, data: "[Int.MIN_VALUE, -1234567, -7777, -1, 0, 1, 7777, 1234567, Int.MAX_VALUE]", @@ -50,7 +50,7 @@ type: "number", primitiveType: "double", elementType: "double", - cast2primitive: " as double", + cast2primitive: ".toDouble()", create: "", primitiveSizeBytes: 8, data: "[Double.MIN_VALUE, Double.MAX_VALUE, 0.0, -0.0, 1e10, 3.141592653589793, 30, 0.5]", @@ -62,7 +62,7 @@ type: "number", primitiveType: "double", elementType: "double", - cast2primitive: " as double", + cast2primitive: ".toDouble()", create: "", primitiveSizeBytes: 8, data: "[0.1, 0.2, 1e10,-1.1111111,-2.8, 0, Double.MIN_VALUE, Double.MAX_VALUE]", @@ -74,11 +74,11 @@ type: "number", primitiveType: "number", elementType: "float", - cast2primitive: " as float", + cast2primitive: ".toFloat()", create: "", primitiveSizeBytes: 4, - data: "[Float.MIN_VALUE, Float.MAX_VALUE, 0.0, -0.0, 1e10, 3.141592653589793 as float, 30, 0.5]", - abnormalData: "[Float.MIN_VALUE - 2, Float.MIN_VALUE - 1, Float.MAX_VALUE + 1, Float.MAX_VALUE + 2]" + data: "[Float.MIN_VALUE, Float.MAX_VALUE, 0.0f, -0.0f, 1e10f, 3.141592653589793f, 30f, 0.5f]", + abnormalData: "[(Float.MIN_VALUE - 2).toFloat(), (Float.MIN_VALUE - 1).toFloat(), (Float.MAX_VALUE + 1).toFloat(), (Float.MAX_VALUE + 2).toFloat()]" } - { diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_typedarrays_instance.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_typedarrays_instance.yaml index bb450f6e01df889cca390999f06bed53dd5ebf6c..ad77be43b8af4e96f7ec43ae1b060020a48f0306 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_typedarrays_instance.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_typedarrays_instance.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Copyright (c) 2021-2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -16,7 +16,7 @@ type: "number", elementType: "byte", primitiveType: "byte", - cast2primitive: " as byte", + cast2primitive: ".toByte()", create: "", primitiveSizeBytes: 1, data: "[Byte.MIN_VALUE as byte, -120 as byte, -77 as byte, -1 as byte, 0 as byte, 1 as byte, 77 as byte, 120 as byte, Byte.MAX_VALUE as byte]" @@ -27,7 +27,7 @@ type: "number", elementType: "short", primitiveType: "short", - cast2primitive: " as short", + cast2primitive: ".toShort()", create: "", primitiveSizeBytes: 2, data: "[Short.MIN_VALUE as short, -12345 as short, -777 as short, -1 as short, 0 as short, 1 as short, 777 as short, 12345 as short, Short.MAX_VALUE as short]" @@ -37,7 +37,7 @@ type: "number", elementType: "int", primitiveType: "int", - cast2primitive: " as int", + cast2primitive: ".toInt()", create: "", primitiveSizeBytes: 4, data: "[Int.MIN_VALUE, -1234567, -7777, -1, 0, 1, 7777, 1234567, Int.MAX_VALUE]" @@ -59,7 +59,7 @@ type: "number", elementType: "double", primitiveType: "double", - cast2primitive: " as double", + cast2primitive: ".toDouble()", create: "", primitiveSizeBytes: 8, data: "[Double.MIN_VALUE, Double.MAX_VALUE, 0.0, -0.0, Double.POSITIVE_INFINITY, -Double.NEGATIVE_INFINITY, 1e10, 3.141592653589793, 30, 0.5]" @@ -70,7 +70,7 @@ type: "number", elementType: "double", primitiveType: "double", - cast2primitive: " as double", + cast2primitive: ".toDouble()", create: "", primitiveSizeBytes: 8, data: "[0.1, 0.2, 1e10]" @@ -81,8 +81,8 @@ type: "number", elementType: "float", primitiveType: "float", - cast2primitive: " as float", + cast2primitive: ".toFloat()", create: "", primitiveSizeBytes: 4, - data: "[Float.MIN_VALUE, Float.MAX_VALUE, 0.0, -0.0, Float.POSITIVE_INFINITY, -Float.NEGATIVE_INFINITY, 1e10 as float, 3.141592653589793, 30, 0.5]" + data: "[Float.MIN_VALUE, Float.MAX_VALUE, 0.0f, -0.0f, Float.POSITIVE_INFINITY, -Float.NEGATIVE_INFINITY, 1e10f, 3.141592653589793f, 30f, 0.5f]" } diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_typedarrays_methods.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_typedarrays_methods.yaml index 1a7c764ffb0c71ee510db63448c84a5a6313e685..63d1836cef302bda5cbf6536dd5b48cc0e765750 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_typedarrays_methods.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_typedarrays_methods.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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,11 +16,11 @@ type: "number", primitiveType: "byte", elementType: "byte", - cast2primitive: " as byte", + cast2primitive: ".toByte()", create: "", primitiveSizeBytes: 1, data: "[Byte.MIN_VALUE as byte, -120 as byte, -77 as byte, -1 as byte, 0 as byte, 1 as byte, 77 as byte, 120 as byte, Byte.MAX_VALUE as byte]", - abnormalData: "[Byte.MIN_VALUE -2 as byte, Byte.MIN_VALUE -1 as byte, Byte.MAX_VALUE + 1 as byte, Byte.MAX_VALUE + 2 as byte]" + abnormalData: "[(Byte.MIN_VALUE - 2).toByte(), (Byte.MIN_VALUE - 1).toByte(), (Byte.MAX_VALUE + 1).toByte(), (Byte.MAX_VALUE + 2).toByte()]" } - { @@ -28,11 +28,11 @@ type: "number", primitiveType: "short", elementType: "short", - cast2primitive: " as short", + cast2primitive: ".toShort()", create: "", primitiveSizeBytes: 2, - data: "[Short.MIN_VALUE as short, -12345 as short, -777 as short, -1 as short, 0 as short, 1 as short, 777 as short, 12345 as short, Short.MAX_VALUE as short]", - abnormalData: "[Short.MIN_VALUE - 2 as short, Short.MIN_VALUE - 1 as short, Short.MAX_VALUE + 1 as short, Short.MAX_VALUE + 2 as short]" + data: "[Short.MIN_VALUE, -12345 as short, -777 as short, -1 as short, 0 as short, 1 as short, 777 as short, 12345 as short, Short.MAX_VALUE]", + abnormalData: "[(Short.MIN_VALUE - 2).toShort(), (Short.MIN_VALUE - 1).toShort(), (Short.MAX_VALUE + 1).toShort(), (Short.MAX_VALUE + 2).toShort()]" } - { @@ -40,7 +40,7 @@ type: "number", primitiveType: "int", elementType: "int", - cast2primitive: " as int", + cast2primitive: ".toInt()", create: "", primitiveSizeBytes: 4, data: "[Int.MIN_VALUE, -1234567, -7777, -1, 0, 1, 7777, 1234567, Int.MAX_VALUE]", @@ -52,7 +52,7 @@ type: "number", primitiveType: "double", elementType: "double", - cast2primitive: " as double", + cast2primitive: ".toDouble()", create: "", primitiveSizeBytes: 8, data: "[Double.MIN_VALUE, Double.MAX_VALUE, 0.0, -0.0, 1e10, 3.141592653589793, 30, 0.5]", @@ -64,7 +64,7 @@ type: "number", primitiveType: "double", elementType: "double", - cast2primitive: " as double", + cast2primitive: ".toDouble()", create: "", primitiveSizeBytes: 8, data: "[0.1, 0.2, 1e10,-1.1111111,-2.8, 0, Double.MIN_VALUE, Double.MAX_VALUE]", @@ -76,10 +76,10 @@ type: "number", primitiveType: "number", elementType: "float", - cast2primitive: " as float", + cast2primitive: ".toFloat()", create: "", primitiveSizeBytes: 4, - data: "[Float.MIN_VALUE, Float.MAX_VALUE, 0.0, -0.0, 1e10, 3.141592653589793 as float, 30, 0.5]", + data: "[Float.MIN_VALUE, Float.MAX_VALUE, 0.0f, -0.0f, 1e10f, 3.141592653589793f, 30f, 0.5f]", abnormalData: "[Float.MIN_VALUE - 2, Float.MIN_VALUE - 1, Float.MAX_VALUE + 1, Float.MAX_VALUE + 2]" } diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_typeduarrays_function1.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_typeduarrays_function1.yaml index 3cc4b74efced9e839448360eea867c8c7571cc06..a9be24768b2dd82ac55afc75f9c55a31ec818802 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_typeduarrays_function1.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_typeduarrays_function1.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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 @@ -30,7 +30,7 @@ type: "number", primitiveType: "short", elementType: "short", - cast2primitive: " as short", + cast2primitive: ".toShort()", create: "", primitiveSizeBytes: 2, primitiveTypeWide: "int", @@ -44,13 +44,13 @@ type: "number", primitiveType: "int", elementType: "int", - cast2primitive: " as int", + cast2primitive: ".toInt()", create: "", primitiveSizeBytes: 4, primitiveTypeWide: "long", sourceElementsType: "number", data: "[0, 1073741824, Int.MAX_VALUE, 3221225472, 3758096384, 4026531840, 4160749568]", - abnormalData: "[-1, 4294967296, 4294967297, Int.MIN_VALUE - 2, Int.MIN_VALUE - 1, Int.MAX_VALUE as number + 1]" + abnormalData: "[-1, 4294967296, 4294967297, Int.MIN_VALUE - 2, Int.MIN_VALUE - 1, Int.MAX_VALUE + 1]" } - { @@ -58,7 +58,7 @@ type: "number", primitiveType: "short", elementType: "short", - cast2primitive: " as short", + cast2primitive: ".toShort()", create: "", primitiveSizeBytes: 1, primitiveTypeWide: "short", diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_typeduarrays_instance.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_typeduarrays_instance.yaml index 39084938c90abe25c4d06cb6094a559a172375ac..0d99ea320cd3e48f1c03bba3145b35dc83cda8ca 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_typeduarrays_instance.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_typeduarrays_instance.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 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,7 +16,7 @@ type: "number", elementType: "number", primitiveType: "number", - cast2primitive: " as number", + cast2primitive: ".toDouble()", create: "", primitiveSizeBytes: 1, data: "[0, 18, 37, 72, 121, 180, 221, 255]" @@ -27,7 +27,7 @@ type: "number", elementType: "number", primitiveType: "number", - cast2primitive: " as number", + cast2primitive: ".toDouble()", create: "", primitiveSizeBytes: 2, data: "[0, 10234, 21445, 32760, 43690, 55321, 65504, 65535]" @@ -38,7 +38,7 @@ type: "number", elementType: "number", primitiveType: "number", - cast2primitive: " as number", + cast2primitive: ".toDouble()", create: "", primitiveSizeBytes: 4, data: "[0, 1073741824, 2147483648, 3221225472, 3758096384, 4026531840, 4160749568, 4294967295]" diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_typeduarrays_methods.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_typeduarrays_methods.yaml index 0d4055f02f330e199117cb897d05daa858fd6150..8d172d72a3cbeed9c343c3013b75c1a286fc6874 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_typeduarrays_methods.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_typeduarrays_methods.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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,13 +16,13 @@ type: "number", primitiveType: "byte", elementType: "byte", - cast2primitive: " as byte", + cast2primitive: ".toByte()", create: "", primitiveSizeBytes: 1, primitiveTypeWide: "short", sourceElementsType: "number", - data: "[0 as byte, 18 as byte, 37 as byte, 72 as byte, Byte.MAX_VALUE as byte]", - abnormalData: "[180 as byte, 221 as byte, 0xFF as byte]", + data: "[0 as byte, 18 as byte, 37 as byte, 72 as byte, Byte.MAX_VALUE]", + abnormalData: "[(180).toByte(), (221).toByte(), (0xFF).toByte()]", } - { @@ -30,13 +30,13 @@ type: "number", primitiveType: "short", elementType: "short", - cast2primitive: " as short", + cast2primitive: ".toShort()", create: "", primitiveSizeBytes: 2, primitiveTypeWide: "int", sourceElementsType: "number", - data: "[0 as short, 10234 as short, 21445 as short, Short.MAX_VALUE as short]", - abnormalData: "[43690 as short, 55321 as short, 65504 as short, 0xFFFF as short]", + data: "[0 as short, 10234 as short, 21445 as short, Short.MAX_VALUE]", + abnormalData: "[(43690).toShort(), (55321).toShort(), (65504).toShort(), (0xFFFF).toShort()]", } - { @@ -44,12 +44,12 @@ type: "number", primitiveType: "int", elementType: "int", - cast2primitive: " as int", + cast2primitive: ".toInt()", create: "", primitiveSizeBytes: 4, primitiveTypeWide: "long", sourceElementsType: "number", - data: "[0 as int, 1073741824 as int, Int.MAX_VALUE as int]", + data: "[0, 1073741824, Int.MAX_VALUE]", abnormalData: "[]", # Note: uncomment once the issue(21569) is fixed # abnormalData: "[3221225472 as int, 3758096384 as int, 4026531840 as int, 4160749568 as int]", @@ -60,12 +60,12 @@ type: "number", primitiveType: "short", elementType: "short", - cast2primitive: " as short", + cast2primitive: ".toShort()", create: "", primitiveSizeBytes: 1, primitiveTypeWide: "short", sourceElementsType: "number", - data: "[0 as short, 18 as short, 37 as short, 72 as short, Byte.MAX_VALUE as short, 180 as short, 221 as short, 0xFF as short]", + data: "[(0).toShort(), (18).toShort(), (37).toShort(), (72).toShort(), Byte.MAX_VALUE, (180).toShort(), (221).toShort(), (0xFF).toShort()]", abnormalData: "[]", } diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_value.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_value.yaml index adf5e6577ae75b618416fde475322b9635101661..5492ad023e45252f4b72732dadd1f6bed31ed6eb 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_value.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_value.yaml @@ -49,7 +49,7 @@ } - { name: float, - init_values: {"0.0 as float", "1.0 as float", "-1.0 as float", "Float.MIN_VALUE as float", "Float.MAX_VALUE as float"}, + init_values: {"0.0f", "1.0 as float", "-1.0 as float", "Float.MIN_VALUE as float", "Float.MAX_VALUE as float"}, value_name: Float, primitive: true } @@ -151,7 +151,7 @@ } - { name: "FixedArray", - init_values: {"[0.0 as float] as FixedArray", "[0.0 as float, 1.0 as float, -1.0 as float, Float.MIN_VALUE as float, Float.MAX_VALUE as float] as FixedArray"}, + init_values: {"[0.0f] as FixedArray", "[0.0f, 1.0f, -1.0f, Float.MIN_VALUE, Float.MAX_VALUE] as FixedArray"}, value_name: Array, primitive: false } diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/serialization/list.std_serialization_json_static.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/serialization/list.std_serialization_json_static.yaml index 458ad180a49d2584c9aaaa2c073fc30f0fafc327..29c7d648338665fcefcad05d267631adf6abf5bd 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/serialization/list.std_serialization_json_static.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/serialization/list.std_serialization_json_static.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 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 @@ -294,13 +294,13 @@ method_signature: {d: "float[]"}, method_throws: "false", method_signature_desc: {d: float_array}, - method_test_index_data: {test1: {d: "[1.1, -1.1, 0.0, -0.0, 2.72182, -2.72182]"}, + method_test_index_data: {test1: {d: "[1.1f, -1.1f, 0.0f, -0.0f, 2.72182f, -2.72182f]"}, test2: {d: "[]"}, test3: {d: "[32]"} }, - method_expected_data: {test1: '"[1.1,-1.1,0,0,2.72182,-2.72182]"', + method_expected_data: {test1: '"[1.1f,-1.1f,0f,0f,2.72182f,-2.72182f]"', test2: '"[]"', - test3: '"[32]"' + test3: '"[32f]"' } } - { diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray.j2 index 6d8c494bafcf8879c3dac672fb2b973d4c7eb5c7..f1509abb1a681b97e2d9df5b17db6d6790bd29a7 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray.j2 @@ -58,12 +58,12 @@ function createTAFromNonEmptyArrayBufferTwoParamsZeroLength(): int { let ss = new ArrayBuffer(5 * {{.item.primitiveSizeBytes}}); // Buffer 5-items length; let target: {{.item.objectType}}; try { - target = new {{.item.objectType}}(ss, 0 as number, 0 as number); + target = new {{.item.objectType}}(ss, 0, 0); } catch(e) { return fail; } - if (target.byteLength as int == 0 && target.byteOffset as int == 0) { return success; } + if (target.byteLength.toInt() == 0 && target.byteOffset.toInt() == 0) { return success; } console.println("Error: Actual bytes length: " + target.byteLength); return fail; } @@ -72,12 +72,12 @@ function createTAFromNonEmptyArrayBufferTwoParams(): int { let ss = new ArrayBuffer(5 * {{.item.primitiveSizeBytes}}); // Buffer 5-items length; let target: {{.item.objectType}}; try { - target = new {{.item.objectType}}(ss, 0 as number, 3 as number); + target = new {{.item.objectType}}(ss, 0, 3); } catch(e) { return fail; } - if (target.byteLength as int == 3*{{.item.primitiveSizeBytes}} && target.byteOffset as int == 0) { return success; } + if (target.byteLength.toInt() == 3*{{.item.primitiveSizeBytes}} && target.byteOffset.toInt() == 0) { return success; } console.println("Error: Actual bytes length: " + target.byteLength); return fail; } @@ -90,14 +90,14 @@ const source: FixedArray<{{.item.primitiveType}}> = {{.item.data}}; {% set skipInfinity = False %} function createArraySetAndGet(): int { - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let target: {{.item.objectType}}; try { target = new {{.item.objectType}}(ss); } catch(e) { return fail; } - for (let i: int = 0; i < source.length as int; i++) { + for (let i: int = 0; i < source.length.toInt(); i++) { try { target.set(i, source[i] as {{.item.primitiveType}}); } catch(e) { @@ -105,7 +105,7 @@ function createArraySetAndGet(): int { return fail; } } - for (let i: int = 0; i < source.length as int; i++) { + for (let i: int = 0; i < source.length.toInt(); i++) { {%- if skipInfinity %} if ((source[i] == {{.posInf}}) && (source[i] == {{.negInf}})) { continue; @@ -116,8 +116,8 @@ function createArraySetAndGet(): int { console.println("Data mismatch for {{.item.objectType}} " + " expected: " + source[i] + " at " + i + " but actual: " + back); return fail; } - if (target[i as int] != target[i as number]) { - console.println("Data mismatch for $_get(int) and $_get(number): " + target[i as int] + " vs " + target[i as number]); + if (target[i.toInt()] != target[i.toDouble()]) { + console.println("Data mismatch for $_get(int) and $_get(number): " + target[i.toInt()] + " vs " + target[i.toDouble()]); return fail; } } @@ -125,13 +125,13 @@ function createArraySetAndGet(): int { // NOTE: comparison of target that filled by set(int, {{.item.primitiveType}}) vs target2.$_set(number, {{.item.primitiveType}}) let target2: {{.item.objectType}}; try { - target2 = new {{.item.objectType}}(new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}})); + target2 = new {{.item.objectType}}(new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}})); } catch(e) { return fail; } for (let i: int = 0; i < source.length; i++) { try { - target2[i as number] = source[i] as {{.item.primitiveType}}; + target2[i.toDouble()] = source[i] as {{.item.primitiveType}}; } catch(e) { console.print("Catched exception at insert via $_set(number, {{.item.primitiveType}})"); return fail; @@ -140,7 +140,7 @@ function createArraySetAndGet(): int { console.print("Data mismatch for $_get(int) vs $_get(int) filled by set(int, {{.item.primitiveType}}) vs $_set(number, {{.item.primitiveType}})"); return fail; } - if (target[i as number] != target2[i as number]) { + if (target[i.toDouble()] != target2[i.toDouble()]) { console.print("Data mismatch for $_get(number) vs $_get(number) filled by set(int, {{.item.primitiveType}}) vs $_set(number, {{.item.primitiveType}})"); return fail; } @@ -149,7 +149,7 @@ function createArraySetAndGet(): int { } function createArrayFromArray(): int { - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let target: {{.item.objectType}}; try { target = new {{.item.objectType}}(ss); @@ -167,7 +167,7 @@ function createArrayFromArray(): int { let sumExp: {{.item.primitiveType}} = 0; let sumAct: {{.item.primitiveType}} = 0; - for (let i: int = 0; i < source.length as int; i++) { + for (let i: int = 0; i < source.length.toInt(); i++) { {%- if skipInfinity %} if ((source[i] == {{.posInf}}) && (source[i] == {{.negInf}})) { continue; @@ -182,7 +182,7 @@ function createArrayFromArray(): int { acc++; } - for (let i: int = 0; i < source.length as int; i++) { + for (let i: int = 0; i < source.length.toInt(); i++) { {%- if skipInfinity %} if ((source[i] == {{.posInf}}) && (source[i] == {{.negInf}})) { continue; @@ -201,7 +201,7 @@ function createArrayFromArray(): int { function createArrayFromArrayWithOffset(): int { let offset: int = 3; - let ss = new ArrayBuffer((source.length as int + offset) * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer((source.length.toInt() + offset) * {{.item.primitiveSizeBytes}}); let target: {{.item.objectType}}; try { target = new {{.item.objectType}}(ss); @@ -217,7 +217,7 @@ function createArrayFromArrayWithOffset(): int { let acc: int = 0; - for (let i: int = offset; i < source.length as int; i++) { + for (let i: int = offset; i < source.length.toInt(); i++) { {%- if skipInfinity %} if ((source[i-offset] == {{.posInf}}) && (source[i-offset] == {{.negInf}})) { continue; @@ -233,7 +233,7 @@ function createArrayFromArrayWithOffset(): int { } function createFilteredArrayFromGiven(): int { - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; try { origin = new {{.item.objectType}}(ss); @@ -250,11 +250,11 @@ function createFilteredArrayFromGiven(): int { } let targetIdx = 0 - for (let originIdx = 0; originIdx < origin.length as int; originIdx++) { + for (let originIdx = 0; originIdx < origin.length.toInt(); originIdx++) { if (origin[originIdx]{{.item.cast2primitive}} <= (0 as long)) { continue } - if (targetIdx >= target.length as int) { + if (targetIdx >= target.length.toInt()) { console.println("filter: buffer overflow") return fail } @@ -264,7 +264,7 @@ function createFilteredArrayFromGiven(): int { } targetIdx++ } - if (targetIdx != target.length as int) { + if (targetIdx != target.length.toInt()) { console.println("new element " + target.at(targetIdx)) return fail } @@ -274,7 +274,7 @@ function createFilteredArrayFromGiven(): int { function testLastIndexOfNotFound(): int { - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let target: {{.item.objectType}}; try { target = new {{.item.objectType}}(ss); @@ -292,7 +292,7 @@ function testLastIndexOfNotFound(): int { function testLastIndexOf4(): int { let source: FixedArray<{{.item.primitiveType}}> = [10 as {{.item.primitiveType}}, 20 as {{.item.primitiveType}}, 50 as {{.item.primitiveType}}, 50 as {{.item.primitiveType}}, 50 as {{.item.primitiveType}}, 60 as {{.item.primitiveType}}]; - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let target: {{.item.objectType}}; @@ -313,7 +313,7 @@ function testLastIndexOf4(): int { function testLastIndexOf3(): int { let source: FixedArray<{{.item.primitiveType}}> = [10 as {{.item.primitiveType}}, 20 as {{.item.primitiveType}}, 50 as {{.item.primitiveType}}, 50 as {{.item.primitiveType}}, 50 as {{.item.primitiveType}}, 60 as {{.item.primitiveType}}]; - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let target: {{.item.objectType}}; @@ -336,7 +336,7 @@ function testLastIndexOf3(): int { function testMap(): int { let source: FixedArray<{{.item.primitiveType}}> = [10 as {{.item.primitiveType}}, 20 as {{.item.primitiveType}}, 30 as {{.item.primitiveType}}, 40 as {{.item.primitiveType}}, 50 as {{.item.primitiveType}}, 60 as {{.item.primitiveType}}]; - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; @@ -359,12 +359,12 @@ function testMap(): int { } - if (target.length as int != source.length as int) { + if (target.length.toInt() != source.length.toInt()) { console.println("Array length mismatch"); return fail; } - for (let i: int = 0; i < source.length as int; i++) { + for (let i: int = 0; i < source.length.toInt(); i++) { {%- if skipInfinity %} if ((source[i] == {{.posInf}}) && (source[i] == {{.negInf}})) { continue; @@ -431,7 +431,7 @@ function testTAFromWithSizeableIterator(): int { } function createFromSource(source: FixedArray<{{.item.primitiveType}}>): {{.item.objectType}} throws { - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; try { @@ -446,16 +446,16 @@ function createFromSource(source: FixedArray<{{.item.primitiveType}}>): {{.item. function dump(source: FixedArray<{{.item.primitiveType}}>, origin: {{.item.objectType}}): void { console.print("Expected: "); - for (let i: int = 0; i < source.length as int; i++) { console.print(source[i] + " "); } + for (let i: int = 0; i < source.length.toInt(); i++) { console.print(source[i] + " "); } console.println(); console.print("Passed: "); - for (let i: int = 0; i < origin.length as int; i++) { console.print(origin[i]{{.item.cast2primitive}} + " "); } + for (let i: int = 0; i < origin.length.toInt(); i++) { console.print(origin[i]{{.item.cast2primitive}} + " "); } console.println(); } function assertArrayEqualsToTypedArray(source: FixedArray<{{.item.primitiveType}}>, origin: {{.item.objectType}}): int { - if (origin.length as int != source.length as int) { + if (origin.length.toInt() != source.length.toInt()) { return fail; } for (let i: int; i < origin.length; i++) { diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_bignum.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_bignum.j2 index 1e967470235f7e34bb45c96ff78597f8caf921a8..716e8e2a553c5a68e301ee79d731111a6fe1e168 100755 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_bignum.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_bignum.j2 @@ -1,5 +1,5 @@ /** - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -45,7 +45,7 @@ function check(result: number, message: String): number { const normalSource: {{.item.primitiveType}}[] = {{.item.data}}; function testTypedUArrayIterator(): number { - let ss = new ArrayBuffer(normalSource.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(normalSource.length.toInt * {{.item.primitiveSizeBytes}}); let typedUArray: {{.item.objectType}}; try { diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_ctors.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_ctors.j2 index d065615769920c198ca701fad4cb80d277e835af..ac8449dfc626d43c37d0f7d6e4447117b320595d 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_ctors.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_ctors.j2 @@ -1,5 +1,5 @@ /** - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -82,25 +82,25 @@ const abnormalSource: {{.item.primitiveType}}[] = {{.item.abnormalData}}; function createDefault(): number { let target: {{.item.objectType}} = new {{.item.objectType}}(); - if (target.length as int == 0 && target.byteOffset as int == 0) return success; + if (target.length.toInt() == 0 && target.byteOffset.toInt() == 0) return success; return fail; } function createEmptyWithNaNLength(): number { let target: {{.item.objectType}} = new {{.item.objectType}}(NaN); - if (target.length as int == 0 && target.byteOffset as int == 0) return success; + if (target.length.toInt() == 0 && target.byteOffset.toInt() == 0) return success; return fail; } function createEmptyWithLength(): number { let target: {{.item.objectType}} = new {{.item.objectType}}(0); - if (target.length as int == 0 && target.byteOffset as int == 0) return success; + if (target.length.toInt() == 0 && target.byteOffset.toInt() == 0) return success; return fail; } function createNonEmptyWithLength(): number { let target: {{.item.objectType}} = new {{.item.objectType}}(5); - if (target.length as int == 5 && target.byteOffset as int == 0 && target.byteLength as int == 5 * {{.item.primitiveSizeBytes}}){ + if (target.length.toInt() == 5 && target.byteOffset.toInt() == 0 && target.byteLength.toInt() == 5 * {{.item.primitiveSizeBytes}}){ return success; } return fail; @@ -108,7 +108,7 @@ function createNonEmptyWithLength(): number { function createNonEmptyWithFloatingLength(): number { let target: {{.item.objectType}} = new {{.item.objectType}}(5.4); - if (target.length as int == 5 && target.byteOffset as int == 0 && target.byteLength as int == 5 * {{.item.primitiveSizeBytes}}){ + if (target.length.toInt() == 5 && target.byteOffset.toInt() == 0 && target.byteLength.toInt() == 5 * {{.item.primitiveSizeBytes}}){ return success; } return fail; @@ -116,7 +116,7 @@ function createNonEmptyWithFloatingLength(): number { function createTypedArrayWithNegativeLength(): number { try { - let target: {{.item.objectType}} = new {{.item.objectType}}(-1 as number); + let target: {{.item.objectType}} = new {{.item.objectType}}(-1); } catch(e) { if (e instanceof TypeError) { return success; @@ -152,13 +152,13 @@ function createTypedArrayWithPositiveInfinityLength(): number { function createTypedArrayWithPositiveNaNLength(): number { let target: {{.item.objectType}} = new {{.item.objectType}}(+NaN); - if (target.length as int == 0 && target.byteOffset as int == 0) return success; + if (target.length.toInt() == 0 && target.byteOffset.toInt() == 0) return success; return fail; } function createTypedArrayWithNegativeNaNLength(): number { let target: {{.item.objectType}} = new {{.item.objectType}}(-NaN); - if (target.length as int == 0 && target.byteOffset as int == 0) return success; + if (target.length.toInt() == 0 && target.byteOffset.toInt() == 0) return success; return fail; } @@ -176,7 +176,7 @@ function createEmptyWithIterable(): number { return fail; } - if (target.length as int == 0){ + if (target.length.toInt() == 0){ return success; } return fail; @@ -189,7 +189,7 @@ function createNonEmptyWithIterable(): number { array.push({{.item.create}}(3)); let target: {{.item.objectType}} = new {{.item.objectType}}(array.values() as Iterable<{{.item.type}}>); - if (target.length as int == 3 && target.byteOffset as int == 0 && target.byteLength as int == 3*{{.item.primitiveSizeBytes}}){ + if (target.length.toInt() == 3 && target.byteOffset.toInt() == 0 && target.byteLength.toInt() == 3*{{.item.primitiveSizeBytes}}){ return success; } @@ -200,7 +200,7 @@ function createNonEmptyWithIterable(): number { } let origin: {{.item.objectType}} = new {{.item.objectType}}(exceptArray.values() as Iterable<{{.item.type}}>); - for (let i: int = 0; i< target.length as int; i++) { + for (let i: int = 0; i< target.length.toInt(); i++) { let tv = target[i]{{.item.cast2primitive}}; let ov = origin[i]{{.item.cast2primitive}}; console.log(tv + "->" + ov); @@ -216,12 +216,12 @@ function createNonEmptyWithIterable(): number { function createTypedArrayWithArrayLike(): number { let array = new Array<{{.item.type}}>(); - array.push({{.item.create}}(1 as Number)); - array.push({{.item.create}}(2 as Number)); - array.push({{.item.create}}(3 as Number)); + array.push({{.item.create}}(1)); + array.push({{.item.create}}(2)); + array.push({{.item.create}}(3)); let target: {{.item.objectType}} = new {{.item.objectType}} (array as ArrayLike<{{.item.type}}>); - if (target.length as int == 3 && target.byteOffset as int == 0){ + if (target.length.toInt() == 3 && target.byteOffset.toInt() == 0){ return success; } return fail; @@ -237,7 +237,7 @@ function createTAFromEmptyArrayBuffer(): number { return fail; } - if (target.length as int == 0 && target.byteOffset as int == 0) return success; + if (target.length.toInt() == 0 && target.byteOffset.toInt() == 0) return success; return fail; } @@ -250,7 +250,7 @@ function createTAFromNonEmptyArrayBuffer(): number { return fail; } - if (target.byteLength as int == 5 * {{.item.primitiveSizeBytes}} && target.byteOffset as int == 0) return success; + if (target.byteLength.toInt() == 5 * {{.item.primitiveSizeBytes}} && target.byteOffset.toInt() == 0) return success; console.println("Error: Actual bytes length: " + target.byteLength); return fail; } @@ -263,17 +263,17 @@ function createTAFromEmptyArrayBufferOneParamNoOffset(): number { } catch(e) { return fail; } - if (target.length as number != 0 || target.byteOffset as number != 0 ) { + if (target.length.toDouble() != 0 || target.byteOffset.toDouble() != 0 ) { return fail; } try { - target = new {{.item.objectType}}(ss, undefined); + target = new {{.item.objectType}}(ss); } catch(e) { return fail; } - if (target.length as number != 0 || target.byteOffset as number != 0) { + if (target.length.toDouble() != 0 || target.byteOffset.toDouble() != 0) { return fail; } @@ -312,20 +312,20 @@ function createTAFromNonEmptyArrayBufferOneParamNoOffset(): number { return fail; } - if (target.byteLength as number != 5 * {{.item.primitiveSizeBytes}} || target.byteOffset as number != 0 - || target.length as number != 5){ + if (target.byteLength.toDouble() != 5 * {{.item.primitiveSizeBytes}} || target.byteOffset.toDouble() != 0 + || target.length.toDouble() != 5){ console.println("Error: Actual bytes length: " + target.byteLength); return fail; } try { - target = new {{.item.objectType}}(ss, undefined); + target = new {{.item.objectType}}(ss); } catch(e) { return fail; } - if (target.byteLength as number != 5 * {{.item.primitiveSizeBytes}} || target.byteOffset as number != 0 - || target.length as number != 5){ + if (target.byteLength.toDouble() != 5 * {{.item.primitiveSizeBytes}} || target.byteOffset.toDouble() != 0 + || target.length.toDouble() != 5){ console.println("Error: Actual bytes length: " + target.byteLength); return fail; } @@ -364,8 +364,8 @@ function createTAFromNonEmptyArrayBufferOneParamWithOffset(): number { return fail; } - if (target.byteLength as int == 5 * {{.item.primitiveSizeBytes}} && target.byteOffset as int == 2*{{.item.primitiveSizeBytes}} - && target.length as int == 5){ + if (target.byteLength.toInt() == 5 * {{.item.primitiveSizeBytes}} && target.byteOffset.toInt() == 2*{{.item.primitiveSizeBytes}} + && target.length.toInt() == 5){ return success; } console.println("Error: Actual bytes length: " + target.byteLength); @@ -384,7 +384,7 @@ function createTAFromNonEmptyArrayBufferOneParamWithOffsetAndSize(): number { return fail; } - if (target.byteLength as int == 4*{{.item.primitiveSizeBytes}} && target.byteOffset as int == 2*{{.item.primitiveSizeBytes}} && target.length as int == 4) return success; + if (target.byteLength.toInt() == 4*{{.item.primitiveSizeBytes}} && target.byteOffset.toInt() == 2*{{.item.primitiveSizeBytes}} && target.length.toInt() == 4) return success; console.println("Error: Actual bytes length: " + target.byteLength); console.println("Error: Actual bytes offset: " + target.byteOffset); console.println("Error: length: " + target.length); @@ -400,7 +400,7 @@ function createTAFromEmptyArrayBufferTwoParams(): number { return fail; } - if (target.length as number != 0 || target.byteOffset as number != 0) { + if (target.length.toDouble() != 0 || target.byteOffset.toDouble() != 0) { return fail; } @@ -410,7 +410,7 @@ function createTAFromEmptyArrayBufferTwoParams(): number { return fail; } - if (target.length as number != 0 || target.byteOffset as number != 0) { + if (target.length.toDouble() != 0 || target.byteOffset.toDouble() != 0) { return fail; } @@ -426,7 +426,7 @@ function createTAFromNonEmptyArrayBufferTwoParams(): number { return fail; } - if (target.byteLength as int == 5 * {{.item.primitiveSizeBytes}} && target.byteOffset as int == 0 && target.length == 5){ + if (target.byteLength.toInt() == 5 * {{.item.primitiveSizeBytes}} && target.byteOffset.toInt() == 0 && target.length == 5){ return success; } console.println("Error: Actual bytes length: " + target.byteLength); diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_function2.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_function2.j2 index 1bbc6dfa123b89530557275299cd30e2bfeac179..6922275894327fb3f9895bd777f5f96bfa739cc6 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_function2.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_function2.j2 @@ -82,7 +82,7 @@ const abnormalSource: FixedArray<{{.item.primitiveType}}> = {{.item.abnormalData function testSubarrayWithOutParam(): int { //let source: FixedArray<{{.item.primitiveType}}> = [10, 20, 30, 40, 50, 60]; - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; @@ -103,13 +103,13 @@ function testSubarrayWithOutParam(): int { return fail; } - if (target.length as int != origin.length as int) { + if (target.length.toInt() != origin.length.toInt()) { console.log("Array length mismatch on slice"); return fail; } //Check all the data copied; - for (let i: int = 0; i< origin.length as int; i++) { + for (let i: int = 0; i< origin.length.toInt(); i++) { let tv = target[i]{{.item.cast2primitive}}; let ov = origin[i]{{.item.cast2primitive}}; console.log(source[i] + "->" + tv + "->" + ov); @@ -120,7 +120,7 @@ function testSubarrayWithOutParam(): int { } origin= new {{.item.objectType}}(0); - if (origin.length as int != 0){ + if (origin.length.toInt() != 0){ return fail; } @@ -131,7 +131,7 @@ function testSubarrayWithOutParam(): int { return fail; } - if (target.length as int != 0){ + if (target.length.toInt() != 0){ return fail; } return success; @@ -139,7 +139,7 @@ function testSubarrayWithOutParam(): int { function testSubarrayOneParam(): int { //let source: FixedArray<{{.item.primitiveType}}> = [10, 20, 30, 40, 50, 60]; - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; @@ -152,7 +152,7 @@ function testSubarrayOneParam(): int { } let subarrayStart: int = 1; - let subarrayEnd: int = origin.length as int; + let subarrayEnd: int = origin.length.toInt(); let target: {{.item.objectType}}; @@ -163,7 +163,7 @@ function testSubarrayOneParam(): int { return fail; } - if (target.length as int != origin.length as int - subarrayStart) { + if (target.length.toInt() != origin.length.toInt() - subarrayStart) { console.log("Array length mismatch on subarray One Params" + target.length); return fail; } @@ -187,7 +187,7 @@ function testSubarrayOneParam(): int { return fail; } - if (target.length as int != origin.length as int) { + if (target.length.toInt() != origin.length.toInt()) { console.log("Array length mismatch on subarray One Params" + target.length); return fail; } @@ -232,7 +232,7 @@ function testSubarrayOneParam(): int { function testSubarrayTwoParams(): int { //let source: FixedArray<{{.item.primitiveType}}> = [10, 20, 30, 40, 50, 60, 70, 80]; - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; @@ -256,7 +256,7 @@ function testSubarrayTwoParams(): int { return fail; } - if (target.length as int != subarrayEnd - subarrayStart) { + if (target.length.toInt() != subarrayEnd - subarrayStart) { console.log("Array length mismatch on subarray2"); return fail; } @@ -273,7 +273,7 @@ function testSubarrayTwoParams(): int { } subarrayStart = 0; - subarrayEnd = origin.length as int; + subarrayEnd = origin.length.toInt(); try { target = origin.subarray(subarrayStart, subarrayEnd); } catch(e) { @@ -281,7 +281,7 @@ function testSubarrayTwoParams(): int { return fail; } - if (target.length as int != subarrayEnd - subarrayStart) { + if (target.length.toInt() != subarrayEnd - subarrayStart) { console.log("Array length mismatch on subarray2"); return fail; } @@ -304,7 +304,7 @@ function testSubarrayTwoParams(): int { return fail; } - if (target.length as int != subarrayEnd - subarrayStart) { + if (target.length.toInt() != subarrayEnd - subarrayStart) { console.log("Array length mismatch on subarray2"); return fail; } @@ -327,7 +327,7 @@ function testSubarrayTwoParams(): int { return fail; } - if (target.length as int != subarrayEnd - subarrayStart) { + if (target.length.toInt() != subarrayEnd - subarrayStart) { console.log("Array length mismatch on subarray2"); return fail; } @@ -350,7 +350,7 @@ function testSubarrayTwoParams(): int { return fail; } - if (target.length as int != subarrayEnd - subarrayStart) { + if (target.length.toInt() != subarrayEnd - subarrayStart) { console.log("Array length mismatch on subarray2"); return fail; } @@ -373,7 +373,7 @@ function testSubarrayTwoParams(): int { return fail; } - if (target.length as int != 0) { + if (target.length.toInt() != 0) { console.log("Array length mismatch on subarray2"); return fail; } @@ -383,7 +383,7 @@ function testSubarrayTwoParams(): int { function testSubarrayTwoParamsWithOtherNumber(): int { //let source: FixedArray<{{.item.primitiveType}}> = [10, 20, 30, 40, 50, 60, 70, 80]; - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; @@ -406,27 +406,27 @@ function testSubarrayTwoParamsWithOtherNumber(): int { return fail; } - if (target.length as int != 0) { + if (target.length.toInt() != 0) { console.log("Array length mismatch on subarray2"); return fail; } subarrayStart = -1; - subarrayEnd = origin.length as int; + subarrayEnd = origin.length.toInt(); try { target = origin.subarray(subarrayStart, subarrayEnd); } catch(e) { return fail; } - if (target.length as int != subarrayEnd - (origin.length + subarrayStart)) { + if (target.length.toInt() != subarrayEnd - (origin.length + subarrayStart)) { console.log("Array length mismatch on subarray2"); return fail; } //Check all the data copied; - for (let i: int = (origin.length + subarrayStart) as int; i< subarrayEnd; i++) { - let tv = target[(i - (origin.length + subarrayStart)) as int]{{.item.cast2primitive}}; + for (let i: int = (origin.length + subarrayStart).toInt(); i< subarrayEnd; i++) { + let tv = target[(i - (origin.length + subarrayStart)).toInt()]{{.item.cast2primitive}}; let ov = origin[i]{{.item.cast2primitive}}; console.log(source[i] + "->" + tv + "->" + ov); if (tv != ov) { @@ -436,7 +436,7 @@ function testSubarrayTwoParamsWithOtherNumber(): int { } subarrayStart = 0; - subarrayEnd = -origin.length as int; + subarrayEnd = -origin.length.toInt(); try { target = origin.subarray(subarrayStart, subarrayEnd); } catch(e) { @@ -444,7 +444,7 @@ function testSubarrayTwoParamsWithOtherNumber(): int { return fail; } - if (target.length as int != (origin.length + subarrayEnd) - subarrayStart) { + if (target.length.toInt() != (origin.length + subarrayEnd) - subarrayStart) { console.log("Array length mismatch on subarray2"); return fail; } @@ -454,7 +454,7 @@ function testSubarrayTwoParamsWithOtherNumber(): int { function testSubarrayOneLengthTwoParams(): int { let source1: FixedArray<{{.item.primitiveType}}> = [10]; - let ss = new ArrayBuffer(source1.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source1.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; @@ -477,7 +477,7 @@ function testSubarrayOneLengthTwoParams(): int { return fail; } - if (target.length as int != 0) { + if (target.length.toInt() != 0) { console.log("Array length mismatch on subarray2"); return fail; } @@ -490,7 +490,7 @@ function testSubarrayOneLengthTwoParams(): int { return fail; } - if (target.length as int != 0) { + if (target.length.toInt() != 0) { console.log("Array length mismatch on subarray2"); return fail; } @@ -512,11 +512,11 @@ function testNonEmptyTypedArraySetValue(): number { let length = typedArray.length; {%- if item.objectType == 'Int8Array' %} - const minValue = Byte.MIN_VALUE as byte; - const maxValue = Byte.MAX_VALUE as byte; + const minValue = Byte.MIN_VALUE.toByte(); + const maxValue = Byte.MAX_VALUE.toByte(); {%- elif item.objectType == 'Int16Array' %} - const minValue = Short.MIN_VALUE as short; - const maxValue = Short.MAX_VALUE as short; + const minValue = Short.MIN_VALUE.toShort(); + const maxValue = Short.MAX_VALUE.toShort(); {%- elif item.objectType == 'Int32Array' %} const minValue = Int.MIN_VALUE; const maxValue = Int.MAX_VALUE; @@ -584,15 +584,15 @@ function assertEq(expr: boolean, expected: boolean, name: string): int { function testTypedArrayEntries(): int { let failures = 0 - const firstResult = [0 as number, {{.item.create}}(1)] as [number, {{.item.type}}] - const secondResult = [1 as number, {{.item.create}}(2)] as [number, {{.item.type}}] + const firstResult = [0, {{.item.create}}(1)] as [number, {{.item.type}}] + const secondResult = [1, {{.item.create}}(2)] as [number, {{.item.type}}] const numbers = [{{.item.create}}(1), {{.item.create}}(2)] let entries = (new {{.item.objectType}}(numbers)).entries() let entry1 = entries.next().value! - let entry1res: [number, {{.item.type}}] = [entry1[0] as number, {{.item.create}}(entry1[1])] + let entry1res: [number, {{.item.type}}] = [entry1[0], {{.item.create}}(entry1[1])] let entry2 = entries.next().value! - let entry2res: [number, {{.item.type}}] = [entry2[0] as number, {{.item.create}}(entry2[1])] + let entry2res: [number, {{.item.type}}] = [entry2[0], {{.item.create}}(entry2[1])] failures += checkEntries(entry1res, firstResult, "{{.item.objectType}}.entries() - next() #1") failures += checkEntries(entry2res, secondResult, "{{.item.objectType}}.entries() - next() #2") @@ -602,7 +602,7 @@ function testTypedArrayEntries(): int { // Test case for TypedArray.includes(searchElement) with Normal Number function testTypedArrayIncludesOneParamWithNormalNum(): number { - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let typedArray: {{.item.objectType}}; try { @@ -637,7 +637,7 @@ function testTypedArrayIncludesOneParamWithNormalNum(): number { {%- if item.objectType != 'BigInt64Array' %} // Test case for TypedArray.includes(searchElement) with abnormal number function testTypedArrayIncludesOneParamWithAbnormalNum(): number { - let ss = new ArrayBuffer(abnormalSource.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(abnormalSource.length.toInt() * {{.item.primitiveSizeBytes}}); let typedArray: {{.item.objectType}}; try { @@ -649,9 +649,9 @@ function testTypedArrayIncludesOneParamWithAbnormalNum(): number { } {%- if item.objectType == 'Int8Array' %} - let searchElementArray: FixedArray<{{.item.primitiveType}}> = [Byte.MAX_VALUE - 1 as byte, Byte.MAX_VALUE as byte, Byte.MIN_VALUE as byte, Byte.MIN_VALUE + 1 as byte]; + let searchElementArray: FixedArray<{{.item.primitiveType}}> = [(Byte.MAX_VALUE - 1).toByte(), Byte.MAX_VALUE, Byte.MIN_VALUE, (Byte.MIN_VALUE + 1).toByte()]; {%- elif item.objectType == 'Int16Array' %} - let searchElementArray: FixedArray<{{.item.primitiveType}}> = [Short.MAX_VALUE - 1 as short, Short.MAX_VALUE as short, Short.MIN_VALUE as short, Short.MIN_VALUE + 1 as short]; + let searchElementArray: FixedArray<{{.item.primitiveType}}> = [(Short.MAX_VALUE - 1).toShort(), Short.MAX_VALUE, Short.MIN_VALUE, (Short.MIN_VALUE + 1).toShort()]; {%- elif item.objectType == 'Int32Array' %} let searchElementArray: FixedArray<{{.item.primitiveType}}> = [Int.MAX_VALUE - 1, Int.MAX_VALUE, Int.MIN_VALUE, Int.MIN_VALUE + 1]; {%- elif item.objectType == 'Float32Array' %} @@ -780,7 +780,7 @@ function testTypedArrayIncludesTwoParamWithAbnormalIndex(): number { //ECMA: if fromIndex < 0(k < 0) ,a. Let k be len + n. // b. If k < 0, set k to 0. typedArray need to be fixed for (let i = 0 as int; i < arrayLen; i++) { - fromIndex = (- arrayLen + i) as int; + fromIndex = (- arrayLen + i).toInt(); result = typedArray.includes(searchElement, fromIndex); let exceptResult = typedArray.includes(searchElement, i); if (result == exceptResult) { @@ -803,7 +803,7 @@ function testTypedArrayIncludesTwoParamWithAbnormalIndex(): number { //Currently not supported for typedArray //b. If k < 0, set k to 0. - fromIndex = (-arrayLen -1) as int; + fromIndex = (-arrayLen -1).toInt(); result = typedArray.includes(searchElement, fromIndex); if (result) { console.log(`Includes ${searchElement} from index ${fromIndex}? true`); @@ -846,7 +846,7 @@ function testTypedArrayJoinWithEmptyArray(): number { } catch(e) { return fail; } - if (typedArray.length as number != 0 || typedArray.byteOffset as number != 0) { + if (typedArray.length != 0 || typedArray.byteOffset != 0) { return fail; } @@ -956,7 +956,7 @@ function testTypedArrayKeysWithEmptyArray(): number { } catch(e) { return fail; } - if (typedArray.length as number != 0 || typedArray.byteOffset as number != 0) { + if (typedArray.length != 0 || typedArray.byteOffset != 0) { return fail; } @@ -1269,18 +1269,18 @@ const testTypedArraySet = parametrize>( {%- if item.objectType != 'BigInt64Array' %} - array[0 as number] = (value + 1) as number + array[0] = (value + 1) const isNumberNumberCorrect = array[0] == {{.item.create}}(value + 1) - array[0 as int] = (value + 2) as number + array[0 as int] = (value + 2) const isIntNumberCorrect = array[0] == {{.item.create}}(value + 2) {%- endif %} - array[0 as number] = (value + 3) as int + array[0] = (value + 3).toInt() const isNumberIntCorrect = array[0] == {{.item.create}}(value + 3) - array[0 as int] = (value + 4) as int + array[0 as int] = (value + 4).toInt() const isIntIntCorrect = array[0] == {{.item.create}}(value + 4) let failures = 0 @@ -1291,11 +1291,11 @@ const testTypedArraySet = parametrize>( failures += check(boolToResult(isPosInfThrows == expected[3]), `{{.item.objectType}} didn't throw: array[+Infinity] = value`) failures += check(boolToResult(isNanZero == expected[4]), `{{.item.objectType}} failed: array[NaN] = value`) {%- if item.objectType != 'BigInt64Array' %} - failures += check(boolToResult(isNumberNumberCorrect == expected[5]), `{{.item.objectType}} failed: array[0 as number] = value as number`) - failures += check(boolToResult(isIntNumberCorrect == expected[6]), `{{.item.objectType}} failed: array[0 as int] = value as number`) + failures += check(boolToResult(isNumberNumberCorrect == expected[5]), `{{.item.objectType}} failed: array[0] = value`) + failures += check(boolToResult(isIntNumberCorrect == expected[6]), `{{.item.objectType}} failed: array[0 as int] = value`) {%- endif %} - failures += check(boolToResult(isNumberIntCorrect == expected[7]), `{{.item.objectType}} failed: array[0 as number] = value as int`) - failures += check(boolToResult(isIntIntCorrect == expected[8]), `{{.item.objectType}} failed: array[0 as int] = value as int`) + failures += check(boolToResult(isNumberIntCorrect == expected[7]), `{{.item.objectType}} failed: array[0] = value.toInt()`) + failures += check(boolToResult(isIntIntCorrect == expected[8]), `{{.item.objectType}} failed: array[0 as int] = value.toInt()`) return failures == 0 ? success: fail } diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_methods.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_methods.j2 index 081b4506e58606192649ee90381e92be05ad8732..16a42efcf650541d20eac1d2b1f8377626988b1d 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_methods.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_methods.j2 @@ -84,7 +84,7 @@ const source: FixedArray<{{.item.primitiveType}}> = {{.item.data}}; const abnormalSource: FixedArray<{{.item.primitiveType}}> = {{.item.abnormalData}}; function testBytePerElement(): number { - if ({{.item.objectType}}.BYTES_PER_ELEMENT as int == {{.item.primitiveSizeBytes}}) return success; + if ({{.item.objectType}}.BYTES_PER_ELEMENT == {{.item.primitiveSizeBytes}}) return success; return fail; } @@ -216,14 +216,14 @@ function testNonEmptyTypedArrayAt(): number { atResult = typedArray.at(index); console.log("testNonEmptyTypedArrayAt [2/3] result: " + atResult); // Assertion - if (atResult == {{.item.create}}(source[index + length as int])) { + if (atResult == {{.item.create}}(source[index + length.toInt()])) { console.log("testNonEmptyTypedArrayAt [2/3] test passed."); } else { console.log("testNonEmptyTypedArrayAt [2/3] test failed."); return fail; } - index = typedArray.length as int; + index = typedArray.length.toInt(); atResult = typedArray.at(index); console.log("testNonEmptyTypedArrayAt result [3/3]: " + atResult); // Assertion @@ -595,7 +595,7 @@ const testTypedArraySort = parametrize>( array.sort() const isEqualToGold = - array.every((x: {{.item.type}}, index: number) => x == expected[index as int]) + array.every((x: {{.item.type}}, index: number) => x == expected[index.toInt()]) // descending array.sort( @@ -639,7 +639,7 @@ const testTypedArrayFindAndFindIndex = parametrize element < {{.item.create}}(0), - [{{.item.create}}(-5), 2 as number] as ExpectationsOptIN + [{{.item.create}}(-5), 2. as double] as ExpectationsOptIN ] ] as ObjectTypeAndExpectations, ], @@ -718,7 +718,7 @@ const testTypedArrayOf = parametrize>( const viaCtor = new {{.item.objectType}}(args) const viaOf = {{.item.objectType}}.of(...args) - const isEqual = viaCtor.every((x: {{.item.type}}, index: number) => x == viaOf[index as int]) + const isEqual = viaCtor.every((x: {{.item.type}}, index: number) => x == viaOf[index.toInt()]) let failures = 0 failures += check(boolToResult(isEqual), "result of .of method call is equal to ctor invoke") diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_slicing.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_slicing.j2 index 58eff8664253ebb45340eb56e096780858c2c869..7d5dcc4a9b09df561abb37614a92744a995eae0e 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_slicing.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_slicing.j2 @@ -58,7 +58,7 @@ const abnormalSource: FixedArray<{{.item.primitiveType}}> = {{.item.abnormalData function testSliceWithOutParam(): int { //let source: FixedArray<{{.item.primitiveType}}> = [10, 20, 30, 40, 50, 60]; - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; @@ -80,13 +80,13 @@ function testSliceWithOutParam(): int { return fail; } - if (target.length as int != origin.length as int) { + if (target.length.toInt() != origin.length.toInt()) { console.log("Array length mismatch on slice"); return fail; } //Check all the data copied; - for (let i: int = 0; i< origin.length as int; i++) { + for (let i: int = 0; i< origin.length.toInt(); i++) { let tv = target[i]{{.item.cast2primitive}}; let ov = origin[i]{{.item.cast2primitive}}; console.log(source[i] + "->" + tv + "->" + ov); @@ -97,7 +97,7 @@ function testSliceWithOutParam(): int { } origin= new {{.item.objectType}}(0); - if (origin.length as int != 0){ + if (origin.length.toInt() != 0){ return fail; } @@ -108,7 +108,7 @@ function testSliceWithOutParam(): int { return fail; } - if (target.length as int != 0){ + if (target.length.toInt() != 0){ return fail; } return success; @@ -116,7 +116,7 @@ function testSliceWithOutParam(): int { function testSliceOneParam(): int { //let source: FixedArray<{{.item.primitiveType}}> = [10, 20, 30, 40, 50, 60]; - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; @@ -129,7 +129,7 @@ function testSliceOneParam(): int { } let sliceStart: int = 1; - let sliceEnd: int = origin.length as int; + let sliceEnd: int = origin.length.toInt(); let target: {{.item.objectType}}; @@ -140,7 +140,7 @@ function testSliceOneParam(): int { return fail; } - if (target.length as int != origin.length as int - sliceStart) { + if (target.length.toInt() != origin.length.toInt() - sliceStart) { console.log("Array length mismatch on slice One Params" + target.length); return fail; } @@ -164,7 +164,7 @@ function testSliceOneParam(): int { return fail; } - if (target.length as int != origin.length as int) { + if (target.length.toInt() != origin.length.toInt()) { console.log("Array length mismatch on slice One Params" + target.length); return fail; } @@ -185,7 +185,7 @@ function testSliceOneParam(): int { function testSliceTwoParams(): int { //let source: FixedArray<{{.item.primitiveType}}> = [10, 20, 30, 40, 50, 60, 70, 80]; - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; @@ -209,7 +209,7 @@ function testSliceTwoParams(): int { return fail; } - if (target.length as int != sliceEnd - sliceStart) { + if (target.length.toInt() != sliceEnd - sliceStart) { console.log("Array length mismatch on slice2"); return fail; } @@ -226,7 +226,7 @@ function testSliceTwoParams(): int { } sliceStart = 0; - sliceEnd = origin.length as int; + sliceEnd = origin.length.toInt(); try { target = origin.slice(sliceStart, sliceEnd); } catch(e) { @@ -234,7 +234,7 @@ function testSliceTwoParams(): int { return fail; } - if (target.length as int != sliceEnd - sliceStart) { + if (target.length.toInt() != sliceEnd - sliceStart) { console.log("Array length mismatch on slice2"); return fail; } @@ -257,7 +257,7 @@ function testSliceTwoParams(): int { return fail; } - if (target.length as int != sliceEnd - sliceStart) { + if (target.length.toInt() != sliceEnd - sliceStart) { console.log("Array length mismatch on slice2"); return fail; } @@ -280,7 +280,7 @@ function testSliceTwoParams(): int { return fail; } - if (target.length as int != sliceEnd - sliceStart) { + if (target.length.toInt() != sliceEnd - sliceStart) { console.log("Array length mismatch on slice2"); return fail; } @@ -303,7 +303,7 @@ function testSliceTwoParams(): int { return fail; } - if (target.length as int != sliceEnd - sliceStart) { + if (target.length.toInt() != sliceEnd - sliceStart) { console.log("Array length mismatch on slice2"); return fail; } @@ -326,7 +326,7 @@ function testSliceTwoParams(): int { return fail; } - if (target.length as int != 0) { + if (target.length.toInt() != 0) { console.log("Array length mismatch on slice2"); return fail; } @@ -336,7 +336,7 @@ function testSliceTwoParams(): int { function testSliceTwoParamsWithOtherNumber(): int { //let source: FixedArray<{{.item.primitiveType}}> = [10, 20, 30, 40, 50, 60, 70, 80]; - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; @@ -359,27 +359,27 @@ function testSliceTwoParamsWithOtherNumber(): int { return fail; } - if (target.length as int != 0) { + if (target.length.toInt() != 0) { console.log("Array length mismatch on slice2"); return fail; } sliceStart = -1; - sliceEnd = origin.length as int; + sliceEnd = origin.length.toInt(); try { target = origin.slice(sliceStart, sliceEnd); } catch(e) { return fail; } - if (target.length as int != sliceEnd - (origin.length + sliceStart)) { + if (target.length.toInt() != sliceEnd - (origin.length + sliceStart)) { console.log("Array length mismatch on slice2"); return fail; } //Check all the data copied; - for (let i: int = (origin.length + sliceStart) as int; i< sliceEnd; i++) { - let tv = target[(i - (origin.length + sliceStart)) as int]{{.item.cast2primitive}}; + for (let i: int = (origin.length + sliceStart).toInt(); i< sliceEnd; i++) { + let tv = target[(i - (origin.length + sliceStart)).toInt()]{{.item.cast2primitive}}; let ov = origin[i]{{.item.cast2primitive}}; console.log(source[i] + "->" + tv + "->" + ov); if (tv != ov) { @@ -389,7 +389,7 @@ function testSliceTwoParamsWithOtherNumber(): int { } sliceStart = 0; - sliceEnd = -origin.length as int; + sliceEnd = -origin.length.toInt(); try { target = origin.slice(sliceStart, sliceEnd); } catch(e) { @@ -397,7 +397,7 @@ function testSliceTwoParamsWithOtherNumber(): int { return fail; } - if (target.length as int != (origin.length + sliceEnd) - sliceStart) { + if (target.length.toInt() != (origin.length + sliceEnd) - sliceStart) { console.log("Array length mismatch on slice2"); return fail; } @@ -407,7 +407,7 @@ function testSliceTwoParamsWithOtherNumber(): int { function testSliceOneLengthTwoParams(): int { let source1: FixedArray<{{.item.type}}> = [{{.item.create}}(10)]; - let ss = new ArrayBuffer(source1.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source1.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; @@ -430,7 +430,7 @@ function testSliceOneLengthTwoParams(): int { return fail; } - if (target.length as int != 0) { + if (target.length.toInt() != 0) { console.log("Array length mismatch on slice2"); return fail; } @@ -443,7 +443,7 @@ function testSliceOneLengthTwoParams(): int { return fail; } - if (target.length as int != 0) { + if (target.length.toInt() != 0) { console.log("Array length mismatch on slice2"); return fail; } diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray.j2 index a13912d1f5700201aacd2e56db37bb0c5eff9e0a..9338f6c4ddf5710cfae61b3a06528cfeb57831a0 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray.j2 @@ -53,14 +53,14 @@ function check(result: int, message: String): int { const source: FixedArray<{{.item.primitiveType}}> = {{.item.data}}; function createArraySetAndGet(): int { - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let target: {{.item.objectType}}; try { target = new {{.item.objectType}}(ss); } catch(e) { return fail; } - for (let i: int = 0; i < source.length as int; i++) { + for (let i: int = 0; i < source.length.toInt(); i++) { try { target.set(i, source[i] as {{.item.primitiveType}}); } catch(e) { @@ -68,14 +68,14 @@ function createArraySetAndGet(): int { return fail; } } - for (let i: int = 0; i < source.length as int; i++) { + for (let i: int = 0; i < source.length.toInt(); i++) { let back = target[i]{{.item.cast2primitive}}; if (back != source[i]) { console.println("Data mismatch for {{.item.objectType}} " + " expected: " + source[i] + " at " + i + " but actual: " + back); return fail; } - if (target[i as int] != target[i as number]) { - console.println("Data mismatch for $_get(int) and $_get(number): " + target[i as int] + " vs " + target[i as number]); + if (target[i.toInt()] != target[i.toDouble()]) { + console.println("Data mismatch for $_get(int) and $_get(number): " + target[i.toInt()] + " vs " + target[i.toDouble()]); return fail; } } @@ -83,13 +83,13 @@ function createArraySetAndGet(): int { // NOTE: comparison of target that filled by set(int, {{.item.type}}) vs target2.$_set(number, {{.item.type}}) let target2: {{.item.objectType}}; try { - target2 = new {{.item.objectType}}(new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}})); + target2 = new {{.item.objectType}}(new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}})); } catch(e) { return fail; } for (let i: int = 0; i < source.length; i++) { try { - target2[i as number] = source[i] as {{.item.primitiveType}}; + target2[i.toDouble()] = source[i] as {{.item.primitiveType}}; } catch(e) { console.print("Catched exception at insert via $_set(number, {{.item.type}})"); return fail; @@ -98,7 +98,7 @@ function createArraySetAndGet(): int { console.print("Data mismatch for $_get(int) vs $_get(int) filled by set(int, {{.item.type}}) vs $_set(number, {{.item.type}})"); return fail; } - if (target[i as number] != target2[i as number]) { + if (target[i.toDouble()] != target2[i.toDouble()]) { console.print("Data mismatch for $_get(number) vs $_get(number) filled by set(int, {{.item.type}}) vs $_set(number, {{.item.type}})"); return fail; } @@ -107,7 +107,7 @@ function createArraySetAndGet(): int { } function createArrayFromArray(): int { - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let target: {{.item.objectType}}; try { target = new {{.item.objectType}}(ss); @@ -125,7 +125,7 @@ function createArrayFromArray(): int { let sumExp: {{.item.primitiveType}} = 0; let sumAct: {{.item.primitiveType}} = 0; - for (let i: int = 0; i < source.length as int; i++) { + for (let i: int = 0; i < source.length.toInt(); i++) { sumExp += source[i]; sumAct += target[i]{{.item.cast2primitive}}; } @@ -135,7 +135,7 @@ function createArrayFromArray(): int { acc++; } - for (let i: int = 0; i < source.length as int; i++) { + for (let i: int = 0; i < source.length.toInt(); i++) { let back = target[i]{{.item.cast2primitive}}; if (back != source[i]) { @@ -150,7 +150,7 @@ function createArrayFromArray(): int { function createArrayFromArrayWithOffset(): int { let offset: int = 3; - let ss = new ArrayBuffer((source.length as int + offset) * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer((source.length.toInt() + offset) * {{.item.primitiveSizeBytes}}); let target: {{.item.objectType}}; try { target = new {{.item.objectType}}(ss); @@ -166,7 +166,7 @@ function createArrayFromArrayWithOffset(): int { let acc: int = 0; - for (let i: int = offset; i < source.length as int; i++) { + for (let i: int = offset; i < source.length.toInt(); i++) { let back = target[i]{{.item.cast2primitive}};; if (back != source[i-offset]) { @@ -178,7 +178,7 @@ function createArrayFromArrayWithOffset(): int { } function createFilteredArrayFromGiven(): int { - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; try { origin = new {{.item.objectType}}(ss); @@ -194,11 +194,11 @@ function createFilteredArrayFromGiven(): int { return fail; } let targetIdx = 0 as int - for (let originIdx = 0; originIdx < origin.length as int; originIdx++) { + for (let originIdx = 0; originIdx < origin.length.toInt(); originIdx++) { if (origin[originIdx]{{.item.cast2primitive}} <= 0) { continue; } - if (targetIdx >= target.length as int) { + if (targetIdx >= target.length.toInt()) { console.println("filter: buffer overflow"); return fail; } @@ -208,7 +208,7 @@ function createFilteredArrayFromGiven(): int { } targetIdx++ } - if (targetIdx != target.length as int) { + if (targetIdx != target.length.toInt()) { console.println("new element " + target.at(targetIdx)); return fail; } @@ -218,7 +218,7 @@ function createFilteredArrayFromGiven(): int { function testLastIndexOfNotFound(): int { - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let target: {{.item.objectType}}; try { target = new {{.item.objectType}}(ss); @@ -237,7 +237,7 @@ function testLastIndexOf4(): int { let source: FixedArray<{{.item.primitiveType}}> = [10 as {{.item.primitiveType}}, 20 as {{.item.primitiveType}}, 50 as {{.item.primitiveType}}, 50 as {{.item.primitiveType}}, 50 as {{.item.primitiveType}}, 60 as {{.item.primitiveType}}]; - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let target: {{.item.objectType}}; @@ -259,7 +259,7 @@ function testLastIndexOf3(): int { let source: FixedArray<{{.item.primitiveType}}> = [10 as {{.item.primitiveType}}, 20 as {{.item.primitiveType}}, 50 as {{.item.primitiveType}}, 50 as {{.item.primitiveType}}, 50 as {{.item.primitiveType}}, 60 as {{.item.primitiveType}}]; - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let target: {{.item.objectType}}; @@ -283,7 +283,7 @@ function testMap(): int { let source: FixedArray<{{.item.primitiveType}}> = [10 as {{.item.primitiveType}}, 20 as {{.item.primitiveType}}, 50 as {{.item.primitiveType}}, 50 as {{.item.primitiveType}}, 50 as {{.item.primitiveType}}, 60 as {{.item.primitiveType}}]; - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; try { @@ -302,12 +302,12 @@ function testMap(): int { return fail; } - if (target.length as int != source.length as int) { + if (target.length.toInt() != source.length.toInt()) { console.println("Array length mismatch"); return fail; } - for (let i: int = 0; i< source.length as int; i++) { + for (let i: int = 0; i< source.length.toInt(); i++) { if (target[i]{{.item.cast2primitive}} != source[i] + 1) { console.println("Array data mismatch"); return fail; @@ -317,7 +317,7 @@ function testMap(): int { } function createFromSource(source: FixedArray<{{.item.primitiveType}}>): {{.item.objectType}} throws { - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; @@ -334,16 +334,16 @@ function createFromSource(source: FixedArray<{{.item.primitiveType}}>): {{.item. function dump(source: FixedArray<{{.item.type}}>, origin: {{.item.objectType}}): void { console.print("Expected: "); - for (let i: int = 0; i< source.length as int; i++) console.print(source[i] + " "); + for (let i: int = 0; i< source.length.toInt(); i++) console.print(source[i] + " "); console.println(); console.print("Passed: "); - for (let i: int = 0; i< origin.length as int; i++) console.print(origin[i] as {{.item.type}} + " "); + for (let i: int = 0; i< origin.length.toInt(); i++) console.print(origin[i] as {{.item.type}} + " "); console.println(); } function assertArrayEqualsToTypedArray(source: FixedArray<{{.item.primitiveType}}>, origin: {{.item.objectType}}): int { - if (origin.length as int != source.length as int) { + if (origin.length.toInt() != source.length.toInt()) { return fail; } for (let i: int; i< origin.length; i++) { diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_ctors.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_ctors.j2 index 2b744dca63533a084409f19258f4cdf27d91e771..f921db9dafac73dac0a1d77876adf0b27d2982b0 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_ctors.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_ctors.j2 @@ -1,5 +1,5 @@ /** - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -81,25 +81,25 @@ const abnormalSource: {{.item.sourceElementsType}}[] = {{.item.abnormalData}}; function createDefault(): number { let target: {{.item.objectType}} = new {{.item.objectType}}(); - if (target.length as int == 0 && target.byteOffset as int == 0) return success; + if (target.length.toInt() == 0 && target.byteOffset.toInt() == 0) return success; return fail; } function createEmptyWithLength(): number { let target: {{.item.objectType}} = new {{.item.objectType}}(0); - if (target.length as int == 0 && target.byteOffset as int == 0) return success; + if (target.length.toInt() == 0 && target.byteOffset.toInt() == 0) return success; return fail; } function createEmptyWithNaNLength(): number { let target: {{.item.objectType}} = new {{.item.objectType}}(NaN); - if (target.length as int == 0 && target.byteOffset as int == 0) return success; + if (target.length.toInt() == 0 && target.byteOffset.toInt() == 0) return success; return fail; } function createNonEmptyWithFloatingLength(): number { let target: {{.item.objectType}} = new {{.item.objectType}}(5.4); - if (target.length as int == 5 && target.byteOffset as int == 0 && target.byteLength as int == 5 * {{.item.primitiveSizeBytes}}) { + if (target.length.toInt() == 5 && target.byteOffset.toInt() == 0 && target.byteLength.toInt() == 5 * {{.item.primitiveSizeBytes}}) { return success; } return fail; @@ -107,7 +107,7 @@ function createNonEmptyWithFloatingLength(): number { function createNonEmptyWithLength(): number { let target: {{.item.objectType}} = new {{.item.objectType}}(5); - if (target.length as int == 5 && target.byteOffset as int == 0 && target.byteLength as int == 5 * {{.item.primitiveSizeBytes}}){ + if (target.length.toInt() == 5 && target.byteOffset.toInt() == 0 && target.byteLength.toInt() == 5 * {{.item.primitiveSizeBytes}}){ return success; } return fail; @@ -115,7 +115,7 @@ function createNonEmptyWithLength(): number { function createtypedUArrayWithNegativeLength(): number { try { - let target: {{.item.objectType}} = new {{.item.objectType}}(-1 as number); + let target: {{.item.objectType}} = new {{.item.objectType}}(-1); } catch(e) { if (e instanceof TypeError) { return success; @@ -151,13 +151,13 @@ function createtypedUArrayWithPositiveInfinityLength(): number { function createtypedUArrayWithNegativeNaNLength(): number { let target: {{.item.objectType}} = new {{.item.objectType}}(-NaN); - if (target.length as int == 0 && target.byteOffset as int == 0) return success; + if (target.length.toInt() == 0 && target.byteOffset.toInt() == 0) return success; return fail; } function createtypedUArrayWithPositiveNaNLength(): number { let target: {{.item.objectType}} = new {{.item.objectType}}(+NaN); - if (target.length as int == 0 && target.byteOffset as int == 0) return success; + if (target.length.toInt() == 0 && target.byteOffset.toInt() == 0) return success; return fail; } @@ -175,7 +175,7 @@ function createEmptyWithIterable(): number { return fail; } - if (target.length as int == 0){ + if (target.length.toInt() == 0){ return success; } @@ -189,7 +189,7 @@ function createNonEmptyWithIterable(): number { array.push({{.item.create}}(3)); let target: {{.item.objectType}} = new {{.item.objectType}}(array.values() as Iterable<{{.item.type}}>); - if (target.length as int == 3 && target.byteOffset as int == 0 && target.byteLength as int == 3*{{.item.primitiveSizeBytes}}){ + if (target.length.toInt() == 3 && target.byteOffset.toInt() == 0 && target.byteLength.toInt() == 3*{{.item.primitiveSizeBytes}}){ return success; } @@ -200,7 +200,7 @@ function createNonEmptyWithIterable(): number { } let origin: {{.item.objectType}} = new {{.item.objectType}}(exceptArray.values() as Iterable<{{.item.type}}>); - for (let i: int = 0; i< target.length as int; i++) { + for (let i: int = 0; i< target.length.toInt(); i++) { let tv = target[i]{{.item.cast2primitive}}; let ov = origin[i]{{.item.cast2primitive}}; console.log(tv + "->" + ov); @@ -387,12 +387,12 @@ function testTypedUArrayIteratorAfterCompletion(): number { function createtypedUArrayWithArrayLike(): number { let array = new Array<{{.item.type}}>(); - array.push({{.item.create}}(1 as Number)); - array.push({{.item.create}}(2 as Number)); - array.push({{.item.create}}(3 as Number)); + array.push({{.item.create}}(1)); + array.push({{.item.create}}(2)); + array.push({{.item.create}}(3)); let target: {{.item.objectType}} = new {{.item.objectType}} (array as ArrayLike<{{.item.type}}>); - if (target.length as int == 3 && target.byteOffset as int == 0){ + if (target.length.toInt() == 3 && target.byteOffset.toInt() == 0){ return success; } return fail; @@ -407,7 +407,7 @@ function createTAFromEmptyArrayBuffer(): number { return fail; } - if (target.length as int == 0 && target.byteOffset as int == 0) return success; + if (target.length.toInt() == 0 && target.byteOffset.toInt() == 0) return success; return fail; } @@ -420,7 +420,7 @@ function createTAFromNonEmptyArrayBuffer(): number { return fail; } - if (target.byteLength as int == 5 * {{.item.primitiveSizeBytes}} && target.byteOffset as int == 0) return success; + if (target.byteLength.toInt() == 5 * {{.item.primitiveSizeBytes}} && target.byteOffset.toInt() == 0) return success; console.println("Error: Actual bytes length: " + target.byteLength); return fail; } @@ -433,17 +433,17 @@ function createTAFromEmptyArrayBufferOneParamNoOffset(): number { } catch(e) { return fail; } - if (target.length as number != 0 || target.byteOffset as number != 0) { + if (target.length.toDouble() != 0 || target.byteOffset.toDouble() != 0) { return fail; } try { - target = new {{.item.objectType}}(ss, undefined); + target = new {{.item.objectType}}(ss); } catch(e) { return fail; } - if (target.length as number != 0 || target.byteOffset as number != 0) { + if (target.length.toDouble() != 0 || target.byteOffset.toDouble() != 0) { return fail; } @@ -482,20 +482,20 @@ function createTAFromNonEmptyArrayBufferOneParamNoOffset(): number { return fail; } - if (target.byteLength as number != 5 * {{.item.primitiveSizeBytes}} || target.byteOffset as number != 0 - || target.length as number != 5){ + if (target.byteLength.toDouble() != 5 * {{.item.primitiveSizeBytes}} || target.byteOffset.toDouble() != 0 + || target.length.toDouble() != 5){ console.println("Error: Actual bytes length: " + target.byteLength); return fail; } try { - target = new {{.item.objectType}}(ss, undefined); + target = new {{.item.objectType}}(ss); } catch(e) { return fail; } - if (target.byteLength as number != 5 * {{.item.primitiveSizeBytes}} || target.byteOffset as number != 0 - || target.length as number != 5){ + if (target.byteLength.toDouble() != 5 * {{.item.primitiveSizeBytes}} || target.byteOffset.toDouble() != 0 + || target.length.toDouble() != 5){ console.println("Error: Actual bytes length: " + target.byteLength); return fail; } @@ -534,8 +534,8 @@ function createTAFromNonEmptyArrayBufferOneParamWithOffset(): number { return fail; } - if (target.byteLength as int == 5 * {{.item.primitiveSizeBytes}} && target.byteOffset as int == 2*{{.item.primitiveSizeBytes}} - && target.length as int == 5){ + if (target.byteLength.toInt() == 5 * {{.item.primitiveSizeBytes}} && target.byteOffset.toInt() == 2*{{.item.primitiveSizeBytes}} + && target.length.toInt() == 5){ return success; } console.println("Error: Actual bytes length: " + target.byteLength); @@ -554,7 +554,7 @@ function createTAFromNonEmptyArrayBufferOneParamWithOffsetAndSize(): number { return fail; } - if (target.byteLength as int == 4*{{.item.primitiveSizeBytes}} && target.byteOffset as int == 2*{{.item.primitiveSizeBytes}} && target.length as int == 4) return success; + if (target.byteLength.toInt() == 4*{{.item.primitiveSizeBytes}} && target.byteOffset.toInt() == 2*{{.item.primitiveSizeBytes}} && target.length.toInt() == 4) return success; console.println("Error: Actual bytes length: " + target.byteLength); console.println("Error: Actual bytes offset: " + target.byteOffset); console.println("Error: length: " + target.length); @@ -570,7 +570,7 @@ function createTAFromEmptyArrayBufferTwoParams(): number { return fail; } - if (target.length as number != 0 || target.byteOffset as number != 0) { + if (target.length.toDouble() != 0 || target.byteOffset.toDouble() != 0) { return fail; } @@ -580,7 +580,7 @@ function createTAFromEmptyArrayBufferTwoParams(): number { return fail; } - if (target.length as number != 0 || target.byteOffset as number != 0) { + if (target.length.toDouble() != 0 || target.byteOffset.toDouble() != 0) { return fail; } @@ -596,7 +596,7 @@ function createTAFromNonEmptyArrayBufferTwoParams(): number { return fail; } - if (target.byteLength as int == 5 * {{.item.primitiveSizeBytes}} && target.byteOffset as int == 0 && target.length == 5){ + if (target.byteLength.toInt() == 5 * {{.item.primitiveSizeBytes}} && target.byteOffset.toInt() == 0 && target.length == 5){ return success; } console.println("Error: Actual bytes length: " + target.byteLength); diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_function2.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_function2.j2 index 00b8ad1afe2a99d2d2ae84edca408910de49cba3..6ddb0fc58abd4c3e94e9b4d22e39826f21e27ed7 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_function2.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_function2.j2 @@ -90,7 +90,7 @@ function testSubarrayWithOutParam(): int { {{.item.create}}(50), {{.item.create}}(60) ]; - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; @@ -111,13 +111,13 @@ function testSubarrayWithOutParam(): int { return fail; } - if (target.length as int != origin.length as int) { + if (target.length.toInt() != origin.length.toInt()) { console.log("Array length mismatch on slice"); return fail; } //Check all the data copied; - for (let i: int = 0; i< origin.length as int; i++) { + for (let i: int = 0; i< origin.length.toInt(); i++) { let tv = target[i] as {{.item.type}}; let ov = origin[i] as {{.item.type}}; console.log(source[i] + "->" + tv + "->" + ov); @@ -128,7 +128,7 @@ function testSubarrayWithOutParam(): int { } origin= new {{.item.objectType}}(0); - if (origin.length as int != 0){ + if (origin.length.toInt() != 0){ return fail; } @@ -139,7 +139,7 @@ function testSubarrayWithOutParam(): int { return fail; } - if (target.length as int != 0){ + if (target.length.toInt() != 0){ return fail; } return success; @@ -154,7 +154,7 @@ function testSubarrayOneParam(): int { {{.item.create}}(50), {{.item.create}}(60) ]; - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; @@ -167,7 +167,7 @@ function testSubarrayOneParam(): int { } let subarrayStart: int = 1; - let subarrayEnd: int = origin.length as int; + let subarrayEnd: int = origin.length.toInt(); let target: {{.item.objectType}}; @@ -178,7 +178,7 @@ function testSubarrayOneParam(): int { return fail; } - if (target.length as int != origin.length as int - subarrayStart) { + if (target.length.toInt() != origin.length.toInt() - subarrayStart) { console.log("Array length mismatch on subarray One Params" + target.length); return fail; } @@ -202,7 +202,7 @@ function testSubarrayOneParam(): int { return fail; } - if (target.length as int != origin.length as int) { + if (target.length.toInt() != origin.length.toInt()) { console.log("Array length mismatch on subarray One Params" + target.length); return fail; } @@ -253,7 +253,7 @@ function testSubarrayTwoParams(): int { {{.item.create}}(50), {{.item.create}}(60) ]; - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; @@ -277,7 +277,7 @@ function testSubarrayTwoParams(): int { return fail; } - if (target.length as int != subarrayEnd - subarrayStart) { + if (target.length.toInt() != subarrayEnd - subarrayStart) { console.log("Array length mismatch on subarray2"); return fail; } @@ -294,7 +294,7 @@ function testSubarrayTwoParams(): int { } subarrayStart = 0; - subarrayEnd = origin.length as int; + subarrayEnd = origin.length.toInt(); try { target = origin.subarray(subarrayStart, subarrayEnd); } catch(e) { @@ -302,7 +302,7 @@ function testSubarrayTwoParams(): int { return fail; } - if (target.length as int != subarrayEnd - subarrayStart) { + if (target.length.toInt() != subarrayEnd - subarrayStart) { console.log("Array length mismatch on subarray2"); return fail; } @@ -325,7 +325,7 @@ function testSubarrayTwoParams(): int { return fail; } - if (target.length as int != subarrayEnd - subarrayStart) { + if (target.length.toInt() != subarrayEnd - subarrayStart) { console.log("Array length mismatch on subarray2"); return fail; } @@ -348,7 +348,7 @@ function testSubarrayTwoParams(): int { return fail; } - if (target.length as int != subarrayEnd - subarrayStart) { + if (target.length.toInt() != subarrayEnd - subarrayStart) { console.log("Array length mismatch on subarray2"); return fail; } @@ -371,7 +371,7 @@ function testSubarrayTwoParams(): int { return fail; } - if (target.length as int != subarrayEnd - subarrayStart) { + if (target.length.toInt() != subarrayEnd - subarrayStart) { console.log("Array length mismatch on subarray2"); return fail; } @@ -394,7 +394,7 @@ function testSubarrayTwoParams(): int { return fail; } - if (target.length as int != 0) { + if (target.length.toInt() != 0) { console.log("Array length mismatch on subarray2"); return fail; } @@ -411,7 +411,7 @@ function testSubarrayTwoParamsWithOtherNumber(): int { {{.item.create}}(50), {{.item.create}}(60) ]; - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; @@ -434,26 +434,26 @@ function testSubarrayTwoParamsWithOtherNumber(): int { return fail; } - if (target.length as int != 0) { + if (target.length.toInt() != 0) { console.log("Array length mismatch on subarray2"); return fail; } subarrayStart = -1; - subarrayEnd = origin.length as int; + subarrayEnd = origin.length.toInt(); try { target = origin.subarray(subarrayStart, subarrayEnd); } catch(e) { return fail; } - if (target.length as int != subarrayEnd - (origin.length + subarrayStart)) { + if (target.length.toInt() != subarrayEnd - (origin.length + subarrayStart)) { console.log("Array length mismatch on subarray2"); return fail; } //Check all the data copied; - for (let i: int = (origin.length + subarrayStart) as int; i< subarrayEnd; i++) { + for (let i: int = (origin.length + subarrayStart).toInt(); i< subarrayEnd; i++) { let tv = target[i - (origin.length + subarrayStart)] as {{.item.type}}; let ov = origin[i] as {{.item.type}}; console.log(source[i] + "->" + tv + "->" + ov); @@ -464,7 +464,7 @@ function testSubarrayTwoParamsWithOtherNumber(): int { } subarrayStart = 0; - subarrayEnd = -origin.length as int; + subarrayEnd = -origin.length.toInt(); try { target = origin.subarray(subarrayStart, subarrayEnd); } catch(e) { @@ -472,7 +472,7 @@ function testSubarrayTwoParamsWithOtherNumber(): int { return fail; } - if (target.length as int != (origin.length + subarrayEnd) - subarrayStart) { + if (target.length.toInt() != (origin.length + subarrayEnd) - subarrayStart) { console.log("Array length mismatch on subarray2"); return fail; } @@ -482,7 +482,7 @@ function testSubarrayTwoParamsWithOtherNumber(): int { function testSubarrayOneLengthTwoParams(): int { let source: FixedArray<{{.item.type}}> = [{{.item.create}}(10)]; - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; @@ -505,7 +505,7 @@ function testSubarrayOneLengthTwoParams(): int { return fail; } - if (target.length as int != 0) { + if (target.length.toInt() != 0) { console.log("Array length mismatch on subarray2"); return fail; } @@ -518,7 +518,7 @@ function testSubarrayOneLengthTwoParams(): int { return fail; } - if (target.length as int != 0) { + if (target.length.toInt() != 0) { console.log("Array length mismatch on subarray2"); return fail; } @@ -594,7 +594,7 @@ function testNonEmptyTypedUArraySetValue(): number { // Test case for typedUArray.includes(searchElement) with Normal Number function testTypedUArrayIncludesOneParamWithNormalNum(): number { - let ss = new ArrayBuffer(normalSource.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(normalSource.length.toInt() * {{.item.primitiveSizeBytes}}); let typedUArray: {{.item.objectType}}; try { @@ -629,7 +629,7 @@ function testTypedUArrayIncludesOneParamWithNormalNum(): number { {%- if item.objectType != 'BigUint64Array' %} // Test case for typedUArray.includes(searchElement) with abnormal number function testTypedUArrayIncludesOneParamWithAbnormalNum(): number { - let ss = new ArrayBuffer(abnormalSource.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(abnormalSource.length.toInt() * {{.item.primitiveSizeBytes}}); let typedUArray: {{.item.objectType}}; try { @@ -647,7 +647,7 @@ function testTypedUArrayIncludesOneParamWithAbnormalNum(): number { {%- elif item.objectType == 'Uint16Array' %} let searchElementArray: FixedArray<{{.item.type}}> = [65535, 0, 1, Short.MAX_VALUE, Short.MAX_VALUE - 1, Short.MAX_VALUE + 1]; {%- else %} - let searchElementArray: FixedArray<{{.item.type}}> = [4294967295, 0, 1, Int.MAX_VALUE, Int.MAX_VALUE - 1, Int.MAX_VALUE as number + 1]; + let searchElementArray: FixedArray<{{.item.type}}> = [4294967295, 0, 1, Int.MAX_VALUE, Int.MAX_VALUE - 1, Int.MAX_VALUE.toDouble() + 1]; {%- endif %} for (let i = 0; i < searchElementArray.length; i++) { @@ -659,7 +659,7 @@ function testTypedUArrayIncludesOneParamWithAbnormalNum(): number { // as int for (let i = 0; i < searchElementArray.length; i++) { - if (!typedUArray.includes(searchElementArray[i] as int)) { + if (!typedUArray.includes(searchElementArray[i].toInt())) { console.log("Test failed. testTypedUArrayIncludesOneParamWithAbnormalNum: as int" + JSON.stringify(searchElementArray[i])); return fail; } @@ -727,7 +727,7 @@ function testTypedUArrayIncludesTwoParamWithNormalIndex(): number { return fail; } //as int - result = typedUArray.includes((searchElement{{.item.cast2primitive}}) as int, fromIndex as int); + result = typedUArray.includes((searchElement{{.item.cast2primitive}}).toInt(), fromIndex.toInt()); if (result) { console.log(`Includes ${searchElement} from index ${fromIndex}? true`); } else { @@ -744,7 +744,7 @@ function testTypedUArrayIncludesTwoParamWithNormalIndex(): number { console.log(`Includes ${searchElement} from index ${fromIndex}? false`); } //as int - result = typedUArray.includes((searchElement{{.item.cast2primitive}}) as int, fromIndex as int); + result = typedUArray.includes((searchElement{{.item.cast2primitive}}).toInt(), fromIndex.toInt()); if (result) { console.log(`Includes ${searchElement} from index ${fromIndex}? true`); return fail; @@ -791,7 +791,7 @@ function testTypedUArrayIncludesTwoParamWithAbnormalIndex(): number { //a. Let k be len + n. let arrayLen = typedUArray.length; for (let i = 0 as int; i < arrayLen; i++) { - fromIndex = (- arrayLen + i) as int; + fromIndex = (- arrayLen + i).toInt(); result = typedUArray.includes(searchElement, fromIndex); let exceptResult = typedUArray.includes(searchElement, i); if (result == exceptResult) { @@ -803,7 +803,7 @@ function testTypedUArrayIncludesTwoParamWithAbnormalIndex(): number { } //b. If k < 0, set k to 0. - fromIndex = (-arrayLen -1) as int; + fromIndex = (-arrayLen -1).toInt(); result = typedUArray.includes(searchElement, fromIndex); if (result) { console.log(`Includes ${searchElement} from index ${fromIndex}? true`); @@ -857,7 +857,7 @@ function testTypedUArrayJoinWithEmptyArray(): number { } catch(e) { return fail; } - if (typedUArray.length as number != 0 || typedUArray.byteOffset as number != 0) { + if (typedUArray.length.toDouble() != 0 || typedUArray.byteOffset.toDouble() != 0) { return fail; } @@ -973,7 +973,7 @@ function testTypedUArrayKeysWithEmptyArray(): number { } catch(e) { return fail; } - if (typedUArray.length as number != 0 || typedUArray.byteOffset as number != 0) { + if (typedUArray.length.toDouble() != 0 || typedUArray.byteOffset.toDouble() != 0) { return fail; } @@ -1283,18 +1283,18 @@ const testTypedArraySet = parametrize>( {%- if item.objectType != 'BigUint64Array' %} - array[0 as number] = (value + 1) as number + array[0] = (value + 1).toDouble() const isNumberNumberCorrect = array[0] == {{.item.create}}(value + 1) - array[0 as int] = (value + 2) as number + array[0] = (value + 2).toDouble() const isIntNumberCorrect = array[0] == {{.item.create}}(value + 2) {%- endif %} - array[0 as number] = (value + 3) as int + array[0] = (value + 3).toInt() const isNumberIntCorrect = array[0] == {{.item.create}}(value + 3) - array[0 as int] = (value + 4) as int + array[0] = (value + 4).toInt() const isIntIntCorrect = array[0] == {{.item.create}}(value + 4) let failures = 0 @@ -1305,10 +1305,10 @@ const testTypedArraySet = parametrize>( failures += check(boolToResult(isPosInfThrows == expected[3]), `didn't throw: array[+Infinity] = value`) failures += check(boolToResult(isNanZero == expected[4]), `failed: array[NaN] = value`) {%- if item.objectType != 'BigUint64Array' %} - failures += check(boolToResult(isNumberNumberCorrect == expected[5]), `failed: array[0 as number] = value as number`) - failures += check(boolToResult(isIntNumberCorrect == expected[6]), `failed: array[0 as int] = value as number`) + failures += check(boolToResult(isNumberNumberCorrect == expected[5]), `failed: array[0.toDouble()] = value.toDouble()`) + failures += check(boolToResult(isIntNumberCorrect == expected[6]), `failed: array[0 as int] = value.toDouble()`) {%- endif %} - failures += check(boolToResult(isNumberIntCorrect == expected[7]), `failed: array[0 as number] = value as int`) + failures += check(boolToResult(isNumberIntCorrect == expected[7]), `failed: array[0.toDouble()] = value as int`) failures += check(boolToResult(isIntIntCorrect == expected[8]), `failed: array[0 as int] = value as int`) return failures == 0 ? success: fail diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_methods.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_methods.j2 index e4c9a2c7c8df07d264b54ef6f680e75896f6a7a7..6fb83cf365d176847c6a83a589e3a3808a15796e 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_methods.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_methods.j2 @@ -221,7 +221,7 @@ const testTypedArraySort = parametrize>( array.sort() const isEqualToGold = - array.every((x: {{.item.type}}, index: number) => x == expected[index as int]) + array.every((x: {{.item.type}}, index: number) => x == expected[index.toInt()]) // descending array.sort( @@ -344,7 +344,7 @@ const testTypedArrayOf = parametrize>( const viaCtor = new {{.item.objectType}}(args) const viaOf = {{.item.objectType}}.of(...args) - const isEqual = viaCtor.every((x: {{.item.type}}, index: number) => x == viaOf[index as int]) + const isEqual = viaCtor.every((x: {{.item.type}}, index: number) => x == viaOf[index.toInt()]) let failures = 0 failures += check(boolToResult(isEqual), "result of .of method call is equal to ctor invoke") diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_slicing.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_slicing.j2 index df0bce7070b83110ea2b9c03b88d40ae87e5317c..c2dc144d1fd16c3202fa756c2e6a5f4eebd63803 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_slicing.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_slicing.j2 @@ -1,5 +1,5 @@ /** - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -63,7 +63,7 @@ function testSliceWithOutParam(): int { {{.item.create}}(50), {{.item.create}}(60), ]; - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; @@ -85,13 +85,13 @@ function testSliceWithOutParam(): int { return fail; } - if (target.length as int != origin.length as int) { + if (target.length.toInt() != origin.length.toInt()) { console.log("Array length mismatch on slice"); return fail; } //Check all the data copied; - for (let i: int = 0; i< origin.length as int; i++) { + for (let i: int = 0; i< origin.length.toInt(); i++) { let tv = target[i] as {{.item.type}}; let ov = origin[i] as {{.item.type}}; console.log(source[i] + "->" + tv + "->" + ov); @@ -102,7 +102,7 @@ function testSliceWithOutParam(): int { } origin= new {{.item.objectType}}(0); - if (origin.length as int != 0){ + if (origin.length.toInt() != 0){ return fail; } @@ -113,7 +113,7 @@ function testSliceWithOutParam(): int { return fail; } - if (target.length as int != 0){ + if (target.length.toInt() != 0){ return fail; } return success; @@ -128,7 +128,7 @@ function testSliceOneParam(): int { {{.item.create}}(50), {{.item.create}}(60) ] - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; @@ -141,7 +141,7 @@ function testSliceOneParam(): int { } let sliceStart: int = 1; - let sliceEnd: int = origin.length as int; + let sliceEnd: int = origin.length.toInt(); let target: {{.item.objectType}}; @@ -152,7 +152,7 @@ function testSliceOneParam(): int { return fail; } - if (target.length as int != origin.length as int - sliceStart) { + if (target.length.toInt() != origin.length.toInt() - sliceStart) { console.log("Array length mismatch on slice One Params" + target.length); return fail; } @@ -176,7 +176,7 @@ function testSliceOneParam(): int { return fail; } - if (target.length as int != origin.length as int) { + if (target.length.toInt() != origin.length.toInt()) { console.log("Array length mismatch on slice One Params" + target.length); return fail; } @@ -206,7 +206,7 @@ function testSliceTwoParams(): int { {{.item.create}}(70), {{.item.create}}(80) ] - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; @@ -230,7 +230,7 @@ function testSliceTwoParams(): int { return fail; } - if (target.length as int != sliceEnd - sliceStart) { + if (target.length.toInt() != sliceEnd - sliceStart) { console.log("Array length mismatch on slice2"); return fail; } @@ -247,7 +247,7 @@ function testSliceTwoParams(): int { } sliceStart = 0; - sliceEnd = origin.length as int; + sliceEnd = origin.length.toInt(); try { target = origin.slice(sliceStart, sliceEnd); } catch(e) { @@ -255,7 +255,7 @@ function testSliceTwoParams(): int { return fail; } - if (target.length as int != sliceEnd - sliceStart) { + if (target.length.toInt() != sliceEnd - sliceStart) { console.log("Array length mismatch on slice2"); return fail; } @@ -278,7 +278,7 @@ function testSliceTwoParams(): int { return fail; } - if (target.length as int != sliceEnd - sliceStart) { + if (target.length.toInt() != sliceEnd - sliceStart) { console.log("Array length mismatch on slice2"); return fail; } @@ -301,7 +301,7 @@ function testSliceTwoParams(): int { return fail; } - if (target.length as int != sliceEnd - sliceStart) { + if (target.length.toInt() != sliceEnd - sliceStart) { console.log("Array length mismatch on slice2"); return fail; } @@ -324,7 +324,7 @@ function testSliceTwoParams(): int { return fail; } - if (target.length as int != sliceEnd - sliceStart) { + if (target.length.toInt() != sliceEnd - sliceStart) { console.log("Array length mismatch on slice2"); return fail; } @@ -347,7 +347,7 @@ function testSliceTwoParams(): int { return fail; } - if (target.length as int != 0) { + if (target.length.toInt() != 0) { console.log("Array length mismatch on slice2"); return fail; } @@ -366,7 +366,7 @@ function testSliceTwoParamsWithOtherNumber(): int { {{.item.create}}(70), {{.item.create}}(80) ] - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; @@ -389,26 +389,26 @@ function testSliceTwoParamsWithOtherNumber(): int { return fail; } - if (target.length as int != 0) { + if (target.length.toInt() != 0) { console.log("Array length mismatch on slice2"); return fail; } sliceStart = -1; - sliceEnd = origin.length as int; + sliceEnd = origin.length.toInt(); try { target = origin.slice(sliceStart, sliceEnd); } catch(e) { return fail; } - if (target.length as int != sliceEnd - (origin.length + sliceStart)) { + if (target.length.toInt() != sliceEnd - (origin.length + sliceStart)) { console.log("Array length mismatch on slice2"); return fail; } //Check all the data copied; - for (let i: int = (origin.length + sliceStart) as int; i< sliceEnd; i++) { + for (let i: int = (origin.length + sliceStart).toInt(); i< sliceEnd; i++) { let tv = target[i - (origin.length + sliceStart)] as {{.item.type}}; let ov = origin[i] as {{.item.type}}; console.log(source[i] + "->" + tv + "->" + ov); @@ -419,7 +419,7 @@ function testSliceTwoParamsWithOtherNumber(): int { } sliceStart = 0; - sliceEnd = -origin.length as int; + sliceEnd = -origin.length.toInt(); try { target = origin.slice(sliceStart, sliceEnd); } catch(e) { @@ -427,7 +427,7 @@ function testSliceTwoParamsWithOtherNumber(): int { return fail; } - if (target.length as int != (origin.length + sliceEnd) - sliceStart) { + if (target.length.toInt() != (origin.length + sliceEnd) - sliceStart) { console.log("Array length mismatch on slice2"); return fail; } @@ -437,7 +437,7 @@ function testSliceTwoParamsWithOtherNumber(): int { function testSliceOneLengthTwoParams(): int { let source: {{.item.type}}[] = [{{.item.create}}(10)]; - let ss = new ArrayBuffer(source.length as int * {{.item.primitiveSizeBytes}}); + let ss = new ArrayBuffer(source.length.toInt() * {{.item.primitiveSizeBytes}}); let origin: {{.item.objectType}}; @@ -460,7 +460,7 @@ function testSliceOneLengthTwoParams(): int { return fail; } - if (target.length as int != 0) { + if (target.length.toInt() != 0) { console.log("Array length mismatch on slice2"); return fail; } @@ -473,7 +473,7 @@ function testSliceOneLengthTwoParams(): int { return fail; } - if (target.length as int != 0) { + if (target.length.toInt() != 0) { console.log("Array length mismatch on slice2"); return fail; } diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_instance_method.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_instance_method.j2 index 36673612b1aca154203d9c6e7511940d8dba4c3a..0ed141a877dbcb28026dd958926a84ecae1830b1 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_instance_method.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_instance_method.j2 @@ -33,11 +33,11 @@ function main(): int { let max_test : int = {{.item.max_attempt}} {%- else %} {% if item.param_list | length > 0 %} - let max_step : int = TEST_DATA_{{.item.param_list.keys()|first|upper}}.length as int; + let max_step : int = TEST_DATA_{{.item.param_list.keys()|first|upper}}.length.toInt(); {% else %} - let max_step : int = TEST_DATA_EXPECTED.length as int; + let max_step : int = TEST_DATA_EXPECTED.length.toInt(); {% endif %} - let max_test : int = TEST_DATA_EXPECTED.length as int; + let max_test : int = TEST_DATA_EXPECTED.length.toInt(); {%- endif %} let passed_counter : int = 0; for (let i = 0; i < max_step; i++, exp_idx++) { @@ -142,7 +142,7 @@ function main(): int { // No exception occurs. Check test result let expected = TEST_DATA_EXPECTED[exp_idx]; {% raw %}// Workaround possible verifier bug, since we can't simply write: "actual as {{.actualType}}" for primitive types {% endraw %} - if ({{.item.verify_test_result_function}}(() => { return actual }() as {{.actualType}}, expected)) { + if ({{.item.verify_test_result_function}}(() => { return actual }().toDouble(), expected)) { {%- else %} // No exception occurs. Check test result let expected = TEST_DATA_EXPECTED[exp_idx]; diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_static_method.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_static_method.j2 index 8bcbcb8364d2720914c9708c7771dab273294171..518b0105d01b3175014fcdeba0b61c30a5cd96ae 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_static_method.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_static_method.j2 @@ -26,12 +26,12 @@ function main(): int { let max_test : int = {{.item.max_attempt}} {%- else %} {% if item.param_list | length > 0 %} - let max_step : int = TEST_DATA_{{.item.param_list.keys()|first|upper}}.length as int; + let max_step : int = TEST_DATA_{{.item.param_list.keys()|first|upper}}.length.toInt(); {% else %} - let max_step : int = TEST_DATA_EXPECTED.length as int; + let max_step : int = TEST_DATA_EXPECTED.length.toInt(); {%- endif %} {%- endif %} - let max_test : int = TEST_DATA_EXPECTED.length as int; + let max_test : int = TEST_DATA_EXPECTED.length.toInt(); let passed_counter : int = 0; for (let i = 0; i < max_step; i++) { {%- for number, param in item.param_list.items() %} diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_utils.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_utils.j2 index 7927ca28196d4964d4bd979dbed2930d1cceef78..464c5490ec29788f52f3ed6348ad22ef5840fb7e 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_utils.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_utils.j2 @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -31,7 +31,7 @@ function parametrize(name: string, inputs: T[], cb: (x: T) => number): () => console.log("✓ Passed test `" + name + "` [" + (i+1) + "/" + inputs.length + "]") } } - return ((failures > 0) ? 1 : 0) as number + return ((failures > 0) ? 1 : 0) } return inner } diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_verifier_lib.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_verifier_lib.j2 index d645d8003c50d4d2d570248c7b0eb1d560522868..d51833cd5b3a5f535a1bc6a41939520e2aa23c95 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_verifier_lib.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_verifier_lib.j2 @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -27,7 +27,7 @@ function compareStringBuilderWithString(actual : StringBuilder, expected : Strin } {%- endif %} -{%- if item.result_nature == "primitive" or item.method_return_type == "UTF_16_CodePoint" or item.method_return_type == "char" or item.method_return_type == "byte" or item.method_return_type == "short" or item.method_return_type == "int" or item.method_return_type == "long" or item.method_return_type == "boolean" or item.method_return_type == "number" or item.method_return_type == "bigint" %} +{%- if item.result_nature == "primitive" or item.method_return_type == "UTF_16_CodePoint" or item.method_return_type|lower == "char" or item.method_return_type|lower == "byte" or item.method_return_type|lower == "short" or item.method_return_type|lower == "int" or item.method_return_type|lower == "long" or item.method_return_type|lower == "boolean" or item.method_return_type|lower == "number" or item.method_return_type|lower == "bigint" %} {%- if item.method_return_type != "void" %} function comparePrimitiveValue(actual : {{.item.method_return_type}}, expected : {{.item.method_return_type}}) : boolean { {%- else %} @@ -38,7 +38,7 @@ function comparePrimitiveValue(actual : {{.item.result_type}}, expected : {{.ite } {%- endif %} -{%- if item.method_return_type == "float" or item.method_return_type == "double" or item.method_return_type == "Float" or item.method_return_type == "Double" %} +{%- if item.method_return_type|lower == "float" or item.method_return_type|lower == "double" or item.method_return_typ|lower == "Float" or item.method_return_type|lower == "Double" %} const DBL_EPSILON : double = 1.0e-6; function compareFloatPointValue(left : double, right : double) : boolean { if (left == right) { @@ -58,11 +58,11 @@ function compareFloatPointValue(left : double, right : double) : boolean { } {% endif %} -{%- if item.method_return_type == "Char" or item.method_return_type == "Boolean" or item.method_return_type == "Byte" or item.method_return_type == "Short" or item.method_return_type == "Int" or item.method_return_type == "Long" or item.method_return_type == "Float" or item.method_return_type == "Double" %} +{%- if item.method_return_type|lower == "Char" or item.method_return_type|lower == "Boolean" or item.method_return_type|lower == "Byte" or item.method_return_type|lower == "Short" or item.method_return_type|lower == "Int" or item.method_return_type|lower == "Long" or item.method_return_type|lower == "Float" or item.method_return_type|lower == "Double" %} function compareWrapperObjectValue(actual : {{.item.method_return_type}}, expected : {{.item.expected_data_item_type}}) : boolean { let actual2 : {{.item.expected_data_item_type}}; actual2 = actual.unboxed(); - {%- if item.method_return_type == "Float" or item.method_return_type == "Double" %} + {%- if item.method_return_type|lower == "Float" or item.method_return_type == "Double" %} return compareFloatPointValue(actual2, expected); {% else %} if (actual2 == expected) return true; diff --git a/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-excluded.txt b/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-excluded.txt index a15e534a2d9edeecee02db539ce555ddbf0e11ba..d77889cce48e3a43c0919aea27b157ce31ee7d69 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-excluded.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-excluded.txt @@ -1,2 +1,58 @@ -# 17363 incorrect test runner work with cyclic dependency with modules -13.compilation_units/06.compilation_unit_initialization/module/cyclic_dependency/test2.ets +# to char conversions, need methods +07.expressions/04.array_literal/01.type_inference_from_context/arr_inf_call_28.ets - bug #23450 in ignore list in main branch + +#24697 deprecated +08.statements/04.local_declarations/local_class.ets +09.classes/01.class_declaration/local_class_in_func_neg.ets +09.classes/01.class_declaration/local_interface_in_func_neg_1.ets +09.classes/01.class_declaration/local_interface_in_func_neg_2.ets +09.classes/01.class_declaration/local_interface_in_meth_neg_1.ets +09.classes/01.class_declaration/local_interface_in_meth_neg_2.ets + +# move from exclude to ignore list on 4/12 +#24840 +17.experimental_features/08.function_method_and_constructor_overloading/03.constructor_overloading/co3_over_3.ets + +#25414 +17.experimental_features/08.function_method_and_constructor_overloading/01.function_overloading/fn_overloading_19.ets + +################################################ +# primitive types refactoring. Need to rework the following tests, because they're incorrect: +################################################ + +# TypeError: Cannot cast type 'Char' to 'Int' +03.types/06.value_types/01.integer_types_and_operations/bitwise_and/bitwise_and_char_3.ets +03.types/06.value_types/01.integer_types_and_operations/bitwise_and/bitwise_and_char_4.ets +03.types/06.value_types/01.integer_types_and_operations/bitwise_or/bitwise_or_char_3.ets +03.types/06.value_types/01.integer_types_and_operations/bitwise_or/bitwise_or_char_4.ets +03.types/06.value_types/01.integer_types_and_operations/bitwise_or/bitwise_or_char_5.ets +03.types/06.value_types/01.integer_types_and_operations/multiplication/multiplication_char_4.ets +03.types/06.value_types/01.integer_types_and_operations/multiplication/multiplication_char_6.ets + +#not clear behaviour for union types, some tests pass, some fail +# to discuss with spec writers +# union types can contain several numerics +03.types/19.union_types/ut_n2_1.ets +03.types/19.union_types/ut_n2_10.ets +03.types/19.union_types/ut_n2_11.ets +03.types/19.union_types/ut_n2_13.ets +03.types/19.union_types/ut_n2_14.ets +03.types/19.union_types/ut_n2_15.ets +03.types/19.union_types/ut_n2_16.ets +03.types/19.union_types/ut_n2_17.ets +03.types/19.union_types/ut_n2_2.ets +03.types/19.union_types/ut_n2_20.ets +03.types/19.union_types/ut_n2_21.ets +03.types/19.union_types/ut_n2_24.ets +03.types/19.union_types/ut_n2_25.ets +03.types/19.union_types/ut_n2_28.ets +03.types/19.union_types/ut_n2_29.ets +03.types/19.union_types/ut_n2_3.ets +03.types/19.union_types/ut_n2_32.ets +03.types/19.union_types/ut_n2_33.ets +03.types/19.union_types/ut_n2_36.ets +03.types/19.union_types/ut_n2_37.ets +03.types/19.union_types/ut_n2_5.ets +03.types/19.union_types/ut_n2_6.ets +03.types/19.union_types/ut_n2_7.ets +03.types/19.union_types/ut_n2_9.ets diff --git a/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored.txt b/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored.txt index 99ef40ab31427e2eb57e9eeac08df41b1c0ad496..ea5cf67759c0d38643490c25b07590d072dcb363 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored.txt @@ -15,6 +15,35 @@ #24420 03.types/19.union_types/ut_34.ets +#26072 expected equality failed: '0' === ' '' +03.types/06.value_types/01.integer_types_and_operations/postfix_decrement/postfix_decrement_char_0.ets +03.types/06.value_types/01.integer_types_and_operations/postfix_decrement/postfix_decrement_char_1.ets +03.types/06.value_types/01.integer_types_and_operations/postfix_decrement/postfix_decrement_char_3.ets +03.types/06.value_types/01.integer_types_and_operations/postfix_decrement/postfix_decrement_char_4.ets +03.types/06.value_types/01.integer_types_and_operations/postfix_increment/postfix_increment_char_0.ets +03.types/06.value_types/01.integer_types_and_operations/postfix_increment/postfix_increment_char_1.ets +03.types/06.value_types/01.integer_types_and_operations/postfix_increment/postfix_increment_char_2.ets +03.types/06.value_types/01.integer_types_and_operations/postfix_increment/postfix_increment_char_4.ets +03.types/06.value_types/01.integer_types_and_operations/prefix_decrement/prefix_decrement_char_0.ets +03.types/06.value_types/01.integer_types_and_operations/prefix_decrement/prefix_decrement_char_1.ets +03.types/06.value_types/01.integer_types_and_operations/prefix_decrement/prefix_decrement_char_3.ets +03.types/06.value_types/01.integer_types_and_operations/prefix_decrement/prefix_decrement_char_4.ets +03.types/06.value_types/01.integer_types_and_operations/prefix_increment/prefix_increment_char_0.ets +03.types/06.value_types/01.integer_types_and_operations/prefix_increment/prefix_increment_char_1.ets +03.types/06.value_types/01.integer_types_and_operations/prefix_increment/prefix_increment_char_2.ets +03.types/06.value_types/01.integer_types_and_operations/prefix_increment/prefix_increment_char_4.ets +03.types/06.value_types/01.integer_types_and_operations/ternary/ternary_char_0.ets +03.types/06.value_types/01.integer_types_and_operations/ternary/ternary_char_1.ets +06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var_1.ets + +#26102 Readonly array assignment does not throw CTE +03.types/15.literal_types/function_literal_type_7.ets +03.types/19.union_types/01.union_types_normalization/norm_29.ets +03.types/19.union_types/01.union_types_normalization/norm_30.ets +03.types/19.union_types/01.union_types_normalization/norm_32.ets +03.types/19.union_types/01.union_types_normalization/norm_34.ets +03.types/19.union_types/01.union_types_normalization/norm_35.ets + #24649 04.names_declarations_and_scopes/04.scopes/type_param_class_neg_3.ets @@ -127,22 +156,14 @@ 05.generics/01.type_parameters/03.type_parameter_variance/generic_classes/type_parameter_variance_out_2.ets 05.generics/01.type_parameters/03.type_parameter_variance/generic_classes/type_parameter_variance_out_3.ets 05.generics/01.type_parameters/03.type_parameter_variance/generic_classes/type_parameter_variance_out_4.ets -05.generics/01.type_parameters/03.type_parameter_variance/generic_classes/type_parameter_variance_out_5.ets -05.generics/01.type_parameters/03.type_parameter_variance/generic_classes/type_parameter_variance_out_6.ets -05.generics/01.type_parameters/03.type_parameter_variance/generic_classes/type_parameter_variance_out_7.ets -05.generics/01.type_parameters/03.type_parameter_variance/generic_classes/type_parameter_variance_out_8.ets 05.generics/01.type_parameters/03.type_parameter_variance/generic_interfaces/type_parameter_variance_out_1.ets 05.generics/01.type_parameters/03.type_parameter_variance/generic_interfaces/type_parameter_variance_out_2.ets -05.generics/01.type_parameters/03.type_parameter_variance/generic_interfaces/type_parameter_variance_out_3.ets 05.generics/01.type_parameters/03.type_parameter_variance/generic_interfaces/type_parameter_variance_out_4.ets -05.generics/01.type_parameters/03.type_parameter_variance/generic_interfaces/type_parameter_variance_out_5.ets -05.generics/01.type_parameters/03.type_parameter_variance/generic_interfaces/type_parameter_variance_out_6.ets -05.generics/01.type_parameters/03.type_parameter_variance/generic_interfaces/type_parameter_variance_out_7.ets -05.generics/01.type_parameters/03.type_parameter_variance/generic_interfaces/type_parameter_variance_out_8.ets #24448 05.generics/01.type_parameters/03.type_parameter_variance/generic_classes/wrong_type_parameter_variance_4.ets + #24444 05.generics/01.type_parameters/03.type_parameter_variance/generic_interfaces/interface_type_parameter_variance.ets @@ -214,6 +235,9 @@ 05.generics/03.utility_types/03.readonly_utility_type/method_excluded_from_readonly_8.ets 05.generics/03.utility_types/03.readonly_utility_type/method_excluded_from_readonly_9.ets +#14001 +06.contexts_and_conversions/03.numeric_operator_contexts/unary_numeric_promotion/array_access_7.ets + #25175 05.generics/generic_declarations/create_array_using_generic_types/create_array_using_generic_types_ext_9.ets 05.generics/generic_declarations/create_array_using_generic_types/create_array_using_generic_types_ext_12.ets @@ -233,9 +257,6 @@ #18118 No ClassCastError on casting to a wrong function type 06.contexts_and_conversions/04.casting_contexts_and_conversions/06.casting_conversions_from_union/cce_5.ets -#18115 CTE on a union type variable in instanceof -06.contexts_and_conversions/04.casting_contexts_and_conversions/06.casting_conversions_from_union/un2_0.ets - #25224 06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/assn_var/assn-var_2.ets 06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/assn_var/assn-var_3.ets @@ -258,6 +279,10 @@ 06.contexts_and_conversions/05.implicit_conversions/11.constant_to_enum_conversions/int2enum_8.ets 06.contexts_and_conversions/05.implicit_conversions/11.constant_to_enum_conversions/int2enum_9.ets +# union types can contain several numerics +#26066 Type 'Short' cannot be assigned to type 'Char' +06.contexts_and_conversions/01.assignment-like_contexts/prim_widening_1.ets + #24036 07.expressions/01.evaluation_of_expressions/03.operator_precedence/typeof.ets @@ -265,20 +290,15 @@ 07.expressions/01.evaluation_of_expressions/typ_2.ets #22791 FixedArray and Array support is not implemented yet -07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_assn_28.ets -07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_call_18.ets -07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_cast_23.ets -07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_cast_27.ets -07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_decl_27.ets -07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_assn_22.ets -07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_assn_27.ets 07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_assn_28.ets -07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_call_28.ets 07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_cast_23.ets -07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_cast_26.ets 07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_cast_27.ets -07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_decl_26.ets 07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_decl_27.ets +07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_assn_28.ets +07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_call_18.ets +07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_cast_23.ets +07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_decl_27.ets +07.expressions/04.array_literal/01.type_inference_from_context/arr2_inf_cast_27.ets #24879 Cannot determine type of array expression in Union type 07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_assn_29.ets @@ -287,9 +307,6 @@ 07.expressions/04.array_literal/01.type_inference_from_context/arr_inf_call_30.ets 07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_cast_28.ets -#23450 Cannot determine type of array literal in call context -07.expressions/04.array_literal/01.type_inference_from_context/arr_inf_call_28.ets - #23453 Cannot cast array literal to union of arrays 07.expressions/04.array_literal/01.type_inference_from_context/arr_inf_cast_27.ets @@ -313,9 +330,6 @@ #24005 07.expressions/05.object_literal/03.object_literal_of_record_type/re_9.ets -#20024 es2panda fails to infer type of spread expression of enum array -07.expressions/06.spread_expression/spex_12.ets - #24006 Array literal type inference needs to be improved 07.expressions/06.spread_expression/spex_lmbd_35.ets 07.expressions/06.spread_expression/spex_lmbd_37.ets @@ -404,9 +418,6 @@ #23062 07.expressions/11.function_call_expression/step_1_selection_of_function/step1_23.ets -#23725 -07.expressions/11.function_call_expression/step_1_selection_of_function/step1n_2.ets - #14001 Type number cannot be used as an index type 07.expressions/12.indexing_expression/01.array_indexing_expression/array_index3_n_0.ets 07.expressions/12.indexing_expression/01.array_indexing_expression/array_index3_n_1.ets @@ -416,9 +427,6 @@ #18843 type compatability 07.expressions/25.equality_expressions/01.numerical_equality_operators/char_eq_n_2.ets -07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/union_equality_operators/eq_0.ets -07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/union_equality_operators/ne_0.ets -07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/union_equality_operators/ne_3.ets #23051 Reference comparison 07.expressions/25.equality_expressions/07.reference_equality/type_conversion_of_one_operand_to_another_type.ets @@ -426,28 +434,6 @@ #24401 Generic lambda is not supported by compiler 07.expressions/32.lambda_expression/generic.ets -#23513 -07.expressions/33.constant_expression/check_array/constant_logical_expression_10.ets -07.expressions/33.constant_expression/check_array/constant_logical_expression_11.ets -07.expressions/33.constant_expression/check_enum/constant_logical_expression_11.ets -07.expressions/33.constant_expression/check_enum/constant_logical_expression_12.ets - -#23515 -07.expressions/33.constant_expression/check_array/constant_logical_expression_12.ets -07.expressions/33.constant_expression/check_array/constant_logical_expression_13.ets -07.expressions/33.constant_expression/check_array/constant_logical_expression_14.ets -07.expressions/33.constant_expression/check_array/constant_logical_expression_15.ets - -#23871 -07.expressions/33.constant_expression/check_enum/constant_logical_expression_9.ets -07.expressions/33.constant_expression/check_enum/constant_logical_expression_10.ets - -#23309 -07.expressions/33.constant_expression/check_enum/constant_str_chain_initializer_2.ets - -#24126 es2panda aborts on for-of over a union type array -08.statements/09.for_of_statements/for_of_28.ets - #25042 Ast verifier failure for for-of with labelled statement 08.statements/11.continue_statements/continue_for_of3l.ets 08.statements/11.continue_statements/continue_for_of5l.ets @@ -494,8 +480,6 @@ 15.semantic_rules/01.subtyping/04.subtyping_for_function_types/positive_3.ets #23537 -15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/override_with_object_13.ets -15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/override_with_object_17.ets 15.semantic_rules/07.overloading_and_overriding/03.overloading_for_functions/function_argument_equivalent_neg_n2_0.ets 15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/access_modifier_over_25.ets 15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/instance_method_over_n2_20.ets @@ -512,7 +496,6 @@ 15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/override_compatibility_tuple_3.ets 15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/override_compatibility_array_9.ets 15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/override_compatible_signature_7.ets -15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/override_with_object_15.ets 15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/override_with_object_10.ets 15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/override_with_object_5.ets 15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/class_method_over_n3_1.ets @@ -574,9 +557,6 @@ 15.semantic_rules/07.overloading_and_overriding/05.overloading_and_overriding_in_interfaces/im_over_7.ets 15.semantic_rules/07.overloading_and_overriding/05.overloading_and_overriding_in_interfaces/im_over_8.ets -#25078 runtime fails with miltiple override error -15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/two_class_method_over_n_10.ets - #24129 15.semantic_rules/07.overloading_and_overriding/05.overloading_and_overriding_in_interfaces/im_over2_3.ets @@ -595,6 +575,9 @@ #18767 Cannot use $_iterator from superclass 17.experimental_features/05.iterable_types/it_4.ets +#23984 +17.experimental_features/08.function_method_and_constructor_overloading/01.function_overloading/fn_overloading_17.ets + #15767 Cannot select the right method among overloaded ones 17.experimental_features/08.function_method_and_constructor_overloading/02.class_method_overloading/cm_over3_3.ets @@ -638,7 +621,6 @@ 17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_a_10.ets #24121 -17.experimental_features/08.function_method_and_constructor_overloading/02.class_method_overloading/cm_over1_4.ets 17.experimental_features/08.function_method_and_constructor_overloading/02.class_method_overloading/cm_over1_8.ets 17.experimental_features/08.function_method_and_constructor_overloading/03.constructor_overloading/co1_over_6.ets @@ -687,6 +669,15 @@ #21301 Not work overloading with union parameter, different union have the similar assambly signature, mangling is necessary 17.experimental_features/17.packages/03.import_and_overloading_of_function_names/pkgs_ab_22.ets +#23995 not yet implemented +17.experimental_features/18.generics_experimental/01.non_nullish_type_parameter/ex1.ets +17.experimental_features/18.generics_experimental/01.non_nullish_type_parameter/ex2.ets +17.experimental_features/18.generics_experimental/01.non_nullish_type_parameter/ex3.ets +17.experimental_features/18.generics_experimental/01.non_nullish_type_parameter/ex3_1.ets +17.experimental_features/18.generics_experimental/01.non_nullish_type_parameter/ex4.ets +17.experimental_features/18.generics_experimental/01.non_nullish_type_parameter/ex4_1.ets +17.experimental_features/18.generics_experimental/01.non_nullish_type_parameter/ex5.ets + #24859 undefined register, Register type conflict 17.experimental_features/03.array_creation_expressions/01.runtime_evaluation_of_array_creation_expressions/expr_1.ets 17.experimental_features/03.array_creation_expressions/01.runtime_evaluation_of_array_creation_expressions/expr_2.ets @@ -697,7 +688,656 @@ 17.experimental_features/09.native_functions_and_methods/01.native_functions/nat7.ets 17.experimental_features/09.native_functions_and_methods/01.native_functions/nat8.ets +############ +# temporary place for the tests related to primitive types refactoring +############ + +# 1. +# Resizable array is inferred for array literal in union context instead of FixedArray +07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_assn_27.ets +07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_assn_28.ets +07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_assn_29.ets +07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_call_28.ets +07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_decl_26.ets +# verifier error +07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_cast_26.ets + +# 2. +# TypeError: Type '[String, Double]' is not compatible with the enclosing method's +# return type '[Object|null|undefined, Object|null|undefined]' [x.ets:1:21] +05.generics/generic_declarations/generic_classes/test_bridge_methods_in_generic_overrides/bridge_methods_generic_5.ets + +# 4. +# TypeError: Floating-point value cannot be converted [init4_2.ets:27:19] +# it seems double literal should also be inferred via preferred type to float +17.experimental_features/17.packages/02.package_initializer/p4/init4_1.ets +17.experimental_features/17.packages/02.package_initializer/p4/init4_2.ets + +# 5. mb +# Seems should be CTE, but now: 1. the test is positive; 2. CTE exists, but it looks like a bug with strange message +10.interfaces/07.interface_inheritance/multi_layer_interface/type_system/type_system_26.ets + +# 8. +# verifier failed for enum in extended conditional expressions +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_35.ets + +# 9. +# assert (!is_array_type) on non-nullish expr +05.generics/03.utility_types/04.record_utility_type/rec_3.ets + +# 12. +# incorrect bytecode - assert in bco +07.expressions/29.assignment/01.simple_assignment_operator/ord23.ets +07.expressions/29.assignment/01.simple_assignment_operator/ord25.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_28.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_29.ets + +# 13. +# Assertion in IsLegalBoxedPrimitiveConversion +17.experimental_features/07.statements/01.for-of_type_annotation/for_of_n_5.ets + +# 16. +# Need to reimplement a check for overload-equivalent sigs in case of type params. Previous impl was buggy +15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/neg_2.ets +15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/overload_equivalent_example_2.ets +15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/overload_equivalent_example_3.ets +15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/overload_equivalent_example_4.ets +15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/overload_equivalent_example_5.ets +17.experimental_features/08.function_method_and_constructor_overloading/01.function_overloading/fn_overloading_n_6.ets + +# 17. +# Strange tests - seems need to be added to exclude due to valid absence of CTE +17.experimental_features/16.async_functions_and_methods/01.async_functions/afunc_n_10.ets +17.experimental_features/16.async_functions_and_methods/01.async_functions/afunc_n_11.ets +17.experimental_features/16.async_functions_and_methods/01.async_functions/afunc_n_9.ets +17.experimental_features/16.async_functions_and_methods/02.async_methods/ameth_n_12.ets +17.experimental_features/16.async_functions_and_methods/02.async_methods/ameth_n_13.ets +17.experimental_features/16.async_functions_and_methods/02.async_methods/ameth_n_14.ets + +# 18. +# need to rework CollectSignaturesForSyntheticType and AddSignatureToSignatureSet function from etsObjectType.cpp +# after rebase on https://gitee.com/openharmony/arkcompiler_ets_frontend/pulls/4393/files +15.semantic_rules/07.overloading_and_overriding/05.overloading_and_overriding_in_interfaces/interface_return_value_overload.ets +15.semantic_rules/07.overloading_and_overriding/05.overloading_and_overriding_in_interfaces/multiple_interfaces_inheritance_0.ets +15.semantic_rules/07.overloading_and_overriding/05.overloading_and_overriding_in_interfaces/multiple_interfaces_inheritance_2.ets +15.semantic_rules/07.overloading_and_overriding/05.overloading_and_overriding_in_interfaces/interface_return_value_overload_1.ets +09.classes/06.method_declarations/09.methods_returning_this/methods_returning_this_interface_03.ets + +# 19. +'TypeError: Type argument '' should be a subtype of 'Object[]'-constraint +05.generics/02.generic_instantiations/01.type_arguments/type_arguments_of_parameterized_declarations/interface_args_12.ets + +# 20. +'TypeError: Array initializer's type is not assignable to tuple type at index: 0 +06.contexts_and_conversions/04.casting_contexts_and_conversions/03.casting_conversions_from_object/tuple_from_object_1.ets +06.contexts_and_conversions/04.casting_contexts_and_conversions/03.casting_conversions_from_object/tuple_from_object_3.ets + +# 22. +Output: 'TypeError: Property 'fld' might not have been initialized +06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/comp_obj/comp-obj_p.ets +07.expressions/17.typeof_expression/tof_obj_21.ets + +# 23. +'SyntaxError: object is a predefined type, cannot be used as an identifier +07.expressions/12.indexing_expression/01.array_indexing_expression/array_index03.ets +07.expressions/12.indexing_expression/01.array_indexing_expression/spec_ex2.ets + +# 24. +'TypeError: Cannot use type 'void' as value. +09.classes/06.method_declarations/06.overriding_methods/overriding_by_instance_methods/abstract_method_overridden_by_instance.ets + +# 25. +'TypeError: Operator '==' cannot be applied to types 'String|Color' and 'Int'. +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_18.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_19.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_20.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_21.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_22.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_23.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_24.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_25.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_26.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_27.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_34.ets +07.expressions/05.object_literal/03.object_literal_of_record_type/re_10.ets + +# 26. +'TypeError: Only abstract or native methods can't have body. +17.experimental_features/18.generics_experimental/01.non_nullish_type_parameter/ex2_1.ets + +# 29 +# TypeError: Call to `foo` is ambiguous as `2` versions of `foo` are available: +# `foo(i: Short): Int` and `foo(i: Char): Int` +04.names_declarations_and_scopes/05.accessible/type_name_const_1.ets + +# 31 +# 'TypeError: A is not abstract and does not implement getter for i property in I +05.generics/03.utility_types/01.partial_utility_type/partial_generic.ets + +# 32 +# Array initializer's type is not assignable to tuple type at index: 2 +07.expressions/04.array_literal/01.type_inference_from_context/tup_inf_cast_1.ets +07.expressions/04.array_literal/01.type_inference_from_context/tup_inf_cast_3.ets +07.expressions/04.array_literal/01.type_inference_from_context/tup_inf_decl_1.ets +07.expressions/04.array_literal/01.type_inference_from_context/tup_inf_decl_3.ets + +# 33 +# seems we don't set context with as for "e" double literals +07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2_num1_10.ets +07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2_num2_10.ets + +# 35 +# '$_invoke' is a static property of 'String' +17.experimental_features/06.callable_types/01.callable_types_with_invoke_method/ct_invoke_13.ets + +# 36 +# Seems the same error is in ohos CI +# Type '(resolve: (p: String) => void, reject: (p: Object|null) => void) => void' is not compatible with +# type '(resolve: (value: String|PromiseLike) => void, reject: (error: Error) => void) => void' at index 1 +17.experimental_features/15.coroutines/promise_class/p_0.ets +17.experimental_features/15.coroutines/promise_class/p_1.ets +17.experimental_features/15.coroutines/promise_class/p_2.ets +17.experimental_features/15.coroutines/promise_class/p_3.ets +17.experimental_features/15.coroutines/promise_class/p_4.ets +17.experimental_features/15.coroutines/promise_class/p_5.ets + +# 37 +# runtime failures: +04.names_declarations_and_scopes/05.accessible/type_name_const_2.ets +04.names_declarations_and_scopes/05.accessible/type_name_const_3.ets +04.names_declarations_and_scopes/05.accessible/type_name_const_4.ets +05.generics/generic_declarations/generic_classes/implementation_of_different_types/implement_generic_interface_20.ets +05.generics/generic_declarations/generic_classes/test_bridge_methods_in_generic_overrides/bridge_methods_generic_0.ets +05.generics/generic_declarations/generic_classes/test_bridge_methods_in_generic_overrides/bridge_methods_generic_11.ets +05.generics/generic_declarations/generic_classes/test_bridge_methods_in_generic_overrides/bridge_methods_generic_13.ets +05.generics/generic_declarations/generic_classes/test_bridge_methods_in_generic_overrides/bridge_methods_generic_4.ets +05.generics/generic_declarations/generic_in_out/generic_in_out_2.ets +05.generics/generic_declarations/generic_in_out/generic_in_out_5.ets +06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_obj/comp-obj-un_2.ets +06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_obj/comp-obj-un_4.ets +06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_field/decl-field-un_2.ets +06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_field/decl-field-un_4.ets +07.expressions/04.array_literal/01.type_inference_from_context/tup_inf_cast_6.ets +07.expressions/04.array_literal/01.type_inference_from_context/tup_inf_cast_7.ets +07.expressions/04.array_literal/01.type_inference_from_context/tup_inf_decl_6.ets +07.expressions/04.array_literal/01.type_inference_from_context/tup_inf_decl_7.ets +07.expressions/12.indexing_expression/02.record_indexing_expression/ind_14.ets +07.expressions/12.indexing_expression/02.record_indexing_expression/ind_17.ets +07.expressions/20.unary_expressions/06.unary_minus/unary_minus_corner_1.ets +07.expressions/20.unary_expressions/06.unary_minus/unary_minus_corner_2.ets +07.expressions/20.unary_expressions/06.unary_minus/unary_minus_corner_3.ets +07.expressions/20.unary_expressions/06.unary_minus/unary_minus_corner_4.ets +07.expressions/21.multiplicative_expressions/01.multiplication/inf_0.ets +07.expressions/21.multiplicative_expressions/01.multiplication/inf_1.ets +07.expressions/21.multiplicative_expressions/01.multiplication/inf_2.ets +07.expressions/21.multiplicative_expressions/01.multiplication/inf_3.ets +07.expressions/21.multiplicative_expressions/02.division/inf_0.ets +07.expressions/21.multiplicative_expressions/02.division/inf_1.ets +07.expressions/21.multiplicative_expressions/02.division/inf_10.ets +07.expressions/21.multiplicative_expressions/02.division/inf_11.ets +07.expressions/21.multiplicative_expressions/02.division/inf_2.ets +07.expressions/21.multiplicative_expressions/02.division/inf_3.ets +07.expressions/22.additive_expressions/02.additive_operators_for_numeric_types/inf_0.ets +07.expressions/22.additive_expressions/02.additive_operators_for_numeric_types/inf_1.ets +07.expressions/22.additive_expressions/02.additive_operators_for_numeric_types/inf_2.ets +07.expressions/22.additive_expressions/02.additive_operators_for_numeric_types/inf_3.ets +07.expressions/22.additive_expressions/02.additive_operators_for_numeric_types/inf_4.ets +07.expressions/22.additive_expressions/02.additive_operators_for_numeric_types/inf_5.ets +07.expressions/25.equality_expressions/01.numerical_equality_operators/float_equality_4.ets +07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/object_type_equality_operators/ne1_7.ets +07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/object_type_equality_operators/ne_11.ets +07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/object_type_equality_operators/ne_7.ets +07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/type_parameter_equality_operators/ne1_7.ets +07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/type_parameter_equality_operators/ne_11.ets +07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/type_parameter_equality_operators/ne_7.ets +07.expressions/31.string_interpolation_expressions/siexp_6.ets +07.expressions/33.constant_expression/check_array/constant_logical_expression_10.ets +07.expressions/33.constant_expression/check_array/constant_logical_expression_11.ets +07.expressions/33.constant_expression/check_enum/constant_logical_expression_11.ets +07.expressions/33.constant_expression/check_enum/constant_logical_expression_12.ets +15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/override_compatibility_array_5.ets +15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/override_compatibility_parameter_10.ets +15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/class_method_over_n3_0.ets +15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/class_method_over_n3_9.ets +15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/static_method_over_n2_0.ets +15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/static_method_over_n2_1.ets +15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/static_method_over_n2_2.ets +15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/static_method_over_n2_3.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_0.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_1.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_12.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_13.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_2.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_3.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_30.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_31.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_32.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_33.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_4.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_5.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_6.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_7.ets +17.experimental_features/04.indexable_types/ind_class_12.ets +17.experimental_features/04.indexable_types/ind_class_13.ets +17.experimental_features/04.indexable_types/ind_interface_12.ets +17.experimental_features/04.indexable_types/ind_interface_13.ets +17.experimental_features/06.callable_types/01.callable_types_with_invoke_method/ct_invoke_9.ets +17.experimental_features/06.callable_types/02.callable_types_with_instantiate_method/ct_inst_10.ets +17.experimental_features/08.function_method_and_constructor_overloading/01.function_overloading/fn_overloading_35.ets +17.experimental_features/08.function_method_and_constructor_overloading/03.constructor_overloading/co1_over_5.ets +17.experimental_features/08.function_method_and_constructor_overloading/03.constructor_overloading/co2_over_5.ets +20.implementation_details/03.how_to_get_type_via_reflection/how_to_get_type_via_reflection_ext_13.ets +20.implementation_details/03.how_to_get_type_via_reflection/how_to_get_type_via_reflection_ext_17.ets +20.implementation_details/03.how_to_get_type_via_reflection/how_to_get_type_via_reflection_ext_34.ets +20.implementation_details/03.how_to_get_type_via_reflection/how_to_get_type_via_reflection_ext_35.ets + +#25179 +05.generics/generic_declarations/create_array_using_generic_types/create_array_using_generic_types_ext_11.ets + +#25177 +10.interfaces/07.interface_inheritance/multi_layer_interface/type_system/type_system_15.ets + +#25187 +10.interfaces/07.interface_inheritance/multiple_interface/abstract_method_same_name/abstract_method_15.ets + #25679 17.experimental_features/02.fixed_array_types/far4a.ets 17.experimental_features/02.fixed_array_types/far4c.ets 17.experimental_features/02.fixed_array_types/far4d.ets + +#25170 +17.experimental_features/18.generics_experimental/generics_nonull_return_ext_0.ets +17.experimental_features/18.generics_experimental/generics_nonull_return_ext_1.ets +17.experimental_features/18.generics_experimental/generics_nonull_return_ext_2.ets +17.experimental_features/18.generics_experimental/generics_nonull_return_ext_3.ets +17.experimental_features/18.generics_experimental/generics_nonull_return_ext_4.ets +17.experimental_features/18.generics_experimental/generics_nonull_return_ext_5.ets + +############ +# temporary place for the tests related to primitive types refactoring +############ + +# 1. +# Resizable array is inferred for array literal in union context instead of FixedArray +07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_assn_27.ets +07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_assn_28.ets +07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_assn_29.ets +07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_call_28.ets +07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_decl_26.ets +# verifier error +07.expressions/04.array_literal/01.type_inference_from_context/arr3_inf_cast_26.ets + +# 2. +# TypeError: Type '[String, Double]' is not compatible with the enclosing method's +# return type '[Object|null|undefined, Object|null|undefined]' [x.ets:1:21] +05.generics/generic_declarations/generic_classes/test_bridge_methods_in_generic_overrides/bridge_methods_generic_5.ets + +# 4. +# TypeError: Floating-point value cannot be converted [init4_2.ets:27:19] +# it seems double literal should also be inferred via preferred type to float +17.experimental_features/17.packages/02.package_initializer/p4/init4_1.ets +17.experimental_features/17.packages/02.package_initializer/p4/init4_2.ets + +# 5. mb +# Seems should be CTE, but now: 1. the test is positive; 2. CTE exists, but it looks like a bug with strange message +10.interfaces/07.interface_inheritance/multi_layer_interface/type_system/type_system_26.ets + +# 8. +# verifier failed for enum in extended conditional expressions +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_35.ets + +# 9. +# assert (!is_array_type) on non-nullish expr +05.generics/03.utility_types/04.record_utility_type/rec_3.ets + +# 12. +# incorrect bytecode - assert in bco +07.expressions/29.assignment/01.simple_assignment_operator/ord23.ets +07.expressions/29.assignment/01.simple_assignment_operator/ord25.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_28.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_29.ets + +# 13. +# Assertion in IsLegalBoxedPrimitiveConversion +17.experimental_features/07.statements/01.for-of_type_annotation/for_of_n_5.ets + +# 16. +# Need to reimplement a check for overload-equivalent sigs in case of type params. Previous impl was buggy +15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/neg_2.ets +15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/overload_equivalent_example_2.ets +15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/overload_equivalent_example_3.ets +15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/overload_equivalent_example_4.ets +15.semantic_rules/07.overloading_and_overriding/01.overload-equivalent_signatures/overload_equivalent_example_5.ets +17.experimental_features/08.function_method_and_constructor_overloading/01.function_overloading/fn_overloading_n_6.ets + +# 17. +# Strange tests - seems need to be added to exclude due to valid absence of CTE +17.experimental_features/16.async_functions_and_methods/01.async_functions/afunc_n_10.ets +17.experimental_features/16.async_functions_and_methods/01.async_functions/afunc_n_11.ets +17.experimental_features/16.async_functions_and_methods/01.async_functions/afunc_n_9.ets +17.experimental_features/16.async_functions_and_methods/02.async_methods/ameth_n_12.ets +17.experimental_features/16.async_functions_and_methods/02.async_methods/ameth_n_13.ets +17.experimental_features/16.async_functions_and_methods/02.async_methods/ameth_n_14.ets + +# 18. +# need to rework CollectSignaturesForSyntheticType and AddSignatureToSignatureSet function from etsObjectType.cpp +# after rebase on https://gitee.com/openharmony/arkcompiler_ets_frontend/pulls/4393/files +15.semantic_rules/07.overloading_and_overriding/05.overloading_and_overriding_in_interfaces/interface_return_value_overload.ets +15.semantic_rules/07.overloading_and_overriding/05.overloading_and_overriding_in_interfaces/multiple_interfaces_inheritance_0.ets +15.semantic_rules/07.overloading_and_overriding/05.overloading_and_overriding_in_interfaces/multiple_interfaces_inheritance_2.ets +15.semantic_rules/07.overloading_and_overriding/05.overloading_and_overriding_in_interfaces/interface_return_value_overload_1.ets +09.classes/06.method_declarations/09.methods_returning_this/methods_returning_this_interface_03.ets + +# 19. +'TypeError: Type argument '' should be a subtype of 'Object[]'-constraint +05.generics/02.generic_instantiations/01.type_arguments/type_arguments_of_parameterized_declarations/interface_args_12.ets + +# 20. +'TypeError: Array initializer's type is not assignable to tuple type at index: 0 +06.contexts_and_conversions/04.casting_contexts_and_conversions/03.casting_conversions_from_object/tuple_from_object_1.ets +06.contexts_and_conversions/04.casting_contexts_and_conversions/03.casting_conversions_from_object/tuple_from_object_3.ets + +# 22. +Output: 'TypeError: Property 'fld' might not have been initialized +06.contexts_and_conversions/05.implicit_conversions/09.tuple_types_conversions/comp_obj/comp-obj_p.ets +07.expressions/17.typeof_expression/tof_obj_21.ets + +# 23. +'SyntaxError: object is a predefined type, cannot be used as an identifier +07.expressions/12.indexing_expression/01.array_indexing_expression/array_index03.ets +07.expressions/12.indexing_expression/01.array_indexing_expression/spec_ex2.ets + +# 24. +'TypeError: Cannot use type 'void' as value. +09.classes/06.method_declarations/06.overriding_methods/overriding_by_instance_methods/abstract_method_overridden_by_instance.ets + +# 25. +'TypeError: Operator '==' cannot be applied to types 'String|Color' and 'Int'. +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_18.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_19.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_20.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_21.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_22.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_23.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_24.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_25.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_26.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_27.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_34.ets +07.expressions/05.object_literal/03.object_literal_of_record_type/re_10.ets + +# 26. +'TypeError: Only abstract or native methods can't have body. +17.experimental_features/18.generics_experimental/01.non_nullish_type_parameter/ex2_1.ets + +# 29 +# TypeError: Call to `foo` is ambiguous as `2` versions of `foo` are available: +# `foo(i: Short): Int` and `foo(i: Char): Int` +04.names_declarations_and_scopes/05.accessible/type_name_const_1.ets + +# 31 +# 'TypeError: A is not abstract and does not implement getter for i property in I +05.generics/03.utility_types/01.partial_utility_type/partial_generic.ets + +# 32 +# Array initializer's type is not assignable to tuple type at index: 2 +07.expressions/04.array_literal/01.type_inference_from_context/tup_inf_cast_1.ets +07.expressions/04.array_literal/01.type_inference_from_context/tup_inf_cast_3.ets +07.expressions/04.array_literal/01.type_inference_from_context/tup_inf_decl_1.ets +07.expressions/04.array_literal/01.type_inference_from_context/tup_inf_decl_3.ets + +# 33 +# seems we don't set context with as for "e" double literals +07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2_num1_10.ets +07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2_num2_10.ets + +# 35 +# '$_invoke' is a static property of 'String' +17.experimental_features/06.callable_types/01.callable_types_with_invoke_method/ct_invoke_13.ets + +# 36 +# Seems the same error is in ohos CI +# Type '(resolve: (p: String) => void, reject: (p: Object|null) => void) => void' is not compatible with +# type '(resolve: (value: String|PromiseLike) => void, reject: (error: Error) => void) => void' at index 1 +17.experimental_features/15.coroutines/promise_class/p_0.ets +17.experimental_features/15.coroutines/promise_class/p_1.ets +17.experimental_features/15.coroutines/promise_class/p_2.ets +17.experimental_features/15.coroutines/promise_class/p_3.ets +17.experimental_features/15.coroutines/promise_class/p_4.ets +17.experimental_features/15.coroutines/promise_class/p_5.ets + +# 37 +# runtime failures: +04.names_declarations_and_scopes/05.accessible/type_name_const_2.ets +04.names_declarations_and_scopes/05.accessible/type_name_const_3.ets +04.names_declarations_and_scopes/05.accessible/type_name_const_4.ets +05.generics/generic_declarations/generic_classes/implementation_of_different_types/implement_generic_interface_20.ets +05.generics/generic_declarations/generic_classes/test_bridge_methods_in_generic_overrides/bridge_methods_generic_0.ets +05.generics/generic_declarations/generic_classes/test_bridge_methods_in_generic_overrides/bridge_methods_generic_11.ets +05.generics/generic_declarations/generic_classes/test_bridge_methods_in_generic_overrides/bridge_methods_generic_13.ets +05.generics/generic_declarations/generic_classes/test_bridge_methods_in_generic_overrides/bridge_methods_generic_4.ets +05.generics/generic_declarations/generic_in_out/generic_in_out_2.ets +05.generics/generic_declarations/generic_in_out/generic_in_out_5.ets +06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_obj/comp-obj-un_2.ets +06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/comp_obj/comp-obj-un_4.ets +06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_field/decl-field-un_2.ets +06.contexts_and_conversions/05.implicit_conversions/04.widening_union_conversions/decl_field/decl-field-un_4.ets +07.expressions/04.array_literal/01.type_inference_from_context/tup_inf_cast_6.ets +07.expressions/04.array_literal/01.type_inference_from_context/tup_inf_cast_7.ets +07.expressions/04.array_literal/01.type_inference_from_context/tup_inf_decl_6.ets +07.expressions/04.array_literal/01.type_inference_from_context/tup_inf_decl_7.ets +07.expressions/12.indexing_expression/02.record_indexing_expression/ind_14.ets +07.expressions/12.indexing_expression/02.record_indexing_expression/ind_17.ets +07.expressions/20.unary_expressions/06.unary_minus/unary_minus_corner_1.ets +07.expressions/20.unary_expressions/06.unary_minus/unary_minus_corner_2.ets +07.expressions/20.unary_expressions/06.unary_minus/unary_minus_corner_3.ets +07.expressions/20.unary_expressions/06.unary_minus/unary_minus_corner_4.ets +07.expressions/21.multiplicative_expressions/01.multiplication/inf_0.ets +07.expressions/21.multiplicative_expressions/01.multiplication/inf_1.ets +07.expressions/21.multiplicative_expressions/01.multiplication/inf_2.ets +07.expressions/21.multiplicative_expressions/01.multiplication/inf_3.ets +07.expressions/21.multiplicative_expressions/02.division/inf_0.ets +07.expressions/21.multiplicative_expressions/02.division/inf_1.ets +07.expressions/21.multiplicative_expressions/02.division/inf_10.ets +07.expressions/21.multiplicative_expressions/02.division/inf_11.ets +07.expressions/21.multiplicative_expressions/02.division/inf_2.ets +07.expressions/21.multiplicative_expressions/02.division/inf_3.ets +07.expressions/22.additive_expressions/02.additive_operators_for_numeric_types/inf_0.ets +07.expressions/22.additive_expressions/02.additive_operators_for_numeric_types/inf_1.ets +07.expressions/22.additive_expressions/02.additive_operators_for_numeric_types/inf_2.ets +07.expressions/22.additive_expressions/02.additive_operators_for_numeric_types/inf_3.ets +07.expressions/22.additive_expressions/02.additive_operators_for_numeric_types/inf_4.ets +07.expressions/22.additive_expressions/02.additive_operators_for_numeric_types/inf_5.ets +07.expressions/25.equality_expressions/01.numerical_equality_operators/float_equality_4.ets +07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/object_type_equality_operators/ne1_7.ets +07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/object_type_equality_operators/ne_11.ets +07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/object_type_equality_operators/ne_7.ets +07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/type_parameter_equality_operators/ne1_7.ets +07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/type_parameter_equality_operators/ne_11.ets +07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/type_parameter_equality_operators/ne_7.ets +07.expressions/31.string_interpolation_expressions/siexp_6.ets +07.expressions/33.constant_expression/check_array/constant_logical_expression_10.ets +07.expressions/33.constant_expression/check_array/constant_logical_expression_11.ets +07.expressions/33.constant_expression/check_enum/constant_logical_expression_11.ets +07.expressions/33.constant_expression/check_enum/constant_logical_expression_12.ets +15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/override_compatibility_array_5.ets +15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/override_compatibility_parameter_10.ets +15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/class_method_over_n3_0.ets +15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/class_method_over_n3_9.ets +15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/static_method_over_n2_0.ets +15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/static_method_over_n2_1.ets +15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/static_method_over_n2_2.ets +15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/static_method_over_n2_3.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_0.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_1.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_12.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_13.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_2.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_3.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_30.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_31.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_32.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_33.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_4.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_5.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_6.ets +15.semantic_rules/10.compatibility_features/01.extended_conditional_expressions/ops2_7.ets +17.experimental_features/04.indexable_types/ind_class_12.ets +17.experimental_features/04.indexable_types/ind_class_13.ets +17.experimental_features/04.indexable_types/ind_interface_12.ets +17.experimental_features/04.indexable_types/ind_interface_13.ets +17.experimental_features/06.callable_types/01.callable_types_with_invoke_method/ct_invoke_9.ets +17.experimental_features/06.callable_types/02.callable_types_with_instantiate_method/ct_inst_10.ets +17.experimental_features/08.function_method_and_constructor_overloading/01.function_overloading/fn_overloading_35.ets +17.experimental_features/08.function_method_and_constructor_overloading/03.constructor_overloading/co1_over_5.ets +17.experimental_features/08.function_method_and_constructor_overloading/03.constructor_overloading/co2_over_5.ets +20.implementation_details/03.how_to_get_type_via_reflection/how_to_get_type_via_reflection_ext_13.ets +20.implementation_details/03.how_to_get_type_via_reflection/how_to_get_type_via_reflection_ext_17.ets +20.implementation_details/03.how_to_get_type_via_reflection/how_to_get_type_via_reflection_ext_34.ets +20.implementation_details/03.how_to_get_type_via_reflection/how_to_get_type_via_reflection_ext_35.ets + +# 38 +# FailKind.VERIFIER_FAIL - 46 tests: +09.classes/05.field_declarations/fields_inheritance_from_superclass_and_superinterface.ets +09.classes/05.field_declarations/fields_inheritance_from_superinterface.ets +09.classes/05.field_declarations/several_inherited_field_paths_from_superinterface.ets +10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/child_interface_constants_inheritance_verification/child_interface_constants_inheritance_verification_01.ets +10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/child_interface_constants_inheritance_verification/child_interface_constants_inheritance_verification_02.ets +10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/child_interface_constants_inheritance_verification/child_interface_constants_inheritance_verification_03.ets +10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/child_interface_constants_inheritance_verification/child_interface_constants_inheritance_verification_04.ets +10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/child_interface_constants_inheritance_verification/child_interface_constants_inheritance_verification_05.ets +10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/child_interface_constants_inheritance_verification/child_interface_constants_inheritance_verification_07.ets +10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/child_interface_constants_inheritance_verification/child_interface_constants_inheritance_verification_09.ets +10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/child_interface_constants_inheritance_verification/child_interface_constants_inheritance_verification_10.ets +10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/test_class_usage_of_conflicting_constants/test_class_usage_of_conflicting_constants_02.ets +10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/test_class_usage_of_conflicting_constants/test_class_usage_of_conflicting_constants_08.ets +10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/test_class_usage_of_conflicting_constants/test_class_usage_of_conflicting_constants_09.ets +10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/test_class_usage_of_conflicting_constants/test_class_usage_of_conflicting_constants_12.ets +10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/test_class_usage_of_conflicting_constants/test_class_usage_of_conflicting_constants_13.ets +10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/test_class_usage_of_conflicting_constants/test_class_usage_of_conflicting_constants_14.ets +10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/test_class_usage_of_conflicting_constants/test_class_usage_of_conflicting_constants_16.ets +10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/test_class_usage_of_conflicting_constants/test_class_usage_of_conflicting_constants_17.ets +10.interfaces/07.interface_inheritance/boundary_situation/transfer_parent_interface/transfer_interface_01.ets +10.interfaces/07.interface_inheritance/boundary_situation/transfer_parent_interface/transfer_interface_13.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_methods_constants/multi_layer_interface_inheritance_10.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_methods_constants/multi_layer_interface_inheritance_11.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_methods_constants/multi_layer_interface_inheritance_12.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_methods_constants/multi_layer_interface_inheritance_13.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_methods_constants/multi_layer_interface_inheritance_14.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_methods_constants/multi_layer_interface_inheritance_15.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_methods_constants/multi_layer_interface_inheritance_16.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_methods_constants/multi_layer_interface_inheritance_17.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_methods_constants/multi_layer_interface_inheritance_2.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_override/multi_layer_interface_inheritance_override_17.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_override/multi_layer_interface_inheritance_override_18.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_override/multi_layer_interface_inheritance_override_19.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_override/multi_layer_interface_inheritance_override_20.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_override/multi_layer_interface_inheritance_override_21.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_override/multi_layer_interface_inheritance_override_22.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_override/multi_layer_interface_inheritance_override_23.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_override/multi_layer_interface_inheritance_override_25.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/multi_layer_interface_inheritance_override/multi_layer_interface_inheritance_override_26.ets +10.interfaces/07.interface_inheritance/multiple_interface/handle_interface_constant_conflicts/handle_interface_constant_conflicts_case_01.ets +10.interfaces/07.interface_inheritance/superinterfaces_and_subinterfaces/interface_inheritance_const/const_17.ets +10.interfaces/07.interface_inheritance/superinterfaces_and_subinterfaces/interface_inheritance_const/const_18.ets +10.interfaces/07.interface_inheritance/superinterfaces_and_subinterfaces/interface_inheritance_const/const_19.ets +10.interfaces/07.interface_inheritance/superinterfaces_and_subinterfaces/verify_constant_values_subinterface_class/constants_int_in_subclass_interface_01.ets +10.interfaces/07.interface_inheritance/superinterfaces_and_subinterfaces/verify_constant_values_subinterface_class/constants_number_in_subclass_interface_01.ets +15.semantic_rules/07.overloading_and_overriding/02.override-compatible_signatures/override_compatibility_parameter_6.ets + +# 39 +# FailKind.ABORT_FAIL - 90 tests: +02.lexical_elements/09.literals/02.integer_literals/incorrect_int_literals_16.ets +04.names_declarations_and_scopes/05.accessible/type_name_interface_prop_0.ets +04.names_declarations_and_scopes/05.accessible/type_name_interface_prop_1.ets +04.names_declarations_and_scopes/05.accessible/type_name_interface_prop_10.ets +04.names_declarations_and_scopes/05.accessible/type_name_interface_prop_11.ets +04.names_declarations_and_scopes/05.accessible/type_name_interface_prop_12.ets +04.names_declarations_and_scopes/05.accessible/type_name_interface_prop_13.ets +04.names_declarations_and_scopes/05.accessible/type_name_interface_prop_14.ets +04.names_declarations_and_scopes/05.accessible/type_name_interface_prop_15.ets +04.names_declarations_and_scopes/05.accessible/type_name_interface_prop_16.ets +04.names_declarations_and_scopes/05.accessible/type_name_interface_prop_19.ets +04.names_declarations_and_scopes/05.accessible/type_name_interface_prop_2.ets +04.names_declarations_and_scopes/05.accessible/type_name_interface_prop_3.ets +04.names_declarations_and_scopes/05.accessible/type_name_interface_prop_4.ets +04.names_declarations_and_scopes/05.accessible/type_name_interface_prop_5.ets +04.names_declarations_and_scopes/05.accessible/type_name_interface_prop_6.ets +04.names_declarations_and_scopes/05.accessible/type_name_interface_prop_7.ets +04.names_declarations_and_scopes/05.accessible/type_name_interface_prop_8.ets +04.names_declarations_and_scopes/05.accessible/type_name_interface_prop_9.ets +04.names_declarations_and_scopes/07.variable_and_constant_declarations/03.assignability_with_initializer/initializer_compatibility_n_13.ets +04.names_declarations_and_scopes/08.function_declarations/03.readonly_parameters/readonly_custom_neg_32.ets +05.generics/03.utility_types/01.partial_utility_type/method_excluded_from_partial_3.ets +05.generics/03.utility_types/01.partial_utility_type/method_excluded_from_partial_4.ets +05.generics/03.utility_types/02.required_utility_type/method_excluded_from_required_3.ets +05.generics/03.utility_types/02.required_utility_type/method_excluded_from_required_4.ets +05.generics/03.utility_types/03.readonly_utility_type/readonly_type_compatibility.ets +07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2_num1_30.ets +07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2_num1_32.ets +07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2_num2_30.ets +07.expressions/04.array_literal/02.type_inference_from_types_of_elements/arr_inf2_num2_32.ets +07.expressions/17.typeof_expression/tof_obj_1.ets +07.expressions/20.unary_expressions/07.bitwise_complement/bitwise_complement_neg.ets +07.expressions/24.relational_expressions/05.enumeration_relational_operators/enum2_3.ets +07.expressions/24.relational_expressions/05.enumeration_relational_operators/enum2_4.ets +07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/object_type_equality_operators/ne1_0.ets +07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/object_type_equality_operators/ne1_2.ets +07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/object_type_equality_operators/ne_0.ets +07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/object_type_equality_operators/ne_1.ets +07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/object_type_equality_operators/ne_2.ets +07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/type_parameter_equality_operators/ne1_2.ets +07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/type_parameter_equality_operators/ne3_20.ets +07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/type_parameter_equality_operators/ne_0.ets +07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/type_parameter_equality_operators/ne_1.ets +07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/type_parameter_equality_operators/ne_2.ets +07.expressions/25.equality_expressions/06.reference_equality_based_on_actual_type/union_equality_operators/ne_20.ets +07.expressions/30.conditional_expressions/first_expression_not_boolean.ets +09.classes/05.field_declarations/superinterface_field_declaration.ets +10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/child_interface_constants_inheritance_verification/child_interface_constants_inheritance_verification_24.ets +10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/child_interface_constants_inheritance_verification/child_interface_constants_inheritance_verification_32.ets +10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/test_class_usage_of_conflicting_constants/test_class_usage_of_conflicting_constants_06.ets +10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/test_class_usage_of_conflicting_constants/test_class_usage_of_conflicting_constants_10.ets +10.interfaces/07.interface_inheritance/Interface_inheritance_class_implementation/test_class_usage_of_conflicting_constants/test_class_usage_of_conflicting_constants_11.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/complex_inheritance/complex_inheritance_0.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/complex_inheritance/complex_inheritance_1.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/complex_inheritance/complex_inheritance_2.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/complex_inheritance/complex_inheritance_3.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/complex_inheritance/complex_inheritance_30.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/complex_inheritance/complex_inheritance_4.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/complex_inheritance/complex_inheritance_5.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/complex_inheritance/complex_inheritance_6.ets +10.interfaces/07.interface_inheritance/multi_layer_interface/type_system/type_system_17.ets +10.interfaces/07.interface_inheritance/superinterfaces_and_subinterfaces/interface_inheritance_const/const_11.ets +10.interfaces/07.interface_inheritance/superinterfaces_and_subinterfaces/interface_inheritance_const/const_13.ets +10.interfaces/07.interface_inheritance/superinterfaces_and_subinterfaces/interface_inheritance_const/const_14.ets +10.interfaces/07.interface_inheritance/superinterfaces_and_subinterfaces/verify_constant_values_subinterface_class/constants_boolean_in_subclass_interface_01.ets +11.enumerations/01.enumeration_integer_values/enum_int_11.ets +15.semantic_rules/07.overloading_and_overriding/04.overloading_and_overriding_in_classes/two_class_method_over_n_17.ets + +# 40 +# FailKind.ES2PANDA_NEG_FAIL - 24 tests: +03.types/18.function_types/01.type_function/negative_1.ets +03.types/19.union_types/union_type_narrowing_attribute_n.ets +05.generics/03.utility_types/02.required_utility_type/method_excluded_from_required_0.ets +05.generics/03.utility_types/02.required_utility_type/required_getter_and_setter_neg_1.ets +05.generics/03.utility_types/02.required_utility_type/required_getter_and_setter_neg_2.ets +06.contexts_and_conversions/01.assignment-like_contexts/widening_refs_unbox_2.ets +06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var-n_6.ets +06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/assn_var/assn-var-n_7.ets +06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/call_cons/call-cons-n3_7.ets +06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/call_func/call-func-n3_7.ets +06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/call_lmbd/call-lmbd-n3_7.ets +06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/call_meth/call-meth-n3_7.ets +06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr-n_6.ets +06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_arr/comp-arr-n_7.ets +06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-clss-n_6.ets +06.contexts_and_conversions/05.implicit_conversions/03.constant_narrowing_integer_conversion/comp_obj/comp-clss-n_7.ets + +# #25111 +17.experimental_features/02.fixed_array_types/far3_0.ets +17.experimental_features/02.fixed_array_types/far3_1.ets +17.experimental_features/02.fixed_array_types/far3_2.ets +17.experimental_features/02.fixed_array_types/far3_3.ets +17.experimental_features/02.fixed_array_types/far3_4.ets +17.experimental_features/02.fixed_array_types/far3_7.ets diff --git a/static_core/plugins/ets/tests/test-lists/ets-es-checked/ets-es-checked-ignored.txt b/static_core/plugins/ets/tests/test-lists/ets-es-checked/ets-es-checked-ignored.txt index 62f8af79384e907bc882818fbc94ff316dc7ec63..fa2296b002041d739c5b7c858f4092856589b19e 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-es-checked/ets-es-checked-ignored.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-es-checked/ets-es-checked-ignored.txt @@ -19,3 +19,8 @@ uint32array_newUint32Array_newArrayBuffer_2_Uint32Array_BYTES_PER_ELEMENT__9_0_p uint8array_newUint8Array_newArrayBuffer_2_Uint8Array_BYTES_PER_ELEMENT___1_0_pars_0.ets #25165 uint8array_newUint8Array_newArrayBuffer_2_Uint8Array_BYTES_PER_ELEMENT__1_0_pars_0.ets +#24986 +set_entries0.ets +array_entries0.ets +array_sort0.ets +array_Array_from_Number___1asNumber_2asNumber_3asNumber__0.ets diff --git a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-excluded-DI.txt b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-excluded-DI.txt index 4b8812c4b136e843a9c11aa7b398e826cf673d6b..d95a6673b92b51a30decb40c72cb72bdb4584f4a 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-excluded-DI.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-excluded-DI.txt @@ -82,3 +82,26 @@ spec/09.classes/constructor-inheritance/issue14720_0.ets spec/09.classes/constructor-inheritance/issue14720_1.ets spec/09.classes/constructor-inheritance/issue14720_3.ets spec/11.Enumerations/issue14636_1.ets + + +#24986 (17 tests) +std/core/Object.ets +std/core/TypedArrayConstructorNumbersInts.ets +std/math/std_math_sign_double.ets +std/core/IntlPluralRulesTest.ets +std/core/TypeAssignableFromTest.ets +std/core/std_core_char_instance_Char_toLowerCase.ets +std/core/std_core_type_numeric_type_numeric_type.ets +escompat/JsonTest.ets +regression/15867_spread_in_arrayof_segfaut.ets +spec/05.Generics/callFromAsyncLambda.ets +spec/09.classes/Accessor_Declarations/issue-15142_9.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0020.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0030.ets +std/containers/concurrent_set/ConcurrentSet_ConstructorTest.ets +std/containers/linked_blocking_queue/LinkedBlockingQueue_ConstructorTest.ets +spec/03.types/References_Types/Tuples_type/tuple_write_3.ets +std/core/NumberTest.ets +escompat/JsonStringifyTest.ets + + \ No newline at end of file diff --git a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-excluded-JIT-REPEATS.txt b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-excluded-JIT-REPEATS.txt index a884e3b8b1262b1e690af892b3d0e013406ef667..70abe786371754ef2e302742f4ce08a9f1129fde 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-excluded-JIT-REPEATS.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-excluded-JIT-REPEATS.txt @@ -111,3 +111,23 @@ std/containers/BlockingQueue/LinkedBlockingQueue_getEnd.ets std/core/ConsoleInfoTest.ets std/core/ConsoleGroupTest.ets # End issue 25934 + +#24986 (17 tests) +std/core/Object.ets +std/core/TypedArrayConstructorNumbersInts.ets +std/math/std_math_sign_double.ets +std/core/IntlPluralRulesTest.ets +std/core/TypeAssignableFromTest.ets +std/core/std_core_char_instance_Char_toLowerCase.ets +std/core/std_core_type_numeric_type_numeric_type.ets +escompat/JsonTest.ets +regression/15867_spread_in_arrayof_segfaut.ets +spec/05.Generics/callFromAsyncLambda.ets +spec/09.classes/Accessor_Declarations/issue-15142_9.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0020.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0030.ets +std/containers/concurrent_set/ConcurrentSet_ConstructorTest.ets +std/containers/linked_blocking_queue/LinkedBlockingQueue_ConstructorTest.ets +spec/03.types/References_Types/Tuples_type/tuple_write_3.ets +std/core/NumberTest.ets +escompat/JsonStringifyTest.ets diff --git a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-excluded-TSAN.txt b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-excluded-TSAN.txt index f72e268106397e6499d04c218309bc348ae573d9..e203e1e4d1f5f86aeea44a4fdfc831dc45bb4fe3 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-excluded-TSAN.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-excluded-TSAN.txt @@ -56,3 +56,24 @@ spec/03.types/References_Types/Bigint/bigint-arithmetic-sub-equal-zero.ets spec/03.types/References_Types/Bigint/bigint-arithmetic-underscore-literals.ets spec/03.types/References_Types/Bigint/bigint-bitwise-xor-3.ets # End issue 14881 + +#24986 (17 tests) +std/core/Object.ets +std/core/TypedArrayConstructorNumbersInts.ets +std/math/std_math_sign_double.ets +std/core/IntlPluralRulesTest.ets +std/core/TypeAssignableFromTest.ets +std/core/std_core_char_instance_Char_toLowerCase.ets +std/core/std_core_type_numeric_type_numeric_type.ets +escompat/JsonTest.ets +regression/15867_spread_in_arrayof_segfaut.ets +spec/05.Generics/callFromAsyncLambda.ets +spec/09.classes/Accessor_Declarations/issue-15142_9.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0020.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0030.ets +std/containers/concurrent_set/ConcurrentSet_ConstructorTest.ets +std/containers/linked_blocking_queue/LinkedBlockingQueue_ConstructorTest.ets +spec/03.types/References_Types/Tuples_type/tuple_write_3.ets +std/core/NumberTest.ets +escompat/JsonStringifyTest.ets + diff --git a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-excluded.txt b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-excluded.txt index 2961de87d731baa82a0ba9a25189cb0cc5014466..6941d29297f430ee85ccdf28ab5fcfc873d02ef0 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-excluded.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-excluded.txt @@ -4,3 +4,24 @@ spec/nullables/nullable-lambda-default-param_3.ets spec/nullables/nullable-lambda-default-param_4.ets spec/nullables/nullable-lambda-default-param_5.ets spec/nullables/nullable-lambda-default-param_6.ets + +#24986 (17 tests) +std/core/Object.ets +std/core/TypedArrayConstructorNumbersInts.ets +std/math/std_math_sign_double.ets +std/core/IntlPluralRulesTest.ets +std/core/TypeAssignableFromTest.ets +std/core/std_core_char_instance_Char_toLowerCase.ets +std/core/std_core_type_numeric_type_numeric_type.ets +escompat/JsonTest.ets +regression/15867_spread_in_arrayof_segfaut.ets +spec/05.Generics/callFromAsyncLambda.ets +spec/09.classes/Accessor_Declarations/issue-15142_9.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0020.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0030.ets +std/containers/concurrent_set/ConcurrentSet_ConstructorTest.ets +std/containers/linked_blocking_queue/LinkedBlockingQueue_ConstructorTest.ets +spec/03.types/References_Types/Tuples_type/tuple_write_3.ets +std/core/NumberTest.ets +escompat/JsonStringifyTest.ets + diff --git a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-AMD64-CPP-OL2-FULLASTV.txt b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-AMD64-CPP-OL2-FULLASTV.txt index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e71b23e20471947fa0230c11ae9d9236f8f75ed4 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-AMD64-CPP-OL2-FULLASTV.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-AMD64-CPP-OL2-FULLASTV.txt @@ -0,0 +1,20 @@ +#24986 (17 tests) +std/core/Object.ets +std/core/TypedArrayConstructorNumbersInts.ets +std/math/std_math_sign_double.ets +std/core/IntlPluralRulesTest.ets +std/core/TypeAssignableFromTest.ets +std/core/std_core_char_instance_Char_toLowerCase.ets +std/core/std_core_type_numeric_type_numeric_type.ets +escompat/JsonTest.ets +regression/15867_spread_in_arrayof_segfaut.ets +spec/05.Generics/callFromAsyncLambda.ets +spec/09.classes/Accessor_Declarations/issue-15142_9.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0020.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0030.ets +std/containers/concurrent_set/ConcurrentSet_ConstructorTest.ets +std/containers/linked_blocking_queue/LinkedBlockingQueue_ConstructorTest.ets +spec/03.types/References_Types/Tuples_type/tuple_write_3.ets +std/core/NumberTest.ets +escompat/JsonStringifyTest.ets + diff --git a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-AMD64-INT-OL2.txt b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-AMD64-INT-OL2.txt index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e71b23e20471947fa0230c11ae9d9236f8f75ed4 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-AMD64-INT-OL2.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-AMD64-INT-OL2.txt @@ -0,0 +1,20 @@ +#24986 (17 tests) +std/core/Object.ets +std/core/TypedArrayConstructorNumbersInts.ets +std/math/std_math_sign_double.ets +std/core/IntlPluralRulesTest.ets +std/core/TypeAssignableFromTest.ets +std/core/std_core_char_instance_Char_toLowerCase.ets +std/core/std_core_type_numeric_type_numeric_type.ets +escompat/JsonTest.ets +regression/15867_spread_in_arrayof_segfaut.ets +spec/05.Generics/callFromAsyncLambda.ets +spec/09.classes/Accessor_Declarations/issue-15142_9.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0020.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0030.ets +std/containers/concurrent_set/ConcurrentSet_ConstructorTest.ets +std/containers/linked_blocking_queue/LinkedBlockingQueue_ConstructorTest.ets +spec/03.types/References_Types/Tuples_type/tuple_write_3.ets +std/core/NumberTest.ets +escompat/JsonStringifyTest.ets + diff --git a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-AMD64-JIT-OL2.txt b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-AMD64-JIT-OL2.txt index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e71b23e20471947fa0230c11ae9d9236f8f75ed4 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-AMD64-JIT-OL2.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-AMD64-JIT-OL2.txt @@ -0,0 +1,20 @@ +#24986 (17 tests) +std/core/Object.ets +std/core/TypedArrayConstructorNumbersInts.ets +std/math/std_math_sign_double.ets +std/core/IntlPluralRulesTest.ets +std/core/TypeAssignableFromTest.ets +std/core/std_core_char_instance_Char_toLowerCase.ets +std/core/std_core_type_numeric_type_numeric_type.ets +escompat/JsonTest.ets +regression/15867_spread_in_arrayof_segfaut.ets +spec/05.Generics/callFromAsyncLambda.ets +spec/09.classes/Accessor_Declarations/issue-15142_9.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0020.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0030.ets +std/containers/concurrent_set/ConcurrentSet_ConstructorTest.ets +std/containers/linked_blocking_queue/LinkedBlockingQueue_ConstructorTest.ets +spec/03.types/References_Types/Tuples_type/tuple_write_3.ets +std/core/NumberTest.ets +escompat/JsonStringifyTest.ets + diff --git a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-AMD64-JIT.txt b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-AMD64-JIT.txt index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e71b23e20471947fa0230c11ae9d9236f8f75ed4 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-AMD64-JIT.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-AMD64-JIT.txt @@ -0,0 +1,20 @@ +#24986 (17 tests) +std/core/Object.ets +std/core/TypedArrayConstructorNumbersInts.ets +std/math/std_math_sign_double.ets +std/core/IntlPluralRulesTest.ets +std/core/TypeAssignableFromTest.ets +std/core/std_core_char_instance_Char_toLowerCase.ets +std/core/std_core_type_numeric_type_numeric_type.ets +escompat/JsonTest.ets +regression/15867_spread_in_arrayof_segfaut.ets +spec/05.Generics/callFromAsyncLambda.ets +spec/09.classes/Accessor_Declarations/issue-15142_9.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0020.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0030.ets +std/containers/concurrent_set/ConcurrentSet_ConstructorTest.ets +std/containers/linked_blocking_queue/LinkedBlockingQueue_ConstructorTest.ets +spec/03.types/References_Types/Tuples_type/tuple_write_3.ets +std/core/NumberTest.ets +escompat/JsonStringifyTest.ets + diff --git a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-AOT.txt b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-AOT.txt index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..c0223e03b2d05fecd8d227b658350921d1f14dc8 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-AOT.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-AOT.txt @@ -0,0 +1,19 @@ +#24986 (17 tests) +std/core/Object.ets +std/core/TypedArrayConstructorNumbersInts.ets +std/math/std_math_sign_double.ets +std/core/IntlPluralRulesTest.ets +std/core/TypeAssignableFromTest.ets +std/core/std_core_char_instance_Char_toLowerCase.ets +std/core/std_core_type_numeric_type_numeric_type.ets +escompat/JsonTest.ets +regression/15867_spread_in_arrayof_segfaut.ets +spec/05.Generics/callFromAsyncLambda.ets +spec/09.classes/Accessor_Declarations/issue-15142_9.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0020.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0030.ets +std/containers/concurrent_set/ConcurrentSet_ConstructorTest.ets +std/containers/linked_blocking_queue/LinkedBlockingQueue_ConstructorTest.ets +spec/03.types/References_Types/Tuples_type/tuple_write_3.ets +std/core/NumberTest.ets +escompat/JsonStringifyTest.ets diff --git a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-ARM64-INT-ASAN.txt b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-ARM64-INT-ASAN.txt index d809f2d8fd9bb4e11aa255f9e205f9495ece253f..678605ec5735f54acdbb4aec4f021eeb77f91729 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-ARM64-INT-ASAN.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-ARM64-INT-ASAN.txt @@ -2,4 +2,25 @@ std/core/std_core_stringbuilder_static_StringBuilder_toString.ets std/core/std_core_stringbuilder_instance_StringBuilder_append.ets std/core/std_core_array_exception_copyTo_ArrayIndexOutOfBoundsError_char_array_char_array_int_int_int.ets std/core/std_core_array_exception_copyTo_ArrayIndexOutOfBoundsError_float_array_float_array_int_int_int.ets -std/core/std_core_array_exception_copyTo_ArrayIndexOutOfBoundsError_double_array_double_array_int_int_int.ets \ No newline at end of file +std/core/std_core_array_exception_copyTo_ArrayIndexOutOfBoundsError_double_array_double_array_int_int_int.ets + +#24986 (17 tests) +std/core/Object.ets +std/core/TypedArrayConstructorNumbersInts.ets +std/math/std_math_sign_double.ets +std/core/IntlPluralRulesTest.ets +std/core/TypeAssignableFromTest.ets +std/core/std_core_char_instance_Char_toLowerCase.ets +std/core/std_core_type_numeric_type_numeric_type.ets +escompat/JsonTest.ets +regression/15867_spread_in_arrayof_segfaut.ets +spec/05.Generics/callFromAsyncLambda.ets +spec/09.classes/Accessor_Declarations/issue-15142_9.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0020.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0030.ets +std/containers/concurrent_set/ConcurrentSet_ConstructorTest.ets +std/containers/linked_blocking_queue/LinkedBlockingQueue_ConstructorTest.ets +spec/03.types/References_Types/Tuples_type/tuple_write_3.ets +std/core/NumberTest.ets +escompat/JsonStringifyTest.ets + diff --git a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-ARM64-JIT-ASAN.txt b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-ARM64-JIT-ASAN.txt index d77b4290bf733e7e7317126daf07ad8adc5d4609..02dc237f07a7381cbe6b3898714fe8189cc1f0ef 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-ARM64-JIT-ASAN.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-ARM64-JIT-ASAN.txt @@ -1,2 +1,23 @@ std/core/std_core_stringbuilder_static_StringBuilder_toString_011.ets -std/core/std_core_array_exception_copyTo_ArrayIndexOutOfBoundsError_float_array_float_array_int_int_int.ets \ No newline at end of file +std/core/std_core_array_exception_copyTo_ArrayIndexOutOfBoundsError_float_array_float_array_int_int_int.ets + +#24986 (17 tests) +std/core/Object.ets +std/core/TypedArrayConstructorNumbersInts.ets +std/math/std_math_sign_double.ets +std/core/IntlPluralRulesTest.ets +std/core/TypeAssignableFromTest.ets +std/core/std_core_char_instance_Char_toLowerCase.ets +std/core/std_core_type_numeric_type_numeric_type.ets +escompat/JsonTest.ets +regression/15867_spread_in_arrayof_segfaut.ets +spec/05.Generics/callFromAsyncLambda.ets +spec/09.classes/Accessor_Declarations/issue-15142_9.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0020.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0030.ets +std/containers/concurrent_set/ConcurrentSet_ConstructorTest.ets +std/containers/linked_blocking_queue/LinkedBlockingQueue_ConstructorTest.ets +spec/03.types/References_Types/Tuples_type/tuple_write_3.ets +std/core/NumberTest.ets +escompat/JsonStringifyTest.ets + diff --git a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-ARM64-JIT-REPEATS.txt b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-ARM64-JIT-REPEATS.txt index 698cbccbc77e97c821f90196474ddaa62f87035c..e50785362041436b3ca1efb0209a7239256b7c5d 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-ARM64-JIT-REPEATS.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-ARM64-JIT-REPEATS.txt @@ -3,3 +3,23 @@ escompat/JsonReplacerTest.ets #24951 std/core/SortNotFromBeginningTest.ets + +#24986 (17 tests) +std/core/Object.ets +std/core/TypedArrayConstructorNumbersInts.ets +std/math/std_math_sign_double.ets +std/core/IntlPluralRulesTest.ets +std/core/TypeAssignableFromTest.ets +std/core/std_core_char_instance_Char_toLowerCase.ets +std/core/std_core_type_numeric_type_numeric_type.ets +escompat/JsonTest.ets +regression/15867_spread_in_arrayof_segfaut.ets +spec/05.Generics/callFromAsyncLambda.ets +spec/09.classes/Accessor_Declarations/issue-15142_9.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0020.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0030.ets +std/containers/concurrent_set/ConcurrentSet_ConstructorTest.ets +std/containers/linked_blocking_queue/LinkedBlockingQueue_ConstructorTest.ets +spec/03.types/References_Types/Tuples_type/tuple_write_3.ets +std/core/NumberTest.ets +escompat/JsonStringifyTest.ets diff --git a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-ARM64-JIT.txt b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-ARM64-JIT.txt index 3813aaa68a2ffba5108ad34ab73fb16e950a3fcc..533d41038fe6df9c1901107259a72e9005dec3f9 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-ARM64-JIT.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-ARM64-JIT.txt @@ -1,2 +1,23 @@ #23132 std/core/SortInternalTestLong.ets + +#24986 (17 tests) +std/core/Object.ets +std/core/TypedArrayConstructorNumbersInts.ets +std/math/std_math_sign_double.ets +std/core/IntlPluralRulesTest.ets +std/core/TypeAssignableFromTest.ets +std/core/std_core_char_instance_Char_toLowerCase.ets +std/core/std_core_type_numeric_type_numeric_type.ets +escompat/JsonTest.ets +regression/15867_spread_in_arrayof_segfaut.ets +spec/05.Generics/callFromAsyncLambda.ets +spec/09.classes/Accessor_Declarations/issue-15142_9.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0020.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0030.ets +std/containers/concurrent_set/ConcurrentSet_ConstructorTest.ets +std/containers/linked_blocking_queue/LinkedBlockingQueue_ConstructorTest.ets +spec/03.types/References_Types/Tuples_type/tuple_write_3.ets +std/core/NumberTest.ets +escompat/JsonStringifyTest.ets + diff --git a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-ASAN.txt b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-ASAN.txt index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e71b23e20471947fa0230c11ae9d9236f8f75ed4 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-ASAN.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-ASAN.txt @@ -0,0 +1,20 @@ +#24986 (17 tests) +std/core/Object.ets +std/core/TypedArrayConstructorNumbersInts.ets +std/math/std_math_sign_double.ets +std/core/IntlPluralRulesTest.ets +std/core/TypeAssignableFromTest.ets +std/core/std_core_char_instance_Char_toLowerCase.ets +std/core/std_core_type_numeric_type_numeric_type.ets +escompat/JsonTest.ets +regression/15867_spread_in_arrayof_segfaut.ets +spec/05.Generics/callFromAsyncLambda.ets +spec/09.classes/Accessor_Declarations/issue-15142_9.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0020.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0030.ets +std/containers/concurrent_set/ConcurrentSet_ConstructorTest.ets +std/containers/linked_blocking_queue/LinkedBlockingQueue_ConstructorTest.ets +spec/03.types/References_Types/Tuples_type/tuple_write_3.ets +std/core/NumberTest.ets +escompat/JsonStringifyTest.ets + diff --git a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-CPP-OL0.txt b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-CPP-OL0.txt index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e71b23e20471947fa0230c11ae9d9236f8f75ed4 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-CPP-OL0.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-CPP-OL0.txt @@ -0,0 +1,20 @@ +#24986 (17 tests) +std/core/Object.ets +std/core/TypedArrayConstructorNumbersInts.ets +std/math/std_math_sign_double.ets +std/core/IntlPluralRulesTest.ets +std/core/TypeAssignableFromTest.ets +std/core/std_core_char_instance_Char_toLowerCase.ets +std/core/std_core_type_numeric_type_numeric_type.ets +escompat/JsonTest.ets +regression/15867_spread_in_arrayof_segfaut.ets +spec/05.Generics/callFromAsyncLambda.ets +spec/09.classes/Accessor_Declarations/issue-15142_9.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0020.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0030.ets +std/containers/concurrent_set/ConcurrentSet_ConstructorTest.ets +std/containers/linked_blocking_queue/LinkedBlockingQueue_ConstructorTest.ets +spec/03.types/References_Types/Tuples_type/tuple_write_3.ets +std/core/NumberTest.ets +escompat/JsonStringifyTest.ets + diff --git a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-JIT-REPEATS.txt b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-JIT-REPEATS.txt index 27bd286df9b60eb87acc55da6c865c684b9bf35c..264aade1fb01b864548198d3c0737cd3a518fccd 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-JIT-REPEATS.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-JIT-REPEATS.txt @@ -11,3 +11,23 @@ std/concurrency/AsyncLockTest.ets #24088 std/containers/linked_blocking_queue/LinkedBlockingQueue_AddTest.ets + +#24986 (17 tests) +std/core/Object.ets +std/core/TypedArrayConstructorNumbersInts.ets +std/math/std_math_sign_double.ets +std/core/IntlPluralRulesTest.ets +std/core/TypeAssignableFromTest.ets +std/core/std_core_char_instance_Char_toLowerCase.ets +std/core/std_core_type_numeric_type_numeric_type.ets +escompat/JsonTest.ets +regression/15867_spread_in_arrayof_segfaut.ets +spec/05.Generics/callFromAsyncLambda.ets +spec/09.classes/Accessor_Declarations/issue-15142_9.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0020.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0030.ets +std/containers/concurrent_set/ConcurrentSet_ConstructorTest.ets +std/containers/linked_blocking_queue/LinkedBlockingQueue_ConstructorTest.ets +spec/03.types/References_Types/Tuples_type/tuple_write_3.ets +std/core/NumberTest.ets +escompat/JsonStringifyTest.ets diff --git a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-TSAN.txt b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-TSAN.txt index 9afc5da259fb83514efe54779f7ee9d320a5ade8..358b9f6843995f0f6e09225ce8d1fcafb1369aac 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-TSAN.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored-TSAN.txt @@ -1,3 +1,24 @@ ### Undefined type spec/undefined-type/undefined-union-array-type_2.ets ### End of Undefined type + +#24986 (17 tests) +std/core/Object.ets +std/core/TypedArrayConstructorNumbersInts.ets +std/math/std_math_sign_double.ets +std/core/IntlPluralRulesTest.ets +std/core/TypeAssignableFromTest.ets +std/core/std_core_char_instance_Char_toLowerCase.ets +std/core/std_core_type_numeric_type_numeric_type.ets +escompat/JsonTest.ets +regression/15867_spread_in_arrayof_segfaut.ets +spec/05.Generics/callFromAsyncLambda.ets +spec/09.classes/Accessor_Declarations/issue-15142_9.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0020.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0030.ets +std/containers/concurrent_set/ConcurrentSet_ConstructorTest.ets +std/containers/linked_blocking_queue/LinkedBlockingQueue_ConstructorTest.ets +spec/03.types/References_Types/Tuples_type/tuple_write_3.ets +std/core/NumberTest.ets +escompat/JsonStringifyTest.ets + diff --git a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored.txt b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored.txt index 4c06c3bc061859bf2457f3a82fce535b25eb4ee3..f6aeb72324899cb07058efc0c8490e7bfa2271d9 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-ignored.txt @@ -401,3 +401,178 @@ std/math/std_math_clz64_long.ets #18766 spec/partial_type/partialType_main.ets + +#25752 +float32array_newFloat32Array_newArrayBuffer_2_Float32Array_BYTES_PER_ELEMENT___1_0_pars_0.ets +#25740 +uint32array_newUint32Array_newArrayBuffer_2_Uint32Array_BYTES_PER_ELEMENT__1_0_pars_0.ets +#25741 +uint32array_newUint32Array_newArrayBuffer_2_Uint32Array_BYTES_PER_ELEMENT__9_0_pars_0.ets + +#21382 - fixed array -> T[] casts +escompat/ArrayGet.ets +escompat/ArrayTest1.ets +escompat/ArrayTest2.ets +escompat/ArrayTest3.ets +escompat/ArrayTest4.ets +escompat/ArrayTest5.ets +escompat/ArrayTest6.ets +escompat/ArrayTestFrom.ets +escompat/ArrayProxyTest.ets +escompat/ArraySetTest.ets +std/containers/array_blocking_queue/ArrayBlockingQueue_ConstructorTest.ets +std/core/std_core_typedarrays_function2_Int8Array.ets + +#21382 - instance method on primitive +std/core/std_core_char_instance_Char_toUpperCase.ets + +#24986 (17 tests) +std/core/Object.ets +std/core/TypedArrayConstructorNumbersInts.ets +std/math/std_math_sign_double.ets +std/core/IntlPluralRulesTest.ets +std/core/TypeAssignableFromTest.ets +std/core/std_core_char_instance_Char_toLowerCase.ets +std/core/std_core_type_numeric_type_numeric_type.ets +escompat/JsonTest.ets +regression/15867_spread_in_arrayof_segfaut.ets +spec/05.Generics/callFromAsyncLambda.ets +spec/09.classes/Accessor_Declarations/issue-15142_9.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0020.ets +spec/17.Experimental_Features/17.3.Indexable_Types/idx-s02-0030.ets +std/containers/concurrent_set/ConcurrentSet_ConstructorTest.ets +std/containers/linked_blocking_queue/LinkedBlockingQueue_ConstructorTest.ets +spec/03.types/References_Types/Tuples_type/tuple_write_3.ets +std/core/NumberTest.ets +escompat/JsonStringifyTest.ets + +############ +# temporary place for the tests related to primitive types refactoring +############ + +# 1. +# TypeError: Reference to splice is ambiguous +escompat/escompat_Array_modifications_Test_escompat_Array_modifications.ets +escompat/escompat_Array_modifications_Test_escompat_Array_modifications_001.ets +escompat/escompat_Array_modifications_Test_escompat_Array_modifications_002.ets +escompat/escompat_Array_modifications_Test_escompat_Array_modifications_003.ets + +# 2. +# TypeError: Property 'toBigInt' does not exist on type 'BigInt' +spec/03.types/References_Types/Bigint/bigint-arithmetic-comparison-11.ets +spec/03.types/References_Types/Bigint/bigint-arithmetic-comparison-12.ets +spec/03.types/References_Types/Bigint/bigint-arithmetic-comparison-13.ets +spec/03.types/References_Types/Bigint/bigint-arithmetic-comparison-18.ets +spec/03.types/References_Types/Bigint/bigint-arithmetic-comparison-19.ets +spec/03.types/References_Types/Bigint/bigint-arithmetic-dec-1.ets +spec/03.types/References_Types/Bigint/bigint-arithmetic-dec-2.ets +spec/03.types/References_Types/Bigint/bigint-arithmetic-dec.ets +spec/03.types/References_Types/Bigint/bigint-arithmetic-expr-4-operands-4-1.ets +spec/03.types/References_Types/Bigint/bigint-arithmetic-expr-4-operands-4.ets +spec/03.types/References_Types/Bigint/bigint-arithmetic-expr-4-operands-5-1.ets +spec/03.types/References_Types/Bigint/bigint-arithmetic-expr-4-operands-5.ets +spec/03.types/References_Types/Bigint/bigint-arithmetic-inc-1.ets +spec/03.types/References_Types/Bigint/bigint-arithmetic-inc-2.ets +spec/03.types/References_Types/Bigint/bigint-arithmetic-inc.ets + +# 3. +# TypeError: Value is possibly nullish +std/containers/concurrent_hash_map/ConcurrentHashMap_ForEachTest.ets +std/containers/concurrent_hash_map/ConcurrentHashMap_PressureTest_Remove.ets +std/core/TypeCreateErasedBodyTest.ets +std/core/TypeMethodInvoke.ets +std/core/std_core_string_String_repeat_int.ets +std/core/std_core_string_String_repeat_number.ets +escompat/escompat_BigInt_instance_BigInt_toString_011.ets +std/core/std_core_string_String_codePointCount_number_number.ets + +# 4. +# TypeError: Reference to lastIndexOf is ambiguous +std/core/std_core_typedarrays__Float32Array.ets +std/core/std_core_typedarrays__Float64Array.ets +std/core/std_core_typedarrays__Float64Array_001.ets +std/core/std_core_typedarrays__Int16Array.ets +std/core/std_core_typedarrays__Int32Array.ets +std/core/std_core_typedarrays__Int8Array.ets +std/core/std_core_typedarrays_methods__Float32Array.ets +std/core/std_core_typedarrays_methods__Float64Array.ets +std/core/std_core_typedarrays_methods__Float64Array_001.ets +std/core/std_core_typedarrays_methods__Int16Array.ets +std/core/std_core_typedarrays_methods__Int32Array.ets +std/core/std_core_typedarrays_methods__Int8Array.ets +std/core/std_core_typeduarrays__Uint16Array.ets +std/core/std_core_typeduarrays__Uint32Array.ets +std/core/std_core_typeduarrays__Uint8Array.ets +std/core/std_core_typeduarrays_methods__Uint16Array.ets +std/core/std_core_typeduarrays_methods__Uint32Array.ets +std/core/std_core_typeduarrays_methods__Uint8Array.ets +std/core/std_core_typeduarrays_methods__Uint8ClampedArray.ets + +# 5. +# TypeError: Unresolved reference compareWrapperObjectValue +# TypeError: This expression is not callable +std/core/std_core_constructor_Float_constructor.ets +std/core/std_core_double_static_Double_valueOf.ets +std/core/std_core_boolean_instance_Boolean_and.ets +std/core/std_core_boolean_instance_Boolean_negate.ets +std/core/std_core_boolean_instance_Boolean_or.ets +std/core/std_core_boolean_instance_Boolean_xor.ets +std/core/std_core_boolean_static_Boolean_valueOf.ets +std/core/std_core_byte_instance_Byte_add.ets +std/core/std_core_byte_instance_Byte_div.ets +std/core/std_core_byte_instance_Byte_mul.ets +std/core/std_core_byte_instance_Byte_sub.ets +std/core/std_core_byte_static_Byte_valueOf.ets +std/core/std_core_char_static_Char_toLowerCase.ets +std/core/std_core_char_static_Char_toUpperCase.ets +std/core/std_core_char_static_Char_valueOf.ets +std/core/std_core_constructor_Boolean_constructor.ets +std/core/std_core_constructor_Byte_constructor.ets +std/core/std_core_constructor_Char_constructor.ets +std/core/std_core_constructor_Double_constructor.ets +std/core/std_core_constructor_Int_constructor.ets +std/core/std_core_constructor_Long_constructor.ets +std/core/std_core_double_instance_Double_add.ets +std/core/std_core_double_instance_Double_div.ets +std/core/std_core_double_instance_Double_mul.ets +std/core/std_core_double_instance_Double_sub.ets +std/core/std_core_constructor_Short_constructor.ets +std/core/std_core_double_static_Double_parseFloat.ets +std/core/std_core_double_static_Double_parseInt.ets +std/core/std_core_double_static_Double_parseInt_006.ets +std/core/std_core_double_static_Double_parseInt_007.ets +std/core/std_core_float_instance_Float_add.ets +std/core/std_core_float_instance_Float_div.ets +std/core/std_core_float_instance_Float_mul.ets +std/core/std_core_float_instance_Float_sub.ets +std/core/std_core_float_static_Float_valueOf.ets +std/core/std_core_int_instance_Int_add.ets +std/core/std_core_int_instance_Int_div.ets +std/core/std_core_int_instance_Int_mul.ets +std/core/std_core_int_instance_Int_sub.ets +std/core/std_core_int_static_Int_valueOf.ets +std/core/std_core_long_instance_Long_add.ets +std/core/std_core_long_instance_Long_div.ets +std/core/std_core_long_instance_Long_mul.ets +std/core/std_core_long_instance_Long_sub.ets +std/core/std_core_long_static_Long_valueOf.ets +std/core/std_core_short_instance_Short_add.ets +std/core/std_core_short_instance_Short_div.ets +std/core/std_core_short_instance_Short_mul.ets +std/core/std_core_short_instance_Short_sub.ets +std/core/std_core_short_static_Short_valueOf.ets + +# 6. +# verifier failures: +std/core/std_core_typedarrays_methods__BigInt64Array.ets +std/core/std_core_typedarrays_methods__Float32Array.ets +std/core/std_core_typedarrays_methods__Float64Array.ets +std/core/std_core_typedarrays_methods__Float64Array_001.ets +std/core/std_core_typedarrays_methods__Int16Array.ets +std/core/std_core_typedarrays_methods__Int32Array.ets +std/core/std_core_typedarrays_methods__Int8Array.ets + +# 7. +# runtime failures: +std/core/std_core_value_array_value_all_006.ets +std/serialization/std_serialization_json_stringify_float_array.ets diff --git a/static_core/plugins/ets/tests/test-lists/system/system-ignored.txt b/static_core/plugins/ets/tests/test-lists/system/system-ignored.txt new file mode 100644 index 0000000000000000000000000000000000000000..2d09ccf95bce5e24592f1610073f5cba0ed4ede9 --- /dev/null +++ b/static_core/plugins/ets/tests/test-lists/system/system-ignored.txt @@ -0,0 +1,4 @@ +#24986 +prohibit_top_level_statements_tests/prohibit_top_level_statements_2.ets +boost_equal_statements_tests/boost_equal_statements_2.ets +warnings_suppresion_tests/warnings_suppression_begin_end_2.ets \ No newline at end of file diff --git a/static_core/plugins/ets/tools/declgen_ts2sts/test/cookbook_tests/arkts-no-duplicate-interfaces-class.d.ets b/static_core/plugins/ets/tools/declgen_ts2sts/test/cookbook_tests/arkts-no-duplicate-interfaces-class.d.ets index 509e8265498613efb5f911f0a9ef05a4a0b9dfaf..9abe6aa3cb43ffc17aa32d64bbb8b84f1a7d1b29 100644 --- a/static_core/plugins/ets/tools/declgen_ts2sts/test/cookbook_tests/arkts-no-duplicate-interfaces-class.d.ets +++ b/static_core/plugins/ets/tools/declgen_ts2sts/test/cookbook_tests/arkts-no-duplicate-interfaces-class.d.ets @@ -24,6 +24,5 @@ export interface Calculator { } export interface I { foo(a: number): void; - foo(a?: number): void; setAge(age: number): void; } diff --git a/static_core/plugins/ets/tools/declgen_ts2sts/test/cookbook_tests/arkts-no-duplicate-interfaces-class.ts b/static_core/plugins/ets/tools/declgen_ts2sts/test/cookbook_tests/arkts-no-duplicate-interfaces-class.ts index b67bd7c19cb9045fd92fdcf42a195bb7a4f97474..7c88416cd6a80c43b21f43bdc6f6bbb0ea8d7cb3 100644 --- a/static_core/plugins/ets/tools/declgen_ts2sts/test/cookbook_tests/arkts-no-duplicate-interfaces-class.ts +++ b/static_core/plugins/ets/tools/declgen_ts2sts/test/cookbook_tests/arkts-no-duplicate-interfaces-class.ts @@ -26,10 +26,6 @@ export interface I { foo(a: number):void; } -export interface I { - foo(a?: number):void; -} - export interface I { setAge(age: number): void; } diff --git a/static_core/plugins/ets/tools/declgen_ts2sts/test/test-lists/declgenparser-ets-ignored.txt b/static_core/plugins/ets/tools/declgen_ts2sts/test/test-lists/declgenparser-ets-ignored.txt index c624b37b45c157ee47c3ec1ccc07df4bcbf1b3fd..ce7b55bd268848c9438aea8ddf56c9e6dd25634e 100644 --- a/static_core/plugins/ets/tools/declgen_ts2sts/test/test-lists/declgenparser-ets-ignored.txt +++ b/static_core/plugins/ets/tools/declgen_ts2sts/test/test-lists/declgenparser-ets-ignored.txt @@ -1,2 +1,3 @@ # TODO: no 'any' type cookbook_tests/arkts-no-private-identifiers.d.ets +cookbook_tests/arkts-no-duplicate-interfaces-class.d.ets diff --git a/static_core/runtime/class_linker_extension.cpp b/static_core/runtime/class_linker_extension.cpp index 01b2583a3ae5552d89b0c3be2d59c4c302cb4b34..2a85564070a1aa63987aec8d1381dc589ec16ffa 100644 --- a/static_core/runtime/class_linker_extension.cpp +++ b/static_core/runtime/class_linker_extension.cpp @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 diff --git a/static_core/runtime/include/value.h b/static_core/runtime/include/value.h index b180d58c172e7a590afbc21c1ff954c9dd54baa1..5f8a8c21396c5df81eb6778910ae834287730f6d 100644 --- a/static_core/runtime/include/value.h +++ b/static_core/runtime/include/value.h @@ -60,6 +60,10 @@ public: { static_assert(std::is_integral_v, "T must be integral type"); ASSERT(IsPrimitive()); + if constexpr (std::is_same_v) { + // Discard the top 32 bit which may contain garbage + return static_cast(static_cast(std::get<0>(value_))); + } return static_cast(std::get<0>(value_)); } diff --git a/static_core/runtime/templates/gen_intrinsics_data.rb b/static_core/runtime/templates/gen_intrinsics_data.rb index 4c22fae9d2d9bd3204b0efe97e3cb491f23a5feb..f024f2c648955d7ad1f651a06cbe37791b9a51b1 100755 --- a/static_core/runtime/templates/gen_intrinsics_data.rb +++ b/static_core/runtime/templates/gen_intrinsics_data.rb @@ -18,6 +18,7 @@ require 'optparse' require 'yaml' require 'json' require 'erb' +require 'ostruct' module Gen def self.on_require(data); end diff --git a/static_core/static_linker/tests/data/ets/sys/2.ets b/static_core/static_linker/tests/data/ets/sys/2.ets index 7d81b046b4d235235457c9a5bd92ce0f93a98c20..ce3509e9d27315847cd896358a73ee1cd79023da 100644 --- a/static_core/static_linker/tests/data/ets/sys/2.ets +++ b/static_core/static_linker/tests/data/ets/sys/2.ets @@ -18,7 +18,7 @@ export @interface FieldAnno { addr: string = "shanghai" d_int: int = 11 d_long: long = 22 - d_float: float = 33.3 + d_float: float = 33.3f d_double: double = 55.55 } @@ -27,7 +27,7 @@ export @interface MethodAnno { addr: string = "shanghai" d_int: int = 11 d_long: long = 22 - d_float: float = 33.3 + d_float: float = 33.3f d_double: double = 55.55 } @@ -36,7 +36,7 @@ export @interface ClassAnno { addr: string = "shanghai" d_int: int = 11 d_long: long = 22 - d_float: float = 33.3 + d_float: float = 33.3f d_double: double = 55.55 } @@ -47,19 +47,19 @@ export abstract class Base { const const_name: string = "billy"; const const_int: int = 11; const const_long: long = 22; -const const_float: float = 33.3; +const const_float: float = 33.3f; const const_double: double = 55.55; -@ClassAnno({names: ["test"], addr: "taiwan", d_int: 11, d_long: 22, d_float: 33.3, d_double: 55.55}) +@ClassAnno({names: ["test"], addr: "taiwan", d_int: 11, d_long: 22, d_float: 33.3f, d_double: 55.55}) export class Cls extends Base { - @FieldAnno({names: ["test"], addr: "taiwan", d_int: 11, d_long: 22, d_float: 33.3, d_double: 55.55}) + @FieldAnno({names: ["test"], addr: "taiwan", d_int: 11, d_long: 22, d_float: 33.3f, d_double: 55.55}) name: string = "alice" name2: string = const_name d_int: int = 11 d_int2: int = const_int d_long: long = 22 d_long2: long = const_long - d_float: float = 33.3 + d_float: float = 33.3f d_float2: float = const_float d_double: double = 55.55 d_double2: double = const_double @@ -84,7 +84,7 @@ export class Cls extends Base { } } - @MethodAnno({names: ["test"], addr: "taiwan", d_int: 11, d_long: 22, d_float: 33.3, d_double: 55.55}) + @MethodAnno({names: ["test"], addr: "taiwan", d_int: 11, d_long: 22, d_float: 33.3f, d_double: 55.55}) add(a: int, b: int): int { return a + b; } diff --git a/static_core/static_linker/tests/data/multi/dedup_debug_info/CustomLong.ets b/static_core/static_linker/tests/data/multi/dedup_debug_info/CustomLong.ets index b9ca84150b6b4536f5c4f390f3414aaf8df31e55..510715a0ca0885dc80a0bc166aad1449894dc15d 100644 --- a/static_core/static_linker/tests/data/multi/dedup_debug_info/CustomLong.ets +++ b/static_core/static_linker/tests/data/multi/dedup_debug_info/CustomLong.ets @@ -17,14 +17,14 @@ import { CustomInt } from './CustomInt'; export class CustomLong { public static calculateNumberOfLeadingZeros(value: long): int { - const asInt: int = (value >>> 32) as int; - return asInt == 0 ? 32 + CustomInt.calculateNumberOfLeadingZeros(value as int) + const asInt: int = (value >>> 32).toInt(); + return asInt == 0 ? 32 + CustomInt.calculateNumberOfLeadingZeros(value.toInt()) : CustomInt.calculateNumberOfLeadingZeros(asInt); } public static calculateNumberOfTrailingZeros(value: long): int { - const asInt: int = value as int; - return asInt == 0 ? 32 + CustomInt.calculateNumberOfTrailingZeros((value >>> 32) as int) + const asInt: int = value.toInt(); + return asInt == 0 ? 32 + CustomInt.calculateNumberOfTrailingZeros((value >>> 32).toInt()) : CustomInt.calculateNumberOfTrailingZeros(asInt); } diff --git a/static_core/templates/merge.rb b/static_core/templates/merge.rb index 9fe381afdee4e24d29b9706cd3c62436177d46e0..b0fdf2e7788704f81d4e0dbbc3a7389b0aff9157 100755 --- a/static_core/templates/merge.rb +++ b/static_core/templates/merge.rb @@ -18,6 +18,7 @@ require 'json' require 'optparse' require 'set' require 'yaml' +require 'ostruct' def check_option(optparser, options, key) return if options[key] diff --git a/static_core/tests/vm-benchmarks/src/vmb/templates/Template.ets b/static_core/tests/vm-benchmarks/src/vmb/templates/Template.ets index 64e8a66d32f8e97693b9fd9d2390cb03dfb9202d..da7a31aa0d3cfee88e8cf37dc33204716f2596db 100644 --- a/static_core/tests/vm-benchmarks/src/vmb/templates/Template.ets +++ b/static_core/tests/vm-benchmarks/src/vmb/templates/Template.ets @@ -46,7 +46,7 @@ let SYS_GC_PAUSE: int = $gc; function log(msg: String): void { // timestamp is needed by GC parser - let now: long = Date.now() as long; + let now: long = Double.toLong(Date.now()); console.info(now + " " + msg); } @@ -81,12 +81,12 @@ function runIters(phase: String, count: int, time: int, bench: $state_name): voi let ops: long = 0; let elapsedMs: long = 0; doGC(); - let start: long = Date.now() as long; + let start: long = Double.toLong(Date.now()); while (elapsedMs < iterMs) { for (let i: long = 0; i < loopCount1; i++) { $method_call } - elapsedMs = (Date.now() as long) - start; + elapsedMs = Double.toLong(Date.now()) - start; ops += loopCount1; } totalOps += ops; @@ -98,7 +98,7 @@ function runIters(phase: String, count: int, time: int, bench: $state_name): voi function main(): void throws { let bench: $state_name = new $state_name(); - log("Startup execution started: " + (Date.now() as long)); + log("Startup execution started: " + Double.toLong(Date.now())); $state_params $state_setup @@ -126,11 +126,11 @@ function main(): void throws { while (loopMs < iterMs && loopCount < MAX_LOOP_COUNT) { loopCount = loopCount * 2; - let start: long = Date.now() as long; + let start: long = Double.toLong(Date.now()); for (let i = 0; i < loopCount; i++) { $method_call } - loopMs = (Date.now() as long) - start; + loopMs = Double.toLong(Date.now()) - start; } loopCount1 = loopCount * iterMs / loopMs; @@ -176,13 +176,13 @@ class Consumer { public static intb: int = 53; public static longa: long = 24; public static longb: long = 53; - public static floata: float = 24.0; - public static floatb: float = 53.0; + public static floata: float = 24.0f; + public static floatb: float = 53.0f; public static doublea: double = 24.0; public static doubleb: double = 53.0; public static localObj = new Object(); public static localObjs: Object[] = [new Object()]; - public static pseudorand: long = Date.now() as long; + public static pseudorand: long = Double.toLong(Date.now()); public static consumeBool(boolc: boolean): void throws { if (boolc == Consumer.boola && boolc == Consumer.boolb) { diff --git a/taihe/compiler/taihe/codegen/ani/gen_sts.py b/taihe/compiler/taihe/codegen/ani/gen_sts.py index 52ca44484a4c4fc9710cf8ff47de362f23f5e6b2..121d7e2cdcdcf44cd92e0ccc51d403bf4b92bbd9 100644 --- a/taihe/compiler/taihe/codegen/ani/gen_sts.py +++ b/taihe/compiler/taihe/codegen/ani/gen_sts.py @@ -1169,7 +1169,7 @@ class STSCodeGenerator: "function __fromArrayBufferToBigInt(arr: ArrayBuffer): BigInt {", " let res: BigInt = 0n;", " for (let i: int = 0; i < arr.getByteLength(); i++) {", - " res |= BigInt(arr.at(i) as long & 0xff) << BigInt(i * 8);", + " res |= BigInt(arr.at(i).toLong() & 0xff) << BigInt(i * 8);", " }", " let m: int = arr.getByteLength();", " if (arr.at(m - 1) < 0) {", @@ -1195,7 +1195,7 @@ class STSCodeGenerator: " }", " let buf = new ArrayBuffer(n);", " for (let i: int = 0; i < n; i++) {", - " buf.set(i, (val & 255n).getLong() as byte)", + " buf.set(i, (val & 255n).getLong().toByte())", " val >>= 8n;", " }", " return buf;",