Browse Source

Add dozens of new integration tests to the GDScript test suite

This also ignores `.out` files in the file format static checks.
Hugo Locurcio 4 years ago
parent
commit
c0083c0f90
100 changed files with 550 additions and 15 deletions
  1. 3 0
      misc/scripts/file_format.sh
  2. 3 0
      modules/gdscript/tests/scripts/analyzer/errors/bitwise_float_left_operand.gd
  3. 2 0
      modules/gdscript/tests/scripts/analyzer/errors/bitwise_float_left_operand.out
  4. 3 0
      modules/gdscript/tests/scripts/analyzer/errors/bitwise_float_right_operand.gd
  5. 2 0
      modules/gdscript/tests/scripts/analyzer/errors/bitwise_float_right_operand.out
  6. 5 0
      modules/gdscript/tests/scripts/analyzer/errors/constant_used_as_function.gd
  7. 2 0
      modules/gdscript/tests/scripts/analyzer/errors/constant_used_as_function.out
  8. 7 0
      modules/gdscript/tests/scripts/analyzer/errors/enum_float_value.gd
  9. 2 0
      modules/gdscript/tests/scripts/analyzer/errors/enum_float_value.out
  10. 7 0
      modules/gdscript/tests/scripts/analyzer/errors/enum_string_value.gd
  11. 2 0
      modules/gdscript/tests/scripts/analyzer/errors/enum_string_value.out
  12. 6 0
      modules/gdscript/tests/scripts/analyzer/errors/function_used_as_property.gd
  13. 2 0
      modules/gdscript/tests/scripts/analyzer/errors/function_used_as_property.out
  14. 3 0
      modules/gdscript/tests/scripts/analyzer/errors/invalid_array_index.gd
  15. 2 0
      modules/gdscript/tests/scripts/analyzer/errors/invalid_array_index.out
  16. 2 0
      modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_bool.gd
  17. 2 0
      modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_bool.out
  18. 2 0
      modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_dictionary.gd
  19. 2 0
      modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_dictionary.out
  20. 2 0
      modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_mixed.gd
  21. 2 0
      modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_mixed.out
  22. 5 0
      modules/gdscript/tests/scripts/analyzer/errors/invalid_constant.gd
  23. 2 0
      modules/gdscript/tests/scripts/analyzer/errors/invalid_constant.out
  24. 3 0
      modules/gdscript/tests/scripts/analyzer/errors/leading_number_separator.gd
  25. 2 0
      modules/gdscript/tests/scripts/analyzer/errors/leading_number_separator.out
  26. 6 0
      modules/gdscript/tests/scripts/analyzer/errors/missing_argument.gd
  27. 0 0
      modules/gdscript/tests/scripts/analyzer/errors/missing_argument.out
  28. 4 0
      modules/gdscript/tests/scripts/analyzer/errors/property_used_as_function.gd
  29. 2 0
      modules/gdscript/tests/scripts/analyzer/errors/property_used_as_function.out
  30. 7 0
      modules/gdscript/tests/scripts/analyzer/errors/redefine_class_constant.gd
  31. 2 0
      modules/gdscript/tests/scripts/analyzer/errors/redefine_class_constant.out
  32. 5 0
      modules/gdscript/tests/scripts/analyzer/errors/redefine_local_constant.gd
  33. 2 0
      modules/gdscript/tests/scripts/analyzer/errors/redefine_local_constant.out
  34. 11 0
      modules/gdscript/tests/scripts/analyzer/errors/super_nonexistent_base_method.gd
  35. 2 0
      modules/gdscript/tests/scripts/analyzer/errors/super_nonexistent_base_method.out
  36. 16 0
      modules/gdscript/tests/scripts/analyzer/features/as.gd
  37. 8 0
      modules/gdscript/tests/scripts/analyzer/features/as.out
  38. 3 0
      modules/gdscript/tests/scripts/parser/errors/array_consecutive_commas.gd
  39. 2 0
      modules/gdscript/tests/scripts/parser/errors/array_consecutive_commas.out
  40. 2 0
      modules/gdscript/tests/scripts/parser/errors/assignment_2_equal_signs.gd
  41. 2 0
      modules/gdscript/tests/scripts/parser/errors/assignment_2_equal_signs.out
  42. 2 0
      modules/gdscript/tests/scripts/parser/errors/assignment_3_equal_signs.gd
  43. 2 0
      modules/gdscript/tests/scripts/parser/errors/assignment_3_equal_signs.out
  44. 4 0
      modules/gdscript/tests/scripts/parser/errors/assignment_in_if.gd
  45. 2 0
      modules/gdscript/tests/scripts/parser/errors/assignment_in_if.out
  46. 2 0
      modules/gdscript/tests/scripts/parser/errors/assignment_in_var.gd
  47. 2 0
      modules/gdscript/tests/scripts/parser/errors/assignment_in_var.out
  48. 4 0
      modules/gdscript/tests/scripts/parser/errors/assignment_in_var_if.gd
  49. 2 0
      modules/gdscript/tests/scripts/parser/errors/assignment_in_var_if.out
  50. 2 0
      modules/gdscript/tests/scripts/parser/errors/assignment_without_identifier.gd
  51. 2 0
      modules/gdscript/tests/scripts/parser/errors/assignment_without_identifier.out
  52. 6 0
      modules/gdscript/tests/scripts/parser/errors/class_name_after_annotation.gd
  53. 2 0
      modules/gdscript/tests/scripts/parser/errors/class_name_after_annotation.out
  54. 3 0
      modules/gdscript/tests/scripts/parser/errors/constant_conflicts_variable.gd
  55. 2 0
      modules/gdscript/tests/scripts/parser/errors/constant_conflicts_variable.out
  56. 7 0
      modules/gdscript/tests/scripts/parser/errors/default_value_in_function_call.gd
  57. 2 0
      modules/gdscript/tests/scripts/parser/errors/default_value_in_function_call.out
  58. 5 0
      modules/gdscript/tests/scripts/parser/errors/function_conflicts_constant.gd
  59. 2 0
      modules/gdscript/tests/scripts/parser/errors/function_conflicts_constant.out
  60. 7 0
      modules/gdscript/tests/scripts/parser/errors/function_conflicts_variable.gd
  61. 2 0
      modules/gdscript/tests/scripts/parser/errors/function_conflicts_variable.out
  62. 3 0
      modules/gdscript/tests/scripts/parser/errors/invalid_identifier_number.gd
  63. 2 0
      modules/gdscript/tests/scripts/parser/errors/invalid_identifier_number.out
  64. 3 0
      modules/gdscript/tests/scripts/parser/errors/invalid_identifier_string.gd
  65. 2 0
      modules/gdscript/tests/scripts/parser/errors/invalid_identifier_string.out
  66. 0 6
      modules/gdscript/tests/scripts/parser/errors/missing_argument.gd
  67. 1 1
      modules/gdscript/tests/scripts/parser/errors/missing_closing_expr_paren.gd
  68. 2 2
      modules/gdscript/tests/scripts/parser/errors/missing_colon.gd
  69. 3 3
      modules/gdscript/tests/scripts/parser/errors/missing_paren_after_args.gd
  70. 3 0
      modules/gdscript/tests/scripts/parser/errors/multiple_number_separators.gd
  71. 2 0
      modules/gdscript/tests/scripts/parser/errors/multiple_number_separators.out
  72. 3 1
      modules/gdscript/tests/scripts/parser/errors/nothing_after_dollar.gd
  73. 2 0
      modules/gdscript/tests/scripts/parser/errors/redefine_keyword.gd
  74. 2 0
      modules/gdscript/tests/scripts/parser/errors/redefine_keyword.out
  75. 5 0
      modules/gdscript/tests/scripts/parser/errors/redefine_local_constant_with_keyword.gd
  76. 2 0
      modules/gdscript/tests/scripts/parser/errors/redefine_local_constant_with_keyword.out
  77. 3 0
      modules/gdscript/tests/scripts/parser/errors/variable_conflicts_constant.gd
  78. 2 0
      modules/gdscript/tests/scripts/parser/errors/variable_conflicts_constant.out
  79. 6 0
      modules/gdscript/tests/scripts/parser/errors/variable_conflicts_function.gd
  80. 2 0
      modules/gdscript/tests/scripts/parser/errors/variable_conflicts_function.out
  81. 3 1
      modules/gdscript/tests/scripts/parser/errors/wrong_value_after_dollar.gd
  82. 3 1
      modules/gdscript/tests/scripts/parser/errors/wrong_value_after_dollar_slash.gd
  83. 16 0
      modules/gdscript/tests/scripts/parser/features/array.gd
  84. 11 0
      modules/gdscript/tests/scripts/parser/features/array.out
  85. 50 0
      modules/gdscript/tests/scripts/parser/features/bitwise_operators.gd
  86. 14 0
      modules/gdscript/tests/scripts/parser/features/bitwise_operators.out
  87. 25 0
      modules/gdscript/tests/scripts/parser/features/class.gd
  88. 3 0
      modules/gdscript/tests/scripts/parser/features/class.out
  89. 33 0
      modules/gdscript/tests/scripts/parser/features/class_inheritance.gd
  90. 10 0
      modules/gdscript/tests/scripts/parser/features/class_inheritance.out
  91. 5 0
      modules/gdscript/tests/scripts/parser/features/class_name.gd
  92. 1 0
      modules/gdscript/tests/scripts/parser/features/class_name.out
  93. 4 0
      modules/gdscript/tests/scripts/parser/features/concatenation.gd
  94. 4 0
      modules/gdscript/tests/scripts/parser/features/concatenation.out
  95. 11 0
      modules/gdscript/tests/scripts/parser/features/constants.gd
  96. 33 0
      modules/gdscript/tests/scripts/parser/features/constants.out
  97. 37 0
      modules/gdscript/tests/scripts/parser/features/dictionary.gd
  98. 14 0
      modules/gdscript/tests/scripts/parser/features/dictionary.out
  99. 12 0
      modules/gdscript/tests/scripts/parser/features/dictionary_mixed_syntax.gd
  100. 2 0
      modules/gdscript/tests/scripts/parser/features/dictionary_mixed_syntax.out

