Files
blockly/tests/generators/loops1.xml

276 lines
11 KiB
XML

<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="unittest_main" x="33" y="140">
<statement name="DO">
<block type="procedures_callnoreturn">
<mutation name="test repeat"></mutation>
<next>
<block type="procedures_callnoreturn">
<mutation name="test while"></mutation>
<next>
<block type="procedures_callnoreturn">
<mutation name="test foreach"></mutation>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" x="31" y="296">
<mutation></mutation>
<title name="NAME">test foreach</title>
<statement name="STACK">
<block type="variables_set" inline="false">
<title name="VAR">log</title>
<value name="VALUE">
<block type="text">
<title name="TEXT"></title>
</block>
</value>
<next>
<block type="controls_forEach" inline="false">
<title name="VAR">x</title>
<value name="LIST">
<block type="lists_create_with" inline="false">
<mutation items="3"></mutation>
<value name="ADD0">
<block type="text">
<title name="TEXT">a</title>
</block>
</value>
<value name="ADD1">
<block type="text">
<title name="TEXT">b</title>
</block>
</value>
<value name="ADD2">
<block type="text">
<title name="TEXT">c</title>
</block>
</value>
</block>
</value>
<statement name="DO">
<block type="text_append" inline="false">
<title name="VAR">log</title>
<value name="TEXT">
<block type="variables_get">
<title name="VAR">x</title>
</block>
</value>
</block>
</statement>
<next>
<block type="unittest_assertequals" inline="false">
<title name="MESSAGE">for loop</title>
<value name="ACTUAL">
<block type="variables_get">
<title name="VAR">log</title>
</block>
</value>
<value name="EXPECTED">
<block type="text">
<title name="TEXT">abc</title>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" x="30" y="624">
<mutation></mutation>
<title name="NAME">test while</title>
<statement name="STACK">
<block type="controls_whileUntil" inline="false">
<title name="MODE">WHILE</title>
<value name="BOOL">
<block type="logic_boolean">
<title name="BOOL">FALSE</title>
</block>
</value>
<statement name="DO">
<block type="unittest_fail">
<title name="MESSAGE">while 0</title>
</block>
</statement>
<next>
<block type="controls_whileUntil" inline="false">
<title name="MODE">UNTIL</title>
<value name="BOOL">
<block type="logic_boolean">
<title name="BOOL">TRUE</title>
</block>
</value>
<statement name="DO">
<block type="unittest_fail">
<title name="MESSAGE">until 0</title>
</block>
</statement>
<next>
<block type="variables_set" inline="false">
<title name="VAR">count</title>
<value name="VALUE">
<block type="math_number">
<title name="NUM">1</title>
</block>
</value>
<next>
<block type="controls_whileUntil" inline="false">
<title name="MODE">WHILE</title>
<value name="BOOL">
<block type="logic_compare" inline="true">
<title name="OP">NEQ</title>
<value name="A">
<block type="variables_get">
<title name="VAR">count</title>
</block>
</value>
<value name="B">
<block type="math_number">
<title name="NUM">10</title>
</block>
</value>
</block>
</value>
<statement name="DO">
<block type="math_change" inline="false">
<title name="VAR">count</title>
<value name="DELTA">
<block type="math_number">
<title name="NUM">1</title>
</block>
</value>
</block>
</statement>
<next>
<block type="unittest_assertequals" inline="false">
<title name="MESSAGE">while 10</title>
<value name="ACTUAL">
<block type="variables_get">
<title name="VAR">count</title>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<title name="NUM">10</title>
</block>
</value>
<next>
<block type="variables_set" inline="false">
<title name="VAR">count</title>
<value name="VALUE">
<block type="math_number">
<title name="NUM">1</title>
</block>
</value>
<next>
<block type="controls_whileUntil" inline="false">
<title name="MODE">UNTIL</title>
<value name="BOOL">
<block type="logic_compare" inline="true">
<title name="OP">EQ</title>
<value name="A">
<block type="variables_get">
<title name="VAR">count</title>
</block>
</value>
<value name="B">
<block type="math_number">
<title name="NUM">10</title>
</block>
</value>
</block>
</value>
<statement name="DO">
<block type="math_change" inline="false">
<title name="VAR">count</title>
<value name="DELTA">
<block type="math_number">
<title name="NUM">1</title>
</block>
</value>
</block>
</statement>
<next>
<block type="unittest_assertequals" inline="false">
<title name="MESSAGE">until 10</title>
<value name="ACTUAL">
<block type="variables_get">
<title name="VAR">count</title>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<title name="NUM">10</title>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" x="397" y="628">
<mutation></mutation>
<title name="NAME">test repeat</title>
<statement name="STACK">
<block type="variables_set" inline="false">
<title name="VAR">count</title>
<value name="VALUE">
<block type="math_number">
<title name="NUM">0</title>
</block>
</value>
<next>
<block type="controls_repeat_ext" inline="true">
<value name="TIMES">
<block type="math_number">
<title name="NUM">10</title>
</block>
</value>
<statement name="DO">
<block type="math_change" inline="false">
<title name="VAR">count</title>
<value name="DELTA">
<block type="math_number">
<title name="NUM">1</title>
</block>
</value>
</block>
</statement>
<next>
<block type="unittest_assertequals" inline="false">
<title name="MESSAGE">repeat 10</title>
<value name="ACTUAL">
<block type="variables_get">
<title name="VAR">count</title>
</block>
</value>
<value name="EXPECTED">
<block type="math_number">
<title name="NUM">10</title>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
</xml>