-
Notifications
You must be signed in to change notification settings - Fork 52
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
feat: add function is blank()
to check if a string is blank
#927
Conversation
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.
@skayliu thank you for your contribution. 🎉
The changes look good. I have only a few minor comments. Please have a look. 🍪
private def isBlankFunction = builtinFunction( | ||
params = List("string"), | ||
invoke = {case List(ValString(string)) => | ||
ValBoolean(string.isBlank) | ||
} | ||
) |
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.
❌ Since is blank()
is a function for a string argument, we should add the function to StringBuiltinFunctions.
BooleanBuiltinFunctions
is for functions with a boolean argument.
@@ -243,4 +243,27 @@ class BuiltinFunctionsTest | |||
"Assertion failure on evaluate the expression 'list contains(assert(my_list, my_list != null, \"The condition is not true\"), 2)': The condition is not true" | |||
) | |||
} | |||
|
|||
"A is blank() function" should "return Boolean" in { |
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.
❌ Same as the implementation, we should add the test cases to BuiltinStringFunctionsTest.
evaluateExpression( | ||
expression = """ is blank("") """ | ||
) should returnResult(true) | ||
|
||
evaluateExpression( | ||
expression = """ is blank(" ") """ | ||
) should returnResult(true) | ||
|
||
evaluateExpression( | ||
expression = """ is blank("hello world") """ | ||
) should returnResult(false) | ||
|
||
evaluateExpression( | ||
expression = """ is blank(" hello world ") """ | ||
) should returnResult(false) | ||
|
||
evaluateExpression( | ||
expression = """ is blank("\t\n\r\f") """ | ||
) should returnResult(true) |
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.
🔧 We could split the test cases into:
should "return true if the string contains only whitespace"
should "return false if the string contains non-whitespace characters"
evaluateExpression( | ||
expression = """ is blank("") """ | ||
) should returnResult(true) |
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.
❌ Add one more test case that verifies the invocation of the function with named parameters:
evaluateExpression(
expression = """ is blank(string: "") """
) should returnResult(true)
This kind of test ensures that we don't change the parameter name accidentally.
Hi, @saig0 , It's done, please check again. |
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.
@skayliu looks good. Thank you for the fast response. 🚀
Description
feat: add function
is blank()
to check if a string is blankRelated issues
related to camunda/camunda#22380