+ 3 - 0
misc/scripts/file_format.sh

@@ -20,6 +20,9 @@ while IFS= read -rd '' f; do
         continue
     elif [[ "$f" == *"sln" ]]; then
         continue
+    elif [[ "$f" == *".out" ]]; then
+        # GDScript integration testing files.
+        continue
     elif [[ "$f" == *"patch" ]]; then
         continue
     elif [[ "$f" == *"pot" ]]; then

+ 3 - 0
modules/gdscript/tests/scripts/analyzer/errors/bitwise_float_left_operand.gd

@@ -0,0 +1,3 @@
+func test():
+	# Error here.
+	print(2.2 << 4)

+ 2 - 0
modules/gdscript/tests/scripts/analyzer/errors/bitwise_float_left_operand.out

@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Invalid operands to operator <<, float and int.

+ 3 - 0
modules/gdscript/tests/scripts/analyzer/errors/bitwise_float_right_operand.gd

@@ -0,0 +1,3 @@
+func test():
+	# Error here.
+	print(2 << 4.4)

+ 2 - 0
modules/gdscript/tests/scripts/analyzer/errors/bitwise_float_right_operand.out

@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Invalid operands to operator <<, int and float.

+ 5 - 0
modules/gdscript/tests/scripts/analyzer/errors/constant_used_as_function.gd

