diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/scene/test_code_edit.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/scene/test_code_edit.h b/tests/scene/test_code_edit.h index 574cacda95..62931cd4dd 100644 --- a/tests/scene/test_code_edit.h +++ b/tests/scene/test_code_edit.h @@ -2179,8 +2179,24 @@ TEST_CASE("[SceneTree][CodeEdit] indent") { SEND_GUI_ACTION(code_edit, "ui_text_newline"); CHECK(code_edit->get_line(0) == "test: # string"); CHECK(code_edit->get_line(1) == ""); + code_edit->remove_string_delimiter("#"); + + /* Non-whitespace prevents auto-indentation. */ + code_edit->add_comment_delimiter("#", ""); + code_edit->set_text(""); + code_edit->insert_text_at_caret("test := 0 # comment"); + SEND_GUI_ACTION(code_edit, "ui_text_newline"); + CHECK(code_edit->get_line(0) == "test := 0 # comment"); + CHECK(code_edit->get_line(1) == ""); code_edit->remove_comment_delimiter("#"); + /* Even when there's no comments. */ + code_edit->set_text(""); + code_edit->insert_text_at_caret("test := 0"); + SEND_GUI_ACTION(code_edit, "ui_text_newline"); + CHECK(code_edit->get_line(0) == "test := 0"); + CHECK(code_edit->get_line(1) == ""); + /* If between brace pairs an extra line is added. */ code_edit->set_text(""); code_edit->insert_text_at_caret("test{}"); @@ -2256,8 +2272,24 @@ TEST_CASE("[SceneTree][CodeEdit] indent") { SEND_GUI_ACTION(code_edit, "ui_text_newline"); CHECK(code_edit->get_line(0) == "test: # string"); CHECK(code_edit->get_line(1) == ""); + code_edit->remove_string_delimiter("#"); + + /* Non-whitespace prevents auto-indentation. */ + code_edit->add_comment_delimiter("#", ""); + code_edit->set_text(""); + code_edit->insert_text_at_caret("test := 0 # comment"); + SEND_GUI_ACTION(code_edit, "ui_text_newline"); + CHECK(code_edit->get_line(0) == "test := 0 # comment"); + CHECK(code_edit->get_line(1) == ""); code_edit->remove_comment_delimiter("#"); + /* Even when there's no comments. */ + code_edit->set_text(""); + code_edit->insert_text_at_caret("test := 0"); + SEND_GUI_ACTION(code_edit, "ui_text_newline"); + CHECK(code_edit->get_line(0) == "test := 0"); + CHECK(code_edit->get_line(1) == ""); + /* If between brace pairs an extra line is added. */ code_edit->set_text(""); code_edit->insert_text_at_caret("test{}"); |