Skip to content

Commit

Permalink
1151-boxed-filter
Browse files Browse the repository at this point in the history
  • Loading branch information
StrayAlien committed Jun 23, 2023
1 parent 5d1bd38 commit 24212fc
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?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>1151-boxed-filter.dmn</modelName>

<testCase id="001">
<description>Will filter 'in' values based on 'match' expression</description>
<resultNode name="decision001" type="decision">
<expected>
<list>
<item>
<value xsi:type="xsd:decimal">3</value>
</item>
<item>
<value xsi:type="xsd:decimal">4</value>
</item>
<item>
<value xsi:type="xsd:decimal">5</value>
</item>
</list>
</expected>
</resultNode>
</testCase>

<testCase id="002">
<!-- spec says MUST return a collection, so no singleton list coercion -->
<description>Will return an empty list when no values match</description>
<resultNode name="decision002" type="decision">
<expected>
<list>
</list>
</expected>
</resultNode>
</testCase>

<testCase id="003">
<description>Will return null when 'in' expression is not a list</description>
<resultNode name="decision003" type="decision" errorResult="true">
<expected>
<value xsi:nil="true"/>
</expected>
</resultNode>
</testCase>

<testCase id="004">
<description>Will return null when 'match' does not return boolean</description>
<resultNode name="decision004" type="decision" errorResult="true">
<expected>
<value xsi:nil="true"/>
</expected>
</resultNode>
</testCase>

<testCase id="005">
<description>Will return null when any 'match' does not return boolean</description>
<resultNode name="decision005" type="decision" errorResult="true">
<expected>
<value xsi:nil="true"/>
</expected>
</resultNode>
</testCase>

<testCase id="006">
<description>Will not coerce single value 'in' expression to list - and return null</description>
<resultNode name="decision006" type="decision" errorResult="true">
<expected>
<value xsi:nil="true"/>
</expected>
</resultNode>
</testCase>

</testCases>
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions namespace="http://www.montera.com.au/spec/DMN/1151-boxed-filter"
name="1151-boxed-filter"
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>Boxed Filter Expression</description>

<decision name="decision001" id="_decision001">
<variable name="decision001"/>
<filter>
<in><literalExpression><text>[1,2,3,4,5]</text></literalExpression></in>
<match><literalExpression><text>item >= 3</text></literalExpression></match>
</filter>
</decision>

<decision name="decision002" id="_decision002">
<variable name="decision002"/>
<filter>
<in><literalExpression><text>[1,2,3,4,5]</text></literalExpression></in>
<match><literalExpression><text>item > 5</text></literalExpression></match>
</filter>
</decision>

<decision name="decision003" id="_decision003">
<variable name="decision003"/>
<filter>
<in><literalExpression><text>"not a list"</text></literalExpression></in>
<match><literalExpression><text>true</text></literalExpression></match>
</filter>
</decision>

<decision name="decision004" id="_decision004">
<variable name="decision004"/>
<filter>
<in><literalExpression><text>[1,2,3,4,5]</text></literalExpression></in>
<match><literalExpression><text>"not a boolean"</text></literalExpression></match>
</filter>
</decision>

<decision name="decision005" id="_decision005">
<variable name="decision005"/>
<filter>
<in><literalExpression><text>[1,2,3,4,5]</text></literalExpression></in>
<match><literalExpression><text>if (item &lt;= 3) then true else "not a boolean"</text></literalExpression></match>
</filter>
</decision>

<decision name="decision006" id="_decision006">
<variable name="decision006"/>
<filter>
<in><literalExpression><text>1</text></literalExpression></in>
<match><literalExpression><text>item >= 3</text></literalExpression></match>
</filter>
</decision>

</definitions>

0 comments on commit 24212fc

Please sign in to comment.