@@ -0,0 +1,5 @@
+const CONSTANT = 25
+
+
+func test():
+	CONSTANT(123)

+ 2 - 0
modules/gdscript/tests/scripts/analyzer/errors/constant_used_as_function.out

@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Member "CONSTANT" is not a function.

+ 7 - 0
modules/gdscript/tests/scripts/analyzer/errors/enum_float_value.gd

@@ -0,0 +1,7 @@
+enum Size {
+	# Error here. Enum values must be integers.
+	S = 0.0,
+}
+
+func test():
+	pass

+ 2 - 0
modules/gdscript/tests/scripts/analyzer/errors/enum_float_value.out

@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Enum values must be integers.

+ 7 - 0
modules/gdscript/tests/scripts/analyzer/errors/enum_string_value.gd

@@ -0,0 +1,7 @@
+enum Size {
+	# Error here. Enum values must be integers.
+	S = "hello",
+}
+
+func test():
+	pass

+ 2 - 0
modules/gdscript/tests/scripts/analyzer/errors/enum_string_value.out

@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Enum values must be integers.

+ 6 - 0
modules/gdscript/tests/scripts/analyzer/errors/function_used_as_property.gd

@@ -0,0 +1,6 @@
+func function():
+	pass
+
+
+func test():
+	function = 25

+ 2 - 0
modules/gdscript/tests/scripts/analyzer/errors/function_used_as_property.out

@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Cannot assign a new value to a constant.

+ 3 - 0
modules/gdscript/tests/scripts/analyzer/errors/invalid_array_index.gd

@@ -0,0 +1,3 @@
+func test():
+	# Error here. Array indices must be integers.
+	print([0, 1][true])

+ 2 - 0
modules/gdscript/tests/scripts/analyzer/errors/invalid_array_index.out

@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Invalid index type "bool" for a base of type "Array".

+ 2 - 0
modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_bool.gd

@@ -0,0 +1,2 @@
+func test():
+	print(true + true)

