Files
blockly/tests/generators/math.xml
Richard Doherty a31003fab9 fix(generators): Fix an operator precedence issue in the math_number_property generators to remove extra parentheses (#5685)
* Fixed issue where the mathIsPrime function inserted extra parenthesis around certain blocks.
* Added tests to generated JS
* Updated generated code in Lua
* Updated Generated code for tests in Dart
* Updated generated code for tests in PHP
* Updated generated code for tests in Python
* Also changed var to const and let.

Co-authored-by: jeremyjacob123 <43049656+jeremyjacob123@users.noreply.github.com>
Co-authored-by: LouisCatala <86700310+LouisCatala@users.noreply.github.com>
Co-authored-by: jeremyjacob123 <43049656+jeremyjacob123@users.noreply.github.com>
2022-01-27 15:54:05 +00:00

2078 lines
94 KiB
XML

<xml xmlns="https://developers.google.com/blockly/xml">
<variables>
<variable>varToChange</variable>
<variable>rand</variable>
</variables>
<block type="unittest_main" x="13" y="13">
<field name="SUITE_NAME">Math</field>
<statement name="DO">
<block type="procedures_callnoreturn">
<mutation name="test arithmetic"></mutation>
<next>
<block type="procedures_callnoreturn">
<mutation name="test single"></mutation>
<next>
<block type="procedures_callnoreturn">
<mutation name="test trig"></mutation>
<next>
<block type="procedures_callnoreturn">
<mutation name="test constant"></mutation>
<next>
<block type="procedures_callnoreturn">
<mutation name="test change"></mutation>
<next>
<block type="procedures_callnoreturn">
<mutation name="test number properties"></mutation>
<next>
<block type="procedures_callnoreturn">
<mutation name="test round"></mutation>
<next>
<block type="procedures_callnoreturn">
<mutation name="test operations on list"></mutation>
<next>
<block type="procedures_callnoreturn">
<mutation name="test constraint"></mutation>
<next>
<block type="procedures_callnoreturn">
<mutation name="test mod"></mutation>
<next>
<block type="procedures_callnoreturn">
<mutation name="test random integer"></mutation>
<next>
<block type="procedures_callnoreturn">
<mutation name="test random fraction"></mutation>
<next>
<block type="procedures_callnoreturn">
<mutation name="test atan2"></mutation>
</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="13" y="388">
<field name="NAME">test single</field>
<comment pinned="false" h="80" w="160">Tests the "single" block.</comment>
<statement name="STACK">
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">sqrt</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_single" inline="false">
<field name="OP">ROOT</field>
<value name="NUM">
<block type="math_number">
<field name="NUM">25</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">5</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">abs</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_single" inline="false">
<field name="OP">ABS</field>
<value name="NUM">
<block type="math_number">
<field name="NUM">-25</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">25</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">negate</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_single" inline="false">
<field name="OP">NEG</field>
<value name="NUM">
<block type="math_number">
<field name="NUM">-25</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">25</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">ln</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_single" inline="false">
<field name="OP">LN</field>
<value name="NUM">
<block type="math_number">
<field name="NUM">1</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">log10</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_single" inline="false">
<field name="OP">LOG10</field>
<value name="NUM">
<block type="math_number">
<field name="NUM">100</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">2</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">exp</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_single" inline="false">
<field name="OP">EXP</field>
<value name="NUM">
<block type="math_number">
<field name="NUM">2</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">7.38905609893065</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">power10</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_single" inline="false">
<field name="OP">POW10</field>
<value name="NUM">
<block type="math_number">
<field name="NUM">2</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">100</field>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" x="13" y="1013">
<field name="NAME">test arithmetic</field>
<comment pinned="false" h="80" w="272">Tests the "arithmetic" block for all operations and checks parenthesis are properly generated for different orders.</comment>
<statement name="STACK">
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">add</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_arithmetic">
<field name="OP">ADD</field>
<value name="A">
<block type="math_number">
<field name="NUM">1</field>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">2</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">3</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">subtract</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_arithmetic">
<field name="OP">MINUS</field>
<value name="A">
<block type="math_number">
<field name="NUM">1</field>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">2</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">-1</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">subtract order with add</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_arithmetic">
<field name="OP">MINUS</field>
<value name="A">
<block type="math_number">
<field name="NUM">1</field>
</block>
</value>
<value name="B">
<block type="math_arithmetic">
<field name="OP">ADD</field>
<value name="A">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">2</field>
</block>
</value>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">-1</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">subtract order with subtract</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_arithmetic">
<field name="OP">MINUS</field>
<value name="A">
<block type="math_number">
<field name="NUM">1</field>
</block>
</value>
<value name="B">
<block type="math_arithmetic">
<field name="OP">MINUS</field>
<value name="A">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">2</field>
</block>
</value>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">3</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">multiply</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_arithmetic">
<field name="OP">MULTIPLY</field>
<value name="A">
<block type="math_number">
<field name="NUM">4</field>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">2.5</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">10</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">multiply order</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_arithmetic">
<field name="OP">MULTIPLY</field>
<value name="A">
<block type="math_number">
<field name="NUM">4</field>
</block>
</value>
<value name="B">
<block type="math_arithmetic">
<field name="OP">ADD</field>
<value name="A">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">2.5</field>
</block>
</value>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">10</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">divide</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_arithmetic">
<field name="OP">DIVIDE</field>
<value name="A">
<block type="math_number">
<field name="NUM">8.2</field>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">-5</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">-1.64</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">divide order</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_arithmetic">
<field name="OP">DIVIDE</field>
<value name="A">
<block type="math_number">
<field name="NUM">8.2</field>
</block>
</value>
<value name="B">
<block type="math_arithmetic">
<field name="OP">ADD</field>
<value name="A">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">-5</field>
</block>
</value>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">-1.64</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">power</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_arithmetic">
<field name="OP">POWER</field>
<value name="A">
<block type="math_number">
<field name="NUM">10</field>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">4</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">10000</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">power order</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_arithmetic">
<field name="OP">POWER</field>
<value name="A">
<block type="math_number">
<field name="NUM">10</field>
</block>
</value>
<value name="B">
<block type="math_arithmetic">
<field name="OP">ADD</field>
<value name="A">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">4</field>
</block>
</value>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">10000</field>
</block>
</value>
</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="13" y="2013">
<field name="NAME">test trig</field>
<comment pinned="false" h="80" w="160">Tests the "trig" block.</comment>
<statement name="STACK">
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">sin</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_trig" inline="false">
<field name="OP">SIN</field>
<value name="NUM">
<block type="math_number">
<field name="NUM">90</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">1</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">cos</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_trig" inline="false">
<field name="OP">COS</field>
<value name="NUM">
<block type="math_number">
<field name="NUM">180</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">-1</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">tan</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_trig" inline="false">
<field name="OP">TAN</field>
<value name="NUM">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">asin</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_trig" inline="false">
<field name="OP">ASIN</field>
<value name="NUM">
<block type="math_number">
<field name="NUM">-1</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">-90</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">acos</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_trig" inline="false">
<field name="OP">ACOS</field>
<value name="NUM">
<block type="math_number">
<field name="NUM">1</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">atan</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_trig" inline="false">
<field name="OP">ATAN</field>
<value name="NUM">
<block type="math_number">
<field name="NUM">1</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">45</field>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" x="13" y="2538">
<field name="NAME">test constant</field>
<comment pinned="false" h="80" w="160">Tests the "constant" blocks.</comment>
<statement name="STACK">
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">const pi</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_round" inline="false">
<field name="OP">ROUNDDOWN</field>
<value name="NUM">
<block type="math_arithmetic">
<field name="OP">MULTIPLY</field>
<value name="A">
<block type="math_constant">
<field name="CONSTANT">PI</field>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">1000</field>
</block>
</value>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">3141</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">const e</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_round" inline="false">
<field name="OP">ROUNDDOWN</field>
<value name="NUM">
<block type="math_arithmetic">
<field name="OP">MULTIPLY</field>
<value name="A">
<block type="math_constant">
<field name="CONSTANT">E</field>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">1000</field>
</block>
</value>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">2718</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">const golden</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_round" inline="false">
<field name="OP">ROUNDDOWN</field>
<value name="NUM">
<block type="math_arithmetic">
<field name="OP">MULTIPLY</field>
<value name="A">
<block type="math_constant">
<field name="CONSTANT">GOLDEN_RATIO</field>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">1000</field>
</block>
</value>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">1618</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">const sqrt 2</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_round" inline="false">
<field name="OP">ROUNDDOWN</field>
<value name="NUM">
<block type="math_arithmetic">
<field name="OP">MULTIPLY</field>
<value name="A">
<block type="math_constant">
<field name="CONSTANT">SQRT2</field>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">1000</field>
</block>
</value>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">1414</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">const sqrt 0.5</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_round" inline="false">
<field name="OP">ROUNDDOWN</field>
<value name="NUM">
<block type="math_arithmetic">
<field name="OP">MULTIPLY</field>
<value name="A">
<block type="math_constant">
<field name="CONSTANT">SQRT1_2</field>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">1000</field>
</block>
</value>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">707</field>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<field name="EXPECTED">TRUE</field>
<value name="MESSAGE">
<block type="text">
<field name="TEXT">const infinity</field>
</block>
</value>
<value name="ACTUAL">
<block type="logic_compare">
<field name="OP">LT</field>
<value name="A">
<block type="math_number">
<field name="NUM">9999</field>
</block>
</value>
<value name="B">
<block type="math_constant">
<field name="CONSTANT">INFINITY</field>
</block>
</value>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" x="13" y="3113">
<field name="NAME">test number properties</field>
<comment pinned="false" h="80" w="160">Tests the "number property" blocks.</comment>
<statement name="STACK">
<block type="unittest_assertvalue" inline="false">
<field name="EXPECTED">TRUE</field>
<value name="MESSAGE">
<block type="text">
<field name="TEXT">even</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_number_property">
<mutation divisor_input="false"></mutation>
<field name="PROPERTY">EVEN</field>
<value name="NUMBER_TO_CHECK">
<block type="math_number">
<field name="NUM">42</field>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<field name="EXPECTED">FALSE</field>
<value name="MESSAGE">
<block type="text">
<field name="TEXT">odd</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_number_property">
<mutation divisor_input="false"></mutation>
<field name="PROPERTY">ODD</field>
<value name="NUMBER_TO_CHECK">
<block type="math_number">
<field name="NUM">42.1</field>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<field name="EXPECTED">TRUE</field>
<value name="MESSAGE">
<block type="text">
<field name="TEXT">prime 5</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_number_property">
<mutation divisor_input="false"></mutation>
<field name="PROPERTY">PRIME</field>
<value name="NUMBER_TO_CHECK">
<block type="math_number">
<field name="NUM">5</field>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<field name="EXPECTED">TRUE</field>
<value name="MESSAGE">
<block type="text">
<field name="TEXT">prime 5 + 2 (extra parentheses)</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_number_property">
<mutation divisor_input="false"></mutation>
<field name="PROPERTY">PRIME</field>
<value name="NUMBER_TO_CHECK">
<block type="math_arithmetic">
<field name="OP">ADD</field>
<value name="A">
<block type="math_number">
<field name="NUM">5</field>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">2</field>
</block>
</value>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<field name="EXPECTED">FALSE</field>
<value name="MESSAGE">
<block type="text">
<field name="TEXT">prime 25</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_number_property">
<mutation divisor_input="false"></mutation>
<field name="PROPERTY">PRIME</field>
<value name="NUMBER_TO_CHECK">
<block type="math_number">
<field name="NUM">25</field>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<field name="EXPECTED">FALSE</field>
<value name="MESSAGE">
<block type="text">
<field name="TEXT">prime negative</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_number_property">
<mutation divisor_input="false"></mutation>
<field name="PROPERTY">PRIME</field>
<value name="NUMBER_TO_CHECK">
<block type="math_number">
<field name="NUM">-31.1</field>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<field name="EXPECTED">FALSE</field>
<value name="MESSAGE">
<block type="text">
<field name="TEXT">whole</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_number_property">
<mutation divisor_input="false"></mutation>
<field name="PROPERTY">WHOLE</field>
<value name="NUMBER_TO_CHECK">
<block type="math_constant">
<field name="CONSTANT">PI</field>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<field name="EXPECTED">TRUE</field>
<value name="MESSAGE">
<block type="text">
<field name="TEXT">positive</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_number_property">
<mutation divisor_input="false"></mutation>
<field name="PROPERTY">POSITIVE</field>
<value name="NUMBER_TO_CHECK">
<block type="math_constant">
<field name="CONSTANT">INFINITY</field>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<field name="EXPECTED">TRUE</field>
<value name="MESSAGE">
<block type="text">
<field name="TEXT">5 + 2 is positive (extra parentheses)</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_number_property">
<mutation divisor_input="false"></mutation>
<field name="PROPERTY">POSITIVE</field>
<value name="NUMBER_TO_CHECK">
<block type="math_arithmetic">
<field name="OP">ADD</field>
<value name="A">
<block type="math_number">
<field name="NUM">5</field>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">2</field>
</block>
</value>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<field name="EXPECTED">TRUE</field>
<value name="MESSAGE">
<block type="text">
<field name="TEXT">negative</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_number_property">
<mutation divisor_input="false"></mutation>
<field name="PROPERTY">NEGATIVE</field>
<value name="NUMBER_TO_CHECK">
<block type="math_number">
<field name="NUM">-42</field>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<field name="EXPECTED">FALSE</field>
<value name="MESSAGE">
<block type="text">
<field name="TEXT">3 + 2 is negative (extra parentheses)</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_number_property">
<mutation divisor_input="false"></mutation>
<field name="PROPERTY">NEGATIVE</field>
<value name="NUMBER_TO_CHECK">
<block type="math_arithmetic">
<field name="OP">ADD</field>
<value name="A">
<block type="math_number">
<field name="NUM">3</field>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">2</field>
</block>
</value>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<field name="EXPECTED">TRUE</field>
<value name="MESSAGE">
<block type="text">
<field name="TEXT">divisible</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_number_property">
<mutation divisor_input="true"></mutation>
<field name="PROPERTY">DIVISIBLE_BY</field>
<value name="NUMBER_TO_CHECK">
<block type="math_number">
<field name="NUM">42</field>
</block>
</value>
<value name="DIVISOR">
<block type="math_number">
<field name="NUM">2</field>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue">
<field name="EXPECTED">TRUE</field>
<value name="MESSAGE">
<block type="text">
<field name="TEXT">divisible by 0</field>
</block>
</value>
<value name="ACTUAL">
<block type="logic_negate">
<value name="BOOL">
<block type="math_number_property">
<mutation divisor_input="true"></mutation>
<field name="PROPERTY">DIVISIBLE_BY</field>
<value name="NUMBER_TO_CHECK">
<block type="math_number">
<field name="NUM">42</field>
</block>
</value>
<value name="DIVISOR">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
</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>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" x="48" y="3799">
<field name="NAME">test round</field>
<comment pinned="false" h="80" w="160">Tests the "round" block.</comment>
<statement name="STACK">
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">round</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_round" inline="false">
<field name="OP">ROUND</field>
<value name="NUM">
<block type="math_number">
<field name="NUM">42.42</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">42</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">round up</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_round" inline="false">
<field name="OP">ROUNDUP</field>
<value name="NUM">
<block type="math_number">
<field name="NUM">-42.42</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">-42</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">round down</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_round" inline="false">
<field name="OP">ROUNDDOWN</field>
<value name="NUM">
<block type="math_number">
<field name="NUM">42.42</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">42</field>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" x="46" y="4064">
<field name="NAME">test change</field>
<comment pinned="false" h="80" w="160">Tests the "change" block.</comment>
<statement name="STACK">
<block type="variables_set" inline="false">
<field name="VAR">varToChange</field>
<value name="VALUE">
<block type="math_number">
<field name="NUM">100</field>
</block>
</value>
<next>
<block type="math_change" inline="false">
<field name="VAR">varToChange</field>
<value name="DELTA">
<block type="math_number">
<field name="NUM">42</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">change</field>
</block>
</value>
<value name="ACTUAL">
<block type="variables_get">
<field name="VAR">varToChange</field>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">142</field>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" x="13" y="4238">
<field name="NAME">test operations on list</field>
<comment pinned="false" h="80" w="160">Tests the "list operation" blocks.</comment>
<statement name="STACK">
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">sum</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_on_list" inline="false">
<mutation op="SUM"></mutation>
<field name="OP">SUM</field>
<value name="LIST">
<block type="lists_create_with" inline="true">
<mutation items="3"></mutation>
<value name="ADD0">
<block type="math_number">
<field name="NUM">3</field>
</block>
</value>
<value name="ADD1">
<block type="math_number">
<field name="NUM">4</field>
</block>
</value>
<value name="ADD2">
<block type="math_number">
<field name="NUM">5</field>
</block>
</value>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">12</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">min</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_on_list" inline="false">
<mutation op="MIN"></mutation>
<field name="OP">MIN</field>
<value name="LIST">
<block type="lists_create_with" inline="true">
<mutation items="3"></mutation>
<value name="ADD0">
<block type="math_number">
<field name="NUM">3</field>
</block>
</value>
<value name="ADD1">
<block type="math_number">
<field name="NUM">4</field>
</block>
</value>
<value name="ADD2">
<block type="math_number">
<field name="NUM">5</field>
</block>
</value>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">3</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">max</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_on_list" inline="false">
<mutation op="MAX"></mutation>
<field name="OP">MAX</field>
<value name="LIST">
<block type="lists_create_with" inline="true">
<mutation items="3"></mutation>
<value name="ADD0">
<block type="math_number">
<field name="NUM">3</field>
</block>
</value>
<value name="ADD1">
<block type="math_number">
<field name="NUM">4</field>
</block>
</value>
<value name="ADD2">
<block type="math_number">
<field name="NUM">5</field>
</block>
</value>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">5</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">average</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_on_list" inline="false">
<mutation op="AVERAGE"></mutation>
<field name="OP">AVERAGE</field>
<value name="LIST">
<block type="lists_create_with" inline="true">
<mutation items="3"></mutation>
<value name="ADD0">
<block type="math_number">
<field name="NUM">3</field>
</block>
</value>
<value name="ADD1">
<block type="math_number">
<field name="NUM">4</field>
</block>
</value>
<value name="ADD2">
<block type="math_number">
<field name="NUM">5</field>
</block>
</value>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">4</field>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">median</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_on_list" inline="false">
<mutation op="MEDIAN"></mutation>
<field name="OP">MEDIAN</field>
<value name="LIST">
<block type="lists_create_with" inline="true">
<mutation items="4"></mutation>
<value name="ADD0">
<block type="math_number">
<field name="NUM">3</field>
</block>
</value>
<value name="ADD1">
<block type="math_number">
<field name="NUM">4</field>
</block>
</value>
<value name="ADD2">
<block type="math_number">
<field name="NUM">5</field>
</block>
</value>
<value name="ADD3">
<block type="math_number">
<field name="NUM">1</field>
</block>
</value>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">3.5</field>
</block>
</value>
<next>
<block type="unittest_assertequals">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">modes</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_on_list" inline="false">
<mutation op="MODE"></mutation>
<field name="OP">MODE</field>
<value name="LIST">
<block type="lists_create_with" inline="true">
<mutation items="3"></mutation>
<value name="ADD0">
<block type="math_number">
<field name="NUM">3</field>
</block>
</value>
<value name="ADD1">
<block type="math_number">
<field name="NUM">4</field>
</block>
</value>
<value name="ADD2">
<block type="math_number">
<field name="NUM">3</field>
</block>
</value>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="lists_create_with" inline="true">
<mutation items="1"></mutation>
<value name="ADD0">
<block type="math_number">
<field name="NUM">3</field>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertequals">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">modes multiple</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_on_list" inline="false">
<mutation op="MODE"></mutation>
<field name="OP">MODE</field>
<value name="LIST">
<block type="lists_create_with" inline="true">
<mutation items="5"></mutation>
<value name="ADD0">
<block type="math_number">
<field name="NUM">3</field>
</block>
</value>
<value name="ADD1">
<block type="math_number">
<field name="NUM">4</field>
</block>
</value>
<value name="ADD2">
<block type="math_number">
<field name="NUM">3</field>
</block>
</value>
<value name="ADD3">
<block type="math_number">
<field name="NUM">1</field>
</block>
</value>
<value name="ADD4">
<block type="math_number">
<field name="NUM">4</field>
</block>
</value>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="lists_create_with" inline="true">
<mutation items="2"></mutation>
<value name="ADD0">
<block type="math_number">
<field name="NUM">3</field>
</block>
</value>
<value name="ADD1">
<block type="math_number">
<field name="NUM">4</field>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">standard dev</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_on_list" inline="false">
<mutation op="STD_DEV"></mutation>
<field name="OP">STD_DEV</field>
<value name="LIST">
<block type="lists_create_with" inline="true">
<mutation items="3"></mutation>
<value name="ADD0">
<block type="math_number">
<field name="NUM">3</field>
</block>
</value>
<value name="ADD1">
<block type="math_number">
<field name="NUM">3</field>
</block>
</value>
<value name="ADD2">
<block type="math_number">
<field name="NUM">3</field>
</block>
</value>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<field name="EXPECTED">TRUE</field>
<value name="MESSAGE">
<block type="text">
<field name="TEXT">random</field>
</block>
</value>
<value name="ACTUAL">
<block type="logic_compare" inline="false">
<field name="OP">GT</field>
<value name="A">
<block type="lists_indexOf" inline="false">
<field name="END">FIRST</field>
<value name="VALUE">
<block type="lists_create_with" inline="true">
<mutation items="3"></mutation>
<value name="ADD0">
<block type="math_number">
<field name="NUM">3</field>
</block>
</value>
<value name="ADD1">
<block type="math_number">
<field name="NUM">4</field>
</block>
</value>
<value name="ADD2">
<block type="math_number">
<field name="NUM">5</field>
</block>
</value>
</block>
</value>
<value name="FIND">
<block type="math_on_list" inline="false">
<mutation op="RANDOM"></mutation>
<field name="OP">RANDOM</field>
<value name="LIST">
<block type="lists_create_with" inline="false">
<mutation items="3"></mutation>
<value name="ADD0">
<block type="math_number">
<field name="NUM">3</field>
</block>
</value>
<value name="ADD1">
<block type="math_number">
<field name="NUM">4</field>
</block>
</value>
<value name="ADD2">
<block type="math_number">
<field name="NUM">5</field>
</block>
</value>
</block>
</value>
</block>
</value>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" x="13" y="5213">
<field name="NAME">test mod</field>
<comment pinned="false" h="80" w="160">Tests the "mod" block.</comment>
<statement name="STACK">
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">mod</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_modulo">
<value name="DIVIDEND">
<block type="math_number">
<field name="NUM">42</field>
</block>
</value>
<value name="DIVISOR">
<block type="math_number">
<field name="NUM">5</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">2</field>
</block>
</value>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" x="13" y="5363">
<field name="NAME">test constraint</field>
<comment pinned="false" h="80" w="160">Tests the "constrain" block.</comment>
<statement name="STACK">
<block type="unittest_assertequals" inline="false">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">constraint</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_constrain">
<value name="VALUE">
<block type="math_number">
<field name="NUM">100</field>
</block>
</value>
<value name="LOW">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
<value name="HIGH">
<block type="math_number">
<field name="NUM">42</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">42</field>
</block>
</value>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" x="13" y="5513">
<field name="NAME">test random integer</field>
<comment pinned="false" h="80" w="160">Tests the "random integer" block.</comment>
<statement name="STACK">
<block type="variables_set" inline="false">
<field name="VAR">rand</field>
<value name="VALUE">
<block type="math_random_int">
<value name="FROM">
<block type="math_number">
<field name="NUM">5</field>
</block>
</value>
<value name="TO">
<block type="math_number">
<field name="NUM">10</field>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<field name="EXPECTED">TRUE</field>
<value name="MESSAGE">
<block type="text">
<field name="TEXT">randRange</field>
</block>
</value>
<value name="ACTUAL">
<block type="logic_operation">
<field name="OP">AND</field>
<value name="A">
<block type="logic_compare">
<field name="OP">GTE</field>
<value name="A">
<block type="variables_get">
<field name="VAR">rand</field>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">5</field>
</block>
</value>
</block>
</value>
<value name="B">
<block type="logic_compare">
<field name="OP">LTE</field>
<value name="A">
<block type="variables_get">
<field name="VAR">rand</field>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">10</field>
</block>
</value>
</block>
</value>
</block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<field name="EXPECTED">TRUE</field>
<value name="MESSAGE">
<block type="text">
<field name="TEXT">randInteger</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_number_property">
<mutation divisor_input="false"></mutation>
<field name="PROPERTY">WHOLE</field>
<value name="NUMBER_TO_CHECK">
<block type="variables_get">
<field name="VAR">rand</field>
</block>
</value>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" x="13" y="5763">
<field name="NAME">test random fraction</field>
<comment pinned="false" h="80" w="160">Tests the "random fraction" block.</comment>
<statement name="STACK">
<block type="variables_set" inline="false">
<field name="VAR">rand</field>
<value name="VALUE">
<block type="math_random_float"></block>
</value>
<next>
<block type="unittest_assertvalue" inline="false">
<field name="EXPECTED">TRUE</field>
<value name="MESSAGE">
<block type="text">
<field name="TEXT">randFloat</field>
</block>
</value>
<value name="ACTUAL">
<block type="logic_operation">
<field name="OP">AND</field>
<value name="A">
<block type="logic_compare">
<field name="OP">GTE</field>
<value name="A">
<block type="variables_get">
<field name="VAR">rand</field>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
</block>
</value>
<value name="B">
<block type="logic_compare">
<field name="OP">LTE</field>
<value name="A">
<block type="variables_get">
<field name="VAR">rand</field>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">1</field>
</block>
</value>
</block>
</value>
</block>
</value>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" y="5938" x="13">
<field name="NAME">test atan2</field>
<comment w="160" h="80" pinned="false">Describe this function...</comment>
<statement name="STACK">
<block type="unittest_assertequals">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">atan2</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_atan2">
<value name="X">
<block type="math_number">
<field name="NUM">-5</field>
</block>
</value>
<value name="Y">
<block type="math_number">
<field name="NUM">5</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">135</field>
</block>
</value>
<next>
<block type="unittest_assertequals">
<value name="MESSAGE">
<block type="text">
<field name="TEXT">atan2</field>
</block>
</value>
<value name="ACTUAL">
<block type="math_atan2">
<value name="X">
<block type="math_number">
<field name="NUM">0</field>
</block>
</value>
<value name="Y">
<block type="math_number">
<field name="NUM">-12</field>
</block>
</value>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<field name="NUM">-90</field>
</block>
</value>
</block>
</next>
</block>
</statement>
</block>
</xml>