Skip to content
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

Parity of split function with C# in Expression #1661

Merged
merged 5 commits into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libraries/botframework-expressions/src/builtInFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1895,9 +1895,9 @@ export class BuiltInFunctions {
(expression: Expression): void => BuiltInFunctions.validateArityAndAnyType(expression, 3, 3, ReturnType.String)),
new ExpressionEvaluator(
ExpressionType.Split,
BuiltInFunctions.apply((args: any []): string[] => BuiltInFunctions.parseStringOrNull(args[0]).split(BuiltInFunctions.parseStringOrNull(args[1])), BuiltInFunctions.verifyStringOrNull),
BuiltInFunctions.apply((args: any []): string[] => BuiltInFunctions.parseStringOrNull(args[0]).split(BuiltInFunctions.parseStringOrNull(args[1]? args[1]: '')), BuiltInFunctions.verifyStringOrNull),
ReturnType.Object,
(expression: Expression): void => BuiltInFunctions.validateArityAndAnyType(expression, 2, 2, ReturnType.String)),
(expression: Expression): void => BuiltInFunctions.validateArityAndAnyType(expression, 1, 2, ReturnType.String)),
new ExpressionEvaluator(
ExpressionType.Substring,
BuiltInFunctions.substring,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const badExpressions =
'replaceIgnoreCase(one, \'l\', \'k\')', // replaceIgnoreCase only accept string parameter
'replaceIgnoreCase(\'hi\', 1, \'k\')', // replaceIgnoreCase only accept string parameter
'replaceIgnoreCase(\'hi\', \'l\', 1)', // replaceIgnoreCase only accept string parameter
'split(hello)', // split need two parameters
'split(hello, \'l\', \'l\')', // split need one or two parameters
'split(one, \'l\')', // split only accept string parameter
'split(hello, 1)', // split only accept string parameter
'substring(hello, 0.5)', // the second parameter of substring must be integer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const dataSource = [
['replaceIgnoreCase(nullObj, \'L\', \'k\')', ''],
['replaceIgnoreCase(\'hello\', \'L\', nullObj)', 'heo'],
['split(\'hello\',\'e\')', ['h', 'llo']],
['split(\'hello\')', ['h', 'e', 'l', 'l', 'o']],
['split(nullObj,\'e\')', ['']],
['split(\'hello\',nullObj)', ['h', 'e', 'l', 'l', 'o']],
['split(nullObj,nullObj)', []],
Expand Down