diff options
Diffstat (limited to 'modules/gdscript/tests')
48 files changed, 278 insertions, 47 deletions
diff --git a/modules/gdscript/tests/gdscript_test_runner.cpp b/modules/gdscript/tests/gdscript_test_runner.cpp index 57405aa1ce..b8448d16c2 100644 --- a/modules/gdscript/tests/gdscript_test_runner.cpp +++ b/modules/gdscript/tests/gdscript_test_runner.cpp @@ -350,13 +350,13 @@ void GDScriptTestRunner::handle_cmdline() { for (List<String>::Element *E = cmdline_args.front(); E; E = E->next()) { String &cmd = E->get(); if (cmd == "--gdscript-generate-tests") { - if (E->next() == nullptr) { - ERR_PRINT("Needed a path for the test files."); - exit(-1); + String path; + if (E->next()) { + path = E->next()->get(); + } else { + path = "modules/gdscript/tests/scripts"; } - const String &path = E->next()->get(); - GDScriptTestRunner runner(path, false, cmdline_args.find("--print-filenames") != nullptr); bool completed = runner.generate_outputs(); @@ -566,6 +566,14 @@ GDScriptTest::TestResult GDScriptTest::execute_test_code(bool p_is_generating) { ERR_FAIL_V_MSG(result, "\nCould not find test function on: '" + source_file + "'"); } + // Setup output handlers. + ErrorHandlerData error_data(&result, this); + + _print_handler.userdata = &result; + _error_handler.userdata = &error_data; + add_print_handler(&_print_handler); + add_error_handler(&_error_handler); + script->reload(); // Create object instance for test. @@ -577,14 +585,6 @@ GDScriptTest::TestResult GDScriptTest::execute_test_code(bool p_is_generating) { obj->set_script(script); GDScriptInstance *instance = static_cast<GDScriptInstance *>(obj->get_script_instance()); - // Setup output handlers. - ErrorHandlerData error_data(&result, this); - - _print_handler.userdata = &result; - _error_handler.userdata = &error_data; - add_print_handler(&_print_handler); - add_error_handler(&_error_handler); - // Call test function. Callable::CallError call_err; instance->callp(GDScriptTestRunner::test_function_name, nullptr, 0, call_err); diff --git a/modules/gdscript/tests/scripts/analyzer/errors/prints_base_type_not_found.gd b/modules/gdscript/tests/scripts/analyzer/errors/prints_base_type_not_found.gd new file mode 100644 index 0000000000..e56ae7b11d --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/prints_base_type_not_found.gd @@ -0,0 +1,6 @@ +class InnerClass: + pass + +func test(): + var x : InnerClass.DoesNotExist + print("FAIL") diff --git a/modules/gdscript/tests/scripts/analyzer/errors/prints_base_type_not_found.out b/modules/gdscript/tests/scripts/analyzer/errors/prints_base_type_not_found.out new file mode 100644 index 0000000000..29c75ae3c0 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/prints_base_type_not_found.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +Could not find type "DoesNotExist" under base "InnerClass". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_constructor_with_return_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/static_constructor_with_return_type.gd new file mode 100644 index 0000000000..3dac751ba9 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/static_constructor_with_return_type.gd @@ -0,0 +1,5 @@ +static func _static_init() -> int: + print("static init") + +func test(): + print("done") diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_constructor_with_return_type.out b/modules/gdscript/tests/scripts/analyzer/errors/static_constructor_with_return_type.out new file mode 100644 index 0000000000..42294b7afb --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/static_constructor_with_return_type.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +Static constructor cannot have an explicit return type. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_call.gd b/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_call.gd new file mode 100644 index 0000000000..1ae814ea34 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_call.gd @@ -0,0 +1,9 @@ +@static_unload + +func non_static(): + return "non static" + +static var static_var = non_static() + +func test(): + print("does not run") diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_call.out b/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_call.out new file mode 100644 index 0000000000..f1e9ec34f2 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_call.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +Cannot call non-static function "non_static()" for static variable initializer. diff --git a/modules/gdscript/tests/scripts/analyzer/features/allow_void_function_to_return_void.out b/modules/gdscript/tests/scripts/analyzer/features/allow_void_function_to_return_void.out index 7c0416371f..f49d93620f 100644 --- a/modules/gdscript/tests/scripts/analyzer/features/allow_void_function_to_return_void.out +++ b/modules/gdscript/tests/scripts/analyzer/features/allow_void_function_to_return_void.out @@ -2,7 +2,7 @@ GDTEST_OK >> WARNING >> Line: 20 >> UNSAFE_VOID_RETURN ->> The method 'return_side_effect()' returns 'void' but it's trying to return a call to 'side_effect()' that can't be ensured to also be 'void'. +>> The method "return_side_effect()" returns "void" but it's trying to return a call to "side_effect()" that can't be ensured to also be "void". hello effect effect diff --git a/modules/gdscript/tests/scripts/analyzer/features/assert_literal_false.gd b/modules/gdscript/tests/scripts/analyzer/features/assert_literal_false.gd new file mode 100644 index 0000000000..d6c3cfc50e --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/assert_literal_false.gd @@ -0,0 +1,6 @@ +func test(): + var never: Variant = false + if never: + assert(false) + assert(false, 'message') + print('ok') diff --git a/modules/gdscript/tests/scripts/analyzer/features/assert_literal_false.out b/modules/gdscript/tests/scripts/analyzer/features/assert_literal_false.out new file mode 100644 index 0000000000..1b47ed10dc --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/assert_literal_false.out @@ -0,0 +1,2 @@ +GDTEST_OK +ok diff --git a/modules/gdscript/tests/scripts/analyzer/features/auto_inferred_type_dont_error.out b/modules/gdscript/tests/scripts/analyzer/features/auto_inferred_type_dont_error.out index 481016138a..22cd5d3a17 100644 --- a/modules/gdscript/tests/scripts/analyzer/features/auto_inferred_type_dont_error.out +++ b/modules/gdscript/tests/scripts/analyzer/features/auto_inferred_type_dont_error.out @@ -2,5 +2,5 @@ GDTEST_OK >> WARNING >> Line: 6 >> UNSAFE_METHOD_ACCESS ->> The method 'free' is not present on the inferred type 'Variant' (but may be present on a subtype). +>> The method "free()" is not present on the inferred type "Variant" (but may be present on a subtype). Ok diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/lambda_unused_arg.out b/modules/gdscript/tests/scripts/analyzer/warnings/lambda_unused_arg.out index 32e230fc80..fe6083c329 100644 --- a/modules/gdscript/tests/scripts/analyzer/warnings/lambda_unused_arg.out +++ b/modules/gdscript/tests/scripts/analyzer/warnings/lambda_unused_arg.out @@ -2,4 +2,4 @@ GDTEST_OK >> WARNING >> Line: 2 >> UNUSED_PARAMETER ->> The parameter 'unused' is never used in the function ''. If this is intended, prefix it with an underscore: '_unused' +>> The parameter "unused" is never used in the function "<anonymous lambda>()". If this is intended, prefix it with an underscore: "_unused". diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.out b/modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.out index 793faa05d4..c76950179d 100644 --- a/modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.out +++ b/modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.out @@ -2,5 +2,5 @@ GDTEST_OK >> WARNING >> Line: 4 >> NATIVE_METHOD_OVERRIDE ->> The method "get" overrides a method from native class "Object". This won't be called by the engine and may not work as expected. +>> The method "get()" overrides a method from native class "Object". This won't be called by the engine and may not work as expected. warn diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/shadowning.out b/modules/gdscript/tests/scripts/analyzer/warnings/shadowning.out index 9d0e567534..8467697a96 100644 --- a/modules/gdscript/tests/scripts/analyzer/warnings/shadowning.out +++ b/modules/gdscript/tests/scripts/analyzer/warnings/shadowning.out @@ -2,19 +2,19 @@ GDTEST_OK >> WARNING >> Line: 5 >> SHADOWED_GLOBAL_IDENTIFIER ->> The variable 'Array' has the same name as a built-in type. +>> The variable "Array" has the same name as a built-in type. >> WARNING >> Line: 6 >> SHADOWED_GLOBAL_IDENTIFIER ->> The variable 'Node' has the same name as a global class. +>> The variable "Node" has the same name as a global class. >> WARNING >> Line: 7 >> SHADOWED_GLOBAL_IDENTIFIER ->> The variable 'is_same' has the same name as a built-in function. +>> The variable "is_same" has the same name as a built-in function. >> WARNING >> Line: 8 >> SHADOWED_GLOBAL_IDENTIFIER ->> The variable 'sqrt' has the same name as a built-in function. +>> The variable "sqrt" has the same name as a built-in function. >> WARNING >> Line: 9 >> SHADOWED_VARIABLE diff --git a/modules/gdscript/tests/scripts/parser/errors/duplicate_icon.gd b/modules/gdscript/tests/scripts/parser/errors/duplicate_icon.gd new file mode 100644 index 0000000000..7500e406f6 --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/errors/duplicate_icon.gd @@ -0,0 +1,5 @@ +@icon("res://1.png") +@icon("res://1.png") + +func test(): + pass diff --git a/modules/gdscript/tests/scripts/parser/errors/duplicate_icon.out b/modules/gdscript/tests/scripts/parser/errors/duplicate_icon.out new file mode 100644 index 0000000000..d6cbc95d10 --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/errors/duplicate_icon.out @@ -0,0 +1,2 @@ +GDTEST_PARSER_ERROR +"@icon" annotation can only be used once. diff --git a/modules/gdscript/tests/scripts/parser/errors/duplicate_tool.gd b/modules/gdscript/tests/scripts/parser/errors/duplicate_tool.gd new file mode 100644 index 0000000000..3a2f7118f9 --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/errors/duplicate_tool.gd @@ -0,0 +1,5 @@ +@tool +@tool + +func test(): + pass diff --git a/modules/gdscript/tests/scripts/parser/errors/duplicate_tool.out b/modules/gdscript/tests/scripts/parser/errors/duplicate_tool.out new file mode 100644 index 0000000000..26fe23fb78 --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/errors/duplicate_tool.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +"@tool" annotation can only be used once. diff --git a/modules/gdscript/tests/scripts/parser/errors/static_constructor_not_static.gd b/modules/gdscript/tests/scripts/parser/errors/static_constructor_not_static.gd new file mode 100644 index 0000000000..cbfa1f314f --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/errors/static_constructor_not_static.gd @@ -0,0 +1,5 @@ +func _static_init(): + print("static init") + +func test(): + print("done") diff --git a/modules/gdscript/tests/scripts/parser/errors/static_constructor_not_static.out b/modules/gdscript/tests/scripts/parser/errors/static_constructor_not_static.out new file mode 100644 index 0000000000..b2b8711e96 --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/errors/static_constructor_not_static.out @@ -0,0 +1,2 @@ +GDTEST_PARSER_ERROR +Static constructor must be declared static. diff --git a/modules/gdscript/tests/scripts/parser/errors/static_constructor_returning_something.gd b/modules/gdscript/tests/scripts/parser/errors/static_constructor_returning_something.gd new file mode 100644 index 0000000000..711243f822 --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/errors/static_constructor_returning_something.gd @@ -0,0 +1,6 @@ +static func _static_init(): + print("static init") + return true + +func test(): + print("done") diff --git a/modules/gdscript/tests/scripts/parser/errors/static_constructor_returning_something.out b/modules/gdscript/tests/scripts/parser/errors/static_constructor_returning_something.out new file mode 100644 index 0000000000..a034850e86 --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/errors/static_constructor_returning_something.out @@ -0,0 +1,2 @@ +GDTEST_PARSER_ERROR +Constructor cannot return a value. diff --git a/modules/gdscript/tests/scripts/parser/features/constants.out b/modules/gdscript/tests/scripts/parser/features/constants.out index 6093e4a6ca..7ec33470d3 100644 --- a/modules/gdscript/tests/scripts/parser/features/constants.out +++ b/modules/gdscript/tests/scripts/parser/features/constants.out @@ -2,32 +2,32 @@ 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' +>> 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' +>> 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' +>> 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' +>> 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' +>> 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' +>> 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' +>> 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' +>> 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". diff --git a/modules/gdscript/tests/scripts/parser/features/match_bind_unused.out b/modules/gdscript/tests/scripts/parser/features/match_bind_unused.out index 057c1b11e5..44d29cb82d 100644 --- a/modules/gdscript/tests/scripts/parser/features/match_bind_unused.out +++ b/modules/gdscript/tests/scripts/parser/features/match_bind_unused.out @@ -2,5 +2,5 @@ GDTEST_OK >> WARNING >> Line: 9 >> UNUSED_VARIABLE ->> The local variable 'value' is declared but never used in the block. If this is intended, prefix it with an underscore: '_value' +>> The local variable "value" is declared but never used in the block. If this is intended, prefix it with an underscore: "_value". value diff --git a/modules/gdscript/tests/scripts/parser/features/static_typing.out b/modules/gdscript/tests/scripts/parser/features/static_typing.out index 207d90fef1..40a8f97416 100644 --- a/modules/gdscript/tests/scripts/parser/features/static_typing.out +++ b/modules/gdscript/tests/scripts/parser/features/static_typing.out @@ -2,20 +2,20 @@ GDTEST_OK >> WARNING >> Line: 11 >> UNUSED_LOCAL_CONSTANT ->> The local constant '_INTEGER' is declared but never used in the block. If this is intended, prefix it with an underscore: '__INTEGER' +>> The local constant "_INTEGER" is declared but never used in the block. If this is intended, prefix it with an underscore: "__INTEGER". >> WARNING >> Line: 12 >> UNUSED_LOCAL_CONSTANT ->> The local constant '_INTEGER_REDUNDANT_TYPED' is declared but never used in the block. If this is intended, prefix it with an underscore: '__INTEGER_REDUNDANT_TYPED' +>> The local constant "_INTEGER_REDUNDANT_TYPED" is declared but never used in the block. If this is intended, prefix it with an underscore: "__INTEGER_REDUNDANT_TYPED". >> WARNING >> Line: 13 >> UNUSED_LOCAL_CONSTANT ->> The local constant '_INTEGER_REDUNDANT_TYPED2' is declared but never used in the block. If this is intended, prefix it with an underscore: '__INTEGER_REDUNDANT_TYPED2' +>> The local constant "_INTEGER_REDUNDANT_TYPED2" is declared but never used in the block. If this is intended, prefix it with an underscore: "__INTEGER_REDUNDANT_TYPED2". >> WARNING >> Line: 14 >> UNUSED_LOCAL_CONSTANT ->> The local constant '_INTEGER_REDUNDANT_INFERRED' is declared but never used in the block. If this is intended, prefix it with an underscore: '__INTEGER_REDUNDANT_INFERRED' +>> The local constant "_INTEGER_REDUNDANT_INFERRED" is declared but never used in the block. If this is intended, prefix it with an underscore: "__INTEGER_REDUNDANT_INFERRED". >> WARNING >> Line: 15 >> UNUSED_LOCAL_CONSTANT ->> The local constant '_INTEGER_REDUNDANT_INFERRED2' is declared but never used in the block. If this is intended, prefix it with an underscore: '__INTEGER_REDUNDANT_INFERRED2' +>> The local constant "_INTEGER_REDUNDANT_INFERRED2" is declared but never used in the block. If this is intended, prefix it with an underscore: "__INTEGER_REDUNDANT_INFERRED2". diff --git a/modules/gdscript/tests/scripts/parser/warnings/return_value_discarded.out b/modules/gdscript/tests/scripts/parser/warnings/return_value_discarded.out index e89bb9226f..f2db4e9307 100644 --- a/modules/gdscript/tests/scripts/parser/warnings/return_value_discarded.out +++ b/modules/gdscript/tests/scripts/parser/warnings/return_value_discarded.out @@ -2,4 +2,4 @@ GDTEST_OK >> WARNING >> Line: 6 >> RETURN_VALUE_DISCARDED ->> The function 'i_return_int()' returns a value that will be discarded if not used. +>> The function "i_return_int()" returns a value that will be discarded if not used. diff --git a/modules/gdscript/tests/scripts/parser/warnings/shadowed_constant.out b/modules/gdscript/tests/scripts/parser/warnings/shadowed_constant.out index 9c9417e11d..75fa01f928 100644 --- a/modules/gdscript/tests/scripts/parser/warnings/shadowed_constant.out +++ b/modules/gdscript/tests/scripts/parser/warnings/shadowed_constant.out @@ -2,7 +2,7 @@ GDTEST_OK >> WARNING >> Line: 8 >> 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' +>> The local constant "TEST" is declared but never used in the block. If this is intended, prefix it with an underscore: "_TEST". >> WARNING >> Line: 8 >> SHADOWED_VARIABLE diff --git a/modules/gdscript/tests/scripts/parser/warnings/shadowed_global_identifier.out b/modules/gdscript/tests/scripts/parser/warnings/shadowed_global_identifier.out index c613140eb8..75a02c5d3c 100644 --- a/modules/gdscript/tests/scripts/parser/warnings/shadowed_global_identifier.out +++ b/modules/gdscript/tests/scripts/parser/warnings/shadowed_global_identifier.out @@ -2,8 +2,8 @@ GDTEST_OK >> WARNING >> Line: 2 >> UNUSED_VARIABLE ->> The local variable 'abs' is declared but never used in the block. If this is intended, prefix it with an underscore: '_abs' +>> The local variable "abs" is declared but never used in the block. If this is intended, prefix it with an underscore: "_abs". >> WARNING >> Line: 2 >> SHADOWED_GLOBAL_IDENTIFIER ->> The variable 'abs' has the same name as a built-in function. +>> The variable "abs" has the same name as a built-in function. diff --git a/modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_class.out b/modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_class.out index 82e467b368..aab27e78e2 100644 --- a/modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_class.out +++ b/modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_class.out @@ -2,7 +2,7 @@ GDTEST_OK >> WARNING >> Line: 8 >> UNUSED_VARIABLE ->> The local variable 'foo' is declared but never used in the block. If this is intended, prefix it with an underscore: '_foo' +>> The local variable "foo" is declared but never used in the block. If this is intended, prefix it with an underscore: "_foo". >> WARNING >> Line: 8 >> SHADOWED_VARIABLE diff --git a/modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_function.out b/modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_function.out index 26ce0465b1..e3cd358126 100644 --- a/modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_function.out +++ b/modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_function.out @@ -2,7 +2,7 @@ GDTEST_OK >> WARNING >> Line: 2 >> UNUSED_VARIABLE ->> The local variable 'test' is declared but never used in the block. If this is intended, prefix it with an underscore: '_test' +>> The local variable "test" is declared but never used in the block. If this is intended, prefix it with an underscore: "_test". >> WARNING >> Line: 2 >> SHADOWED_VARIABLE diff --git a/modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.out b/modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.out index 3933a35178..77994ce9ba 100644 --- a/modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.out +++ b/modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.out @@ -2,6 +2,6 @@ GDTEST_OK >> WARNING >> Line: 11 >> STATIC_CALLED_ON_INSTANCE ->> The function 'num_uint64()' is a static function but was called from an instance. Instead, it should be directly called from the type: 'String.num_uint64()'. +>> The function "num_uint64()" is a static function but was called from an instance. Instead, it should be directly called from the type: "String.num_uint64()". 8589934592 8589934592 diff --git a/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable.out b/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable.out index cf14502e9a..10f89be132 100644 --- a/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable.out +++ b/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable.out @@ -2,4 +2,4 @@ GDTEST_OK >> WARNING >> Line: 2 >> UNASSIGNED_VARIABLE ->> The variable '__' was used but never assigned a value. +>> The variable "__" was used but never assigned a value. diff --git a/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable_op_assign.out b/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable_op_assign.out index ba55a4e0f8..4fc91487f2 100644 --- a/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable_op_assign.out +++ b/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable_op_assign.out @@ -2,4 +2,4 @@ GDTEST_OK >> WARNING >> Line: 4 >> UNASSIGNED_VARIABLE_OP_ASSIGN ->> Using assignment with operation but the variable '__' was not previously assigned a value. +>> Using assignment with operation but the variable "__" was not previously assigned a value. diff --git a/modules/gdscript/tests/scripts/parser/warnings/unreachable_code_after_return.out b/modules/gdscript/tests/scripts/parser/warnings/unreachable_code_after_return.out index 9316abd5eb..f67dbdcd03 100644 --- a/modules/gdscript/tests/scripts/parser/warnings/unreachable_code_after_return.out +++ b/modules/gdscript/tests/scripts/parser/warnings/unreachable_code_after_return.out @@ -2,4 +2,4 @@ GDTEST_OK >> WARNING >> Line: 7 >> UNREACHABLE_CODE ->> Unreachable code (statement after return) in function 'test()'. +>> Unreachable code (statement after return) in function "test()". diff --git a/modules/gdscript/tests/scripts/parser/warnings/unused_argument.out b/modules/gdscript/tests/scripts/parser/warnings/unused_argument.out index 92f3308f85..3a03406f92 100644 --- a/modules/gdscript/tests/scripts/parser/warnings/unused_argument.out +++ b/modules/gdscript/tests/scripts/parser/warnings/unused_argument.out @@ -2,4 +2,4 @@ GDTEST_OK >> WARNING >> Line: 2 >> UNUSED_PARAMETER ->> The parameter 'p_arg2' is never used in the function 'function_with_unused_argument'. If this is intended, prefix it with an underscore: '_p_arg2' +>> The parameter "p_arg2" is never used in the function "function_with_unused_argument()". If this is intended, prefix it with an underscore: "_p_arg2". diff --git a/modules/gdscript/tests/scripts/parser/warnings/unused_variable.out b/modules/gdscript/tests/scripts/parser/warnings/unused_variable.out index 270e0e69c0..b9b3968473 100644 --- a/modules/gdscript/tests/scripts/parser/warnings/unused_variable.out +++ b/modules/gdscript/tests/scripts/parser/warnings/unused_variable.out @@ -2,4 +2,4 @@ GDTEST_OK >> WARNING >> Line: 2 >> UNUSED_VARIABLE ->> The local variable 'unused' is declared but never used in the block. If this is intended, prefix it with an underscore: '_unused' +>> The local variable "unused" is declared but never used in the block. If this is intended, prefix it with an underscore: "_unused". diff --git a/modules/gdscript/tests/scripts/runtime/features/assign_operator.gd b/modules/gdscript/tests/scripts/runtime/features/assign_operator.gd new file mode 100644 index 0000000000..2a9fe851ef --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/assign_operator.gd @@ -0,0 +1,31 @@ +# https://github.com/godotengine/godot/issues/75832 + +@warning_ignore("narrowing_conversion") +func test(): + var hf := 2.0 + var sf = 2.0 + + var i := 2 + i *= hf + i *= sf + i *= 2.0 + print(i) + var v2 := Vector2i(1, 2) + v2 *= hf + v2 *= sf + v2 *= 2.0 + print(v2) + var v3 := Vector3i(1, 2, 3) + v3 *= hf + v3 *= sf + v3 *= 2.0 + print(v3) + var v4 := Vector4i(1, 2, 3, 4) + v4 *= hf + v4 *= sf + v4 *= 2.0 + print(v4) + + var arr := [1, 2, 3] + arr += [4, 5] + print(arr) diff --git a/modules/gdscript/tests/scripts/runtime/features/assign_operator.out b/modules/gdscript/tests/scripts/runtime/features/assign_operator.out new file mode 100644 index 0000000000..bfcfc1dff5 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/assign_operator.out @@ -0,0 +1,6 @@ +GDTEST_OK +16 +(8, 16) +(8, 16, 24) +(8, 16, 24, 32) +[1, 2, 3, 4, 5] diff --git a/modules/gdscript/tests/scripts/runtime/features/getter_with_freed_object.gd b/modules/gdscript/tests/scripts/runtime/features/getter_with_freed_object.gd new file mode 100644 index 0000000000..a2d09bf7d3 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/getter_with_freed_object.gd @@ -0,0 +1,15 @@ +# https://github.com/godotengine/godot/issues/68184 + +var node: Node: + get: + return node + set(n): + node = n + + +func test(): + node = Node.new() + node.free() + + if !is_instance_valid(node): + print("It is freed") diff --git a/modules/gdscript/tests/scripts/runtime/features/getter_with_freed_object.out b/modules/gdscript/tests/scripts/runtime/features/getter_with_freed_object.out new file mode 100644 index 0000000000..b380f593d9 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/getter_with_freed_object.out @@ -0,0 +1,2 @@ +GDTEST_OK +It is freed diff --git a/modules/gdscript/tests/scripts/runtime/features/static_constructor.gd b/modules/gdscript/tests/scripts/runtime/features/static_constructor.gd new file mode 100644 index 0000000000..e08f77df12 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/static_constructor.gd @@ -0,0 +1,13 @@ +@static_unload + +static var foo = "bar" + +static func _static_init(): + print("static init called") + prints("foo is", foo) + +func test(): + var _lambda = func _static_init(): + print("lambda does not conflict with static constructor") + + print("done") diff --git a/modules/gdscript/tests/scripts/runtime/features/static_constructor.out b/modules/gdscript/tests/scripts/runtime/features/static_constructor.out new file mode 100644 index 0000000000..7f72a0ac2c --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/static_constructor.out @@ -0,0 +1,4 @@ +GDTEST_OK +static init called +foo is bar +done diff --git a/modules/gdscript/tests/scripts/runtime/features/static_variables.gd b/modules/gdscript/tests/scripts/runtime/features/static_variables.gd new file mode 100644 index 0000000000..e193312381 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/static_variables.gd @@ -0,0 +1,56 @@ +@static_unload + +static var perm := 0 + +static var prop := "Hello!": + get: return prop + " suffix" + set(value): prop = "prefix " + str(value) + +static func get_data(): + return "data" + +static var data = get_data() + +class Inner: + static var prop := "inner" + static func _static_init() -> void: + prints("Inner._static_init", prop) + + class InnerInner: + static var prop := "inner inner" + static func _static_init() -> void: + prints("InnerInner._static_init", prop) + +func test(): + prints("data:", data) + + prints("perm:", perm) + prints("prop:", prop) + + perm = 1 + prop = "World!" + + prints("perm:", perm) + prints("prop:", prop) + + print("other.perm:", StaticVariablesOther.perm) + print("other.prop:", StaticVariablesOther.prop) + + StaticVariablesOther.perm = 2 + StaticVariablesOther.prop = "foo" + + print("other.perm:", StaticVariablesOther.perm) + print("other.prop:", StaticVariablesOther.prop) + + @warning_ignore("unsafe_method_access") + var path = get_script().get_path().get_base_dir() + var other = load(path + "/static_variables_load.gd") + + print("load.perm:", other.perm) + print("load.prop:", other.prop) + + other.perm = 3 + other.prop = "bar" + + print("load.perm:", other.perm) + print("load.prop:", other.prop) diff --git a/modules/gdscript/tests/scripts/runtime/features/static_variables.out b/modules/gdscript/tests/scripts/runtime/features/static_variables.out new file mode 100644 index 0000000000..d2491aef5e --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/static_variables.out @@ -0,0 +1,16 @@ +GDTEST_OK +Inner._static_init inner +InnerInner._static_init inner inner +data: data +perm: 0 +prop: prefix Hello! suffix +perm: 1 +prop: prefix World! suffix +other.perm:0 +other.prop:prefix Hello! suffix +other.perm:2 +other.prop:prefix foo suffix +load.perm:0 +load.prop:prefix Hello! suffix +load.perm:3 +load.prop:prefix bar suffix diff --git a/modules/gdscript/tests/scripts/runtime/features/static_variables_load.gd b/modules/gdscript/tests/scripts/runtime/features/static_variables_load.gd new file mode 100644 index 0000000000..8913b02756 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/static_variables_load.gd @@ -0,0 +1,10 @@ +@static_unload + +static var perm := 0 + +static var prop := "Hello!": + get: return prop + " suffix" + set(value): prop = "prefix " + str(value) + +func test(): + print("ok") diff --git a/modules/gdscript/tests/scripts/runtime/features/static_variables_load.out b/modules/gdscript/tests/scripts/runtime/features/static_variables_load.out new file mode 100644 index 0000000000..1b47ed10dc --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/static_variables_load.out @@ -0,0 +1,2 @@ +GDTEST_OK +ok diff --git a/modules/gdscript/tests/scripts/runtime/features/static_variables_other.gd b/modules/gdscript/tests/scripts/runtime/features/static_variables_other.gd new file mode 100644 index 0000000000..7a3b0acca6 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/static_variables_other.gd @@ -0,0 +1,11 @@ +@static_unload +class_name StaticVariablesOther + +static var perm := 0 + +static var prop := "Hello!": + get: return prop + " suffix" + set(value): prop = "prefix " + str(value) + +func test(): + print("ok") diff --git a/modules/gdscript/tests/scripts/runtime/features/static_variables_other.out b/modules/gdscript/tests/scripts/runtime/features/static_variables_other.out new file mode 100644 index 0000000000..1b47ed10dc --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/static_variables_other.out @@ -0,0 +1,2 @@ +GDTEST_OK +ok |