diff --git a/core/procedures.js b/core/procedures.js
index eef9c9d2a..98ebf41b6 100644
--- a/core/procedures.js
+++ b/core/procedures.js
@@ -140,11 +140,11 @@ Blockly.Procedures.isNameUsed = function(name, workspace, opt_exclude) {
if (blocks[i].getProcedureDef) {
var procName = blocks[i].getProcedureDef();
if (Blockly.Names.equals(procName[0], name)) {
- return false;
+ return true;
}
}
}
- return true;
+ return false;
};
/**
diff --git a/core/variables.js b/core/variables.js
index 2cf00d5f4..ac952844e 100644
--- a/core/variables.js
+++ b/core/variables.js
@@ -248,7 +248,7 @@ Blockly.Variables.createVariable = function(workspace, opt_callback, opt_type) {
promptAndCheckWithAlert(text); // Recurse
});
}
- else if (!Blockly.Procedures.isNameUsed(text, workspace)) {
+ else if (Blockly.Procedures.isNameUsed(text, workspace)) {
Blockly.alert(Blockly.Msg.PROCEDURE_ALREADY_EXISTS.replace('%1',
text.toLowerCase()),
function() {
@@ -297,7 +297,7 @@ Blockly.Variables.renameVariable = function(workspace, variable,
promptAndCheckWithAlert(newName); // Recurse
});
}
- else if (!Blockly.Procedures.isNameUsed(newName, workspace)) {
+ else if (Blockly.Procedures.isNameUsed(newName, workspace)) {
Blockly.alert(Blockly.Msg.PROCEDURE_ALREADY_EXISTS.replace('%1',
newName.toLowerCase()),
function() {
diff --git a/tests/jsunit/index.html b/tests/jsunit/index.html
index dd62a536a..940111ecb 100644
--- a/tests/jsunit/index.html
+++ b/tests/jsunit/index.html
@@ -25,6 +25,7 @@
+