From 9779049cc15b6f86e90ead2154e93cf6e562b85b Mon Sep 17 00:00:00 2001 From: Pawel Lampe Date: Thu, 19 Sep 2024 21:40:48 +0200 Subject: [PATCH] Add tests for multistatement lambda corner case, #326 --- ...bug_326_multistatement_lambda_corner_case.in.gd | 8 ++++++++ ...ug_326_multistatement_lambda_corner_case.out.gd | 14 ++++++++++++++ tests/formatter/test_input_output_pairs.py | 2 ++ tests/formatter/test_scripts_validity.py | 2 ++ tests/parser/test_parser.py | 3 +++ 5 files changed, 29 insertions(+) create mode 100644 tests/formatter/input-output-pairs/bug_326_multistatement_lambda_corner_case.in.gd create mode 100644 tests/formatter/input-output-pairs/bug_326_multistatement_lambda_corner_case.out.gd diff --git a/tests/formatter/input-output-pairs/bug_326_multistatement_lambda_corner_case.in.gd b/tests/formatter/input-output-pairs/bug_326_multistatement_lambda_corner_case.in.gd new file mode 100644 index 00000000..9a428414 --- /dev/null +++ b/tests/formatter/input-output-pairs/bug_326_multistatement_lambda_corner_case.in.gd @@ -0,0 +1,8 @@ +extends Node + +func _ready() -> void: + get_tree().create_timer(1.0).timeout.connect( + func(): + print("Hello world!") + print("This is a bug test.") + ) diff --git a/tests/formatter/input-output-pairs/bug_326_multistatement_lambda_corner_case.out.gd b/tests/formatter/input-output-pairs/bug_326_multistatement_lambda_corner_case.out.gd new file mode 100644 index 00000000..9ad1d3b6 --- /dev/null +++ b/tests/formatter/input-output-pairs/bug_326_multistatement_lambda_corner_case.out.gd @@ -0,0 +1,14 @@ +extends Node + + +func _ready() -> void: + ( + get_tree() + . create_timer(1.0) + . timeout + . connect( + func(): + print("Hello world!") + print("This is a bug test.") + ) + ) diff --git a/tests/formatter/test_input_output_pairs.py b/tests/formatter/test_input_output_pairs.py index 235332af..de76426b 100644 --- a/tests/formatter/test_input_output_pairs.py +++ b/tests/formatter/test_input_output_pairs.py @@ -9,6 +9,8 @@ [ # TODO: fix "inline_lambdas_w_comments", + # Desired yet not possible to support due to Godot bug: + "bug_326_multistatement_lambda_corner_case", ] ) # type: Set[str] diff --git a/tests/formatter/test_scripts_validity.py b/tests/formatter/test_scripts_validity.py index e4efe1e0..bebd5e89 100644 --- a/tests/formatter/test_scripts_validity.py +++ b/tests/formatter/test_scripts_validity.py @@ -10,6 +10,8 @@ DATA_DIR = "./input-output-pairs" EXCEPTIONS = set( [ + # Godot bugs: + "bug_326_multistatement_lambda_corner_case.out.gd", # cases where Godot does more than just parsing "inline_lambdas_w_comments.in.gd", "inline_lambdas_w_comments.out.gd", diff --git a/tests/parser/test_parser.py b/tests/parser/test_parser.py index 888890a3..6791e493 100644 --- a/tests/parser/test_parser.py +++ b/tests/parser/test_parser.py @@ -31,6 +31,9 @@ def pytest_generate_tests(metafunc): @pytest.mark.parser def test_parsing_success(gdscript_ok_path): + # TODO: fix lexer + if "bug_326_multistatement_lambda_corner_case" in gdscript_ok_path: + return with open(gdscript_ok_path, "r", encoding="utf-8") as handle: code = handle.read() parser.parse(code) # just checking if not throwing