Refactors modify and add tests (#2955)

* Refactors modify and add tests
This commit is contained in:
alschmiedt
2019-09-04 10:58:47 -07:00
committed by GitHub
parent 8ce619e827
commit 6e8d200857
5 changed files with 176 additions and 93 deletions

View File

@@ -385,7 +385,7 @@ Blockly.navigation.insertFromFlyout = function() {
newBlock.setConnectionsHidden(false);
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createBlockNode(newBlock));
if (!Blockly.navigation.modify()) {
if (!Blockly.navigation.modify_()) {
Blockly.navigation.warn('Something went wrong while inserting a block from the flyout.');
}
@@ -412,11 +412,12 @@ Blockly.navigation.resetFlyout = function(shouldHide) {
/************/
/**
* Handle the modifier key (currently I for Insert).
* @return {boolean} True if the key was handled; false if something went wrong.
* @package
* Warns the user if the cursor or marker is on a type that can not be connected.
* @return {boolean} True if the marker and cursor are valid types, false
* otherwise.
* @private
*/
Blockly.navigation.modify = function() {
Blockly.navigation.modifyWarn_ = function() {
var markerNode = Blockly.navigation.marker_.getCurNode();
var cursorNode = Blockly.navigation.cursor_.getCurNode();
@@ -432,68 +433,83 @@ Blockly.navigation.modify = function() {
var markerType = markerNode.getType();
var cursorType = cursorNode.getType();
// Check the marker for invalid types.
if (markerType == Blockly.ASTNode.types.FIELD) {
Blockly.navigation.warn('Should not have been able to mark a field.');
return false;
}
if (markerType == Blockly.ASTNode.types.BLOCK) {
} else if (markerType == Blockly.ASTNode.types.BLOCK) {
Blockly.navigation.warn('Should not have been able to mark a block.');
return false;
}
if (markerType == Blockly.ASTNode.types.STACK) {
} else if (markerType == Blockly.ASTNode.types.STACK) {
Blockly.navigation.warn('Should not have been able to mark a stack.');
return false;
}
// Check the cursor for invalid types.
if (cursorType == Blockly.ASTNode.types.FIELD) {
Blockly.navigation.warn('Cannot attach a field to anything else.');
return false;
}
if (cursorType == Blockly.ASTNode.types.WORKSPACE) {
} else if (cursorType == Blockly.ASTNode.types.WORKSPACE) {
Blockly.navigation.warn('Cannot attach a workspace to anything else.');
return false;
}
return true;
};
/**
* Disconnect the block from its parent and move to the position of the
* workspace node.
* @param {!Blockly.Block} block The block to be moved to the workspace.
* @param {!Blockly.ASTNode} wsNode The workspace node holding the position the
* block will be moved to.
* @return {boolean} True if the block can be moved to the workspace,
* false otherwise.
* @private
*/
Blockly.navigation.moveBlockToWorkspace_ = function(block, wsNode) {
if (block.isShadow()) {
Blockly.navigation.warn('Cannot move a shadow block to the workspace.');
return false;
}
if (block.getParent()) {
block.unplug(false);
}
block.moveTo(wsNode.getWsCoordinate());
return true;
};
/**
* Handle the modifier key (currently I for Insert).
* Tries to connect the current marker and cursor location. Warns the user if
* the two locations can not be connected.
* @return {boolean} True if the key was handled; false if something went wrong.
* @private
*/
Blockly.navigation.modify_ = function() {
var markerNode = Blockly.navigation.marker_.getCurNode();
var cursorNode = Blockly.navigation.cursor_.getCurNode();
if (!Blockly.navigation.modifyWarn_()) {
return false;
}
var markerType = markerNode.getType();
var cursorType = cursorNode.getType();
var cursorLoc = cursorNode.getLocation();
var markerLoc = markerNode.getLocation();
if (markerNode.isConnection()) {
// TODO: Handle the case when one or both are already connected.
if (cursorNode.isConnection()) {
return Blockly.navigation.connect(cursorLoc, markerLoc);
} else if (cursorType == Blockly.ASTNode.types.BLOCK ||
cursorType == Blockly.ASTNode.types.STACK) {
return Blockly.navigation.insertBlock(cursorLoc, markerLoc);
}
if (markerNode.isConnection() && cursorNode.isConnection()) {
return Blockly.navigation.connect(cursorLoc, markerLoc);
} else if (markerNode.isConnection() &&
(cursorType == Blockly.ASTNode.types.BLOCK ||
cursorType == Blockly.ASTNode.types.STACK)) {
return Blockly.navigation.insertBlock(cursorLoc, markerLoc);
} else if (markerType == Blockly.ASTNode.types.WORKSPACE) {
if (cursorNode.isConnection()) {
if (cursorType == Blockly.ASTNode.types.INPUT ||
cursorType == Blockly.ASTNode.types.NEXT) {
Blockly.navigation.warn(
'Cannot move a next or input connection to the workspace.');
return false;
}
var block = cursorLoc.getSourceBlock();
} else if (cursorType == Blockly.ASTNode.types.BLOCK ||
cursorType == Blockly.ASTNode.types.STACK) {
var block = cursorLoc;
} else {
return false;
}
if (block.isShadow()) {
Blockly.navigation.warn('Cannot move a shadow block to the workspace.');
return false;
}
if (block.getParent()) {
block.unplug(false);
}
block.moveTo(markerNode.getWsCoordinate());
return true;
var block = Blockly.navigation.getSourceBlock_(cursorNode);
return Blockly.navigation.moveBlockToWorkspace_(block, markerNode);
}
Blockly.navigation.warn('Unexpected state in Blockly.navigation.modify.');
Blockly.navigation.warn('Unexpected state in Blockly.navigation.modify_.');
return false;
// TODO: Make sure the cursor and marker end up in the right places.
};
/**
@@ -768,8 +784,9 @@ Blockly.navigation.getSourceBlock_ = function(node) {
}
if (node.getType() === Blockly.ASTNode.types.BLOCK) {
return node.getLocation();
} else if (node.getType() === Blockly.ASTNode.types.WORKSPACE ||
node.getType() === Blockly.ASTNode.types.STACK) {
} else if (node.getType() === Blockly.ASTNode.types.STACK) {
return node.getLocation();
} else if (node.getType() === Blockly.ASTNode.types.WORKSPACE) {
return null;
} else {
return node.getLocation().getSourceBlock();
@@ -894,7 +911,7 @@ Blockly.navigation.workspaceOnAction_ = function(action) {
Blockly.navigation.cursor_.in();
return true;
case Blockly.navigation.actionNames.INSERT:
Blockly.navigation.modify();
Blockly.navigation.modify_();
return true;
case Blockly.navigation.actionNames.MARK:
Blockly.navigation.handleEnterForWS();

View File

@@ -15,7 +15,8 @@
"assertUndefined": true,
"assertNotUndefined": true,
"defineStackBlock": true,
"defineRowBlock": true
"defineRowBlock": true,
"defineStatementBlock": true
},
"extends": "../../.eslintrc.json"

View File

@@ -5,9 +5,12 @@ suite('Insert/Modify', function() {
'<block type="stack_block" id="stack_block_2" x="12" y="113"></block>' +
'<block type="row_block" id="row_block_1" x="13" y="213"></block>' +
'<block type="row_block" id="row_block_2" x="12" y="288"></block>' +
'<block type="statement_block" id="statement_block_1" x="12" y="288"></block>' +
'<block type="statement_block" id="statement_block_2" x="12" y="288"></block>' +
'</xml>';
defineStackBlock();
defineRowBlock();
defineStatementBlock();
var toolbox = document.getElementById('toolbox-connections');
this.workspace = Blockly.inject('blocklyDiv', {toolbox: toolbox});
@@ -17,6 +20,8 @@ suite('Insert/Modify', function() {
this.stack_block_2 = this.workspace.getBlockById('stack_block_2');
this.row_block_1 = this.workspace.getBlockById('row_block_1');
this.row_block_2 = this.workspace.getBlockById('row_block_2');
this.statement_block_1 = this.workspace.getBlockById('statement_block_1');
this.statement_block_2 = this.workspace.getBlockById('statement_block_2');
Blockly.navigation.enableKeyboardAccessibility();
Blockly.navigation.focusWorkspace();
@@ -25,9 +30,8 @@ suite('Insert/Modify', function() {
teardown(function() {
delete Blockly.Blocks['stack_block'];
delete Blockly.Blocks['row_block'];
delete Blockly.Blocks['statement_block'];
this.workspace.dispose();
// Does disposing of the workspace dispose of cursors and markers
// correctly?
});
suite('Marked Connection', function() {
@@ -42,13 +46,13 @@ suite('Insert/Modify', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createWorkspaceNode(this.workspace,
new Blockly.utils.Coordinate(0, 0)));
chai.assert.isFalse(Blockly.navigation.modify());
chai.assert.isFalse(Blockly.navigation.modify_());
});
test('Cursor on compatible connection', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createConnectionNode(
this.stack_block_2.previousConnection));
chai.assert.isTrue(Blockly.navigation.modify());
chai.assert.isTrue(Blockly.navigation.modify_());
chai.assert.equal(this.stack_block_1.getNextBlock().id, 'stack_block_2');
});
test('Cursor on incompatible connection', function() {
@@ -57,21 +61,21 @@ suite('Insert/Modify', function() {
this.stack_block_2.nextConnection));
// Connect method will try to find a way to connect blocks with
// incompatible types.
chai.assert.isTrue(Blockly.navigation.modify());
chai.assert.isTrue(Blockly.navigation.modify_());
chai.assert.equal(this.stack_block_1.getNextBlock(), this.stack_block_2);
});
test('Cursor on really incompatible connection', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createConnectionNode(
this.row_block_1.outputConnection));
chai.assert.isFalse(Blockly.navigation.modify());
chai.assert.isFalse(Blockly.navigation.modify_());
chai.assert.isNull(this.stack_block_1.getNextBlock());
});
test('Cursor on block', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createBlockNode(
this.stack_block_2));
chai.assert.isTrue(Blockly.navigation.modify());
chai.assert.isTrue(Blockly.navigation.modify_());
chai.assert.equal(this.stack_block_1.getNextBlock().id, 'stack_block_2');
});
});
@@ -86,35 +90,35 @@ suite('Insert/Modify', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createConnectionNode(
this.stack_block_2.nextConnection));
chai.assert.isTrue(Blockly.navigation.modify());
chai.assert.isTrue(Blockly.navigation.modify_());
chai.assert.equal(this.stack_block_1.getPreviousBlock().id, 'stack_block_2');
});
test('Cursor on incompatible connection', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createConnectionNode(
this.stack_block_2.previousConnection));
chai.assert.isFalse(Blockly.navigation.modify());
chai.assert.isFalse(Blockly.navigation.modify_());
chai.assert.isNull(this.stack_block_1.getPreviousBlock());
});
test('Cursor on really incompatible connection', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createConnectionNode(
this.row_block_1.outputConnection));
chai.assert.isFalse(Blockly.navigation.modify());
chai.assert.isFalse(Blockly.navigation.modify_());
chai.assert.isNull(this.stack_block_1.getNextBlock());
});
test('Cursor on block', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createBlockNode(
this.stack_block_2));
chai.assert.isTrue(Blockly.navigation.modify());
chai.assert.isTrue(Blockly.navigation.modify_());
chai.assert.equal(this.stack_block_1.getPreviousBlock().id, 'stack_block_2');
});
test('Cursor on incompatible block', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createBlockNode(
this.row_block_1));
chai.assert.isFalse(Blockly.navigation.modify());
chai.assert.isFalse(Blockly.navigation.modify_());
chai.assert.isNull(this.stack_block_1.getPreviousBlock());
});
});
@@ -129,7 +133,7 @@ suite('Insert/Modify', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createConnectionNode(
this.row_block_2.outputConnection));
chai.assert.isTrue(Blockly.navigation.modify());
chai.assert.isTrue(Blockly.navigation.modify_());
chai.assert.equal(this.row_block_2.getParent().id, 'row_block_1');
});
test('Cursor on incompatible connection', function() {
@@ -138,7 +142,7 @@ suite('Insert/Modify', function() {
this.row_block_2.inputList[0].connection));
// Connect method will try to find a way to connect blocks with
// incompatible types.
chai.assert.isTrue(Blockly.navigation.modify());
chai.assert.isTrue(Blockly.navigation.modify_());
chai.assert.equal(this.row_block_1.inputList[0].connection.targetBlock(),
this.row_block_2);
});
@@ -146,19 +150,49 @@ suite('Insert/Modify', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createConnectionNode(
this.stack_block_1.previousConnection));
chai.assert.isFalse(Blockly.navigation.modify());
chai.assert.isFalse(Blockly.navigation.modify_());
});
test('Cursor on block', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createBlockNode(
this.row_block_2));
chai.assert.isTrue(Blockly.navigation.modify());
chai.assert.isTrue(Blockly.navigation.modify_());
chai.assert.equal(this.row_block_2.getParent().id, 'row_block_1');
});
});
suite('Statement input', function() {
// TODO: fill this out.
suite('Marked Statement input', function() {
setup(function() {
this.statement_block_1.inputList[0].connection.connect(
this.stack_block_1.previousConnection);
this.stack_block_1.nextConnection.connect(this.stack_block_2.previousConnection);
Blockly.navigation.marker_.setLocation(
Blockly.ASTNode.createInputNode(
this.statement_block_1.inputList[0]));
});
test('Cursor on block inside statement', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createConnectionNode(
this.stack_block_2.previousConnection));
chai.assert.isTrue(Blockly.navigation.modify_());
chai.assert.equal(this.stack_block_2.previousConnection.targetBlock(),
this.statement_block_1);
});
test('Cursor on stack', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createStackNode(
this.statement_block_2));
chai.assert.isTrue(Blockly.navigation.modify_());
chai.assert.equal(this.statement_block_2.getParent().id, 'statement_block_1');
});
test('Cursor on incompatible type', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createConnectionNode(
this.row_block_1.outputConnection));
chai.assert.isFalse(Blockly.navigation.modify_());
chai.assert.equal(this.row_block_1.getParent(), null);
});
});
suite('Marker on output', function() {
@@ -171,26 +205,26 @@ suite('Insert/Modify', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createConnectionNode(
this.row_block_2.inputList[0].connection));
chai.assert.isTrue(Blockly.navigation.modify());
chai.assert.isTrue(Blockly.navigation.modify_());
chai.assert.equal(this.row_block_1.getParent().id, 'row_block_2');
});
test('Cursor on incompatible connection', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createConnectionNode(
this.row_block_2.outputConnection));
chai.assert.isFalse(Blockly.navigation.modify());
chai.assert.isFalse(Blockly.navigation.modify_());
});
test('Cursor on really incompatible connection', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createConnectionNode(
this.stack_block_1.previousConnection));
chai.assert.isFalse(Blockly.navigation.modify());
chai.assert.isFalse(Blockly.navigation.modify_());
});
test('Cursor on block', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createBlockNode(
this.row_block_2));
chai.assert.isTrue(Blockly.navigation.modify());
chai.assert.isTrue(Blockly.navigation.modify_());
chai.assert.equal(this.row_block_1.getParent().id, 'row_block_2');
});
});
@@ -207,7 +241,7 @@ suite('Insert/Modify', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createBlockNode(
this.row_block_1));
chai.assert.isTrue(Blockly.navigation.modify());
chai.assert.isTrue(Blockly.navigation.modify_());
var pos = this.row_block_1.getRelativeToSurfaceXY();
chai.assert.equal(100, pos.x);
chai.assert.equal(200, pos.y);
@@ -217,7 +251,7 @@ suite('Insert/Modify', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createConnectionNode(
this.row_block_1.outputConnection));
chai.assert.isTrue(Blockly.navigation.modify());
chai.assert.isTrue(Blockly.navigation.modify_());
var pos = this.row_block_1.getRelativeToSurfaceXY();
chai.assert.equal(100, pos.x);
chai.assert.equal(200, pos.y);
@@ -227,7 +261,7 @@ suite('Insert/Modify', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createConnectionNode(
this.stack_block_1.previousConnection));
chai.assert.isTrue(Blockly.navigation.modify());
chai.assert.isTrue(Blockly.navigation.modify_());
var pos = this.stack_block_1.getRelativeToSurfaceXY();
chai.assert.equal(100, pos.x);
chai.assert.equal(200, pos.y);
@@ -237,14 +271,16 @@ suite('Insert/Modify', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createConnectionNode(
this.row_block_1.inputList[0].connection));
chai.assert.isFalse(Blockly.navigation.modify());
// Move the source block to the marked location on the workspace.
chai.assert.isTrue(Blockly.navigation.modify_());
});
test('Cursor on next connection', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createConnectionNode(
this.stack_block_1.nextConnection));
chai.assert.isFalse(Blockly.navigation.modify());
// Move the source block to the marked location on the workspace.
chai.assert.isTrue(Blockly.navigation.modify_());
});
test('Cursor on child block (row)', function() {
@@ -255,7 +291,7 @@ suite('Insert/Modify', function() {
Blockly.ASTNode.createBlockNode(
this.row_block_2));
chai.assert.isTrue(Blockly.navigation.modify());
chai.assert.isTrue(Blockly.navigation.modify_());
chai.assert.isNull(this.row_block_2.getParent());
var pos = this.row_block_2.getRelativeToSurfaceXY();
chai.assert.equal(100, pos.x);
@@ -270,7 +306,7 @@ suite('Insert/Modify', function() {
Blockly.ASTNode.createBlockNode(
this.stack_block_2));
chai.assert.isTrue(Blockly.navigation.modify());
chai.assert.isTrue(Blockly.navigation.modify_());
chai.assert.isNull(this.stack_block_2.getParent());
var pos = this.stack_block_2.getRelativeToSurfaceXY();
chai.assert.equal(100, pos.x);
@@ -281,7 +317,7 @@ suite('Insert/Modify', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createWorkspaceNode(
this.workspace, new Blockly.utils.Coordinate(100, 100)));
chai.assert.isFalse(Blockly.navigation.modify());
chai.assert.isFalse(Blockly.navigation.modify_());
});
});
@@ -300,7 +336,7 @@ suite('Insert/Modify', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createWorkspaceNode(
this.workspace, new Blockly.utils.Coordinate(100, 100)));
chai.assert.isFalse(Blockly.navigation.modify());
chai.assert.isFalse(Blockly.navigation.modify_());
});
});
@@ -314,25 +350,25 @@ suite('Insert/Modify', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createBlockNode(
this.row_block_1));
chai.assert.isFalse(Blockly.navigation.modify());
chai.assert.isFalse(Blockly.navigation.modify_());
});
test('Cursor on stack block', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createBlockNode(
this.stack_block_1));
chai.assert.isFalse(Blockly.navigation.modify());
chai.assert.isFalse(Blockly.navigation.modify_());
});
test('Cursor on next connection', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createConnectionNode(
this.stack_block_2.nextConnection));
chai.assert.isFalse(Blockly.navigation.modify());
chai.assert.isFalse(Blockly.navigation.modify_());
});
test('Cursor on previous connection', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createConnectionNode(
this.stack_block_2.previousConnection));
chai.assert.isFalse(Blockly.navigation.modify());
chai.assert.isFalse(Blockly.navigation.modify_());
});
});
suite('Marked row block', function() {
@@ -345,25 +381,25 @@ suite('Insert/Modify', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createBlockNode(
this.stack_block_1));
chai.assert.isFalse(Blockly.navigation.modify());
chai.assert.isFalse(Blockly.navigation.modify_());
});
test('Cursor on row block', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createBlockNode(
this.row_block_1));
chai.assert.isFalse(Blockly.navigation.modify());
chai.assert.isFalse(Blockly.navigation.modify_());
});
test('Cursor on value input connection', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createConnectionNode(
this.row_block_2.inputList[0].connection));
chai.assert.isFalse(Blockly.navigation.modify());
chai.assert.isFalse(Blockly.navigation.modify_());
});
test('Cursor on output connection', function() {
Blockly.navigation.cursor_.setLocation(
Blockly.ASTNode.createConnectionNode(
this.row_block_2.outputConnection));
chai.assert.isFalse(Blockly.navigation.modify());
chai.assert.isFalse(Blockly.navigation.modify_());
});
});
});

View File

@@ -282,13 +282,13 @@ suite('Navigation', function() {
});
test('Insert', function() {
sinon.spy(Blockly.navigation, 'modify');
sinon.spy(Blockly.navigation, 'modify_');
this.mockEvent.keyCode = Blockly.utils.KeyCodes.I;
chai.assert.isTrue(Blockly.navigation.onKeyPress(this.mockEvent));
chai.assert.isTrue(Blockly.navigation.modify.calledOnce);
chai.assert.isTrue(Blockly.navigation.modify_.calledOnce);
chai.assert.equal(Blockly.navigation.currentState_,
Blockly.navigation.STATE_WS);
Blockly.navigation.modify.restore();
Blockly.navigation.modify_.restore();
});
test('Mark', function() {
@@ -504,7 +504,7 @@ suite('Navigation', function() {
var sourceNode = Blockly.ASTNode.createConnectionNode(this.basicBlock2.nextConnection);
Blockly.navigation.cursor_.setLocation(sourceNode);
Blockly.navigation.modify();
Blockly.navigation.modify_();
var insertedBlock = this.basicBlock.previousConnection.targetBlock();
chai.assert.isNotNull(insertedBlock);
@@ -673,5 +673,16 @@ suite('Navigation', function() {
chai.assert.equal(this.workspace.cursor.getCurNode().getType(),
Blockly.ASTNode.types.WORKSPACE);
});
test('Delete top block in stack', function() {
this.basicBlockA.nextConnection.connect(this.basicBlockB.previousConnection);
var astNode = Blockly.ASTNode.createStackNode(this.basicBlockA);
// Set the cursor to be on the stack
this.workspace.cursor.setLocation(astNode);
// Remove the top block in the stack
this.basicBlockA.dispose();
chai.assert.equal(this.workspace.cursor.getCurNode().getType(),
Blockly.ASTNode.types.WORKSPACE);
});
});
});

View File

@@ -1,7 +1,7 @@
/* exported assertEquals, assertNotEquals, assertArrayEquals, assertTrue, assertFalse,
assertNull, assertNotNull, assertNotNullNorUndefined, assert,
isEqualArrays, assertUndefined, assertNotUndefined,
defineRowBlock, defineStackBlock */
defineRowBlock, defineStackBlock, defineStatementBlock */
function _argumentsIncludeComments(expectedNumberOfNonCommentArgs, args) {
return args.length == expectedNumberOfNonCommentArgs + 1;
}
@@ -158,3 +158,21 @@ function defineRowBlock() {
}]);
}
function defineStatementBlock() {
Blockly.defineBlocksWithJsonArray([{
"type": "statement_block",
"message0": "%1",
"args0": [
{
"type": "input_statement",
"name": "NAME"
}
],
"previousStatement": null,
"nextStatement": null,
"colour": 230,
"tooltip": "",
"helpUrl": ""
}]);
}