mirror of
https://github.com/google/blockly.git
synced 2026-01-10 02:17:09 +01:00
Merge pull request #1124 from marisaleung/develop_appease_lint
Appease eslint: semicolons and such.
This commit is contained in:
@@ -155,7 +155,7 @@ Blockly.FieldVariable.dropdownCreate = function() {
|
||||
}
|
||||
options.push([Blockly.Msg.RENAME_VARIABLE, Blockly.RENAME_VARIABLE_ID]);
|
||||
options.push([Blockly.Msg.DELETE_VARIABLE.replace('%1', name),
|
||||
Blockly.DELETE_VARIABLE_ID]);
|
||||
Blockly.DELETE_VARIABLE_ID]);
|
||||
return options;
|
||||
};
|
||||
|
||||
|
||||
@@ -81,8 +81,10 @@ Blockly.VariableModel.prototype.getId = function() {
|
||||
* A custom compare function for the VariableModel objects.
|
||||
* @param {Blockly.VariableModel} var1 First variable to compare.
|
||||
* @param {Blockly.VariableModel} var2 Second variable to compare.
|
||||
* @return {number} -1 if name of var1 is less than name of var2, 0 if equal,
|
||||
* and 1 if greater.
|
||||
* @package
|
||||
*/
|
||||
Blockly.VariableModel.compareByName = function(var1, var2) {
|
||||
return goog.string.caseInsensitiveCompare(var1.name, var2.name)
|
||||
return goog.string.caseInsensitiveCompare(var1.name, var2.name);
|
||||
};
|
||||
|
||||
@@ -215,8 +215,8 @@ Blockly.Workspace.prototype.updateVariableStore = function(clear) {
|
||||
// Get variable model with the used variable name.
|
||||
var tempVar = this.getVariable(name);
|
||||
if (tempVar) {
|
||||
varList.push({'name': tempVar.name, 'type': tempVar.type,
|
||||
'id': tempVar.getId()});
|
||||
varList.push({'name': tempVar.name, 'type': tempVar.type,
|
||||
'id': tempVar.getId()});
|
||||
}
|
||||
else {
|
||||
varList.push({'name': name, 'type': null, 'id': null});
|
||||
@@ -248,7 +248,7 @@ Blockly.Workspace.prototype.renameVariableInternal_ = function(variable, newName
|
||||
|
||||
// If they are different types, throw an error.
|
||||
if (variable && newVariable && variable.type != newVariable.type) {
|
||||
throw Error('Variable "' + oldName + '" is type "' + variable.type +
|
||||
throw Error('Variable "' + variable.name + '" is type "' + variable.type +
|
||||
'" and variable "' + newName + '" is type "' + newVariable.type +
|
||||
'". Both must be the same type.');
|
||||
}
|
||||
@@ -295,7 +295,7 @@ Blockly.Workspace.prototype.renameVariable = function(oldName, newName) {
|
||||
Blockly.Workspace.prototype.renameVariableById = function(id, newName) {
|
||||
var variable = this.getVariableById(id);
|
||||
this.renameVariableInternal_(variable, newName);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a variable with a given name, optional type, and optional id.
|
||||
|
||||
@@ -103,7 +103,7 @@ function test_createVariableTrivial() {
|
||||
function test_createVariableAlreadyExists() {
|
||||
// Expect that when the variable already exists, the variableMap_ is unchanged.
|
||||
variableMapTest_setUp();
|
||||
var var_1 = variable_map.createVariable('name1', 'type1', 'id1');
|
||||
variable_map.createVariable('name1', 'type1', 'id1');
|
||||
|
||||
// Assert there is only one variable in the variable_map.
|
||||
var keys = Object.keys(variable_map.variableMap_);
|
||||
|
||||
@@ -75,4 +75,4 @@ function testInit_OnlyNameProvided() {
|
||||
assertEquals('', variable.type);
|
||||
assertNotNull(variable.id_);
|
||||
variableTest_tearDown();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,14 +26,14 @@ var workspace;
|
||||
var mockControl_;
|
||||
var saved_msg = Blockly.Msg.DELETE_VARIABLE;
|
||||
Blockly.defineBlocksWithJsonArray([{
|
||||
"type": "get_var_block",
|
||||
"message0": "%1",
|
||||
"args0": [
|
||||
{
|
||||
"type": "field_variable",
|
||||
"name": "VAR",
|
||||
}
|
||||
]
|
||||
"type": "get_var_block",
|
||||
"message0": "%1",
|
||||
"args0": [
|
||||
{
|
||||
"type": "field_variable",
|
||||
"name": "VAR",
|
||||
}
|
||||
]
|
||||
}]);
|
||||
|
||||
function workspaceTest_setUp() {
|
||||
@@ -220,7 +220,7 @@ function test_getBlockById() {
|
||||
}
|
||||
|
||||
function test_deleteVariable_InternalTrivial() {
|
||||
workspaceTest_setUpWithMockBlocks()
|
||||
workspaceTest_setUpWithMockBlocks();
|
||||
var var_1 = workspace.createVariable('name1', 'type1', 'id1');
|
||||
workspace.createVariable('name2', 'type2', 'id2');
|
||||
createMockBlock('name1');
|
||||
@@ -309,7 +309,7 @@ function test_updateVariableStore_ClearAndOneInUse() {
|
||||
}
|
||||
|
||||
function test_addTopBlock_TrivialFlyoutIsTrue() {
|
||||
workspaceTest_setUpWithMockBlocks()
|
||||
workspaceTest_setUpWithMockBlocks();
|
||||
workspace.isFlyout = true;
|
||||
var block = createMockBlock();
|
||||
workspace.removeTopBlock(block);
|
||||
@@ -395,7 +395,7 @@ function test_renameVariable_NoBlocks() {
|
||||
|
||||
function test_renameVariable_SameNameNoBlocks() {
|
||||
// Expect 'renameVariable' to create new variable with newName.
|
||||
workspaceTest_setUpWithMockBlocks()
|
||||
workspaceTest_setUpWithMockBlocks();
|
||||
var name = 'name1';
|
||||
workspace.createVariable(name, 'type1', 'id1');
|
||||
|
||||
@@ -406,7 +406,7 @@ function test_renameVariable_SameNameNoBlocks() {
|
||||
|
||||
function test_renameVariable_OnlyOldNameBlockExists() {
|
||||
// Expect 'renameVariable' to change oldName variable name to newName.
|
||||
workspaceTest_setUpWithMockBlocks()
|
||||
workspaceTest_setUpWithMockBlocks();
|
||||
var oldName = 'name1';
|
||||
var newName = 'name2';
|
||||
workspace.createVariable(oldName, 'type1', 'id1');
|
||||
@@ -424,7 +424,7 @@ function test_renameVariable_OnlyOldNameBlockExists() {
|
||||
function test_renameVariable_TwoVariablesSameType() {
|
||||
// Expect 'renameVariable' to change oldName variable name to newName.
|
||||
// Expect oldName block name to change to newName
|
||||
workspaceTest_setUpWithMockBlocks()
|
||||
workspaceTest_setUpWithMockBlocks();
|
||||
var oldName = 'name1';
|
||||
var newName = 'name2';
|
||||
workspace.createVariable(oldName, 'type1', 'id1');
|
||||
@@ -445,7 +445,7 @@ function test_renameVariable_TwoVariablesSameType() {
|
||||
|
||||
function test_renameVariable_TwoVariablesDifferentType() {
|
||||
// Expect triggered error because of different types
|
||||
workspaceTest_setUpWithMockBlocks()
|
||||
workspaceTest_setUpWithMockBlocks();
|
||||
var oldName = 'name1';
|
||||
var newName = 'name2';
|
||||
workspace.createVariable(oldName, 'type1', 'id1');
|
||||
@@ -478,14 +478,14 @@ function test_renameVariable_OldCase() {
|
||||
|
||||
workspace.renameVariable(oldCase, newName);
|
||||
workspaceTest_checkVariableValues(newName, 'type1', 'id1');
|
||||
var result_oldCase = workspace.getVariable(oldCase).name
|
||||
var result_oldCase = workspace.getVariable(oldCase).name;
|
||||
assertNotEquals(oldCase, result_oldCase);
|
||||
workspaceTest_tearDownWithMockBlocks();
|
||||
}
|
||||
|
||||
function test_renameVariable_TwoVariablesAndOldCase() {
|
||||
// Expect triggered error because of different types
|
||||
workspaceTest_setUpWithMockBlocks()
|
||||
workspaceTest_setUpWithMockBlocks();
|
||||
var oldName = 'name1';
|
||||
var oldCase = 'Name2';
|
||||
var newName = 'name2';
|
||||
@@ -513,7 +513,7 @@ function test_renameVariable_TwoVariablesAndOldCase() {
|
||||
function test_renameVariableById_TwoVariablesSameType() {
|
||||
// Expect 'renameVariableById' to change oldName variable name to newName.
|
||||
// Expect oldName block name to change to newName
|
||||
workspaceTest_setUpWithMockBlocks()
|
||||
workspaceTest_setUpWithMockBlocks();
|
||||
var oldName = 'name1';
|
||||
var newName = 'name2';
|
||||
workspace.createVariable(oldName, 'type1', 'id1');
|
||||
@@ -523,7 +523,7 @@ function test_renameVariableById_TwoVariablesSameType() {
|
||||
|
||||
workspace.renameVariableById('id1', newName);
|
||||
workspaceTest_checkVariableValues(newName, 'type1', 'id2');
|
||||
var variable = workspace.getVariable(oldName)
|
||||
var variable = workspace.getVariable(oldName);
|
||||
var block_var_name_1 = workspace.topBlocks_[0].getVars()[0];
|
||||
var block_var_name_2 = workspace.topBlocks_[1].getVars()[0];
|
||||
assertNull(variable);
|
||||
@@ -533,7 +533,7 @@ function test_renameVariableById_TwoVariablesSameType() {
|
||||
}
|
||||
|
||||
function test_deleteVariable_Trivial() {
|
||||
workspaceTest_setUpWithMockBlocks()
|
||||
workspaceTest_setUpWithMockBlocks();
|
||||
workspace.createVariable('name1', 'type1', 'id1');
|
||||
workspace.createVariable('name2', 'type1', 'id2');
|
||||
createMockBlock('name1');
|
||||
@@ -549,7 +549,7 @@ function test_deleteVariable_Trivial() {
|
||||
}
|
||||
|
||||
function test_deleteVariableById_Trivial() {
|
||||
workspaceTest_setUpWithMockBlocks()
|
||||
workspaceTest_setUpWithMockBlocks();
|
||||
workspace.createVariable('name1', 'type1', 'id1');
|
||||
workspace.createVariable('name2', 'type1', 'id2');
|
||||
createMockBlock('name1');
|
||||
|
||||
@@ -308,17 +308,17 @@ function test_appendDomToWorkspace() {
|
||||
}
|
||||
|
||||
function test_blockToDom_fieldToDom_trivial() {
|
||||
xmlTest_setUpWithMockBlocks()
|
||||
xmlTest_setUpWithMockBlocks();
|
||||
workspace.createVariable('name1', 'type1', 'id1');
|
||||
var block = new Blockly.Block(workspace, 'field_variable_test_block');
|
||||
block.inputList[0].fieldRow[0].setValue('name1');
|
||||
var resultFieldDom = Blockly.Xml.blockToDom(block).childNodes[0];
|
||||
xmlTest_checkVariableFieldDomValues(resultFieldDom, 'VAR', 'type1', 'id1', 'name1')
|
||||
xmlTest_tearDownWithMockBlocks()
|
||||
xmlTest_tearDownWithMockBlocks();
|
||||
}
|
||||
|
||||
function test_blockToDom_fieldToDom_defaultCase() {
|
||||
xmlTest_setUpWithMockBlocks()
|
||||
xmlTest_setUpWithMockBlocks();
|
||||
var mockGenUid = mockControl_.createMethodMock(Blockly.utils, 'genUid');
|
||||
mockGenUid().$returns('1');
|
||||
mockGenUid().$replay();
|
||||
@@ -327,8 +327,8 @@ function test_blockToDom_fieldToDom_defaultCase() {
|
||||
block.inputList[0].fieldRow[0].setValue('name1');
|
||||
var resultFieldDom = Blockly.Xml.blockToDom(block).childNodes[0];
|
||||
// Expect type is '' and id is '1' since we don't specify type and id.
|
||||
xmlTest_checkVariableFieldDomValues(resultFieldDom, 'VAR', '', '1', 'name1')
|
||||
xmlTest_tearDownWithMockBlocks()
|
||||
xmlTest_checkVariableFieldDomValues(resultFieldDom, 'VAR', '', '1', 'name1');
|
||||
xmlTest_tearDownWithMockBlocks();
|
||||
}
|
||||
|
||||
function test_blockToDom_fieldToDom_notAFieldVariable() {
|
||||
@@ -343,12 +343,12 @@ function test_blockToDom_fieldToDom_notAFieldVariable() {
|
||||
}
|
||||
],
|
||||
}]);
|
||||
xmlTest_setUpWithMockBlocks()
|
||||
xmlTest_setUpWithMockBlocks();
|
||||
var block = new Blockly.Block(workspace, 'field_angle_test_block');
|
||||
var resultFieldDom = Blockly.Xml.blockToDom(block).childNodes[0];
|
||||
xmlTest_checkNonVariableField(resultFieldDom, 'VAR', '90');
|
||||
delete Blockly.Blocks.field_angle_block;
|
||||
xmlTest_tearDownWithMockBlocks()
|
||||
xmlTest_tearDownWithMockBlocks();
|
||||
}
|
||||
|
||||
function test_variablesToDom_oneVariable() {
|
||||
|
||||
Reference in New Issue
Block a user