+ 2 - 0
modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_bool.out

@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Invalid operands to operator +, bool and bool.

+ 2 - 0
modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_dictionary.gd

@@ -0,0 +1,2 @@
+func test():
+	print({"hello": "world"} + {"godot": "engine"})

+ 2 - 0
modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_dictionary.out

@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Invalid operands "Dictionary" and "Dictionary" for "+" operator.

+ 2 - 0
modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_mixed.gd

@@ -0,0 +1,2 @@
+func test():
+	print("hello" + ["world"])

+ 2 - 0
modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_mixed.out

@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Invalid operands "String" and "Array" for "+" operator.

+ 5 - 0
modules/gdscript/tests/scripts/analyzer/errors/invalid_constant.gd

@@ -0,0 +1,5 @@
+func test():
+	var i = 12
+	# Constants must be made of a constant, deterministic expression.
+	# A constant that depends on a variable's value is not a constant expression.
+	const TEST = 13 + i

+ 2 - 0
modules/gdscript/tests/scripts/analyzer/errors/invalid_constant.out

@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Assigned value for constant "TEST" isn't a constant expression.

+ 3 - 0
modules/gdscript/tests/scripts/analyzer/errors/leading_number_separator.gd

@@ -0,0 +1,3 @@
+func test():
+	# Number separators may not be placed at the beginning of a number.
+	var __ = _123

+ 2 - 0
modules/gdscript/tests/scripts/analyzer/errors/leading_number_separator.out

@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Identifier "_123" not declared in the current scope.

+ 6 - 0
modules/gdscript/tests/scripts/analyzer/errors/missing_argument.gd

@@ -0,0 +1,6 @@
+func args(a, b):
+	print(a)
+	print(b)
+
+func test():
+	args(1,)

+ 0 - 0
modules/gdscript/tests/scripts/parser/errors/missing_argument.out → modules/gdscript/tests/scripts/analyzer/errors/missing_argument.out


+ 4 - 0
modules/gdscript/tests/scripts/analyzer/errors/property_used_as_function.gd

@@ -0,0 +1,4 @@
+var property = 25
+
+func test():
+	property()

+ 2 - 0
modules/gdscript/tests/scripts/analyzer/errors/property_used_as_function.out

@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Member "property" is not a function.

+ 7 - 0
modules/gdscript/tests/scripts/analyzer/errors/redefine_class_constant.gd

@@ -0,0 +1,7 @@
+# See also `parser-warnings/shadowed-constant.gd`.
+const TEST = 25
+
+
+func test():
+	# Error here (trying to set a new value to a constant).
+	TEST = 50

+ 2 - 0
modules/gdscript/tests/scripts/analyzer/errors/redefine_class_constant.out

@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Cannot assign a new value to a constant.

+ 5 - 0
modules/gdscript/tests/scripts/analyzer/errors/redefine_local_constant.gd

@@ -0,0 +1,5 @@
+func test():
+	const TEST = 25
+
+	# Error here (can't assign a new value to a constant).
+	TEST = 50

+ 2 - 0
modules/gdscript/tests/scripts/analyzer/errors/redefine_local_constant.out

@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Cannot assign a new value to a constant.

+ 11 - 0
modules/gdscript/tests/scripts/analyzer/errors/super_nonexistent_base_method.gd

@@ -0,0 +1,11 @@
+# `class` extends RefCounted by default.
+class Say:
+	func say():
+		super()
+		print("say something")
+
+
+func test():
+	# RefCounted doesn't have a `say()` method, so the `super()` call in the method
+	# definition will cause a run-time error.
+	Say.new().say()

+ 2 - 0
modules/gdscript/tests/scripts/analyzer/errors/super_nonexistent_base_method.out

@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Function "say()" not found in base RefCounted.

+ 16 - 0
modules/gdscript/tests/scripts/analyzer/features/as.gd

@@ -0,0 +1,16 @@
+func test():
+	var some_bool = 5 as bool
+	var some_int = 5 as int
+	var some_float = 5 as float
+	print(typeof(some_bool))
+	print(typeof(some_int))
+	print(typeof(some_float))
+
+	print()
+
+	var some_bool_typed := 5 as bool
+	var some_int_typed := 5 as int
+	var some_float_typed := 5 as float
+	print(typeof(some_bool_typed))
+	print(typeof(some_int_typed))
+	print(typeof(some_float_typed))

+ 8 - 0
modules/gdscript/tests/scripts/analyzer/features/as.out

@@ -0,0 +1,8 @@
+GDTEST_OK
+1
+2
+3
+
+1
+2
+3

