chore(tests): update generator test blocks to use forBlock (#7311)

This commit is contained in:
Rachel Fenichel
2023-07-28 09:04:07 -07:00
committed by GitHub
parent c3aa970107
commit 9c24848039
5 changed files with 40 additions and 40 deletions

View File

@@ -9,7 +9,7 @@
*/
'use strict';
phpGenerator['unittest_main'] = function(block) {
phpGenerator.forBlock['unittest_main'] = function(block) {
// Container for unit tests.
var resultsVar = phpGenerator.nameDB_.getName('unittestResults',
Blockly.Names.DEVELOPER_VARIABLE_TYPE);
@@ -60,7 +60,7 @@ phpGenerator['unittest_main'] = function(block) {
return code;
};
phpGenerator['unittest_main'].defineAssert_ = function(block) {
function phpDefineAssert() {
var resultsVar = phpGenerator.nameDB_.getName('unittestResults',
Blockly.Names.DEVELOPER_VARIABLE_TYPE);
var functionName = phpGenerator.provideFunction_(
@@ -86,7 +86,7 @@ phpGenerator['unittest_main'].defineAssert_ = function(block) {
return functionName;
};
phpGenerator['unittest_assertequals'] = function(block) {
phpGenerator.forBlock['unittest_assertequals'] = function(block) {
// Asserts that a value equals another value.
var message = phpGenerator.valueToCode(block, 'MESSAGE',
phpGenerator.ORDER_NONE) || '';
@@ -94,11 +94,11 @@ phpGenerator['unittest_assertequals'] = function(block) {
phpGenerator.ORDER_NONE) || 'null';
var expected = phpGenerator.valueToCode(block, 'EXPECTED',
phpGenerator.ORDER_NONE) || 'null';
return phpGenerator['unittest_main'].defineAssert_() +
return phpDefineAssert() +
'(' + actual + ', ' + expected + ', ' + message + ');\n';
};
phpGenerator['unittest_assertvalue'] = function(block) {
phpGenerator.forBlock['unittest_assertvalue'] = function(block) {
// Asserts that a value is true, false, or null.
var message = phpGenerator.valueToCode(block, 'MESSAGE',
phpGenerator.ORDER_NONE) || '';
@@ -112,11 +112,11 @@ phpGenerator['unittest_assertvalue'] = function(block) {
} else if (expected == 'NULL') {
expected = 'null';
}
return phpGenerator['unittest_main'].defineAssert_() +
return phpDefineAssert() +
'(' + actual + ', ' + expected + ', ' + message + ');\n';
};
phpGenerator['unittest_fail'] = function(block) {
phpGenerator.forBlock['unittest_fail'] = function(block) {
// Always assert an error.
var resultsVar = phpGenerator.nameDB_.getName('unittestResults',
Blockly.Names.DEVELOPER_VARIABLE_TYPE);
@@ -135,7 +135,7 @@ phpGenerator['unittest_fail'] = function(block) {
return functionName + '(' + message + ');\n';
};
phpGenerator['unittest_adjustindex'] = function(block) {
phpGenerator.forBlock['unittest_adjustindex'] = function(block) {
var index = phpGenerator.valueToCode(block, 'INDEX',
phpGenerator.ORDER_ADDITION) || '0';
// Adjust index if using one-based indexing.