Files
blockly/tests/generators/logic.xml

792 lines
37 KiB
XML

<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="unittest_main" x="-4" y="-12">
<statement name="DO">
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">True</title>
<title name="EXPECTED">TRUE</title>
<value name="ACTUAL">
<block type="logic_boolean">
<title name="BOOL">TRUE</title>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">False</title>
<title name="EXPECTED">FALSE</title>
<value name="ACTUAL">
<block type="logic_boolean">
<title name="BOOL">FALSE</title>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">Not true</title>
<title name="EXPECTED">TRUE</title>
<value name="ACTUAL">
<block type="logic_negate" inline="false">
<value name="BOOL">
<block type="logic_boolean">
<title name="BOOL">FALSE</title>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">Not false</title>
<title name="EXPECTED">FALSE</title>
<value name="ACTUAL">
<block type="logic_negate" inline="false">
<value name="BOOL">
<block type="logic_boolean">
<title name="BOOL">TRUE</title>
</block>
</value>
</block>
</value>
<next>
<block type="procedures_callnoreturn">
<mutation name="test if"></mutation>
<next>
<block type="procedures_callnoreturn">
<mutation name="test equalities"></mutation>
<next>
<block type="procedures_callnoreturn">
<mutation name="test and"></mutation>
<next>
<block type="procedures_callnoreturn">
<mutation name="test or"></mutation>
<next>
<block type="procedures_callnoreturn">
<mutation name="test ternary"></mutation>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" x="385" y="-3">
<mutation></mutation>
<title name="NAME">test if</title>
<statement name="STACK">
<block type="controls_if" inline="false">
<value name="IF0">
<block type="logic_boolean">
<title name="BOOL">FALSE</title>
</block>
</value>
<statement name="DO0">
<block type="unittest_fail">
<title name="MESSAGE">if false</title>
</block>
</statement>
<next>
<block type="variables_set" inline="false">
<title name="VAR">ok</title>
<value name="VALUE">
<block type="logic_boolean">
<title name="BOOL">FALSE</title>
</block>
</value>
<next>
<block type="controls_if" inline="false">
<value name="IF0">
<block type="logic_boolean">
<title name="BOOL">TRUE</title>
</block>
</value>
<statement name="DO0">
<block type="variables_set" inline="false">
<title name="VAR">ok</title>
<value name="VALUE">
<block type="logic_boolean">
<title name="BOOL">TRUE</title>
</block>
</value>
</block>
</statement>
<next>
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">if true</title>
<title name="EXPECTED">TRUE</title>
<value name="ACTUAL">
<block type="variables_get">
<title name="VAR">ok</title>
</block>
</value>
<next>
<block type="variables_set" inline="false">
<title name="VAR">ok</title>
<value name="VALUE">
<block type="logic_boolean">
<title name="BOOL">FALSE</title>
</block>
</value>
<next>
<block type="controls_if" inline="false">
<mutation else="1"></mutation>
<value name="IF0">
<block type="logic_boolean">
<title name="BOOL">FALSE</title>
</block>
</value>
<statement name="DO0">
<block type="unittest_fail">
<title name="MESSAGE">if/else false</title>
</block>
</statement>
<statement name="ELSE">
<block type="variables_set" inline="false">
<title name="VAR">ok</title>
<value name="VALUE">
<block type="logic_boolean">
<title name="BOOL">TRUE</title>
</block>
</value>
</block>
</statement>
<next>
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">if/else false</title>
<title name="EXPECTED">TRUE</title>
<value name="ACTUAL">
<block type="variables_get">
<title name="VAR">ok</title>
</block>
</value>
<next>
<block type="variables_set" inline="false">
<title name="VAR">ok</title>
<value name="VALUE">
<block type="logic_boolean">
<title name="BOOL">FALSE</title>
</block>
</value>
<next>
<block type="controls_if" inline="false">
<mutation else="1"></mutation>
<value name="IF0">
<block type="logic_boolean">
<title name="BOOL">TRUE</title>
</block>
</value>
<statement name="DO0">
<block type="variables_set" inline="false">
<title name="VAR">ok</title>
<value name="VALUE">
<block type="logic_boolean">
<title name="BOOL">TRUE</title>
</block>
</value>
</block>
</statement>
<statement name="ELSE">
<block type="unittest_fail">
<title name="MESSAGE">if/else true</title>
</block>
</statement>
<next>
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">if/else true</title>
<title name="EXPECTED">TRUE</title>
<value name="ACTUAL">
<block type="variables_get">
<title name="VAR">ok</title>
</block>
</value>
<next>
<block type="variables_set" inline="false">
<title name="VAR">ok</title>
<value name="VALUE">
<block type="logic_boolean">
<title name="BOOL">FALSE</title>
</block>
</value>
<next>
<block type="controls_if" inline="false">
<mutation elseif="2" else="1"></mutation>
<value name="IF0">
<block type="logic_boolean">
<title name="BOOL">FALSE</title>
</block>
</value>
<statement name="DO0">
<block type="unittest_fail">
<title name="MESSAGE">elseif 1</title>
</block>
</statement>
<value name="IF1">
<block type="logic_boolean">
<title name="BOOL">TRUE</title>
</block>
</value>
<statement name="DO1">
<block type="variables_set" inline="false">
<title name="VAR">ok</title>
<value name="VALUE">
<block type="logic_boolean">
<title name="BOOL">TRUE</title>
</block>
</value>
</block>
</statement>
<value name="IF2">
<block type="logic_boolean">
<title name="BOOL">TRUE</title>
</block>
</value>
<statement name="DO2">
<block type="unittest_fail">
<title name="MESSAGE">elseif 2</title>
</block>
</statement>
<statement name="ELSE">
<block type="unittest_fail">
<title name="MESSAGE">elseif 3</title>
</block>
</statement>
<next>
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">elseif 4</title>
<title name="EXPECTED">TRUE</title>
<value name="ACTUAL">
<block type="variables_get">
<title name="VAR">ok</title>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" x="-7" y="384">
<mutation></mutation>
<title name="NAME">test equalities</title>
<statement name="STACK">
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">Equal yes</title>
<title name="EXPECTED">TRUE</title>
<value name="ACTUAL">
<block type="logic_compare" inline="true">
<title name="OP">EQ</title>
<value name="A">
<block type="math_number">
<title name="NUM">2</title>
</block>
</value>
<value name="B">
<block type="math_number">
<title name="NUM">2</title>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">Equal no</title>
<title name="EXPECTED">FALSE</title>
<value name="ACTUAL">
<block type="logic_compare" inline="true">
<title name="OP">EQ</title>
<value name="A">
<block type="math_number">
<title name="NUM">3</title>
</block>
</value>
<value name="B">
<block type="math_number">
<title name="NUM">4</title>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">Not equal yes</title>
<title name="EXPECTED">TRUE</title>
<value name="ACTUAL">
<block type="logic_compare" inline="true">
<title name="OP">NEQ</title>
<value name="A">
<block type="math_number">
<title name="NUM">5</title>
</block>
</value>
<value name="B">
<block type="math_number">
<title name="NUM">6</title>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">Not equal no</title>
<title name="EXPECTED">FALSE</title>
<value name="ACTUAL">
<block type="logic_compare" inline="true">
<title name="OP">EQ</title>
<value name="A">
<block type="math_number">
<title name="NUM">3</title>
</block>
</value>
<value name="B">
<block type="math_number">
<title name="NUM">4</title>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">Smaller yes</title>
<title name="EXPECTED">TRUE</title>
<value name="ACTUAL">
<block type="logic_compare" inline="true">
<title name="OP">LT</title>
<value name="A">
<block type="math_number">
<title name="NUM">5</title>
</block>
</value>
<value name="B">
<block type="math_number">
<title name="NUM">6</title>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">Smaller no</title>
<title name="EXPECTED">FALSE</title>
<value name="ACTUAL">
<block type="logic_compare" inline="true">
<title name="OP">LT</title>
<value name="A">
<block type="math_number">
<title name="NUM">7</title>
</block>
</value>
<value name="B">
<block type="math_number">
<title name="NUM">7</title>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">Greater yes</title>
<title name="EXPECTED">TRUE</title>
<value name="ACTUAL">
<block type="logic_compare" inline="true">
<title name="OP">GT</title>
<value name="A">
<block type="math_number">
<title name="NUM">9</title>
</block>
</value>
<value name="B">
<block type="math_number">
<title name="NUM">8</title>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">Greater no</title>
<title name="EXPECTED">FALSE</title>
<value name="ACTUAL">
<block type="logic_compare" inline="true">
<title name="OP">GT</title>
<value name="A">
<block type="math_number">
<title name="NUM">10</title>
</block>
</value>
<value name="B">
<block type="math_number">
<title name="NUM">10</title>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">Smaller-equal yes</title>
<title name="EXPECTED">TRUE</title>
<value name="ACTUAL">
<block type="logic_compare" inline="true">
<title name="OP">LTE</title>
<value name="A">
<block type="math_number">
<title name="NUM">11</title>
</block>
</value>
<value name="B">
<block type="math_number">
<title name="NUM">11</title>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">Smaller-equal no</title>
<title name="EXPECTED">FALSE</title>
<value name="ACTUAL">
<block type="logic_compare" inline="true">
<title name="OP">LTE</title>
<value name="A">
<block type="math_number">
<title name="NUM">13</title>
</block>
</value>
<value name="B">
<block type="math_number">
<title name="NUM">12</title>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">Greater-equal yes</title>
<title name="EXPECTED">TRUE</title>
<value name="ACTUAL">
<block type="logic_compare" inline="true">
<title name="OP">GTE</title>
<value name="A">
<block type="math_number">
<title name="NUM">14</title>
</block>
</value>
<value name="B">
<block type="math_number">
<title name="NUM">14</title>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">Greater-equal no</title>
<title name="EXPECTED">FALSE</title>
<value name="ACTUAL">
<block type="logic_compare" inline="true">
<title name="OP">GTE</title>
<value name="A">
<block type="math_number">
<title name="NUM">15</title>
</block>
</value>
<value name="B">
<block type="math_number">
<title name="NUM">16</title>
</block>
</value>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" x="-5" y="1200">
<mutation></mutation>
<title name="NAME">test or</title>
<statement name="STACK">
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">Or true/true</title>
<title name="EXPECTED">TRUE</title>
<value name="ACTUAL">
<block type="logic_operation" inline="true">
<title name="OP">OR</title>
<value name="A">
<block type="logic_boolean">
<title name="BOOL">TRUE</title>
</block>
</value>
<value name="B">
<block type="logic_boolean">
<title name="BOOL">TRUE</title>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">Or false/true</title>
<title name="EXPECTED">TRUE</title>
<value name="ACTUAL">
<block type="logic_operation" inline="true">
<title name="OP">OR</title>
<value name="A">
<block type="logic_boolean">
<title name="BOOL">FALSE</title>
</block>
</value>
<value name="B">
<block type="logic_boolean">
<title name="BOOL">TRUE</title>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">Or true/false</title>
<title name="EXPECTED">TRUE</title>
<value name="ACTUAL">
<block type="logic_operation" inline="true">
<title name="OP">OR</title>
<value name="A">
<block type="logic_boolean">
<title name="BOOL">TRUE</title>
</block>
</value>
<value name="B">
<block type="logic_boolean">
<title name="BOOL">FALSE</title>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">Or false/false</title>
<title name="EXPECTED">FALSE</title>
<value name="ACTUAL">
<block type="logic_operation" inline="true">
<title name="OP">OR</title>
<value name="A">
<block type="logic_boolean">
<title name="BOOL">FALSE</title>
</block>
</value>
<value name="B">
<block type="logic_boolean">
<title name="BOOL">FALSE</title>
</block>
</value>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" x="385" y="1208">
<mutation></mutation>
<title name="NAME">test and</title>
<statement name="STACK">
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">And true/true</title>
<title name="EXPECTED">TRUE</title>
<value name="ACTUAL">
<block type="logic_operation" inline="true">
<title name="OP">AND</title>
<value name="A">
<block type="logic_boolean">
<title name="BOOL">TRUE</title>
</block>
</value>
<value name="B">
<block type="logic_boolean">
<title name="BOOL">TRUE</title>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">And false/true</title>
<title name="EXPECTED">FALSE</title>
<value name="ACTUAL">
<block type="logic_operation" inline="true">
<title name="OP">AND</title>
<value name="A">
<block type="logic_boolean">
<title name="BOOL">FALSE</title>
</block>
</value>
<value name="B">
<block type="logic_boolean">
<title name="BOOL">TRUE</title>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">And true/false</title>
<title name="EXPECTED">FALSE</title>
<value name="ACTUAL">
<block type="logic_operation" inline="true">
<title name="OP">AND</title>
<value name="A">
<block type="logic_boolean">
<title name="BOOL">TRUE</title>
</block>
</value>
<value name="B">
<block type="logic_boolean">
<title name="BOOL">FALSE</title>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<title name="MESSAGE">And false/false</title>
<title name="EXPECTED">FALSE</title>
<value name="ACTUAL">
<block type="logic_operation" inline="true">
<title name="OP">AND</title>
<value name="A">
<block type="logic_boolean">
<title name="BOOL">FALSE</title>
</block>
</value>
<value name="B">
<block type="logic_boolean">
<title name="BOOL">FALSE</title>
</block>
</value>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" x="3" y="1527">
<mutation></mutation>
<title name="NAME">test ternary</title>
<statement name="STACK">
<block type="unittest_assertequals" inline="false">
<title name="MESSAGE">if true</title>
<value name="ACTUAL">
<block type="logic_ternary" inline="true">
<value name="IF">
<block type="logic_boolean">
<title name="BOOL">TRUE</title>
</block>
</value>
<value name="THEN">
<block type="math_number">
<title name="NUM">42</title>
</block>
</value>
<value name="ELSE">
<block type="math_number">
<title name="NUM">99</title>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<title name="NUM">42</title>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<title name="MESSAGE">if true</title>
<value name="ACTUAL">
<block type="logic_ternary" inline="true">
<value name="IF">
<block type="logic_boolean">
<title name="BOOL">FALSE</title>
</block>
</value>
<value name="THEN">
<block type="math_number">
<title name="NUM">42</title>
</block>
</value>
<value name="ELSE">
<block type="math_number">
<title name="NUM">99</title>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<title name="NUM">99</title>
</block>
</value>
</block>
</next>
</block>
</statement>
</block>
</xml>