From 5cc1de7e4085137187ccd16938ed096ed8dfeafb Mon Sep 17 00:00:00 2001 From: StrayAlien Date: Thu, 15 Aug 2024 22:05:40 +1000 Subject: [PATCH] DMN 1.5 - 1156-range-function (#658) --- .../1156-range-function-test-01.xml | 529 ++++++++++++++++++ .../1156-range-function.dmn | 490 ++++++++++++++++ 2 files changed, 1019 insertions(+) create mode 100644 TestCases/compliance-level-3/1156-range-function/1156-range-function-test-01.xml create mode 100644 TestCases/compliance-level-3/1156-range-function/1156-range-function.dmn diff --git a/TestCases/compliance-level-3/1156-range-function/1156-range-function-test-01.xml b/TestCases/compliance-level-3/1156-range-function/1156-range-function-test-01.xml new file mode 100644 index 000000000..dc83e68e5 --- /dev/null +++ b/TestCases/compliance-level-3/1156-range-function/1156-range-function-test-01.xml @@ -0,0 +1,529 @@ + + + + 1156-range-function.dmn + + + Sanity check something is in range + + + true + + + + + + range(number) instance of range<number> + + + true + + + + + + range(number) instance of range<number> + + + true + + + + + + range(string) instance of range<string> + + + true + + + + + + range(date) instance of range<date> + + + true + + + + + + range(date and time) instance of range<date and time> + + + true + + + + + + range(time) instance of range<time> + + + true + + + + + + range(days and time duration) instance of range<days and time duration> + + + true + + + + + + range(years and months duration) instance of range<years and months duration> + + + true + + + + + + sanity check using a non-literal string expression + + + true + + + + + + range() function result equals FEEL range: [..] + + + true + + + + + + range() function result equals FEEL range: (..] + + + true + + + + + + range() function result equals FEEL range: ]..] + + + true + + + + + + range() function result equals FEEL range: [..) + + + true + + + + + + range() function result equals FEEL range: [..[ + + + true + + + + + + closed start endpoint with no value is not valid and gives null + + + + + + + + + closed end endpoint with no value is not valid and gives null + + + + + + + + + range(string) function equals a unary FEEL range: string + + + true + + + + + + range(date) function equals a unary FEEL range: date + + + true + + + + + + range(date and time) function equals a unary FEEL range: date and time + + + true + + + + + + range(time) function equals a unary FEEL range: time + + + true + + + + + + range(days and time duration) function equals a unary FEEL range: days and time duration + + + true + + + + + + range(years and months duration) function equals a unary FEEL range: years and months duration + + + true + + + + + + will ignore whitespace when parsing + + + true + + + + + + use of date() function literal is permitted + + + true + + + + + + use of date() function as non literal is not permitted and gives null + + + + + + + + + use of date() function as non literal is not permitted and gives null + + 1970-01-01 + + + + + + + + + + use of date and time() function literal is permitted + + + true + + + + + + use of date and time() function as non literal is not permitted and gives null + + + + + + + + + use of date and time() function as non literal is not permitted and gives null + + 1970-01-01T00:00:00 + + + + + + + + + + use of time() function literal is permitted + + + true + + + + + + use of time() function as non literal is not permitted and gives null + + + + + + + + + use of time() function as non literal is not permitted and gives null + + 00:00:00 + + + + + + + + + + use of duration() function literal is permitted + + + true + + + + + + use of duration() function as non literal is not permitted and gives null + + + + + + + + + use of duration() function as non literal is not permitted and gives null + + P1D + + + + + + + + + + named argument + + + true + + + + + + invalidly named argument gives null + + + + + + + + + too many arguments gives null + + + + + + + + + too few arguments gives null + + + + + + + + + invalid argument type gives null + + + + + + + + + empty string gives null + + + + + + + + + whitespace only gives null + + + + + + + + + non-literal argument providing invalid range string gives null + + + + + + + + + a unary range is not a valid literal range string and gives null + + + + + + + + + mismatching endpoint types gives null + + + + + + + + + + date and date and time end points are not equivalent and gives null + + + + + + + + + + date and date and time end points are not equivalent and gives null + + + + + + + + + descending numeric range gives null + + + + + + + + + descending date range gives null + + + + + + + + + descending date time range gives null + + + + + + + + + descending string range gives null + + + + + + + + + descending date duration range gives null + + + + + + + + + descending year duration range gives null + + + + + + + + + descending time range gives null + + + + + + + + + both null endpoints gives null + + + + + + + + + + diff --git a/TestCases/compliance-level-3/1156-range-function/1156-range-function.dmn b/TestCases/compliance-level-3/1156-range-function/1156-range-function.dmn new file mode 100644 index 000000000..bf3010168 --- /dev/null +++ b/TestCases/compliance-level-3/1156-range-function/1156-range-function.dmn @@ -0,0 +1,490 @@ + + + FEEL built-in function 'range(string)' in category conversion functions + + + + + + + + + + 2 in range("[1..3]") + + + + + + + + range("[1..3]") instance of range<number> + + + + + + + + range(string("[1..3]")) instance of range<number> + + + + + + + + range("[\"a\"..\"c\"]") instance of range<string> + + + + + + + + range("[@\"1970-01-01\"..@\"1970-01-02\"]") instance of range<date> + + + + + + + + range("[@\"1970-01-01T00:00:00\"..@\"1970-01-02T00:00:00\"]") instance of range<date and time> + + + + + + + + + range("[@\"00:00:00\"..@\"00:00:00\"]") instance of range<time> + + + + + + + + range("[@\"P1D\"..@\"P2D\"]") instance of range<days and time duration> + + + + + + + + range("[@\"P1Y\"..@\"P2Y\"]") instance of range<years and months duration> + + + + + + + + 2 in range(string("[1..3]")) + + + + + + + + range("[18..21]") = [18..21] + + + + + + + + range("(18..21]") = (18..21] + + + + + + + + range("]18..21]") = ]18..21] + + + + + + + + range("[18..21)") = [18..21) + + + + + + + + range("[18..21[") = [18..21[ + + + + + + + + range("[..2]") + + + + + + + + range("[1..]") + + + + + + + + range("[\"a\"..\"c\"]") = ["a".."c"] + + + + + + + + range("[@\"1970-01-01\"..@\"1970-01-02\"]") = [@"1970-01-01"..@"1970-01-02"] + + + + + + + + range("[@\"1970-01-01T00:00:00\"..@\"1970-01-02T00:00:00\"]") = + [@"1970-01-01T00:00:00"..@"1970-01-02T00:00:00"] + + + + + + + + + range("[@\"00:00:00\"..@\"00:00:00\"]") = [@"00:00:00"..@"00:00:00"] + + + + + + + + range("[@\"P1D\"..@\"P2D\"]") = [@"P1D"..@"P2D"] + + + + + + + + range("[@\"P1Y\"..@\"P2Y\"]") = [@"P1Y"..@"P2Y"] + + + + + + + + range(" [ 1 .. 3 ] ") = [1..3] + + + + + + + + range("[date(\"1970-01-01\")..date(\"1970-01-02\")]") = [date("1970-01-01")..date("1970-01-02")] + + + + + + + + + + range("[date(string(\"1970-01-01\"))..date(\"1970-01-02\")]") + + + + + + + + + + + + range("[date(input_001)..date(\"1970-01-02\")]") + + + + + + + + range("[date and time(\"1970-01-01T00:00:00\")..@\"1970-01-02T00:00:00\"]") = + [@"1970-01-01T00:00:00"..@"1970-01-02T00:00:00"] + + + + + + + + + + range("[date and time(string(\"1970-01-01T00:00:00\"))..@\"1970-01-02T00:00:00\"]") + + + + + + + + + + + + range("[date and time(input_001)..@\"1970-01-02T00:00:00\"]") + + + + + + + + range("[time(\"00:00:00\")..@\"00:00:00\"]") = [@"00:00:00"..@"00:00:00"] + + + + + + + + + range("[time(string(\"00:00:00\"))..@\"00:00:00\"]") + + + + + + + + + + + + range("[time(input_001)..@\"00:00:00\"]") + + + + + + + + range("[duration(\"P1D\")..@\"P2D\"]") = [@"P1D"..@"P2D"] + + + + + + + + + range("[duration(string(\"P1D\"))..@\"P2D\"]") + + + + + + + + + + + + range("[duration(input_001)..@\"P2D\"]") + + + + + + + + range(from: "[1..3]") = [1..3] + + + + + + + + range(fron: "[1..3]") + + + + + + + + range("[1..3]", "foo") + + + + + + + + range() + + + + + + + + range([1..3]) + + + + + + + + range("") + + + + + + + + range(" ") + + + + + + + + range(string("")) + + + + + + + + range(">=10") + + + + + + + + range("[1..\"b\"]") + + + + + + + + range("[@\"1970-01-01\"..@\"1970-01-02T00:00:00\"]") + + + + + + + + range("[@\"1970-01-01T00:00:00\"..@\"1970-01-02\"]") + + + + + + + + range("[3..1]") + + + + + + + + range("[@\"1970-01-02\"..@\"1970-01-01\"]") + + + + + + + + range("[@\"1970-01-02T00:00:00\"..@\"1970-01-01T00:00:00\"]") + + + + + + + + range("[\"z\"..\"a\"]") + + + + + + + + range("[@\"P2D\"..@\"P1D\"]") + + + + + + + + range("[@\"P2Y\"..@\"P1Y\"]") + + + + + + + + range("[@\"02:00:00\"..@\"01:00:00\"]") + + + + + + + + range("[null..null]") + + + + + + +