From fab4a13eedd58256a3c41f66dada7cbd1f959f7d Mon Sep 17 00:00:00 2001 From: Boglarka Haag Date: Wed, 16 Jul 2025 16:00:15 +0200 Subject: [PATCH] Align typeof for numeric types to latest spec Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICLSAP Reason: Typeof output needs to be changed in case of numerics. Description: Extra checks added, tests modified. Fixed internal issue: #27651 Change-Id: I203b320adeb342caaa784788b0ee97f914f1c5ca Signed-off-by: Haag Boglarka --- ets2panda/checker/ETSAnalyzer.cpp | 6 +++ ets2panda/lsp/src/inlay_hints.cpp | 35 +++++++++++++ ets2panda/lsp/src/quick_info.cpp | 4 ++ ets2panda/parser/ETSparser.cpp | 1 + ets2panda/parser/ETSparserTypes.cpp | 1 + .../annotation_for_type_parameter02.ets | 4 +- .../test/runtime/ets/TypeInferObject1.ets | 12 ++--- .../test/runtime/ets/TypeInferObject2.ets | 12 ++--- .../test/runtime/ets/TypeInferObject3.ets | 2 +- ets2panda/test/runtime/ets/Typeof.ets | 50 +++++++++---------- .../unit/lsp/class_hierarchy_info_test.cpp | 16 +++--- ...plement_inherited_abstract_member_test.cpp | 6 +-- .../unit/lsp/get_class_property_info_test.cpp | 8 +-- .../lsp/get_completions_entry_details.cpp | 8 +-- ets2panda/test/unit/lsp/inlay_hints_test.cpp | 8 +-- ets2panda/test/unit/lsp/quick_info_test_1.cpp | 6 +-- ...eed_to_state_create_ets_new_expression.cpp | 4 +- ..._proceed_to_state_is_accessor-expected.txt | 2 +- ...ceed_to_state_misc_expression-expected.txt | 2 +- 19 files changed, 117 insertions(+), 70 deletions(-) diff --git a/ets2panda/checker/ETSAnalyzer.cpp b/ets2panda/checker/ETSAnalyzer.cpp index 74631ae976..8f68d272dc 100644 --- a/ets2panda/checker/ETSAnalyzer.cpp +++ b/ets2panda/checker/ETSAnalyzer.cpp @@ -2641,11 +2641,17 @@ static checker::Type *GetTypeOfStringType(checker::Type *argType, ETSChecker *ch case TypeFlag::ETS_BOOLEAN: return checker->CreateETSStringLiteralType("boolean"); case TypeFlag::BYTE: + return checker->CreateETSStringLiteralType("byte"); case TypeFlag::CHAR: + return checker->CreateETSStringLiteralType("char"); case TypeFlag::SHORT: + return checker->CreateETSStringLiteralType("short"); case TypeFlag::INT: + return checker->CreateETSStringLiteralType("int"); case TypeFlag::LONG: + return checker->CreateETSStringLiteralType("long"); case TypeFlag::FLOAT: + return checker->CreateETSStringLiteralType("float"); case TypeFlag::DOUBLE: return checker->CreateETSStringLiteralType("number"); default: diff --git a/ets2panda/lsp/src/inlay_hints.cpp b/ets2panda/lsp/src/inlay_hints.cpp index 4aecc7a552..5d1d749810 100644 --- a/ets2panda/lsp/src/inlay_hints.cpp +++ b/ets2panda/lsp/src/inlay_hints.cpp @@ -291,6 +291,32 @@ void GetFunctionReturnTypeForHints(const ir::AstNode *decl, InlayHintList *resul } } +std::string PrimitiveTypeToString(ir::PrimitiveType type) +{ + switch (type) { + case ir::PrimitiveType::BYTE: + return "byte"; + case ir::PrimitiveType::INT: + return "int"; + case ir::PrimitiveType::LONG: + return "long"; + case ir::PrimitiveType::SHORT: + return "short"; + case ir::PrimitiveType::FLOAT: + return "float"; + case ir::PrimitiveType::DOUBLE: + return "double"; + case ir::PrimitiveType::BOOLEAN: + return "boolean"; + case ir::PrimitiveType::CHAR: + return "char"; + case ir::PrimitiveType::VOID: + return "void"; + default: + UNREACHABLE(); + } +} + void AddTypeParamIfTypeRef(const ir::AstNode *childNode, const ir::AstNode *param, InlayHintList *result) { if (childNode->IsETSTypeReference()) { @@ -299,6 +325,14 @@ void AddTypeParamIfTypeRef(const ir::AstNode *childNode, const ir::AstNode *para } } +void AddTypeParamIfPrimitiveType(const ir::AstNode *childNode, const ir::AstNode *param, InlayHintList *result) +{ + if (childNode->IsETSPrimitiveType()) { + AddTypeHints(PrimitiveTypeToString(childNode->AsETSPrimitiveType()->GetPrimitiveType()), param->End().index, + result); + } +} + void GetFunctionParameterTypeForHints(const ir::AstNode *node, InlayHintList *result) { const auto nodeParams = node->AsMethodDefinition()->Function()->Params(); @@ -309,6 +343,7 @@ void GetFunctionParameterTypeForHints(const ir::AstNode *node, InlayHintList *re if (param->IsETSParameterExpression()) { param->AsETSParameterExpression()->FindChild([param, &result](ark::es2panda::ir::AstNode *childNode) { AddTypeParamIfTypeRef(childNode, param, result); + AddTypeParamIfPrimitiveType(childNode, param, result); return false; }); } diff --git a/ets2panda/lsp/src/quick_info.cpp b/ets2panda/lsp/src/quick_info.cpp index a129392c19..155ce10676 100644 --- a/ets2panda/lsp/src/quick_info.cpp +++ b/ets2panda/lsp/src/quick_info.cpp @@ -789,6 +789,10 @@ std::vector CreateDisplayOfReturnType(ark::es2panda::ir::Type if (returnType->Type() == ir::AstNodeType::TS_THIS_TYPE) { displayParts.emplace_back(CreateReturnType("this")); } + if (returnType->Type() == ir::AstNodeType::ETS_PRIMITIVE_TYPE) { + auto typeName = PrimitiveTypeToName(returnType->AsETSPrimitiveType()->GetPrimitiveType()); + displayParts.emplace_back(CreateReturnType(typeName)); + } return displayParts; } diff --git a/ets2panda/parser/ETSparser.cpp b/ets2panda/parser/ETSparser.cpp index 9a13cfadb2..71228948ec 100644 --- a/ets2panda/parser/ETSparser.cpp +++ b/ets2panda/parser/ETSparser.cpp @@ -1415,6 +1415,7 @@ bool TypedParser::IsPrimitiveType(const lexer::TokenType &tokenType) case lexer::TokenType::KEYW_BYTE: case lexer::TokenType::KEYW_CHAR: case lexer::TokenType::KEYW_DOUBLE: + case lexer::TokenType::KEYW_NUMBER: case lexer::TokenType::KEYW_FLOAT: case lexer::TokenType::KEYW_INT: case lexer::TokenType::KEYW_LONG: diff --git a/ets2panda/parser/ETSparserTypes.cpp b/ets2panda/parser/ETSparserTypes.cpp index 5fa69bbfd2..335ee3e9aa 100644 --- a/ets2panda/parser/ETSparserTypes.cpp +++ b/ets2panda/parser/ETSparserTypes.cpp @@ -136,6 +136,7 @@ ir::TypeNode *ETSParser::GetTypeAnnotationOfPrimitiveType([[maybe_unused]] lexer typeAnnotation = ParsePrimitiveType(options, ir::PrimitiveType::BOOLEAN); break; case lexer::TokenType::KEYW_DOUBLE: + case lexer::TokenType::KEYW_NUMBER: typeAnnotation = ParsePrimitiveType(options, ir::PrimitiveType::DOUBLE); break; case lexer::TokenType::KEYW_BYTE: diff --git a/ets2panda/test/ast/compiler/ets/annotation_tests/annotation_for_type_parameter02.ets b/ets2panda/test/ast/compiler/ets/annotation_tests/annotation_for_type_parameter02.ets index 86cf1c3590..931391a4f8 100644 --- a/ets2panda/test/ast/compiler/ets/annotation_tests/annotation_for_type_parameter02.ets +++ b/ets2panda/test/ast/compiler/ets/annotation_tests/annotation_for_type_parameter02.ets @@ -20,8 +20,8 @@ let array1: Array<@Anno() Int > = new Array < @Anno() Int > () class A { foo() { } bar() { - foo < @Anno number > () - this.foo < @Anno number > () + foo < @Anno Number > () + this.foo < @Anno Number > () } } diff --git a/ets2panda/test/runtime/ets/TypeInferObject1.ets b/ets2panda/test/runtime/ets/TypeInferObject1.ets index c25166f08a..178a236fc1 100644 --- a/ets2panda/test/runtime/ets/TypeInferObject1.ets +++ b/ets2panda/test/runtime/ets/TypeInferObject1.ets @@ -36,7 +36,7 @@ class B { } function func1(arg: A, arg1: K){ - arktest.assertEQ(typeof arg1, "number") + arktest.assertEQ(typeof arg1, "int") return new A(arg.value2, arg.value1); } @@ -51,21 +51,21 @@ function func3(arg: A){ function main(): void { let a = new A(10, "Test"); arktest.assertEQ(typeof a, "object") - arktest.assertEQ(typeof a.value1, "number") + arktest.assertEQ(typeof a.value1, "int") arktest.assertEQ(typeof a.value2, "string") let funcValue1 = func1(a, 12); arktest.assertEQ(typeof funcValue1.value1, "string") - arktest.assertEQ(typeof funcValue1.value2, "number", `got ${typeof funcValue1.value2}`) + arktest.assertEQ(typeof funcValue1.value2, "int", `got ${typeof funcValue1.value2}`) let b = new B(10, "Test", 40); let funcValue2 = func2(b); arktest.assertEQ(typeof funcValue2.value1, "string") - arktest.assertEQ(typeof funcValue2.value2, "number") - arktest.assertEQ(typeof funcValue2.value3, "number") + arktest.assertEQ(typeof funcValue2.value2, "int") + arktest.assertEQ(typeof funcValue2.value3, "int") let c = new A(10, "Test"); let funcValue3 = func3(c); arktest.assertEQ(typeof funcValue3.value1, "string") - arktest.assertEQ(typeof funcValue3.value2, "number") + arktest.assertEQ(typeof funcValue3.value2, "int") } diff --git a/ets2panda/test/runtime/ets/TypeInferObject2.ets b/ets2panda/test/runtime/ets/TypeInferObject2.ets index afde846f63..d162145e09 100644 --- a/ets2panda/test/runtime/ets/TypeInferObject2.ets +++ b/ets2panda/test/runtime/ets/TypeInferObject2.ets @@ -26,9 +26,9 @@ class A { } function foo>(a: A, b: U, c: K, d: U, e: L) { - arktest.assertEQ(typeof a.a, "number") + arktest.assertEQ(typeof a.a, "int") arktest.assertEQ(typeof a.b, "string") - arktest.assertEQ(typeof a.c, "number") + arktest.assertEQ(typeof a.c, "int") arktest.assertEQ(typeof b, "number") arktest.assertEQ(typeof c, "string") arktest.assertEQ(typeof d, "number") @@ -37,9 +37,9 @@ function foo>(a: A, b: U } function bar(a: A, b : U) { - arktest.assertEQ(typeof a.a, "number") + arktest.assertEQ(typeof a.a, "int") arktest.assertEQ(typeof a.b, "string") - arktest.assertEQ(typeof a.c, "number") + arktest.assertEQ(typeof a.c, "int") arktest.assertEQ(typeof b, "number") return new A(a.a, b, a.b); } @@ -48,11 +48,11 @@ function main() { let a = new A(10, "Test", 40); let b: number = 20; let c = foo(a, b, "Test", 20, a); - arktest.assertEQ(typeof c.a, "number") + arktest.assertEQ(typeof c.a, "int") arktest.assertEQ(typeof c.b, "number") arktest.assertEQ(typeof c.c, "string") let d = bar(a, b); - arktest.assertEQ(typeof d.a, "number") + arktest.assertEQ(typeof d.a, "int") arktest.assertEQ(typeof d.b, "number") arktest.assertEQ(typeof d.c, "string") } diff --git a/ets2panda/test/runtime/ets/TypeInferObject3.ets b/ets2panda/test/runtime/ets/TypeInferObject3.ets index 2bb54ca5bb..49622448db 100644 --- a/ets2panda/test/runtime/ets/TypeInferObject3.ets +++ b/ets2panda/test/runtime/ets/TypeInferObject3.ets @@ -35,7 +35,7 @@ function foo(a: A, String, K>): void { arktest.assertEQ((typeof a.c), "boolean") arktest.assertEQ((typeof a.a.a), "boolean") arktest.assertEQ((typeof a.a.b), "string") - arktest.assertEQ((typeof a.a.c), "number") + arktest.assertEQ((typeof a.a.c), "int") } function main(): void { diff --git a/ets2panda/test/runtime/ets/Typeof.ets b/ets2panda/test/runtime/ets/Typeof.ets index aa64c3aae3..3e399d5ca9 100644 --- a/ets2panda/test/runtime/ets/Typeof.ets +++ b/ets2panda/test/runtime/ets/Typeof.ets @@ -50,12 +50,12 @@ function main() { let x07: double let x08: bigint = 123456789n arktest.assertEQ(typeof x00, "boolean") - arktest.assertEQ(typeof x01, "number") - arktest.assertEQ(typeof x02, "number") - arktest.assertEQ(typeof x03, "number") - arktest.assertEQ(typeof x04, "number") - arktest.assertEQ(typeof x05, "number") - arktest.assertEQ(typeof x06, "number") + arktest.assertEQ(typeof x01, "byte") + arktest.assertEQ(typeof x02, "char") + arktest.assertEQ(typeof x03, "short") + arktest.assertEQ(typeof x04, "int") + arktest.assertEQ(typeof x05, "long") + arktest.assertEQ(typeof x06, "float") arktest.assertEQ(typeof x07, "number") arktest.assertEQ(typeof x08, "bigint") @@ -69,12 +69,12 @@ function main() { let x007: Double = new Double() let x008: BigInt = new BigInt() arktest.assertEQ(typeof x000, "boolean") - arktest.assertEQ(typeof x001, "number") - arktest.assertEQ(typeof x002, "number") - arktest.assertEQ(typeof x003, "number") - arktest.assertEQ(typeof x004, "number") - arktest.assertEQ(typeof x005, "number") - arktest.assertEQ(typeof x006, "number") + arktest.assertEQ(typeof x001, "byte") + arktest.assertEQ(typeof x002, "char") + arktest.assertEQ(typeof x003, "short") + arktest.assertEQ(typeof x004, "int") + arktest.assertEQ(typeof x005, "long") + arktest.assertEQ(typeof x006, "float") arktest.assertEQ(typeof x007, "number") arktest.assertEQ(typeof x008, "bigint") @@ -88,12 +88,12 @@ function main() { let x7 = new Double() let x8 = new BigInt() arktest.assertEQ(typeof x0, "boolean") - arktest.assertEQ(typeof x1, "number") - arktest.assertEQ(typeof x2, "number") - arktest.assertEQ(typeof x3, "number") - arktest.assertEQ(typeof x4, "number") - arktest.assertEQ(typeof x5, "number") - arktest.assertEQ(typeof x6, "number") + arktest.assertEQ(typeof x1, "byte") + arktest.assertEQ(typeof x2, "char") + arktest.assertEQ(typeof x3, "short") + arktest.assertEQ(typeof x4, "int") + arktest.assertEQ(typeof x5, "long") + arktest.assertEQ(typeof x6, "float") arktest.assertEQ(typeof x7, "number") arktest.assertEQ(typeof x8, "bigint") @@ -144,12 +144,12 @@ function main() { // exprs with numbers (objects) arktest.assertEQ(typeof new Boolean(), "boolean") - arktest.assertEQ(typeof new Byte(), "number") - arktest.assertEQ(typeof new Char(), "number") - arktest.assertEQ(typeof new Short(), "number") - arktest.assertEQ(typeof new Int(), "number") - arktest.assertEQ(typeof new Long(), "number") - arktest.assertEQ(typeof new Float(), "number") + arktest.assertEQ(typeof new Byte(), "byte") + arktest.assertEQ(typeof new Char(), "char") + arktest.assertEQ(typeof new Short(), "short") + arktest.assertEQ(typeof new Int(), "int") + arktest.assertEQ(typeof new Long(), "long") + arktest.assertEQ(typeof new Float(), "float") arktest.assertEQ(typeof new Number(), "number") arktest.assertEQ(typeof new BigInt(), "bigint") @@ -175,7 +175,7 @@ function main() { arktest.assertEQ(typeof ("123" + "124"), "string") x004 = 9 x4 = 6 - arktest.assertEQ(typeof (x4 + x004), "number") + arktest.assertEQ(typeof (x4 + x004), "int") x8 = 1n x08 = new BigInt(10) arktest.assertEQ(typeof (x8 + x08), "bigint") diff --git a/ets2panda/test/unit/lsp/class_hierarchy_info_test.cpp b/ets2panda/test/unit/lsp/class_hierarchy_info_test.cpp index 231e38ae56..2802d072e7 100644 --- a/ets2panda/test/unit/lsp/class_hierarchy_info_test.cpp +++ b/ets2panda/test/unit/lsp/class_hierarchy_info_test.cpp @@ -62,7 +62,7 @@ private privateMethod(): void { ASSERT_TRUE(it->second != nullptr); ASSERT_EQ(it->second->GetSetterStyle(), ark::es2panda::lsp::SetterStyle::NONE); ASSERT_EQ(it->second->GetAccessModifierStyle(), ark::es2panda::lsp::AccessModifierStyle::PUBLIC); - it = methods.find("action(fileName: string, position: number): number"); + it = methods.find("action(fileName: string, position: double): double"); ASSERT_TRUE(it != methods.end()); ASSERT_TRUE(it->second != nullptr); ASSERT_EQ(it->second->GetSetterStyle(), ark::es2panda::lsp::SetterStyle::NONE); @@ -233,9 +233,9 @@ class A extends B {/*1*/};)"; auto classCItems = classHierarchy[1].GetMethodItemList(); ASSERT_TRUE(classCItems.find("func1(): void") != classCItems.end()); ASSERT_TRUE(classCItems.find("func2(): string") != classCItems.end()); - ASSERT_TRUE(classCItems.find("func3(): number") != classCItems.end()); + ASSERT_TRUE(classCItems.find("func3(): double") != classCItems.end()); ASSERT_TRUE(classCItems.find("func4(): boolean") != classCItems.end()); - ASSERT_TRUE(classCItems.find("func5(): Array") != classCItems.end()); + ASSERT_TRUE(classCItems.find("func5(): Array") != classCItems.end()); initializer.DestroyContext(context); } @@ -267,8 +267,8 @@ class A extends B {/*1*/};)"; ASSERT_FALSE(classHierarchy.empty()); ASSERT_EQ(classHierarchy[0].GetClassName(), "B"); auto classBItems = classHierarchy[0].GetMethodItemList(); - ASSERT_TRUE(classBItems.find("method1(parameter1: number): parameter") != classBItems.end()); - ASSERT_TRUE(classBItems.find("method2(parameter1: number): number") != classBItems.end()); + ASSERT_TRUE(classBItems.find("method1(parameter1: double): parameter") != classBItems.end()); + ASSERT_TRUE(classBItems.find("method2(parameter1: double): double") != classBItems.end()); ASSERT_TRUE(classBItems.find("method3(parameter1: string): Promise") != classBItems.end()); initializer.DestroyContext(context); } @@ -356,11 +356,11 @@ class GrandSon extends Son {/*1*/ auto sonItems = classHierarchy[0].GetPropertyItemList(); size_t expectPropertyListSize = 2; ASSERT_EQ(sonItems.size(), expectPropertyListSize); - ASSERT_TRUE(sonItems.find("property1: number") != sonItems.end()); - ASSERT_TRUE(sonItems.find("ChildExtraProperty2: number") != sonItems.end()); + ASSERT_TRUE(sonItems.find("property1: double") != sonItems.end()); + ASSERT_TRUE(sonItems.find("ChildExtraProperty2: double") != sonItems.end()); auto parentItems = classHierarchy[1].GetPropertyItemList(); ASSERT_EQ(parentItems.size(), 1); - ASSERT_TRUE(parentItems.find("property4: number") != parentItems.end()); + ASSERT_TRUE(parentItems.find("property4: double") != parentItems.end()); initializer.DestroyContext(context); } } // namespace diff --git a/ets2panda/test/unit/lsp/fix_class_doesnt_implement_inherited_abstract_member_test.cpp b/ets2panda/test/unit/lsp/fix_class_doesnt_implement_inherited_abstract_member_test.cpp index be40871cb8..b2027ef3fa 100644 --- a/ets2panda/test/unit/lsp/fix_class_doesnt_implement_inherited_abstract_member_test.cpp +++ b/ets2panda/test/unit/lsp/fix_class_doesnt_implement_inherited_abstract_member_test.cpp @@ -92,7 +92,7 @@ class B extends A { const size_t start = 109; ark::es2panda::lsp::FixClassNotImplementingInheritedMembers handle; auto result = handle.MakeTextChange(ctx, start); - std::string expectedNewText = " foo1(a: number, b: number) {}\n"; + std::string expectedNewText = " foo1(a: double, b: double) {}\n"; const size_t expectedStart = 122; const size_t expectedLength = 0; ASSERT_EQ(result.newText, expectedNewText); @@ -117,7 +117,7 @@ class C extends A { const size_t start = 109; const size_t length = 20; auto result = MockGetCodeActions(ctx, {start, length}); - std::string expectedNewText = " foo(a: number, b: number): number {}\n foo1(a: number, b: number) {}\n"; + std::string expectedNewText = " foo(a: double, b: double): double {}\n foo1(a: double, b: double) {}\n"; std::string expectedFileName = "LspFixAbstractMemberTests_002.ets"; const size_t expectedStart = 122; const size_t expectedLength = 0; @@ -142,7 +142,7 @@ class B extends A { class C extends A { })"); auto result = MockGetAllCodeActions(ctx); - std::string expectedNewText = " foo(a: number, b: number): number {}\n foo1(a: number, b: number) {}\n"; + std::string expectedNewText = " foo(a: double, b: double): double {}\n foo1(a: double, b: double) {}\n"; std::string expectedFileName = "LspFixAbstractMemberTests_003.ets"; const size_t expectedStart = 122; const size_t expectedStart2 = 145; diff --git a/ets2panda/test/unit/lsp/get_class_property_info_test.cpp b/ets2panda/test/unit/lsp/get_class_property_info_test.cpp index 039281bfc6..f5f72ab798 100644 --- a/ets2panda/test/unit/lsp/get_class_property_info_test.cpp +++ b/ets2panda/test/unit/lsp/get_class_property_info_test.cpp @@ -632,7 +632,7 @@ TEST_F(LspGetClassPropertyInfoTests, GetClassPropertyInfoMethod5) } std::vector>> expectedResult6 = { - {"jkk", 195, 207, "classField", {"public"}}, {"wwa", 210, 222, "classField", {"public"}}}; + {"jkk", 195, 207, "classField", {"public"}}, {"wwa", 210, 221, "classField", {"public"}}}; TEST_F(LspGetClassPropertyInfoTests, GetClassPropertyInfoMethod6) { @@ -780,7 +780,7 @@ TEST_F(LspGetClassPropertyInfoTests, GetClassPropertyInfoMethod9) } std::vector>> expectedResult10 = { - {"a", 17, 34, "classField", {"public"}}}; + {"a", 17, 33, "classField", {"public"}}}; TEST_F(LspGetClassPropertyInfoTests, GetClassPropertyInfoMethod10) { @@ -817,7 +817,7 @@ TEST_F(LspGetClassPropertyInfoTests, GetClassPropertyInfoMethod10) } std::vector>> expectedResult11 = { - {"a", 32, 49, "classField", {"public"}}}; + {"a", 32, 48, "classField", {"public"}}}; TEST_F(LspGetClassPropertyInfoTests, GetClassPropertyInfoMethod11) { @@ -893,7 +893,7 @@ TEST_F(LspGetClassPropertyInfoTests, GetClassPropertyInfoMethod12) } std::vector>> expectedResult13 = { - {"aa", 216, 227, "classField", {"public"}}}; + {"aa", 216, 226, "classField", {"public"}}}; TEST_F(LspGetClassPropertyInfoTests, GetClassPropertyInfoMethod13) { diff --git a/ets2panda/test/unit/lsp/get_completions_entry_details.cpp b/ets2panda/test/unit/lsp/get_completions_entry_details.cpp index c635af38c8..2855e811fe 100644 --- a/ets2panda/test/unit/lsp/get_completions_entry_details.cpp +++ b/ets2panda/test/unit/lsp/get_completions_entry_details.cpp @@ -238,11 +238,11 @@ TEST_F(LSPCompletionsEntryDetailsTests, GetCompletionEntryDetails5) expected.emplace_back("value", "functionParameter"); expected.emplace_back(":", "punctuation"); expected.emplace_back(" ", "space"); - expected.emplace_back("string | number | boolean", "typeParameter"); + expected.emplace_back("string | double | boolean", "typeParameter"); expected.emplace_back(")", "punctuation"); expected.emplace_back(":", "punctuation"); expected.emplace_back(" ", "space"); - expected.emplace_back("number", "returnType"); + expected.emplace_back("double", "returnType"); auto expectedCompletionEntryDetails = CompletionEntryDetails(entryName, kind, kindModifiers, expected, document, source, sourceDisplay, expectedFileName); @@ -272,7 +272,7 @@ TEST_F(LSPCompletionsEntryDetailsTests, GetCompletionEntryDetails6) expected.emplace_back("mqw1", "property"); expected.emplace_back(":", "punctuation"); expected.emplace_back(" ", "space"); - expected.emplace_back("[string, number, number]", "typeName"); + expected.emplace_back("[string, double, double]", "typeName"); auto expectedCompletionEntryDetails = CompletionEntryDetails(entryName, kind, kindModifiers, expected, document, source, sourceDisplay, expectedFileName); initializer.DestroyContext(ctx); @@ -358,7 +358,7 @@ TEST_F(LSPCompletionsEntryDetailsTests, CreateDisplayForUnionTypeAlias) expected.emplace_back(" ", "space"); expected.emplace_back("=", "operator"); expected.emplace_back(" ", "space"); - expected.emplace_back("string | number", "typeName"); + expected.emplace_back("string | double", "typeName"); ASSERT_EQ(expected, display); initializer.DestroyContext(ctx); } diff --git a/ets2panda/test/unit/lsp/inlay_hints_test.cpp b/ets2panda/test/unit/lsp/inlay_hints_test.cpp index dbea5dad24..058aa4f6a3 100644 --- a/ets2panda/test/unit/lsp/inlay_hints_test.cpp +++ b/ets2panda/test/unit/lsp/inlay_hints_test.cpp @@ -160,12 +160,12 @@ TEST_F(LSPInlayHintsTests, VisitFunctionLikeForParameterTypeTest) let message = greet("Alice", 30); )"}; const std::string voidString = "void"; - const std::string numberString = "number"; + const std::string numberString = "double"; const std::string stdString = "string"; - const size_t index1 = 32; - const size_t index2 = 43; + const size_t index1 = 31; + const size_t index2 = 42; const size_t index3 = 127; - const size_t index4 = 140; + const size_t index4 = 139; const size_t i0 = 0; const size_t i1 = 1; const size_t i2 = 2; diff --git a/ets2panda/test/unit/lsp/quick_info_test_1.cpp b/ets2panda/test/unit/lsp/quick_info_test_1.cpp index 371e781deb..0b0dd7a472 100644 --- a/ets2panda/test/unit/lsp/quick_info_test_1.cpp +++ b/ets2panda/test/unit/lsp/quick_info_test_1.cpp @@ -173,7 +173,7 @@ TEST_F(LspQuickInfoTests, CreateDisplayForUnionTypeAlias) expected.emplace_back(" ", "space"); expected.emplace_back("=", "operator"); expected.emplace_back(" ", "space"); - expected.emplace_back("string | number", "typeName"); + expected.emplace_back("string | double", "typeName"); ASSERT_EQ(expected, display); initializer.DestroyContext(ctx); } @@ -307,7 +307,7 @@ TEST_F(LspQuickInfoTests, CreateDisplayForMethodDefinition) expected.emplace_back("a", "functionParameter"); expected.emplace_back(":", "punctuation"); expected.emplace_back(" ", "space"); - expected.emplace_back("number", "typeParameter"); + expected.emplace_back("double", "typeParameter"); expected.emplace_back(")", "punctuation"); expected.emplace_back(":", "punctuation"); expected.emplace_back(" ", "space"); @@ -403,7 +403,7 @@ TEST_F(LspQuickInfoTests, CreateDisplayForClassProperty2) expected.emplace_back("myProp", "property"); expected.emplace_back(":", "punctuation"); expected.emplace_back(" ", "space"); - expected.emplace_back("number", "typeName"); + expected.emplace_back("double", "typeName"); ASSERT_EQ(expected, display); initializer.DestroyContext(ctx); diff --git a/ets2panda/test/unit/plugin/plugin_proceed_to_state_create_ets_new_expression.cpp b/ets2panda/test/unit/plugin/plugin_proceed_to_state_create_ets_new_expression.cpp index c1d8d9290a..d8c9098f18 100644 --- a/ets2panda/test/unit/plugin/plugin_proceed_to_state_create_ets_new_expression.cpp +++ b/ets2panda/test/unit/plugin/plugin_proceed_to_state_create_ets_new_expression.cpp @@ -142,7 +142,7 @@ void FindE(es2panda_AstNode *ast, es2panda_AstNode *declarator, char *name) } g_impl->AstNodeSetParent(g_ctx, typeReference, expression); auto str = g_impl->AstNodeDumpEtsSrcConst(g_ctx, declarator); - if (strcmp(str, "e = new number[5][5]") == 0) { + if (strcmp(str, "e = new double[5][5]") == 0) { g_count--; } } @@ -162,7 +162,7 @@ void FindF(es2panda_AstNode *ast, es2panda_AstNode *declarator, char *name) } g_impl->AstNodeSetParent(g_ctx, typeReference, expression); auto str = g_impl->AstNodeDumpEtsSrcConst(g_ctx, declarator); - if (strcmp(str, "f = new number[5][5]") == 0) { + if (strcmp(str, "f = new double[5][5]") == 0) { g_count--; } } diff --git a/ets2panda/test/unit/plugin/plugin_proceed_to_state_is_accessor-expected.txt b/ets2panda/test/unit/plugin/plugin_proceed_to_state_is_accessor-expected.txt index 5f87b4030e..6ceeee85ee 100644 --- a/ets2panda/test/unit/plugin/plugin_proceed_to_state_is_accessor-expected.txt +++ b/ets2panda/test/unit/plugin/plugin_proceed_to_state_is_accessor-expected.txt @@ -1,7 +1,7 @@ LOAD SUCCESS PROCEED TO PARSE SUCCESS SETTER: -public set member(value: number) { +public set member(value: double) { this.m = value; } diff --git a/ets2panda/test/unit/plugin/plugin_proceed_to_state_misc_expression-expected.txt b/ets2panda/test/unit/plugin/plugin_proceed_to_state_misc_expression-expected.txt index 63eef7873c..a03c05490e 100644 --- a/ets2panda/test/unit/plugin/plugin_proceed_to_state_misc_expression-expected.txt +++ b/ets2panda/test/unit/plugin/plugin_proceed_to_state_misc_expression-expected.txt @@ -2,7 +2,7 @@ LOAD SUCCESS PROCEED TO PARSE SUCCESS PROGRAM NODE: -function add(a: number, b: number) { +function add(a: double, b: double) { return ((a) + (b)); } -- Gitee