From 7fc814f69783ee5d3bde040bdbb057730e50bc30 Mon Sep 17 00:00:00 2001 From: Adam Scott Date: Sat, 17 Dec 2022 16:19:18 -0500 Subject: Fix external enums not assignable as constants - Add external enums test - Rename external inner class test - Clean up `GDScriptAnalyzer::reduce_identifier_from_base` class behavior --- .../tests/scripts/analyzer/features/external_enum_as_constant.gd | 6 ++++++ .../tests/scripts/analyzer/features/external_enum_as_constant.out | 3 +++ .../analyzer/features/external_enum_as_constant_external.notest.gd | 4 ++++ .../scripts/analyzer/features/external_inner_class_as_constant.gd | 7 +++++++ .../scripts/analyzer/features/external_inner_class_as_constant.out | 2 ++ .../features/external_inner_class_as_constant_external.notest.gd | 2 ++ .../scripts/analyzer/features/inner_class_constant_assignment.gd | 7 ------- .../scripts/analyzer/features/inner_class_constant_assignment.out | 2 -- .../features/inner_class_constant_assignment_external.notest.gd | 2 -- 9 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 modules/gdscript/tests/scripts/analyzer/features/external_enum_as_constant.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/features/external_enum_as_constant.out create mode 100644 modules/gdscript/tests/scripts/analyzer/features/external_enum_as_constant_external.notest.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/features/external_inner_class_as_constant.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/features/external_inner_class_as_constant.out create mode 100644 modules/gdscript/tests/scripts/analyzer/features/external_inner_class_as_constant_external.notest.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/features/inner_class_constant_assignment.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/features/inner_class_constant_assignment.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/features/inner_class_constant_assignment_external.notest.gd (limited to 'modules/gdscript/tests') diff --git a/modules/gdscript/tests/scripts/analyzer/features/external_enum_as_constant.gd b/modules/gdscript/tests/scripts/analyzer/features/external_enum_as_constant.gd new file mode 100644 index 0000000000..757744b6f1 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/external_enum_as_constant.gd @@ -0,0 +1,6 @@ +const External = preload("external_enum_as_constant_external.notest.gd") +const MyEnum = External.MyEnum + +func test(): + print(MyEnum.WAITING == 0) + print(MyEnum.GODOT == 1) diff --git a/modules/gdscript/tests/scripts/analyzer/features/external_enum_as_constant.out b/modules/gdscript/tests/scripts/analyzer/features/external_enum_as_constant.out new file mode 100644 index 0000000000..9d111a8322 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/external_enum_as_constant.out @@ -0,0 +1,3 @@ +GDTEST_OK +true +true diff --git a/modules/gdscript/tests/scripts/analyzer/features/external_enum_as_constant_external.notest.gd b/modules/gdscript/tests/scripts/analyzer/features/external_enum_as_constant_external.notest.gd new file mode 100644 index 0000000000..7c090844d0 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/external_enum_as_constant_external.notest.gd @@ -0,0 +1,4 @@ +enum MyEnum { + WAITING, + GODOT +} diff --git a/modules/gdscript/tests/scripts/analyzer/features/external_inner_class_as_constant.gd b/modules/gdscript/tests/scripts/analyzer/features/external_inner_class_as_constant.gd new file mode 100644 index 0000000000..18dca109fb --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/external_inner_class_as_constant.gd @@ -0,0 +1,7 @@ +const External = preload("external_inner_class_as_constant_external.notest.gd") +const ExternalInnerClass = External.InnerClass + +func test(): + var inst_external: ExternalInnerClass = ExternalInnerClass.new() + inst_external.x = 4.0 + print(inst_external.x) diff --git a/modules/gdscript/tests/scripts/analyzer/features/external_inner_class_as_constant.out b/modules/gdscript/tests/scripts/analyzer/features/external_inner_class_as_constant.out new file mode 100644 index 0000000000..15666c46ad --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/external_inner_class_as_constant.out @@ -0,0 +1,2 @@ +GDTEST_OK +4 diff --git a/modules/gdscript/tests/scripts/analyzer/features/external_inner_class_as_constant_external.notest.gd b/modules/gdscript/tests/scripts/analyzer/features/external_inner_class_as_constant_external.notest.gd new file mode 100644 index 0000000000..788c99d469 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/external_inner_class_as_constant_external.notest.gd @@ -0,0 +1,2 @@ +class InnerClass: + var x: = 3.0 diff --git a/modules/gdscript/tests/scripts/analyzer/features/inner_class_constant_assignment.gd b/modules/gdscript/tests/scripts/analyzer/features/inner_class_constant_assignment.gd deleted file mode 100644 index ed5fb18b73..0000000000 --- a/modules/gdscript/tests/scripts/analyzer/features/inner_class_constant_assignment.gd +++ /dev/null @@ -1,7 +0,0 @@ -const External = preload("inner_class_constant_assignment_external.notest.gd") -const ExternalInnerClass = External.InnerClass - -func test(): - var inst_external: ExternalInnerClass = ExternalInnerClass.new() - inst_external.x = 4.0 - print(inst_external.x) diff --git a/modules/gdscript/tests/scripts/analyzer/features/inner_class_constant_assignment.out b/modules/gdscript/tests/scripts/analyzer/features/inner_class_constant_assignment.out deleted file mode 100644 index 15666c46ad..0000000000 --- a/modules/gdscript/tests/scripts/analyzer/features/inner_class_constant_assignment.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_OK -4 diff --git a/modules/gdscript/tests/scripts/analyzer/features/inner_class_constant_assignment_external.notest.gd b/modules/gdscript/tests/scripts/analyzer/features/inner_class_constant_assignment_external.notest.gd deleted file mode 100644 index 788c99d469..0000000000 --- a/modules/gdscript/tests/scripts/analyzer/features/inner_class_constant_assignment_external.notest.gd +++ /dev/null @@ -1,2 +0,0 @@ -class InnerClass: - var x: = 3.0 -- cgit v1.2.3