+ 3 - 0
modules/gdscript/tests/scripts/parser/errors/array_consecutive_commas.gd

@@ -0,0 +1,3 @@
+func test():
+	# Arrays with consecutive commas are not allowed.
+	var array = ["arrays",,,,]

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/array_consecutive_commas.out

@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+Expected expression as array element.

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/assignment_2_equal_signs.gd

@@ -0,0 +1,2 @@
+func test():
+	var hello == "world"

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/assignment_2_equal_signs.out

@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+Expected end of statement after variable declaration, found "==" instead.

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/assignment_3_equal_signs.gd

@@ -0,0 +1,2 @@
+func test():
+	var hello === "world"

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/assignment_3_equal_signs.out

@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+Expected end of statement after variable declaration, found "==" instead.

+ 4 - 0
modules/gdscript/tests/scripts/parser/errors/assignment_in_if.gd

@@ -0,0 +1,4 @@
+func test():
+	# Error here.
+	if foo = 25:
+		print(foo)

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/assignment_in_if.out

@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+Assignment is not allowed inside an expression.

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/assignment_in_var.gd

@@ -0,0 +1,2 @@
+func test():
+	var hello = "world" = "test"

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/assignment_in_var.out

@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+Assignment is not allowed inside an expression.

+ 4 - 0
modules/gdscript/tests/scripts/parser/errors/assignment_in_var_if.gd

@@ -0,0 +1,4 @@
+func test():
+	# Error here.
+	if var foo = 25:
+		print(foo)

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/assignment_in_var_if.out

@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+Expected conditional expression after "if".

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/assignment_without_identifier.gd

@@ -0,0 +1,2 @@
+func test():
+	var = "world"

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/assignment_without_identifier.out

@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+Expected variable name after "var".

+ 6 - 0
modules/gdscript/tests/scripts/parser/errors/class_name_after_annotation.gd

@@ -0,0 +1,6 @@
+# Error here. `class_name` should be used *before* annotations, not after.
+@icon("res://path/to/optional/icon.svg")
+class_name HelloWorld
+
+func test():
+	pass

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/class_name_after_annotation.out

@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+"class_name" should be used before annotations.

+ 3 - 0
modules/gdscript/tests/scripts/parser/errors/constant_conflicts_variable.gd

@@ -0,0 +1,3 @@
+func test():
+	var TEST = 50
+	const TEST = 25

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/constant_conflicts_variable.out

@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+There is already a variable named "TEST" declared in this scope.

+ 7 - 0
modules/gdscript/tests/scripts/parser/errors/default_value_in_function_call.gd

@@ -0,0 +1,7 @@
+func hello(arg1):
+	print(arg1)
+
+
+func test():
+	# Error here.
+	hello(arg1 = 25)

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/default_value_in_function_call.out

@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+Assignment is not allowed inside an expression.

+ 5 - 0
modules/gdscript/tests/scripts/parser/errors/function_conflicts_constant.gd

@@ -0,0 +1,5 @@
+const test = 25
+
+
+func test():
+	pass

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/function_conflicts_constant.out

@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+Function "test" has the same name as a previously declared constant.

+ 7 - 0
modules/gdscript/tests/scripts/parser/errors/function_conflicts_variable.gd

@@ -0,0 +1,7 @@
+func test():
+	pass
+
+
+# Error here. The difference with `variable-conflicts-function.gd` is that here,
+# the function is defined *before* the variable.
+var test = 25

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/function_conflicts_variable.out

@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+Variable "test" has the same name as a previously declared function.

+ 3 - 0
modules/gdscript/tests/scripts/parser/errors/invalid_identifier_number.gd

@@ -0,0 +1,3 @@
+func test():
+	# Error here.
+	var 23test = "is not a valid identifier"

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/invalid_identifier_number.out

@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+Expected variable name after "var".

+ 3 - 0
modules/gdscript/tests/scripts/parser/errors/invalid_identifier_string.gd

@@ -0,0 +1,3 @@
+func test():
+	# Error here.
+	var "yes" = "is not a valid identifier"

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/invalid_identifier_string.out

@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+Expected variable name after "var".

+ 0 - 6
modules/gdscript/tests/scripts/parser/errors/missing_argument.gd

@@ -1,6 +0,0 @@
-func args(a, b):
-    print(a)
-    print(b)
-
-func test():
-    args(1,)

+ 1 - 1
modules/gdscript/tests/scripts/parser/errors/missing_closing_expr_paren.gd

@@ -1,2 +1,2 @@
 func test():
