Use let instead of var in script.js

This commit is contained in:
Christoph Diehl 2017-05-02 17:01:32 +03:00
parent 2ed3e76ab2
commit b55264b24f

View file

@ -7,9 +7,9 @@ utils.script = {
if (isNaN(numOptional)) {
numOptional = 0
}
var arity = list.length - random.number(numOptional)
var params = []
for (var i = 0; i < arity; i++) {
let arity = list.length - random.number(numOptional)
let params = []
for (let i = 0; i < arity; i++) {
params.push(random.pick([list[i]]))
}
return '(' + params.join(', ') + ')'
@ -18,8 +18,8 @@ utils.script = {
if (!utils.common.getKeysFromHash(methodHash).length || !objectName) {
return ''
}
var methodName = random.key(methodHash)
var methodArgs = methodHash[methodName]
let methodName = random.key(methodHash)
let methodArgs = methodHash[methodName]
if (typeof (methodArgs) === 'function') { // Todo: Hmmmm..
return methodArgs()
}
@ -29,9 +29,9 @@ utils.script = {
if (!utils.common.getKeysFromHash(attributeHash).length || !objectName) {
return ''
}
var attributeName = random.key(attributeHash)
var attributeValue = random.pick(attributeHash[attributeName])
var operator = ' = '
let attributeName = random.key(attributeHash)
let attributeValue = random.pick(attributeHash[attributeName])
let operator = ' = '
/*
if (typeof(attributeValue) == "number" && Random.chance(8)) {
operator = " " + Make.randomAssignmentOperator() + " ";
@ -43,17 +43,17 @@ utils.script = {
return objectName + '.' + attributeName + operator + attributeValue + ';'
},
makeConstraint: function (keys, values) {
var o = {}
var n = random.range(0, keys.length)
let o = {}
let n = random.range(0, keys.length)
while (n--) {
o[random.pick(keys)] = random.pick(values)
}
return o
},
makeRandomOptions: function (baseObject) {
var o = {}
var unique = random.some(Object.keys(baseObject))
for (var i = 0; i < unique.length; i++) {
let o = {}
let unique = random.some(Object.keys(baseObject))
for (let i = 0; i < unique.length; i++) {
o[unique[i]] = random.pick(baseObject[unique[i]])
}
return JSON.stringify(o)
@ -65,7 +65,7 @@ utils.script = {
return 'try { ' + s + ' } catch(e) { }'
},
makeLoop: function (s, max) {
return 'for (var i = 0; i < ' + (max || make.number.rangeNumber()) + '; i++) {' + s + '}'
return 'for (let i = 0; i < ' + (max || make.number.rangeNumber()) + '; i++) {' + s + '}'
},
makeArray: function (type, arrayLength, cb) {
if (type === null || type === undefined) {
@ -73,7 +73,7 @@ utils.script = {
}
switch (random.number(8)) {
case 0:
var src = 'function() { var buffer = new ' + type + 'Array(' + arrayLength + ');'
let src = 'function() { let buffer = new ' + type + 'Array(' + arrayLength + ');'
src += utils.script.makeLoop('buffer[i] = ' + cb() + ';', arrayLength)
src += 'return buffer;}()'
return src