From 4918df4527b3a9fec06d1add3edc93f19f5320c1 Mon Sep 17 00:00:00 2001 From: George Marques Date: Tue, 24 Aug 2021 13:58:06 -0300 Subject: GDScript: Allow access to outer constant and enum values --- .../scripts/analyzer/features/constants_from_parent.gd | 16 ++++++++++++++++ .../scripts/analyzer/features/constants_from_parent.out | 4 ++++ .../tests/scripts/analyzer/features/enum_from_parent.gd | 14 ++++++++++++++ .../tests/scripts/analyzer/features/enum_from_parent.out | 4 ++++ .../scripts/analyzer/features/enum_value_from_parent.gd | 14 ++++++++++++++ .../scripts/analyzer/features/enum_value_from_parent.out | 4 ++++ 6 files changed, 56 insertions(+) create mode 100644 modules/gdscript/tests/scripts/analyzer/features/constants_from_parent.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/features/constants_from_parent.out create mode 100644 modules/gdscript/tests/scripts/analyzer/features/enum_from_parent.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/features/enum_from_parent.out create mode 100644 modules/gdscript/tests/scripts/analyzer/features/enum_value_from_parent.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/features/enum_value_from_parent.out (limited to 'modules/gdscript/tests/scripts/analyzer/features') diff --git a/modules/gdscript/tests/scripts/analyzer/features/constants_from_parent.gd b/modules/gdscript/tests/scripts/analyzer/features/constants_from_parent.gd new file mode 100644 index 0000000000..135b6c3d85 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/constants_from_parent.gd @@ -0,0 +1,16 @@ +extends Node + +const NO_TYPE_CONST = 0 +const TYPE_CONST: int = 1 +const GUESS_TYPE_CONST := 2 + +class Test: + var a = NO_TYPE_CONST + var b = TYPE_CONST + var c = GUESS_TYPE_CONST + +func test(): + var test_instance = Test.new() + prints("a", test_instance.a, test_instance.a == NO_TYPE_CONST) + prints("b", test_instance.b, test_instance.b == TYPE_CONST) + prints("c", test_instance.c, test_instance.c == GUESS_TYPE_CONST) diff --git a/modules/gdscript/tests/scripts/analyzer/features/constants_from_parent.out b/modules/gdscript/tests/scripts/analyzer/features/constants_from_parent.out new file mode 100644 index 0000000000..cefcdc6d42 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/constants_from_parent.out @@ -0,0 +1,4 @@ +GDTEST_OK +a 0 True +b 1 True +c 2 True diff --git a/modules/gdscript/tests/scripts/analyzer/features/enum_from_parent.gd b/modules/gdscript/tests/scripts/analyzer/features/enum_from_parent.gd new file mode 100644 index 0000000000..5f57c5b8c2 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/enum_from_parent.gd @@ -0,0 +1,14 @@ +extends Node + +enum Named { VALUE_A, VALUE_B, VALUE_C = 42 } + +class Test: + var a = Named.VALUE_A + var b = Named.VALUE_B + var c = Named.VALUE_C + +func test(): + var test_instance = Test.new() + prints("a", test_instance.a, test_instance.a == Named.VALUE_A) + prints("b", test_instance.b, test_instance.b == Named.VALUE_B) + prints("c", test_instance.c, test_instance.c == Named.VALUE_C) diff --git a/modules/gdscript/tests/scripts/analyzer/features/enum_from_parent.out b/modules/gdscript/tests/scripts/analyzer/features/enum_from_parent.out new file mode 100644 index 0000000000..1f00b77c32 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/enum_from_parent.out @@ -0,0 +1,4 @@ +GDTEST_OK +a 0 True +b 1 True +c 42 True diff --git a/modules/gdscript/tests/scripts/analyzer/features/enum_value_from_parent.gd b/modules/gdscript/tests/scripts/analyzer/features/enum_value_from_parent.gd new file mode 100644 index 0000000000..26edce353d --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/enum_value_from_parent.gd @@ -0,0 +1,14 @@ +extends Node + +enum { VALUE_A, VALUE_B, VALUE_C = 42 } + +class Test: + var a = VALUE_A + var b = VALUE_B + var c = VALUE_C + +func test(): + var test_instance = Test.new() + prints("a", test_instance.a, test_instance.a == VALUE_A) + prints("b", test_instance.b, test_instance.b == VALUE_B) + prints("c", test_instance.c, test_instance.c == VALUE_C) diff --git a/modules/gdscript/tests/scripts/analyzer/features/enum_value_from_parent.out b/modules/gdscript/tests/scripts/analyzer/features/enum_value_from_parent.out new file mode 100644 index 0000000000..1f00b77c32 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/enum_value_from_parent.out @@ -0,0 +1,4 @@ +GDTEST_OK +a 0 True +b 1 True +c 42 True -- cgit v1.2.3