-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Added Procedure Tests #2576
Added Procedure Tests #2576
Conversation
blocks/procedures.js
Outdated
@@ -164,7 +164,7 @@ Blockly.Blocks['procedures_defnoreturn'] = { | |||
* @this Blockly.Block | |||
*/ | |||
decompose: function(workspace) { | |||
var containerBlock = workspace.newBlock('procedures_mutatorcontainer'); | |||
/*var containerBlock = workspace.newBlock('procedures_mutatorcontainer'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to change this because the initSvg() calls were breaking my tests.
@@ -205,11 +234,7 @@ Blockly.Blocks['procedures_defnoreturn'] = { | |||
var varName = paramBlock.getFieldValue('NAME'); | |||
this.arguments_.push(varName); | |||
var variable = this.workspace.getVariable(varName, ''); | |||
if (variable != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set the broken mocha test to skip because I'm not sure why the dropdownCreate function looks like this:
It broke because I had to add the msg files to the mocha and it started adding the delete option. |
XML tests would be great. If you are planning on writing more than 2 or 3 tests then I would create a xml_procedures_test.js file, otherwise I would just put them into the xml_test.js file |
tests/mocha/procedures_test.js
Outdated
* @license | ||
* Blockly Tests | ||
* | ||
* Copyright 2017 Google Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Change to 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -6,6 +6,16 @@ | |||
|
|||
<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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to include all these blocks? If we don't could you remove the ones that you are not using?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
tests/mocha/procedures_test.js
Outdated
context.defType = types[0]; | ||
context.callType = types[1]; | ||
|
||
context.defBlock = new Blockly.Block(this.workspace, types[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use context.defType instead of types[0]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
tests/mocha/procedures_test.js
Outdated
|
||
context.defBlock = new Blockly.Block(this.workspace, types[0]); | ||
context.defBlock.setFieldValue(startName, 'NAME'); | ||
context.callBlock = new Blockly.Block(this.workspace, types[1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
var callers = Blockly.Procedures.getCallers('name1', this.workspace); | ||
chai.assert.equal(callers.length, 1); | ||
chai.assert.equal(callers[0], this.callBlock); | ||
}, 'name'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you ad a bit more detailed comment here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote down a procedure for how to replicate it, does it sound good to you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup that is great thanks!
tests/mocha/procedures_test.js
Outdated
clearVariables.call(this); | ||
}, 'name'); | ||
}); | ||
test('Set Arg Empty (#1958)', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add #1958 in a comment instead of in the test case name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
blocks/procedures.js
Outdated
@@ -185,7 +185,36 @@ Blockly.Blocks['procedures_defnoreturn'] = { | |||
paramBlock.oldLocation = i; | |||
connection.connect(paramBlock.previousConnection); | |||
connection = paramBlock.nextConnection; | |||
}*/ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove commented out code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
tests/mocha/field_variable_test.js
Outdated
@@ -68,7 +68,7 @@ suite('Variable Fields', function() { | |||
sinon.restore(); | |||
}); | |||
|
|||
test('Dropdown contains variables', function() { | |||
test.skip('Dropdown contains variables', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the move here is to update the test to expect 5 instead of 4 since having the delete option is expected behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
c9eabf9
to
b34ca2f
Compare
Noted, probably won't get to it today but I have put it in my task management system. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@alschmiedt Did you want me to create issues for those skipped tests? |
Yup that would be great : ) I looked over them and they all seem like valid issues. |
The basics
The details
Resolves
I think this should cover closing #860
Proposed Changes
Adds tests to start covering procedure behavior.
[EDIT: I also removed the old jsunit tests because they were inaccurate]
Reason for Changes
Procedures were dangerously undocumented.
Test Coverage
Adds tests for:
Additional Information
Some things are broken, those tests are skipped. Here are two particularly bad ones I took gifs of:


But most things should be pretty easy to fix.
I'll create issues for the skipped tests once I get confirmation that all of them are bad.
Additional Additional Information
I'd also like to create XML tests for the procedures, would you like that in this file, the xml file, a new file, or none file (if you don't think it's useful)?