-    var a = ("missing paren ->"
+	var a = ("missing paren ->"

+ 2 - 2
modules/gdscript/tests/scripts/parser/errors/missing_colon.gd

@@ -1,3 +1,3 @@
 func test():
-    if true # Missing colon here.
-        print("true")
+	if true # Missing colon here.
+		print("true")

+ 3 - 3
modules/gdscript/tests/scripts/parser/errors/missing_paren_after_args.gd

@@ -1,6 +1,6 @@
 func args(a, b):
-    print(a)
-    print(b)
+	print(a)
+	print(b)
 
 func test():
-    args(1,2
+	args(1,2

+ 3 - 0
modules/gdscript/tests/scripts/parser/errors/multiple_number_separators.gd

@@ -0,0 +1,3 @@
+func test():
+	# Number separators may not be placed right next to each other.
+	var __ = 1__23

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/multiple_number_separators.out

@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+Only one underscore can be used as a numeric separator.

+ 3 - 1
modules/gdscript/tests/scripts/parser/errors/nothing_after_dollar.gd

@@ -1,3 +1,5 @@
 extends Node
+
+
 func test():
-    var a = $ # Expected some node path.
+	var a = $ # Expected some node path.

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/redefine_keyword.gd

@@ -0,0 +1,2 @@
+func test():
+	var while = "it's been a while"

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/redefine_keyword.out

@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+Expected variable name after "var".

+ 5 - 0
modules/gdscript/tests/scripts/parser/errors/redefine_local_constant_with_keyword.gd

@@ -0,0 +1,5 @@
+func test():
+	const TEST = 25
+
+	# Error here (can't redeclare a constant on the same scope).
+	const TEST = 50

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/redefine_local_constant_with_keyword.out

@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+There is already a constant named "TEST" declared in this scope.

+ 3 - 0
modules/gdscript/tests/scripts/parser/errors/variable_conflicts_constant.gd

@@ -0,0 +1,3 @@
+func test():
+	const TEST = 25
+	var TEST = 50

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/variable_conflicts_constant.out

@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+There is already a constant named "TEST" declared in this scope.

+ 6 - 0
modules/gdscript/tests/scripts/parser/errors/variable_conflicts_function.gd

@@ -0,0 +1,6 @@
+var test = 25
+
+# Error here. The difference with `variable-conflicts-function.gd` is that here,
+# the function is defined *before* the variable.
+func test():
+	pass

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/variable_conflicts_function.out

@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+Function "test" has the same name as a previously declared variable.

+ 3 - 1
modules/gdscript/tests/scripts/parser/errors/wrong_value_after_dollar.gd

@@ -1,3 +1,5 @@
 extends Node
+
+
 func test():
-    $23 # Can't use number here.
+	$23 # Can't use number here.

+ 3 - 1
modules/gdscript/tests/scripts/parser/errors/wrong_value_after_dollar_slash.gd

@@ -1,3 +1,5 @@
 extends Node
+
+
 func test():
-    $MyNode/23 # Can't use number here.
+	$MyNode/23 # Can't use number here.

+ 16 - 0
modules/gdscript/tests/scripts/parser/features/array.gd

@@ -0,0 +1,16 @@
+func test():
+	# Indexing from the beginning:
+	print([1, 2, 3][0])
+	print([1, 2, 3][1])
+	print([1, 2, 3][2])
+
+	# Indexing from the end:
+	print([1, 2, 3][-1])
+	print([1, 2, 3][-2])
+	print([1, 2, 3][-3])
+
+	# Float indices are currently allowed, but should probably be an error?
+	print([1, 2, 3][0.4])
+	print([1, 2, 3][0.8])
+	print([1, 2, 3][1.0])
+	print([1, 2, 3][-1.0])

+ 11 - 0
modules/gdscript/tests/scripts/parser/features/array.out

@@ -0,0 +1,11 @@
+GDTEST_OK
+1
+2
+3
+3
+2
+1
+1
+1
+2
+3

+ 50 - 0
modules/gdscript/tests/scripts/parser/features/bitwise_operators.gd

@@ -0,0 +1,50 @@
+enum Flags {
+	FIRE = 1 << 1,
+	ICE = 1 << 2,
+	SLIPPERY = 1 << 3,
+	STICKY = 1 << 4,
+	NONSOLID = 1 << 5,
+
+	ALL = FIRE | ICE | SLIPPERY | STICKY | NONSOLID,
+}
+
+
+func test():
+	var flags = Flags.FIRE | Flags.SLIPPERY
+	print(flags)
+
+	flags = Flags.FIRE & Flags.SLIPPERY
+	print(flags)
+
+	flags = Flags.FIRE ^ Flags.SLIPPERY
+	print(flags)
+
+	flags = Flags.ALL & (Flags.FIRE | Flags.ICE)
+	print(flags)
+
+	flags = (Flags.ALL & Flags.FIRE) | Flags.ICE
+	print(flags)
+
+	flags = Flags.ALL & Flags.FIRE | Flags.ICE
+	print(flags)
+
+	# Enum value must be casted to an integer. Otherwise, a parser error is emitted.
+	flags &= int(Flags.ICE)
+	print(flags)
+
+	flags ^= int(Flags.ICE)
+	print(flags)
+
+	flags |= int(Flags.STICKY | Flags.SLIPPERY)
+	print(flags)
+
+	print()
+
+	var num = 2 << 4
+	print(num)
+
+	num <<= 2
+	print(num)
+
+	num >>= 2
+	print(num)

+ 14 - 0
modules/gdscript/tests/scripts/parser/features/bitwise_operators.out

@@ -0,0 +1,14 @@
+GDTEST_OK
+10
+0
+10
+6
+6
+6
+4
+0
+24
+
+32
+128
+32

+ 25 - 0
modules/gdscript/tests/scripts/parser/features/class.gd

@@ -0,0 +1,25 @@
+# Test non-nested/slightly nested class architecture.
+class Test:
+	var number = 25
+	var string = "hello"
+
+
+class TestSub extends Test:
+	var other_string = "bye"
+
+
+class TestConstructor:
+	func _init(argument = 10):
+		print(str("constructor with argument ", argument))
+
+
+func test():
+	var test_instance = Test.new()
+	test_instance.number = 42
+
+	var test_sub = TestSub.new()
+	assert(test_sub.number == 25)  # From Test.
+	assert(test_sub.other_string == "bye")  # From TestSub.
+
+	TestConstructor.new()
+	TestConstructor.new(500)

+ 3 - 0
modules/gdscript/tests/scripts/parser/features/class.out

@@ -0,0 +1,3 @@
+GDTEST_OK
+constructor with argument 10
+constructor with argument 500

+ 33 - 0
modules/gdscript/tests/scripts/parser/features/class_inheritance.gd

@@ -0,0 +1,33 @@
+# Test deeply nested class architectures.
+class Test:
+	var depth = 1
+
+	class Nested:
+		var depth_nested = 10
+
+
+class Test2 extends Test:
+	var depth2 = 2
+
+
+class Test3 extends Test2:
+	var depth3 = 3
+
+
+class Test4 extends Test3:
+	var depth4 = 4
+
+	class Nested2:
+		var depth4_nested = 100
+
+
+func test():
+	print(Test.new().depth)
+	print(Test2.new().depth)
+	print(Test2.new().depth2)
+	print(Test3.new().depth)
+	print(Test3.new().depth3)
+	print(Test4.new().depth)
+	print(Test4.new().depth4)
+	print(Test.Nested.new().depth_nested)
+	print(Test4.Nested2.new().depth4_nested)

+ 10 - 0
modules/gdscript/tests/scripts/parser/features/class_inheritance.out

@@ -0,0 +1,10 @@
+GDTEST_OK
+1
+1
+2
+1
+3
+1
+4
+10
+100

+ 5 - 0
modules/gdscript/tests/scripts/parser/features/class_name.gd

@@ -0,0 +1,5 @@
+class_name HelloWorld
+@icon("res://path/to/optional/icon.svg")
+
+func test():
+	pass

+ 1 - 0
modules/gdscript/tests/scripts/parser/features/class_name.out

@@ -0,0 +1 @@
+GDTEST_OK

+ 4 - 0
modules/gdscript/tests/scripts/parser/features/concatenation.gd

@@ -0,0 +1,4 @@
+func test():
+	print(20 + 20)
+	print("hello" + "world")
+	print([1, 2] + [3, 4])

+ 4 - 0
modules/gdscript/tests/scripts/parser/features/concatenation.out

@@ -0,0 +1,4 @@
+GDTEST_OK
+40
+helloworld
+[1, 2, 3, 4]

+ 11 - 0
modules/gdscript/tests/scripts/parser/features/constants.gd

@@ -0,0 +1,11 @@
+func test():
+	const _TEST = 12 + 34 - 56 * 78
+	const _STRING = "yes"
+	const _VECTOR = Vector2(5, 6)
+	const _ARRAY = []
+	const _DICTIONARY = {"this": "dictionary"}
+
+	# Create user constants from built-in constants.
+	const _HELLO = PI + TAU
+	const _INFINITY = INF
+	const _NOT_A_NUMBER = NAN

+ 33 - 0
modules/gdscript/tests/scripts/parser/features/constants.out

@@ -0,0 +1,33 @@
+GDTEST_OK
+>> WARNING
+>> Line: 2
+>> UNUSED_LOCAL_CONSTANT
+>> The local constant '_TEST' is declared but never used in the block. If this is intended, prefix it with an underscore: '__TEST'
+>> WARNING
+>> Line: 3
+>> UNUSED_LOCAL_CONSTANT
+>> The local constant '_STRING' is declared but never used in the block. If this is intended, prefix it with an underscore: '__STRING'
+>> WARNING
+>> Line: 4
+>> UNUSED_LOCAL_CONSTANT
+>> The local constant '_VECTOR' is declared but never used in the block. If this is intended, prefix it with an underscore: '__VECTOR'
+>> WARNING
+>> Line: 5
+>> UNUSED_LOCAL_CONSTANT
+>> The local constant '_ARRAY' is declared but never used in the block. If this is intended, prefix it with an underscore: '__ARRAY'
+>> WARNING
+>> Line: 6
+>> UNUSED_LOCAL_CONSTANT
+>> The local constant '_DICTIONARY' is declared but never used in the block. If this is intended, prefix it with an underscore: '__DICTIONARY'
+>> WARNING
+>> Line: 9
+>> UNUSED_LOCAL_CONSTANT
+>> The local constant '_HELLO' is declared but never used in the block. If this is intended, prefix it with an underscore: '__HELLO'
+>> WARNING
+>> Line: 10
+>> UNUSED_LOCAL_CONSTANT
+>> The local constant '_INFINITY' is declared but never used in the block. If this is intended, prefix it with an underscore: '__INFINITY'
+>> WARNING
+>> Line: 11
+>> UNUSED_LOCAL_CONSTANT
+>> The local constant '_NOT_A_NUMBER' is declared but never used in the block. If this is intended, prefix it with an underscore: '__NOT_A_NUMBER'

+ 37 - 0
modules/gdscript/tests/scripts/parser/features/dictionary.gd

@@ -0,0 +1,37 @@
+func test():
+	# Non-string keys are valid.
+	print({ 12: "world" }[12])
+
+	var contents = {
+		0: "zero",
+		0.0: "zero point zero",
+		null: "null",
+		false: "false",
+		[]: "empty array",
+		Vector2i(): "zero Vector2i",
+		15: {
+			22: {
+				4: ["nesting", "arrays"],
+			},
+		},
+	}
+
+	print(contents[0.0])
+	# Making sure declaration order doesn't affect things...
+	print({ 0.0: "zero point zero", 0: "zero",  null: "null", false: "false", []: "empty array" }[0])
+	print({ 0.0: "zero point zero", 0: "zero", null: "null", false: "false", []: "empty array" }[0.0])
+
+	print(contents[null])
+	print(contents[false])
+	print(contents[[]])
+	print(contents[Vector2i()])
+	print(contents[15])
+	print(contents[15][22])
+	print(contents[15][22][4])
+	print(contents[15][22][4][0])
+	print(contents[15][22][4][1])
+
+	# Currently fails with "invalid get index 'hello' on base Dictionary".
+	# Both syntaxes are valid however.
+	#print({ "hello": "world" }["hello"])
+	#print({ "hello": "world" }.hello)

+ 14 - 0
modules/gdscript/tests/scripts/parser/features/dictionary.out

@@ -0,0 +1,14 @@
+GDTEST_OK
+world
+zero point zero
+zero
+zero point zero
+null
+false
+empty array
+zero Vector2i
+{22:{4:[nesting, arrays]}}
+{4:[nesting, arrays]}
+[nesting, arrays]
+nesting
+arrays

+ 12 - 0
modules/gdscript/tests/scripts/parser/features/dictionary_mixed_syntax.gd

@@ -0,0 +1,12 @@
+func test():
+	# Mixing Python-style and Lua-style syntax in the same dictionary declaration
+	# is allowed.
+	var dict = {
+		"hello": {
+			world = {
+				"is": "beautiful",
+			},
+		},
+	}
+
+	print(dict)

+ 2 - 0
modules/gdscript/tests/scripts/parser/features/dictionary_mixed_syntax.out

@@ -0,0 +1,2 @@
+GDTEST_OK
+{hello:{world:{is:beautiful}}}

Some files were not shown because too many files changed in this diff