Skip to content

Commit

Permalink
Parity of split function with C# in Expression (#1661)
Browse files Browse the repository at this point in the history
* parity of split function

* retrigger

* retrigger

* retrigger

* fix a test case
  • Loading branch information
cosmicshuai authored Feb 5, 2020
1 parent af05f01 commit 93f46ab
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
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

0 comments on commit 93f46ab

Please sign in to comment.