diff options
Diffstat (limited to 'modules/gdscript/tests/scripts')
12 files changed, 75 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/lambda_no_return.gd b/modules/gdscript/tests/scripts/analyzer/errors/lambda_no_return.gd new file mode 100644 index 0000000000..70973c33d4 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/lambda_no_return.gd @@ -0,0 +1,4 @@ +func test(): + var lambda := func() -> int: + print('no return') + lambda.call() diff --git a/modules/gdscript/tests/scripts/analyzer/errors/lambda_no_return.out b/modules/gdscript/tests/scripts/analyzer/errors/lambda_no_return.out new file mode 100644 index 0000000000..fe1472c54d --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/lambda_no_return.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +Not all code paths return a value. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/lambda_wrong_return.gd b/modules/gdscript/tests/scripts/analyzer/errors/lambda_wrong_return.gd new file mode 100644 index 0000000000..3c247a5b02 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/lambda_wrong_return.gd @@ -0,0 +1,4 @@ +func test(): + var lambda := func() -> int: + return 'string' + print(lambda.call()) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/lambda_wrong_return.out b/modules/gdscript/tests/scripts/analyzer/errors/lambda_wrong_return.out new file mode 100644 index 0000000000..53e2b012e6 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/lambda_wrong_return.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +Cannot return value of type "String" because the function return type is "int". diff --git a/modules/gdscript/tests/scripts/analyzer/features/lambda_typed.gd b/modules/gdscript/tests/scripts/analyzer/features/lambda_typed.gd new file mode 100644 index 0000000000..114d7f7652 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/lambda_typed.gd @@ -0,0 +1,12 @@ +func test(): + var lambda_0 := func() -> void: + print(0) + lambda_0.call() + + var lambda_1 := func(printed: int) -> void: + print(printed) + lambda_1.call(1) + + var lambda_2 := func(identity: int) -> int: + return identity + print(lambda_2.call(2)) diff --git a/modules/gdscript/tests/scripts/analyzer/features/lambda_typed.out b/modules/gdscript/tests/scripts/analyzer/features/lambda_typed.out new file mode 100644 index 0000000000..63e262aeff --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/lambda_typed.out @@ -0,0 +1,4 @@ +GDTEST_OK +0 +1 +2 diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/lambda_shadowing_arg.gd b/modules/gdscript/tests/scripts/analyzer/warnings/lambda_shadowing_arg.gd new file mode 100644 index 0000000000..939496324c --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/warnings/lambda_shadowing_arg.gd @@ -0,0 +1,6 @@ +var shadow: int + +func test(): + var lambda := func(shadow: String) -> void: + print(shadow) + lambda.call('shadow') diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/lambda_shadowing_arg.out b/modules/gdscript/tests/scripts/analyzer/warnings/lambda_shadowing_arg.out new file mode 100644 index 0000000000..a98d80514c --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/warnings/lambda_shadowing_arg.out @@ -0,0 +1,6 @@ +GDTEST_OK +>> WARNING +>> Line: 4 +>> SHADOWED_VARIABLE +>> The local function parameter "shadow" is shadowing an already-declared variable at line 1. +shadow diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/lambda_unused_arg.gd b/modules/gdscript/tests/scripts/analyzer/warnings/lambda_unused_arg.gd new file mode 100644 index 0000000000..6fc90ea29c --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/warnings/lambda_unused_arg.gd @@ -0,0 +1,4 @@ +func test(): + var lambda := func(unused: Variant) -> void: + pass + lambda.call() diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/lambda_unused_arg.out b/modules/gdscript/tests/scripts/analyzer/warnings/lambda_unused_arg.out new file mode 100644 index 0000000000..b018091c18 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/warnings/lambda_unused_arg.out @@ -0,0 +1,5 @@ +GDTEST_OK +>> WARNING +>> Line: 2 +>> UNUSED_PARAMETER +>> diff --git a/modules/gdscript/tests/scripts/parser/features/multiline_assert.gd b/modules/gdscript/tests/scripts/parser/features/multiline_assert.gd new file mode 100644 index 0000000000..8c699c604d --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/features/multiline_assert.gd @@ -0,0 +1,24 @@ +func test(): + var x := 5 + + assert(x > 0) + assert(x > 0,) + assert(x > 0, 'message') + assert(x > 0, 'message',) + + assert( + x > 0 + ) + assert( + x > 0, + ) + assert( + x > 0, + 'message' + ) + assert( + x > 0, + 'message', + ) + + print('OK') diff --git a/modules/gdscript/tests/scripts/parser/features/multiline_assert.out b/modules/gdscript/tests/scripts/parser/features/multiline_assert.out new file mode 100644 index 0000000000..1ccb591560 --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/features/multiline_assert.out @@ -0,0 +1,2 @@ +GDTEST_OK +OK |