Fixes to Generator tests (#1510)

* Remove unneeded report variable from generator tests.
* Fix missing message parameter in unittest_fail.  This was a compile error in Dart.
* Fix indentation in PHP.
* Equality helper function not needed in PHP.
This commit is contained in:
Neil Fraser
2017-12-12 17:38:38 -08:00
committed by GitHub
parent 0cb5dfc437
commit bc1a5baa48
5 changed files with 118 additions and 157 deletions

View File

@@ -63,13 +63,10 @@ Blockly.JavaScript['unittest_main'] = function(block) {
// Run tests (unindented).
code += Blockly.JavaScript.statementToCode(block, 'DO')
.replace(/^ /, '').replace(/\n /g, '\n');
var reportVar = Blockly.JavaScript.variableDB_.getDistinctName(
'report', Blockly.Variables.NAME_TYPE);
code += 'var ' + reportVar + ' = ' + functionName + '();\n';
// Send the report to the console (that's where errors will go anyway).
code += 'console.log(' + functionName + '());\n';
// Destroy results.
code += resultsVar + ' = null;\n';
// Send the report to the console (that's where errors will go anyway).
code += 'console.log(' + reportVar + ');\n';
return code;
};
@@ -147,8 +144,7 @@ Blockly.JavaScript['unittest_fail'] = function(block) {
// Always assert an error.
var resultsVar = Blockly.JavaScript.variableDB_.getName('unittestResults',
Blockly.Variables.NAME_TYPE);
var message = Blockly.JavaScript.valueToCode(block, 'MESSAGE',
Blockly.JavaScript.ORDER_NONE) || '';
var message = Blockly.JavaScript.quote_(block.getFieldValue('MESSAGE'));
var functionName = Blockly.JavaScript.provideFunction_(
'unittest_fail',
[ 'function ' + Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_ +