diff --git a/blocks/procedures.js b/blocks/procedures.js index c14fab60d..45fd1709b 100644 --- a/blocks/procedures.js +++ b/blocks/procedures.js @@ -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( - '' + - ' ' + - ' ' + - ' ' + - '').children[0]; + '' + + ' ' + + ''); var node = xml.getElementsByTagName('statement')[0]; for (var i = 0; i < this.arguments_.length; i++) { node.appendChild(Blockly.Xml.textToDom( - '' + - ' ' + - ' ' + this.arguments_[i] + '' + - ' ' + - ' ' + - '' - ).children[0]); + '' + + ' ' + this.arguments_[i] + '' + + ' ' + + '' + )); node = node.getElementsByTagName('xml'); } diff --git a/tests/mocha/field_variable_test.js b/tests/mocha/field_variable_test.js index 0bfa75b45..f83f06718 100644 --- a/tests/mocha/field_variable_test.js +++ b/tests/mocha/field_variable_test.js @@ -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']); diff --git a/tests/mocha/index.html b/tests/mocha/index.html index 0c731e0cf..0025120a1 100644 --- a/tests/mocha/index.html +++ b/tests/mocha/index.html @@ -7,14 +7,6 @@ - - - - - - - - diff --git a/tests/mocha/procedures_test.js b/tests/mocha/procedures_test.js index 944a7b980..4b73fcfca 100644 --- a/tests/mocha/procedures_test.js +++ b/tests/mocha/procedures_test.js @@ -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);