Skip to content

Commit

Permalink
fix decompiler tests
Browse files Browse the repository at this point in the history
  • Loading branch information
riknoll committed Jan 30, 2024
1 parent 0f12a9f commit 92b2702
Show file tree
Hide file tree
Showing 14 changed files with 148 additions and 105 deletions.
3 changes: 1 addition & 2 deletions pxtcompiler/emitter/decompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1127,9 +1127,8 @@ ${output}</xml>`;
}

function mkDraggableReporterValue(valueName: string, varName: string, varType: string) {
const reporterType = pxt.blocks.reporterTypeForArgType(varType);
const reporterShadowBlock = getDraggableReporterBlock(varName, varType, true);
return mkValue(valueName, reporterShadowBlock, reporterType);
return mkValue(valueName, reporterShadowBlock, undefined);
}

function getDraggableReporterBlock(varName: string, varType: string, draggable: boolean) {
Expand Down
5 changes: 3 additions & 2 deletions tests/decompile-test/baselines/always_enums.blocks
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
<statement name="HANDLER">
<block type="pxt_controls_for">
<value name="VAR">
<shadow type="variables_get_reporter">
<block type="variables_get_reporter">
<mutation duplicateondrag="true" />
<field name="VAR">i</field>
</shadow>
</block>
</value>
<value name="TO">
<shadow type="math_whole_number"><field name="NUM">0</field></shadow>
Expand Down
10 changes: 6 additions & 4 deletions tests/decompile-test/baselines/array_for_of.blocks
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
</block>
</value>
<value name="VAR">
<shadow type="variables_get_reporter">
<block type="variables_get_reporter">
<mutation duplicateondrag="true" />
<field name="VAR">a</field>
</shadow>
</block>
</value>
<statement name="DO">
<block type="variables_change">
Expand All @@ -49,9 +50,10 @@
</block>
</value>
<value name="VAR">
<shadow type="variables_get_reporter">
<block type="variables_get_reporter">
<mutation duplicateondrag="true" />
<field name="VAR">b</field>
</shadow>
</block>
</value>
<statement name="DO">
</statement>
Expand Down
5 changes: 3 additions & 2 deletions tests/decompile-test/baselines/array_for_of_string.blocks
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
</shadow>
</value>
<value name="VAR">
<shadow type="variables_get_reporter">
<block type="variables_get_reporter">
<mutation duplicateondrag="true" />
<field name="VAR">i</field>
</shadow>
</block>
</value>
<statement name="DO">
<block type="variables_set">
Expand Down
15 changes: 9 additions & 6 deletions tests/decompile-test/baselines/block_for.blocks
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
<statement name="HANDLER">
<block type="pxt_controls_for">
<value name="VAR">
<shadow type="variables_get_reporter">
<block type="variables_get_reporter">
<mutation duplicateondrag="true" />
<field name="VAR">i</field>
</shadow>
</block>
</value>
<value name="TO">
<shadow type="math_whole_number">
Expand All @@ -17,9 +18,10 @@
<next>
<block type="pxt_controls_for">
<value name="VAR">
<shadow type="variables_get_reporter">
<block type="variables_get_reporter">
<mutation duplicateondrag="true" />
<field name="VAR">j</field>
</shadow>
</block>
</value>
<value name="TO">
<shadow type="math_whole_number">
Expand Down Expand Up @@ -148,9 +150,10 @@
<next>
<block type="pxt_controls_for">
<value name="VAR">
<shadow type="variables_get_reporter">
<block type="variables_get_reporter">
<mutation duplicateondrag="true" />
<field name="VAR">u</field>
</shadow>
</block>
</value>
<value name="TO">
<shadow type="math_whole_number"><field name="NUM">0</field></shadow>
Expand Down
5 changes: 3 additions & 2 deletions tests/decompile-test/baselines/block_for2.blocks
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
<statement name="HANDLER">
<block type="pxt_controls_for">
<value name="VAR">
<shadow type="variables_get_reporter">
<block type="variables_get_reporter">
<mutation duplicateondrag="true" />
<field name="VAR">i</field>
</shadow>
</block>
</value>
<value name="TO">
<shadow type="math_whole_number">
Expand Down
5 changes: 3 additions & 2 deletions tests/decompile-test/baselines/block_repeat.blocks
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
<next>
<block type="pxt_controls_for">
<value name="VAR">
<shadow type="variables_get_reporter">
<block type="variables_get_reporter">
<mutation duplicateondrag="true" />
<field name="VAR">r</field>
</shadow>
</block>
</value>
<value name="TO">
<shadow type="math_whole_number"><field name="NUM">0</field></shadow>
Expand Down
10 changes: 6 additions & 4 deletions tests/decompile-test/baselines/break_continue.blocks
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
<statement name="HANDLER">
<block type="pxt_controls_for">
<value name="VAR">
<shadow type="variables_get_reporter">
<block type="variables_get_reporter">
<mutation duplicateondrag="true" />
<field name="VAR">i</field>
</shadow>
</block>
</value>
<value name="TO">
<shadow type="math_whole_number">
Expand All @@ -19,9 +20,10 @@
<next>
<block type="pxt_controls_for">
<value name="VAR">
<shadow type="variables_get_reporter">
<block type="variables_get_reporter">
<mutation duplicateondrag="true" />
<field name="VAR">j</field>
</shadow>
</block>
</value>
<value name="TO">
<shadow type="math_whole_number">
Expand Down
40 changes: 24 additions & 16 deletions tests/decompile-test/baselines/draggable_parameters.blocks
Original file line number Diff line number Diff line change
@@ -1,56 +1,64 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="test_handler_arguments3">
<value name="HANDLER_DRAG_PARAM_c">
<shadow type="variables_get_reporter">
<block type="variables_get_reporter">
<mutation duplicateondrag="true" />
<field name="VAR">hello</field>
</shadow>
</block>
</value>
<value name="HANDLER_DRAG_PARAM_d">
<shadow type="variables_get_reporter">
<block type="variables_get_reporter">
<mutation duplicateondrag="true" />
<field name="VAR">goodbye</field>
</shadow>
</block>
</value>
<statement name="HANDLER">
</statement>
</block>
<block type="test_handler_arguments3">
<value name="HANDLER_DRAG_PARAM_c">
<shadow type="variables_get_reporter">
<block type="variables_get_reporter">
<mutation duplicateondrag="true" />
<field name="VAR">sure</field>
</shadow>
</block>
</value>
<value name="HANDLER_DRAG_PARAM_d">
<shadow type="variables_get_reporter">
<block type="variables_get_reporter">
<mutation duplicateondrag="true" />
<field name="VAR">whatever</field>
</shadow>
</block>
</value>
<statement name="HANDLER">
</statement>
</block>
<block type="test_handler_arguments3">
<value name="HANDLER_DRAG_PARAM_c">
<shadow type="variables_get_reporter">
<block type="variables_get_reporter">
<mutation duplicateondrag="true" />
<field name="VAR">okay</field>
</shadow>
</block>
</value>
<value name="HANDLER_DRAG_PARAM_d">
<shadow type="variables_get_reporter">
<block type="variables_get_reporter">
<mutation duplicateondrag="true" />
<field name="VAR">d</field>
</shadow>
</block>
</value>
<statement name="HANDLER">
</statement>
</block>
<block type="test_handler_arguments3">
<value name="HANDLER_DRAG_PARAM_c">
<shadow type="variables_get_reporter">
<block type="variables_get_reporter">
<mutation duplicateondrag="true" />
<field name="VAR">c</field>
</shadow>
</block>
</value>
<value name="HANDLER_DRAG_PARAM_d">
<shadow type="variables_get_reporter">
<block type="variables_get_reporter">
<mutation duplicateondrag="true" />
<field name="VAR">d</field>
</shadow>
</block>
</value>
<statement name="HANDLER">
</statement>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,100 +1,112 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="test_handler_arguments4">
<value name="HANDLER_DRAG_PARAM_c">
<shadow type="argument_reporter_string">
<block type="argument_reporter_string">
<mutation duplicateondrag="true" />
<field name="VALUE">hello</field>
</shadow>
</block>
</value>
<value name="HANDLER_DRAG_PARAM_d">
<shadow type="argument_reporter_number">
<block type="argument_reporter_number">
<mutation duplicateondrag="true" />
<field name="VALUE">goodbye</field>
</shadow>
</block>
</value>
<value name="HANDLER_DRAG_PARAM_e">
<shadow type="argument_reporter_boolean">
<block type="argument_reporter_boolean">
<mutation duplicateondrag="true" />
<field name="VALUE">e</field>
</shadow>
</block>
</value>
<value name="HANDLER_DRAG_PARAM_f">
<shadow type="argument_reporter_custom">
<mutation typename="testNamespace.TestClass" />
<block type="argument_reporter_custom">
<mutation typename="testNamespace.TestClass" duplicateondrag="true" />
<field name="VALUE">f</field>
</shadow>
</block>
</value>
<statement name="HANDLER">
</statement>
</block>
<block type="test_handler_arguments4">
<value name="HANDLER_DRAG_PARAM_c">
<shadow type="argument_reporter_string">
<block type="argument_reporter_string">
<mutation duplicateondrag="true" />
<field name="VALUE">what</field>
</shadow>
</block>
</value>
<value name="HANDLER_DRAG_PARAM_d">
<shadow type="argument_reporter_number">
<block type="argument_reporter_number">
<mutation duplicateondrag="true" />
<field name="VALUE">are</field>
</shadow>
</block>
</value>
<value name="HANDLER_DRAG_PARAM_e">
<shadow type="argument_reporter_boolean">
<block type="argument_reporter_boolean">
<mutation duplicateondrag="true" />
<field name="VALUE">you</field>
</shadow>
</block>
</value>
<value name="HANDLER_DRAG_PARAM_f">
<shadow type="argument_reporter_custom">
<mutation typename="testNamespace.TestClass" />
<block type="argument_reporter_custom">
<mutation typename="testNamespace.TestClass" duplicateondrag="true" />
<field name="VALUE">doing</field>
</shadow>
</block>
</value>
<statement name="HANDLER">
</statement>
</block>
<block type="test_handler_arguments4">
<value name="HANDLER_DRAG_PARAM_c">
<shadow type="argument_reporter_string">
<block type="argument_reporter_string">
<mutation duplicateondrag="true" />
<field name="VALUE">stahp</field>
</shadow>
</block>
</value>
<value name="HANDLER_DRAG_PARAM_d">
<shadow type="argument_reporter_number">
<block type="argument_reporter_number">
<mutation duplicateondrag="true" />
<field name="VALUE">d</field>
</shadow>
</block>
</value>
<value name="HANDLER_DRAG_PARAM_e">
<shadow type="argument_reporter_boolean">
<block type="argument_reporter_boolean">
<mutation duplicateondrag="true" />
<field name="VALUE">e</field>
</shadow>
</block>
</value>
<value name="HANDLER_DRAG_PARAM_f">
<shadow type="argument_reporter_custom">
<mutation typename="testNamespace.TestClass" />
<block type="argument_reporter_custom">
<mutation typename="testNamespace.TestClass" duplicateondrag="true" />
<field name="VALUE">f</field>
</shadow>
</block>
</value>
<statement name="HANDLER">
</statement>
</block>
<block type="test_handler_arguments4">
<value name="HANDLER_DRAG_PARAM_c">
<shadow type="argument_reporter_string">
<block type="argument_reporter_string">
<mutation duplicateondrag="true" />
<field name="VALUE">c</field>
</shadow>
</block>
</value>
<value name="HANDLER_DRAG_PARAM_d">
<shadow type="argument_reporter_number">
<block type="argument_reporter_number">
<mutation duplicateondrag="true" />
<field name="VALUE">d</field>
</shadow>
</block>
</value>
<value name="HANDLER_DRAG_PARAM_e">
<shadow type="argument_reporter_boolean">
<block type="argument_reporter_boolean">
<mutation duplicateondrag="true" />
<field name="VALUE">e</field>
</shadow>
</block>
</value>
<value name="HANDLER_DRAG_PARAM_f">
<shadow type="argument_reporter_custom">
<mutation typename="testNamespace.TestClass" />
<block type="argument_reporter_custom">
<mutation typename="testNamespace.TestClass" duplicateondrag="true" />
<field name="VALUE">f</field>
</shadow>
</block>
</value>
<statement name="HANDLER">
</statement>
Expand Down
5 changes: 3 additions & 2 deletions tests/decompile-test/baselines/for_loop_non_int.blocks
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
<statement name="HANDLER">
<block type="pxt_controls_for">
<value name="VAR">
<shadow type="variables_get_reporter">
<block type="variables_get_reporter">
<mutation duplicateondrag="true" />
<field name="VAR">i</field>
</shadow>
</block>
</value>
<value name="TO">
<shadow type="math_whole_number"><field name="NUM">0</field></shadow>
Expand Down
Loading

0 comments on commit 92b2702

Please sign in to comment.