diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 9d9b690f..626338fe 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -169,10 +169,6 @@ getJasmineRequireObj().requireMatchers = function(jRequire, j$) { }; getJasmineRequireObj().base = function(j$, jasmineGlobal) { - j$.unimplementedMethod_ = function() { - throw new Error('unimplemented method'); - }; - /** * Maximum object depth the pretty printer will print to. * Set this to a lower value to speed up pretty printing if you have large objects. @@ -600,34 +596,10 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { getJasmineRequireObj().util = function(j$) { const util = {}; - util.inherit = function(childClass, parentClass) { - const Subclass = function() {}; - Subclass.prototype = parentClass.prototype; - childClass.prototype = new Subclass(); - }; - - util.argsToArray = function(args) { - const arrayOfArgs = []; - for (let i = 0; i < args.length; i++) { - arrayOfArgs.push(args[i]); - } - return arrayOfArgs; - }; - util.isUndefined = function(obj) { return obj === void 0; }; - util.arrayContains = function(array, search) { - let i = array.length; - while (i--) { - if (array[i] === search) { - return true; - } - } - return false; - }; - util.clone = function(obj) { if (Object.prototype.toString.apply(obj) === '[object Array]') { return obj.slice(); @@ -644,22 +616,19 @@ getJasmineRequireObj().util = function(j$) { }; util.cloneArgs = function(args) { - const clonedArgs = []; - const argsAsArray = j$.util.argsToArray(args); - for (let i = 0; i < argsAsArray.length; i++) { - const str = Object.prototype.toString.apply(argsAsArray[i]), + return Array.from(args).map(function(arg) { + const str = Object.prototype.toString.apply(arg), primitives = /^\[object (Boolean|String|RegExp|Number)/; // All falsey values are either primitives, `null`, or `undefined. - if (!argsAsArray[i] || str.match(primitives)) { - clonedArgs.push(argsAsArray[i]); + if (!arg || str.match(primitives)) { + return arg; } else if (str === '[object Date]') { - clonedArgs.push(new Date(argsAsArray[i].valueOf())); + return new Date(arg.valueOf()); } else { - clonedArgs.push(j$.util.clone(argsAsArray[i])); + return j$.util.clone(arg); } - } - return clonedArgs; + }); }; util.getPropertyDescriptor = function(obj, methodName) { @@ -702,10 +671,6 @@ getJasmineRequireObj().util = function(j$) { }; })(); - function StopIteration() {} - StopIteration.prototype = Object.create(Error.prototype); - StopIteration.prototype.constructor = StopIteration; - util.validateTimeout = function(timeout, msgPrefix) { // Timeouts are implemented with setTimeout, which only supports a limited // range of values. The limit is unspecified, as is the behavior when it's @@ -3790,12 +3755,6 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) { ); } - function forEachFunction(funcsToRun, callback) { - for (const f of funcsToRun) { - callback(f); - } - } - function runScheduledFunctions(endTime, tickDate) { tickDate = tickDate || function() {}; if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) { @@ -3818,19 +3777,19 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) { delete scheduledFunctions[currentTime]; - forEachFunction(funcsToRun, function(funcToRun) { - if (funcToRun.recurring) { - reschedule(funcToRun); + for (const fn of funcsToRun) { + if (fn.recurring) { + reschedule(fn); } - }); + } - forEachFunction(funcsToRun, function(funcToRun) { - if (j$.util.arrayContains(deletedKeys, funcToRun.timeoutKey)) { + for (const fn of funcsToRun) { + if (deletedKeys.includes(fn.timeoutKey)) { // skip a timeoutKey deleted whilst we were running return; } - funcToRun.funcToCall.apply(null, funcToRun.params || []); - }); + fn.funcToCall.apply(null, fn.params || []); + } deletedKeys = []; } while ( scheduledLookup.length > 0 && @@ -4038,7 +3997,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) { let empty = true; for (const prop in error) { - if (j$.util.arrayContains(ignoredProperties, prop)) { + if (ignoredProperties.includes(prop)) { continue; } result[prop] = error[prop]; @@ -7611,7 +7570,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { } catch (e) { this.emitScalar('has-invalid-toString-method'); } - } else if (j$.util.arrayContains(this.seen, value)) { + } else if (this.seen.includes(value)) { this.emitScalar( ' endTime) { @@ -147,19 +141,19 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) { delete scheduledFunctions[currentTime]; - forEachFunction(funcsToRun, function(funcToRun) { - if (funcToRun.recurring) { - reschedule(funcToRun); + for (const fn of funcsToRun) { + if (fn.recurring) { + reschedule(fn); } - }); + } - forEachFunction(funcsToRun, function(funcToRun) { - if (j$.util.arrayContains(deletedKeys, funcToRun.timeoutKey)) { + for (const fn of funcsToRun) { + if (deletedKeys.includes(fn.timeoutKey)) { // skip a timeoutKey deleted whilst we were running return; } - funcToRun.funcToCall.apply(null, funcToRun.params || []); - }); + fn.funcToCall.apply(null, fn.params || []); + } deletedKeys = []; } while ( scheduledLookup.length > 0 && diff --git a/src/core/ExceptionFormatter.js b/src/core/ExceptionFormatter.js index 6cbff6da..e5ba82ed 100644 --- a/src/core/ExceptionFormatter.js +++ b/src/core/ExceptionFormatter.js @@ -83,7 +83,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) { let empty = true; for (const prop in error) { - if (j$.util.arrayContains(ignoredProperties, prop)) { + if (ignoredProperties.includes(prop)) { continue; } result[prop] = error[prop]; diff --git a/src/core/PrettyPrinter.js b/src/core/PrettyPrinter.js index f3231359..bc6b2224 100644 --- a/src/core/PrettyPrinter.js +++ b/src/core/PrettyPrinter.js @@ -61,7 +61,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) { } catch (e) { this.emitScalar('has-invalid-toString-method'); } - } else if (j$.util.arrayContains(this.seen, value)) { + } else if (this.seen.includes(value)) { this.emitScalar( '