Skip to content

Commit

Permalink
DMN 1.4 - 1142-feel-round-down-function (#593)
Browse files Browse the repository at this point in the history
* 1142-feel-round-down-function

* commented out decimal and negative range tests.

* commented out error test for func usage with no scale

* commented out test 11b as per discussion.
  • Loading branch information
StrayAlien authored Nov 16, 2023
1 parent d9e24ad commit 1308d95
Show file tree
Hide file tree
Showing 2 changed files with 370 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Contributed to DMN TCK by StrayAlien -->
<testCases xmlns="http://www.omg.org/spec/DMN/20160719/testcase"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=""
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<modelName>1142-feel-round-down-function.dmn</modelName>
<labels>
<label>Compliance Level 3</label>
<label>Data Type: Number</label>
<label>FEEL Functions: number</label>
</labels>

<testCase id="001">
<description>Will round to integer</description>
<resultNode name="decision001" type="decision">
<expected>
<value xsi:type="xsd:decimal">5</value>
</expected>
</resultNode>
</testCase>

<testCase id="002">
<description>Will round to negative to integer</description>
<resultNode name="decision002" type="decision">
<expected>
<value xsi:type="xsd:decimal">-5</value>
</expected>
</resultNode>
</testCase>

<testCase id="003">
<description>Will round positive to scale</description>
<resultNode name="decision003" type="decision">
<expected>
<value xsi:type="xsd:decimal">1.12</value>
</expected>
</resultNode>
</testCase>

<testCase id="004">
<description>Will round negative to scale</description>
<resultNode name="decision004" type="decision">
<expected>
<value xsi:type="xsd:decimal">-1.12</value>
</expected>
</resultNode>
</testCase>

<testCase id="005">
<description>No params gives null</description>
<resultNode errorResult="true" name="decision005" type="decision">
<expected>
<value xsi:nil="true"/>
</expected>
</resultNode>
</testCase>

<!-- commented out pending RTF. https://github.com/dmn-tck/tck/pull/592#issuecomment-1769761733 -->
<!--
<testCase id="006">
<description>Missing scale param gives null</description>
<resultNode errorResult="true" name="decision006" type="decision">
<expected>
<value xsi:nil="true"/>
</expected>
</resultNode>
</testCase>
-->

<testCase id="007">
<description>null number gives null</description>
<resultNode errorResult="true" name="decision007" type="decision">
<expected>
<value xsi:nil="true"/>
</expected>
</resultNode>
</testCase>

<testCase id="008">
<description>null scale gives null</description>
<resultNode errorResult="true" name="decision008" type="decision">
<expected>
<value xsi:nil="true"/>
</expected>
</resultNode>
</testCase>

<testCase id="009">
<description>Too many params gives null</description>
<resultNode errorResult="true" name="decision009" type="decision">
<expected>
<value xsi:nil="true"/>
</expected>
</resultNode>
</testCase>

<testCase id="010">
<description>named params</description>
<resultNode name="decision010" type="decision">
<expected>
<value xsi:type="xsd:decimal">5</value>
</expected>
</resultNode>
</testCase>

<testCase id="011_a">
<description>Missing 'n' named param gives null </description>
<resultNode errorResult="true" name="decision011_a" type="decision">
<expected>
<value xsi:nil="true"/>
</expected>
</resultNode>
</testCase>

<!-- comment pending RTF. https://github.com/dmn-tck/tck/pull/592#issuecomment-1769761733 -->
<!--
<testCase id="011_b">
<description>Missing 'scale' named param gives null </description>
<resultNode errorResult="true" name="decision011_b" type="decision">
<expected>
<value xsi:nil="true"/>
</expected>
</resultNode>
</testCase>
-->

<testCase id="012">
<description>Incorrect named param gives null</description>
<resultNode errorResult="true" name="decision012" type="decision">
<expected>
<value xsi:nil="true"/>
</expected>
</resultNode>
</testCase>

<testCase id="013">
<description>Incorrect 'n' type gives null</description>
<resultNode errorResult="true" name="decision013" type="decision">
<expected>
<value xsi:nil="true"/>
</expected>
</resultNode>
</testCase>

<testCase id="014">
<description>Incorrect 'scale' type gives null</description>
<resultNode errorResult="true" name="decision014" type="decision">
<expected>
<value xsi:nil="true"/>
</expected>
</resultNode>
</testCase>

<!-- comment decimal scale tests for now, subject to clarification -->
<!--
<testCase id="015">
<description>Non integer scale param gives null</description>
<resultNode errorResult="true" name="decision015" type="decision">
<expected>
<value xsi:nil="true"/>
</expected>
</resultNode>
</testCase>
-->

<!--
what is expected for a negative scale?
<testCase id="016_a">
<description>Min scale is −6111</description>
<resultNode errorResult="true" name="decision016_a" type="decision">
<expected>
<value xsi:type="xsd:decimal">5.5</value>
</expected>
</resultNode>
</testCase>
-->

<testCase id="016_b">
<description>less than min scale gives null</description>
<resultNode errorResult="true" name="decision016_b" type="decision">
<expected>
<value xsi:nil="true"/>
</expected>
</resultNode>
</testCase>

<testCase id="017_a">
<description>Max scale is 6176</description>
<resultNode name="decision017_a" type="decision">
<expected>
<value xsi:type="xsd:decimal">5.5</value>
</expected>
</resultNode>
</testCase>

<testCase id="017_b">
<description>Greater than max scale gives null</description>
<resultNode errorResult="true" name="decision017_b" type="decision">
<expected>
<value xsi:nil="true"/>
</expected>
</resultNode>
</testCase>

</testCases>
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions namespace="http://www.montera.com.au/spec/DMN/1142-feel-round-down-function"
name="1142-feel-round-down-function"
id="_i9fboPUUEeesLuP4RHs4vA"
xmlns="https://www.omg.org/spec/DMN/20211108/MODEL/"
xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/"
xmlns:dmndi="https://www.omg.org/spec/DMN/20191111/DMNDI/"
xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<description>FEEL built-in function 'round down(n,scale)' in category number functions</description>

<decision name="decision001" id="_decision001">
<variable name="decision001"/>
<literalExpression>
<text>round down(5.5, 0)</text>
</literalExpression>
</decision>

<decision name="decision002" id="_decision002">
<variable name="decision002"/>
<literalExpression>
<text>round down(-5.5, 0)</text>
</literalExpression>
</decision>

<decision name="decision003" id="_decision003">
<variable name="decision003"/>
<literalExpression>
<text>round down(1.121, 2)</text>
</literalExpression>
</decision>

<decision name="decision004" id="_decision004">
<variable name="decision004"/>
<literalExpression>
<text>round down(-1.126, 2)</text>
</literalExpression>
</decision>

<decision name="decision005" id="_decision005">
<variable name="decision005"/>
<literalExpression>
<text>round down()</text>
</literalExpression>
</decision>

<!-- commented out pending RTF. https://github.com/dmn-tck/tck/pull/592#issuecomment-1769761733 -->
<!--
<decision name="decision006" id="_decision006">
<variable name="decision006"/>
<literalExpression>
<text>round down(1234)</text>
</literalExpression>
</decision>
-->

<decision name="decision007" id="_decision007">
<variable name="decision007"/>
<literalExpression>
<text>round down(null,0)</text>
</literalExpression>
</decision>

<decision name="decision008" id="_decision008">
<variable name="decision008"/>
<literalExpression>
<text>round down(1234,null)</text>
</literalExpression>
</decision>

<decision name="decision009" id="_decision009">
<variable name="decision009"/>
<literalExpression>
<text>round down(1234.12,1,2)</text>
</literalExpression>
</decision>

<decision name="decision010" id="_decision010">
<variable name="decision010"/>
<literalExpression>
<text>round down(n:5.5,scale:0)</text>
</literalExpression>
</decision>

<decision name="decision011_a" id="_decision011_a">
<variable name="decision011_a"/>
<literalExpression>
<text>round down(scale:0)</text>
</literalExpression>
</decision>

<!-- comment pending RTF. https://github.com/dmn-tck/tck/pull/592#issuecomment-1769761733 -->
<!--
<decision name="decision011_b" id="_decision011_b">
<variable name="decision011_b"/>
<literalExpression>
<text>round down(n:5.5)</text>
</literalExpression>
</decision>
-->

<decision name="decision012" id="_decision012">
<variable name="decision012"/>
<literalExpression>
<text>round down(n:5.5,scale:0,foo:123)</text>
</literalExpression>
</decision>

<decision name="decision013" id="_decision013">
<variable name="decision013"/>
<literalExpression>
<text>round down("123", 0)</text>
</literalExpression>
</decision>

<decision name="decision014" id="_decision014">
<variable name="decision014"/>
<literalExpression>
<text>round down(5.5, "0")</text>
</literalExpression>
</decision>

<!-- comment decimal scale tests for now, subject to clarification -->
<!--
<decision name="decision015" id="_decision015">
<variable name="decision015"/>
<literalExpression>
<text>round down(5.5, 1.1)</text>
</literalExpression>
</decision>
-->

<!--
<decision name="decision016_a" id="_decision016_a">
<variable name="decision016_a"/>
<literalExpression>
<text>round down(5.5, -6111)</text>
</literalExpression>
</decision>
-->

<decision name="decision016_b" id="_decision016_b">
<variable name="decision016_b"/>
<literalExpression>
<text>round down(5.5, (-6111 - 1))</text>
</literalExpression>
</decision>

<decision name="decision017_a" id="_decision017_a">
<variable name="decision017_a"/>
<literalExpression>
<text>round down(5.5, 6176)</text>
</literalExpression>
</decision>

<decision name="decision017_b" id="_decision017_b">
<variable name="decision017_b"/>
<literalExpression>
<text>round down(5.5, (6176 + 1))</text>
</literalExpression>
</decision>

</definitions>

0 comments on commit 1308d95

Please sign in to comment.