From 671f411e59a60693393514ef0fbe177fc3e39b63 Mon Sep 17 00:00:00 2001 From: andrew-coleman Date: Mon, 18 Nov 2019 10:14:46 +0000 Subject: [PATCH] check for unsupported sequence in parseInteger Signed-off-by: andrew-coleman --- src/datetime.js | 6 ++++++ src/jsonata.js | 2 +- .../groups/function-parseInteger/parseInteger.json | 8 ++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/datetime.js b/src/datetime.js index f611aba4..a0d85350 100644 --- a/src/datetime.js +++ b/src/datetime.js @@ -1030,6 +1030,12 @@ const dateTime = (function () { } return parseInt(digits); }; + break; + case formats.SEQUENCE: + throw { + code: 'D3130', + value: formatSpec.token + }; } } diff --git a/src/jsonata.js b/src/jsonata.js index b43355b0..7cebe55e 100644 --- a/src/jsonata.js +++ b/src/jsonata.js @@ -1970,7 +1970,7 @@ var jsonata = (function() { "D3110": "The argument of the toMillis function must be an ISO 8601 formatted timestamp. Given {{value}}", "D3120": "Syntax error in expression passed to function eval: {{value}}", "D3121": "Dynamic error evaluating the expression passed to function eval: {{value}}", - "D3130": "Formatting an integer as a sequence starting with {{value}} is not supported by this implementation", + "D3130": "Formatting or parsing an integer as a sequence starting with {{value}} is not supported by this implementation", "D3131": "In a decimal digit pattern, all digits must be from the same decimal group", "D3132": "Unknown component specifier {{value}} in date/time picture string", "D3133": "The 'name' modifier can only be applied to months and days in the date/time picture string, not {{value}}", diff --git a/test/test-suite/groups/function-parseInteger/parseInteger.json b/test/test-suite/groups/function-parseInteger/parseInteger.json index 09eb1218..5729f75b 100644 --- a/test/test-suite/groups/function-parseInteger/parseInteger.json +++ b/test/test-suite/groups/function-parseInteger/parseInteger.json @@ -478,5 +478,13 @@ "expr": "$parseInteger('FZPH', 'A')", "data": {}, "result": 123456 + }, + { + "function": "#parseInteger", + "category": "errors", + "description": "unsupported picture string", + "expr": "$parseInteger('50', '#')", + "data": {}, + "code": "D3130" } ]