Merge make.strings into make.text

This commit is contained in:
pyoor 2017-05-31 15:57:05 -04:00
parent 96d2ffa450
commit 7f68b11902
2 changed files with 12 additions and 42 deletions

View File

@ -1,42 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
make.strings = {
toString: function (object) {
return object ? object.toSource() : '' + object
},
string: function (maxlen) {
let s = ''
if (maxlen === null || maxlen === undefined) {
maxlen = make.number.rangeNumber()
}
for (let i = 0; i < maxlen; i++) {
// Todo: s += String.fromCodePoint(Random.pick(make.fonts.layoutCharCodes));
s += 'A'
}
return s
},
quotedString: function (maxlen) {
return utils.common.quote(make.strings.string(maxlen))
},
stringFromBlocks: function (set, maxlen) {
let s = ''
for (let i = 0; i < random.number(maxlen || 255); i++) {
s += random.pick(set)
}
return s
},
digitsHex: function (n) {
let s = ''
while (n-- > 0) {
s += (random.number(16)).toString(16)
}
return s
}
}

View File

@ -179,6 +179,18 @@ make.text = {
'XBD', 'XSU', 'XTS', 'XXX'
])
},
fromBlocks: function (set, maxlen) {
let s = ''
for (let i=0; i<random.number(maxlen || 255); i++) {
s += random.pick(set)
}
return s
},
quotedString: function () {
return utils.common.quote(make.text.any())
},
chars: function() {
return random.pick([
make.text.controlChar,