From 21b04b31dcac077f9d376a796ba038c14a5c1dbe Mon Sep 17 00:00:00 2001 From: F1r3w477 Date: Thu, 17 Jul 2025 21:53:47 -0500 Subject: [PATCH 1/4] add expr length tests --- .../tests/syntaxes/expressions/ExprLength.sk | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/test/skript/tests/syntaxes/expressions/ExprLength.sk diff --git a/src/test/skript/tests/syntaxes/expressions/ExprLength.sk b/src/test/skript/tests/syntaxes/expressions/ExprLength.sk new file mode 100644 index 00000000000..de6a7abbdfb --- /dev/null +++ b/src/test/skript/tests/syntaxes/expressions/ExprLength.sk @@ -0,0 +1,34 @@ +test "basic string length": + assert length of "hello" is 5 + + set {_string} to "Skript" + assert length of {_string} is 6 + +test "edge case string lengths": + set {_empty_string} to "" + assert length of {_empty_string} is 0 + + assert length of " " is 3 + assert length of "😂" is 2 + +test "type conversion for length": + assert length of "12345" is 5 + + clear {_undefined} + assert length of {_undefined} is not set + +test "list looping behavior of length": + set {_list::*} to "a", "bb", and "cherry" + set {_lengths::*} to length of {_list::*} + + assert {_lengths::1} is 1 + assert {_lengths::2} is 2 + assert {_lengths::3} is 6 + +test "string interpolation": + set {_string} to "Skript" + set {_empty_string} to "" + + assert "%length of "hello"%" is "5" + assert "%length of {_string}%" is "6" + assert "%length of {_empty_string}%" is "0" \ No newline at end of file From 27dbdfd232e4835385a393e9d37bb247cd3e21d1 Mon Sep 17 00:00:00 2001 From: F1r3w477 Date: Thu, 17 Jul 2025 22:45:25 -0500 Subject: [PATCH 2/4] tab spacing, remove unneeded clear --- .../tests/syntaxes/expressions/ExprLength.sk | 39 +++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/test/skript/tests/syntaxes/expressions/ExprLength.sk b/src/test/skript/tests/syntaxes/expressions/ExprLength.sk index de6a7abbdfb..ffdbeb44238 100644 --- a/src/test/skript/tests/syntaxes/expressions/ExprLength.sk +++ b/src/test/skript/tests/syntaxes/expressions/ExprLength.sk @@ -1,34 +1,33 @@ test "basic string length": - assert length of "hello" is 5 + assert length of "hello" is 5 - set {_string} to "Skript" - assert length of {_string} is 6 + set {_string} to "Skript" + assert length of {_string} is 6 test "edge case string lengths": - set {_empty_string} to "" - assert length of {_empty_string} is 0 + set {_empty_string} to "" + assert length of {_empty_string} is 0 - assert length of " " is 3 - assert length of "😂" is 2 + assert length of " " is 3 + assert length of "😂" is 2 test "type conversion for length": - assert length of "12345" is 5 + assert length of "12345" is 5 - clear {_undefined} - assert length of {_undefined} is not set + assert length of {_undefined} is not set test "list looping behavior of length": - set {_list::*} to "a", "bb", and "cherry" - set {_lengths::*} to length of {_list::*} + set {_list::*} to "a", "bb", and "cherry" + set {_lengths::*} to length of {_list::*} - assert {_lengths::1} is 1 - assert {_lengths::2} is 2 - assert {_lengths::3} is 6 + assert {_lengths::1} is 1 + assert {_lengths::2} is 2 + assert {_lengths::3} is 6 test "string interpolation": - set {_string} to "Skript" - set {_empty_string} to "" + set {_string} to "Skript" + set {_empty_string} to "" - assert "%length of "hello"%" is "5" - assert "%length of {_string}%" is "6" - assert "%length of {_empty_string}%" is "0" \ No newline at end of file + assert "%length of "hello"%" is "5" + assert "%length of {_string}%" is "6" + assert "%length of {_empty_string}%" is "0" \ No newline at end of file From 921e9d72ad1768011316c90ad19a52f30734ad93 Mon Sep 17 00:00:00 2001 From: F1r3w477 Date: Sat, 19 Jul 2025 20:25:08 -0500 Subject: [PATCH 3/4] add new line --- src/test/skript/tests/syntaxes/expressions/ExprLength.sk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/skript/tests/syntaxes/expressions/ExprLength.sk b/src/test/skript/tests/syntaxes/expressions/ExprLength.sk index ffdbeb44238..99bf1a1ca8a 100644 --- a/src/test/skript/tests/syntaxes/expressions/ExprLength.sk +++ b/src/test/skript/tests/syntaxes/expressions/ExprLength.sk @@ -30,4 +30,5 @@ test "string interpolation": assert "%length of "hello"%" is "5" assert "%length of {_string}%" is "6" - assert "%length of {_empty_string}%" is "0" \ No newline at end of file + assert "%length of {_empty_string}%" is "0" + \ No newline at end of file From c7b97b86be185359b2d275231034e9753e32c565 Mon Sep 17 00:00:00 2001 From: F1r3w477 Date: Sun, 20 Jul 2025 00:35:05 -0500 Subject: [PATCH 4/4] with "..." additions, formatting --- .../tests/syntaxes/expressions/ExprLength.sk | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/test/skript/tests/syntaxes/expressions/ExprLength.sk b/src/test/skript/tests/syntaxes/expressions/ExprLength.sk index 99bf1a1ca8a..8b104d853ea 100644 --- a/src/test/skript/tests/syntaxes/expressions/ExprLength.sk +++ b/src/test/skript/tests/syntaxes/expressions/ExprLength.sk @@ -1,34 +1,34 @@ test "basic string length": - assert length of "hello" is 5 + assert length of "hello" is 5 with "Length of a simple string literal should be correct" set {_string} to "Skript" - assert length of {_string} is 6 + assert length of {_string} is 6 with "Length of a string variable should be correct" test "edge case string lengths": set {_empty_string} to "" - assert length of {_empty_string} is 0 + assert length of {_empty_string} is 0 with "Length of an empty string should be 0" - assert length of " " is 3 - assert length of "😂" is 2 + assert length of " " is 3 with "Length of a string with only whitespace should be correct" + assert length of "😂" is 2 with "Length of a Unicode emoji should be calculated correctly" test "type conversion for length": - assert length of "12345" is 5 + assert length of "12345" is 5 with "Length of a numeric string should be correct" - assert length of {_undefined} is not set + clear {_undefined} + assert length of {_undefined} is not set with "Length of an undefined variable should be unset" test "list looping behavior of length": set {_list::*} to "a", "bb", and "cherry" set {_lengths::*} to length of {_list::*} - assert {_lengths::1} is 1 - assert {_lengths::2} is 2 - assert {_lengths::3} is 6 + assert {_lengths::1} is 1 with "First element of looped lengths should be correct" + assert {_lengths::2} is 2 with "Second element of looped lengths should be correct" + assert {_lengths::3} is 6 with "Third element of looped lengths should be correct" test "string interpolation": set {_string} to "Skript" set {_empty_string} to "" - assert "%length of "hello"%" is "5" - assert "%length of {_string}%" is "6" - assert "%length of {_empty_string}%" is "0" - \ No newline at end of file + assert "%length of "hello"%" is "5" with "String interpolation with a literal should work" + assert "%length of {_string}%" is "6" with "String interpolation with a variable should work" + assert "%length of {_empty_string}%" is "0" with "String interpolation with an empty string should work"