- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 414
 
add expr length tests #8052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev/feature
Are you sure you want to change the base?
add expr length tests #8052
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| test "basic string length": | ||
| 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 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 with "Length of an empty string should be 0" | ||
| 
     | 
||
| 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 with "Length of a numeric string should be correct" | ||
| 
     | 
||
| 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 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": | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is also not really necessary and should be handled in a different test focused on VariableString behavior There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that this test would ideally live in a dedicated  Given that overall test coverage is a known issue Skript is working to improve, would it be acceptable to keep this integration test here for now? This ensures this case is covered now, rather than waiting until a  It can always be moved to a more appropriate file later on.  | 
||
| set {_string} to "Skript" | ||
| set {_empty_string} to "" | ||
| 
     | 
||
| 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" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this test is necessary - it's not handled by ExprLength but rather internally (and should be tested elsewhere)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point about the test for the undefined variable. I'll remove that assertion.
Regarding the length of "12345" test, my intention was to test the expression with a string literal that contains numeric characters. Since ExprLength is registered for %strings%, this directly tests its intended functionality.
To avoid future confusion, I'll renamed the test block from "type conversion for length" to "numeric string length"