Fixed review comments.

This commit is contained in:
Beka Westberg
2019-06-25 15:07:07 -07:00
parent 347519b2a1
commit b34ca2f93b
4 changed files with 25 additions and 52 deletions

View File

@@ -164,45 +164,18 @@ Blockly.Blocks['procedures_defnoreturn'] = {
* @this Blockly.Block
*/
decompose: function(workspace) {
/*var containerBlock = workspace.newBlock('procedures_mutatorcontainer');
containerBlock.initSvg();
// Check/uncheck the allow statement box.
if (this.getInput('RETURN')) {
containerBlock.setFieldValue(
this.hasStatements_ ? 'TRUE' : 'FALSE', 'STATEMENTS');
} else {
containerBlock.removeInput('STATEMENT_INPUT');
}
// Parameter list.
var connection = containerBlock.getInput('STACK').connection;
for (var i = 0; i < this.arguments_.length; i++) {
var paramBlock = workspace.newBlock('procedures_mutatorarg');
paramBlock.initSvg();
paramBlock.setFieldValue(this.arguments_[i], 'NAME');
// Store the old location.
paramBlock.oldLocation = i;
connection.connect(paramBlock.previousConnection);
connection = paramBlock.nextConnection;
}*/
var xml = Blockly.Xml.textToDom(
'<xml>' +
' <block type="procedures_mutatorcontainer">' +
' <statement name="STACK"></statement>' +
' </block>' +
'</xml>').children[0];
'<block type="procedures_mutatorcontainer">' +
' <statement name="STACK"></statement>' +
'</block>');
var node = xml.getElementsByTagName('statement')[0];
for (var i = 0; i < this.arguments_.length; i++) {
node.appendChild(Blockly.Xml.textToDom(
'<xml>' +
' <block type="procedures_mutatorarg">' +
' <field name="NAME">' + this.arguments_[i] + '</field>' +
' <next></next>' +
' </block>' +
'</xml>'
).children[0]);
'<block type="procedures_mutatorarg">' +
' <field name="NAME">' + this.arguments_[i] + '</field>' +
' <next></next>' +
'</block>'
));
node = node.getElementsByTagName('xml');
}

View File

@@ -68,7 +68,7 @@ suite('Variable Fields', function() {
sinon.restore();
});
test.skip('Dropdown contains variables', function() {
test('Dropdown contains variables', function() {
// Expect that the dropdown options will contain the variables that exist
this.workspace.createVariable('name1', '', 'id1');
this.workspace.createVariable('name2', '', 'id2');
@@ -81,7 +81,7 @@ suite('Variable Fields', function() {
fieldVariable);
// Expect three variable options and a rename option.
assertEquals(result_options.length, 4);
assertEquals(result_options.length, 5);
isEqualArrays(result_options[0], ['name1', 'id1']);
isEqualArrays(result_options[1], ['name2', 'id2']);
isEqualArrays(result_options[2], ['name3', 'id3']);

View File

@@ -7,14 +7,6 @@
<link href="https://unpkg.com/mocha@5.2.0/mocha.css" rel="stylesheet" />
<script src="../../blockly_uncompressed.js"></script>
<script src="../../msg/messages.js"></script>
<script src="../../blocks/logic.js"></script>
<script src="../../blocks/loops.js"></script>
<script src="../../blocks/math.js"></script>
<script src="../../blocks/text.js"></script>
<script src="../../blocks/lists.js"></script>
<script src="../../blocks/colour.js"></script>
<script src="../../blocks/variables.js"></script>
<script src="../../blocks/variables_dynamic.js"></script>
<script src="../../blocks/procedures.js"></script>
</head>
<body>

View File

@@ -2,7 +2,7 @@
* @license
* Blockly Tests
*
* Copyright 2017 Google Inc.
* Copyright 2019 Google Inc.
* https://developers.google.com/blockly/
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -42,9 +42,9 @@ suite('Procedures', function() {
context.defType = types[0];
context.callType = types[1];
context.defBlock = new Blockly.Block(this.workspace, types[0]);
context.defBlock = new Blockly.Block(this.workspace, context.defType);
context.defBlock.setFieldValue(startName, 'NAME');
context.callBlock = new Blockly.Block(this.workspace, types[1]);
context.callBlock = new Blockly.Block(this.workspace, context.callType);
context.callBlock.setFieldValue(startName, 'NAME');
func.call(context);
context.defBlock.dispose();
@@ -234,10 +234,17 @@ suite('Procedures', function() {
caller2.dispose();
}, 'name1');
});
// This can happen using the trashcan to retrieve blocks.
test.skip('Call Different Case', function() {
// This can occur if you:
// 1) Create an uppercase definition and call block.
// 2) Delete both blocks.
// 3) Create a lowercase definition and call block.
// 4) Retrieve the uppercase call block from the trashcan.
// (And vise versa for creating lowercase blocks first)
// When converted to code all function names will be lowercase, so a
// caller should still be returned for a differently-cased procedure.
test('Call Different Case', function() {
this.callForAllTypes(function() {
this.callBlock.setFieldValue('NAME', 'NAME');
this.callBlock.setFieldValue('NAME1', 'NAME');
var callers = Blockly.Procedures.getCallers('name1', this.workspace);
chai.assert.equal(callers.length, 1);
chai.assert.equal(callers[0], this.callBlock);
@@ -387,7 +394,8 @@ suite('Procedures', function() {
clearVariables.call(this);
}, 'name');
});
test('Set Arg Empty (#1958)', function() {
// Test case for #1958
test('Set Arg Empty', function() {
this.callForAllTypes(function() {
var args = ['arg1'];
createMutator.call(this, args);