mirror of
https://github.com/google/blockly.git
synced 2026-01-10 02:17:09 +01:00
Move tokenizeIntepolation into Blockly.utils namespace.
This commit is contained in:
@@ -1021,7 +1021,7 @@ Blockly.Block.prototype.jsonInit = function(json) {
|
||||
* @private
|
||||
*/
|
||||
Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign) {
|
||||
var tokens = Blockly.tokenizeInterpolation(message);
|
||||
var tokens = Blockly.utils.tokenizeInterpolation(message);
|
||||
// Interpolate the arguments. Build a list of elements.
|
||||
var indexDup = [];
|
||||
var indexCount = 0;
|
||||
|
||||
@@ -549,7 +549,8 @@ Blockly.addChangeListener = function(func) {
|
||||
|
||||
/**
|
||||
* Returns the main workspace. Returns the last used main workspace (based on
|
||||
* focus).
|
||||
* focus). Try not to use this function, particularly if there are multiple
|
||||
* Blockly instances on a page.
|
||||
* @return {!Blockly.Workspace} The main workspace.
|
||||
*/
|
||||
Blockly.getMainWorkspace = function() {
|
||||
|
||||
@@ -423,7 +423,7 @@ Blockly.isNumber = function(str) {
|
||||
* @param {string} message Text containing interpolation tokens.
|
||||
* @return {!Array.<string|number>} Array of strings and numbers.
|
||||
*/
|
||||
Blockly.tokenizeInterpolation = function(message) {
|
||||
Blockly.utils.tokenizeInterpolation = function(message) {
|
||||
var tokens = [];
|
||||
var chars = message.split('');
|
||||
chars.push(''); // End marker.
|
||||
|
||||
@@ -123,18 +123,18 @@ function test_commonWordSuffix() {
|
||||
}
|
||||
|
||||
function test_tokenizeInterpolation() {
|
||||
var tokens = Blockly.tokenizeInterpolation('');
|
||||
var tokens = Blockly.utils.tokenizeInterpolation('');
|
||||
assertArrayEquals('Null interpolation', [], tokens);
|
||||
tokens = Blockly.tokenizeInterpolation('Hello');
|
||||
tokens = Blockly.utils.tokenizeInterpolation('Hello');
|
||||
assertArrayEquals('No interpolation', ['Hello'], tokens);
|
||||
tokens = Blockly.tokenizeInterpolation('Hello%World');
|
||||
tokens = Blockly.utils.tokenizeInterpolation('Hello%World');
|
||||
assertArrayEquals('Unescaped %.', ['Hello%World'], tokens);
|
||||
tokens = Blockly.tokenizeInterpolation('Hello%%World');
|
||||
tokens = Blockly.utils.tokenizeInterpolation('Hello%%World');
|
||||
assertArrayEquals('Escaped %.', ['Hello%World'], tokens);
|
||||
tokens = Blockly.tokenizeInterpolation('Hello %1 World');
|
||||
tokens = Blockly.utils.tokenizeInterpolation('Hello %1 World');
|
||||
assertArrayEquals('Interpolation.', ['Hello ', 1, ' World'], tokens);
|
||||
tokens = Blockly.tokenizeInterpolation('%123Hello%456World%789');
|
||||
tokens = Blockly.utils.tokenizeInterpolation('%123Hello%456World%789');
|
||||
assertArrayEquals('Interpolations.', [123, 'Hello', 456, 'World', 789], tokens);
|
||||
tokens = Blockly.tokenizeInterpolation('%%%x%%0%00%01%');
|
||||
tokens = Blockly.utils.tokenizeInterpolation('%%%x%%0%00%01%');
|
||||
assertArrayEquals('Torture interpolations.', ['%%x%0', 0, 1, '%'], tokens);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user