summaryrefslogtreecommitdiff
path: root/xstatic
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-06-24 14:00:02 +0000
committerGerrit Code Review <review@openstack.org>2015-06-24 14:00:02 +0000
commitcf95a6556c18762df48a3c66c28ccf0fea14c049 (patch)
tree493953f4adc1010ce56195230760f11e1be5b8be /xstatic
parent82972a4a754e042c937ec3d3bd9661696e69b42d (diff)
parent0274ed3433f23b763eee4123b09123397e82c963 (diff)
downloadxstatic-jasmine-2.2.0.1.tar.gz
Merge "Upgrade Jasmine to 2.2.0"2.2.0.12.2.0.0
Diffstat (limited to 'xstatic')
-rw-r--r--xstatic/pkg/jasmine/__init__.py4
-rwxr-xr-xxstatic/pkg/jasmine/data/boot.js3
-rwxr-xr-xxstatic/pkg/jasmine/data/console.js2
-rwxr-xr-xxstatic/pkg/jasmine/data/jasmine-html.js22
-rwxr-xr-xxstatic/pkg/jasmine/data/jasmine.js469
5 files changed, 326 insertions, 174 deletions
diff --git a/xstatic/pkg/jasmine/__init__.py b/xstatic/pkg/jasmine/__init__.py
index 21ab86f..59b285f 100644
--- a/xstatic/pkg/jasmine/__init__.py
+++ b/xstatic/pkg/jasmine/__init__.py
@@ -11,10 +11,10 @@ NAME = __name__.split('.')[-1] # package name (e.g. 'foo' or 'foo_bar')
# please use a all-lowercase valid python
# package name
-VERSION = '2.1.2' # version of the packaged files, please use the upstream
+VERSION = '2.2.0' # version of the packaged files, please use the upstream
# version number
BUILD = '0' # our package build number, so we can release new builds
- # with fixes for xstatic stuff.
+ # with fixes for xstatic stuff.
PACKAGE_VERSION = VERSION + '.' + BUILD # version used for PyPi
DESCRIPTION = "%s %s (XStatic packaging standard)" % (DISPLAY_NAME, VERSION)
diff --git a/xstatic/pkg/jasmine/data/boot.js b/xstatic/pkg/jasmine/data/boot.js
index 164f068..e8ddd55 100755
--- a/xstatic/pkg/jasmine/data/boot.js
+++ b/xstatic/pkg/jasmine/data/boot.js
@@ -62,7 +62,8 @@
*/
var htmlReporter = new jasmine.HtmlReporter({
env: env,
- onRaiseExceptionsClick: function() { queryString.setParam("catch", !env.catchingExceptions()); },
+ onRaiseExceptionsClick: function() { queryString.navigateWithNewParam("catch", !env.catchingExceptions()); },
+ addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); },
getContainer: function() { return document.body; },
createElement: function() { return document.createElement.apply(document, arguments); },
createTextNode: function() { return document.createTextNode.apply(document, arguments); },
diff --git a/xstatic/pkg/jasmine/data/console.js b/xstatic/pkg/jasmine/data/console.js
index a65876e..e154806 100755
--- a/xstatic/pkg/jasmine/data/console.js
+++ b/xstatic/pkg/jasmine/data/console.js
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2008-2014 Pivotal Labs
+Copyright (c) 2008-2015 Pivotal Labs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
diff --git a/xstatic/pkg/jasmine/data/jasmine-html.js b/xstatic/pkg/jasmine/data/jasmine-html.js
index 898108b..bee5a04 100755
--- a/xstatic/pkg/jasmine/data/jasmine-html.js
+++ b/xstatic/pkg/jasmine/data/jasmine-html.js
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2008-2014 Pivotal Labs
+Copyright (c) 2008-2015 Pivotal Labs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@@ -40,6 +40,7 @@ jasmineRequire.HtmlReporter = function(j$) {
createElement = options.createElement,
createTextNode = options.createTextNode,
onRaiseExceptionsClick = options.onRaiseExceptionsClick || function() {},
+ addToExistingQueryString = options.addToExistingQueryString || defaultQueryString,
timer = options.timer || noopTimer,
results = [],
specsExecuted = 0,
@@ -220,6 +221,9 @@ jasmineRequire.HtmlReporter = function(j$) {
if(noExpectations(resultNode.result)) {
specDescription = 'SPEC HAS NO EXPECTATIONS ' + specDescription;
}
+ if(resultNode.result.status === 'pending' && resultNode.result.pendingReason !== '') {
+ specDescription = specDescription + ' PENDING WITH MESSAGE: ' + resultNode.result.pendingReason;
+ }
specListNode.appendChild(
createDom('li', {
className: resultNode.result.status,
@@ -267,7 +271,7 @@ jasmineRequire.HtmlReporter = function(j$) {
function clearPrior() {
// return the reporter
var oldReporter = find('');
-
+
if(oldReporter) {
getContainer().removeChild(oldReporter);
}
@@ -306,7 +310,11 @@ jasmineRequire.HtmlReporter = function(j$) {
}
function specHref(result) {
- return '?spec=' + encodeURIComponent(result.fullName);
+ return addToExistingQueryString('spec', result.fullName);
+ }
+
+ function defaultQueryString(key, value) {
+ return '?' + key + '=' + value;
}
function setMenuModeTo(mode) {
@@ -358,10 +366,14 @@ jasmineRequire.ResultsNode = function() {
jasmineRequire.QueryString = function() {
function QueryString(options) {
- this.setParam = function(key, value) {
+ this.navigateWithNewParam = function(key, value) {
+ options.getWindowLocation().search = this.fullStringWithNewParam(key, value);
+ };
+
+ this.fullStringWithNewParam = function(key, value) {
var paramMap = queryStringToParamMap();
paramMap[key] = value;
- options.getWindowLocation().search = toQueryString(paramMap);
+ return toQueryString(paramMap);
};
this.getParam = function(key) {
diff --git a/xstatic/pkg/jasmine/data/jasmine.js b/xstatic/pkg/jasmine/data/jasmine.js
index e4c574f..6bf3f02 100755
--- a/xstatic/pkg/jasmine/data/jasmine.js
+++ b/xstatic/pkg/jasmine/data/jasmine.js
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2008-2014 Pivotal Labs
+Copyright (c) 2008-2015 Pivotal Labs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@@ -20,13 +20,16 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-getJasmineRequireObj = (function (jasmineGlobal) {
+var getJasmineRequireObj = (function (jasmineGlobal) {
var jasmineRequire;
if (typeof module !== 'undefined' && module.exports) {
jasmineGlobal = global;
jasmineRequire = exports;
} else {
+ if (typeof window !== 'undefined' && typeof window.toString === 'function' && window.toString() === '[object GjsGlobal]') {
+ jasmineGlobal = window;
+ }
jasmineRequire = jasmineGlobal.jasmineRequire = jasmineGlobal.jasmineRequire || {};
}
@@ -40,6 +43,7 @@ getJasmineRequireObj = (function (jasmineGlobal) {
jRequire.base(j$, jasmineGlobal);
j$.util = jRequire.util();
j$.Any = jRequire.Any();
+ j$.Anything = jRequire.Anything(j$);
j$.CallTracker = jRequire.CallTracker();
j$.MockDate = jRequire.MockDate();
j$.Clock = jRequire.Clock();
@@ -51,12 +55,14 @@ getJasmineRequireObj = (function (jasmineGlobal) {
j$.JsApiReporter = jRequire.JsApiReporter();
j$.matchersUtil = jRequire.matchersUtil(j$);
j$.ObjectContaining = jRequire.ObjectContaining(j$);
+ j$.ArrayContaining = jRequire.ArrayContaining(j$);
j$.pp = jRequire.pp(j$);
j$.QueueRunner = jRequire.QueueRunner(j$);
j$.ReportDispatcher = jRequire.ReportDispatcher();
j$.Spec = jRequire.Spec(j$);
j$.SpyRegistry = jRequire.SpyRegistry(j$);
j$.SpyStrategy = jRequire.SpyStrategy();
+ j$.StringMatching = jRequire.StringMatching(j$);
j$.Suite = jRequire.Suite();
j$.Timer = jRequire.Timer();
j$.version = jRequire.version();
@@ -138,14 +144,30 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
return obj.nodeType > 0;
};
+ j$.fnNameFor = function(func) {
+ return func.name || func.toString().match(/^\s*function\s*(\w*)\s*\(/)[1];
+ };
+
j$.any = function(clazz) {
return new j$.Any(clazz);
};
+ j$.anything = function() {
+ return new j$.Anything();
+ };
+
j$.objectContaining = function(sample) {
return new j$.ObjectContaining(sample);
};
+ j$.stringMatching = function(expected) {
+ return new j$.StringMatching(expected);
+ };
+
+ j$.arrayContaining = function(sample) {
+ return new j$.ArrayContaining(sample);
+ };
+
j$.createSpy = function(name, originalFn) {
var spyStrategy = new j$.SpyStrategy({
@@ -190,6 +212,11 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
};
j$.createSpyObj = function(baseName, methodNames) {
+ if (j$.isArray_(baseName) && j$.util.isUndefined(methodNames)) {
+ methodNames = baseName;
+ baseName = 'unknown';
+ }
+
if (!j$.isArray_(methodNames) || methodNames.length === 0) {
throw 'createSpyObj requires a non-empty array of method names to create spies for';
}
@@ -285,7 +312,8 @@ getJasmineRequireObj().Spec = function(j$) {
description: this.description,
fullName: this.getFullName(),
failedExpectations: [],
- passedExpectations: []
+ passedExpectations: [],
+ pendingReason: ''
};
}
@@ -334,7 +362,7 @@ getJasmineRequireObj().Spec = function(j$) {
Spec.prototype.onException = function onException(e) {
if (Spec.isPendingSpecException(e)) {
- this.pend();
+ this.pend(extractCustomPendingMessage(e));
return;
}
@@ -351,8 +379,11 @@ getJasmineRequireObj().Spec = function(j$) {
this.disabled = true;
};
- Spec.prototype.pend = function() {
+ Spec.prototype.pend = function(message) {
this.markedPending = true;
+ if (message) {
+ this.result.pendingReason = message;
+ }
};
Spec.prototype.status = function() {
@@ -379,6 +410,14 @@ getJasmineRequireObj().Spec = function(j$) {
return this.getSpecName(this);
};
+ var extractCustomPendingMessage = function(e) {
+ var fullMessage = e.toString(),
+ boilerplateStart = fullMessage.indexOf(Spec.pendingSpecExceptionMessage),
+ boilerplateEnd = boilerplateStart + Spec.pendingSpecExceptionMessage.length;
+
+ return fullMessage.substr(boilerplateEnd);
+ };
+
Spec.pendingSpecExceptionMessage = '=> marked Pending';
Spec.isPendingSpecException = function(e) {
@@ -573,13 +612,7 @@ getJasmineRequireObj().Env = function(j$) {
env: this,
id: getNextSuiteId(),
description: 'Jasmine__TopLevel__Suite',
- queueRunner: queueRunnerFactory,
- onStart: function(suite) {
- reporter.suiteStarted(suite.result);
- },
- resultCallback: function(attrs) {
- reporter.suiteDone(attrs);
- }
+ queueRunner: queueRunnerFactory
});
runnableLookupTable[topSuite.id] = topSuite;
defaultResourcesForRunnable(topSuite.id);
@@ -637,11 +670,12 @@ getJasmineRequireObj().Env = function(j$) {
onStart: suiteStarted,
expectationFactory: expectationFactory,
expectationResultFactory: expectationResultFactory,
+ runnablesExplictlySetGetter: runnablesExplictlySetGetter,
resultCallback: function(attrs) {
if (!suite.disabled) {
clearResourcesForRunnable(suite.id);
- currentlyExecutingSuites.pop();
}
+ currentlyExecutingSuites.pop();
reporter.suiteDone(attrs);
}
});
@@ -829,8 +863,12 @@ getJasmineRequireObj().Env = function(j$) {
});
};
- this.pending = function() {
- throw j$.Spec.pendingSpecExceptionMessage;
+ this.pending = function(message) {
+ var fullMessage = j$.Spec.pendingSpecExceptionMessage;
+ if(message) {
+ fullMessage += message;
+ }
+ throw fullMessage;
};
this.fail = function(error) {
@@ -845,7 +883,8 @@ getJasmineRequireObj().Env = function(j$) {
passed: false,
expected: '',
actual: '',
- message: message
+ message: message,
+ error: error && error.message ? error : null
});
};
}
@@ -932,43 +971,6 @@ getJasmineRequireObj().JsApiReporter = function() {
return JsApiReporter;
};
-getJasmineRequireObj().Any = function() {
-
- function Any(expectedObject) {
- this.expectedObject = expectedObject;
- }
-
- Any.prototype.jasmineMatches = function(other) {
- if (this.expectedObject == String) {
- return typeof other == 'string' || other instanceof String;
- }
-
- if (this.expectedObject == Number) {
- return typeof other == 'number' || other instanceof Number;
- }
-
- if (this.expectedObject == Function) {
- return typeof other == 'function' || other instanceof Function;
- }
-
- if (this.expectedObject == Object) {
- return typeof other == 'object';
- }
-
- if (this.expectedObject == Boolean) {
- return typeof other == 'boolean';
- }
-
- return other instanceof this.expectedObject;
- };
-
- Any.prototype.jasmineToString = function() {
- return '<jasmine.any(' + this.expectedObject + ')>';
- };
-
- return Any;
-};
-
getJasmineRequireObj().CallTracker = function() {
function CallTracker() {
@@ -1250,6 +1252,12 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
scheduledFn.runAtMillis + scheduledFn.millis);
}
+ function forEachFunction(funcsToRun, callback) {
+ for (var i = 0; i < funcsToRun.length; ++i) {
+ callback(funcsToRun[i]);
+ }
+ }
+
function runScheduledFunctions(endTime) {
if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) {
return;
@@ -1261,15 +1269,15 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
var funcsToRun = scheduledFunctions[currentTime];
delete scheduledFunctions[currentTime];
- for (var i = 0; i < funcsToRun.length; ++i) {
- var funcToRun = funcsToRun[i];
-
+ forEachFunction(funcsToRun, function(funcToRun) {
if (funcToRun.recurring) {
reschedule(funcToRun);
}
+ });
+ forEachFunction(funcsToRun, function(funcToRun) {
funcToRun.funcToCall.apply(null, funcToRun.params || []);
- }
+ });
} while (scheduledLookup.length > 0 &&
// checking first if we're out of time prevents setTimeout(0)
// scheduled in a funcToRun from forcing an extra iteration
@@ -1411,15 +1419,20 @@ getJasmineRequireObj().buildExpectationResult = function() {
var messageFormatter = options.messageFormatter || function() {},
stackFormatter = options.stackFormatter || function() {};
- return {
+ var result = {
matcherName: options.matcherName,
- expected: options.expected,
- actual: options.actual,
message: message(),
stack: stack(),
passed: options.passed
};
+ if(!result.passed) {
+ result.expected = options.expected;
+ result.actual = options.actual;
+ }
+
+ return result;
+
function message() {
if (options.passed) {
return 'Passed.';
@@ -1507,7 +1520,7 @@ getJasmineRequireObj().MockDate = function() {
case 6:
return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3],
arguments[4], arguments[5]);
- case 7:
+ default:
return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3],
arguments[4], arguments[5], arguments[6]);
}
@@ -1534,41 +1547,6 @@ getJasmineRequireObj().MockDate = function() {
return MockDate;
};
-getJasmineRequireObj().ObjectContaining = function(j$) {
-
- function ObjectContaining(sample) {
- this.sample = sample;
- }
-
- ObjectContaining.prototype.jasmineMatches = function(other, mismatchKeys, mismatchValues) {
- if (typeof(this.sample) !== 'object') { throw new Error('You must provide an object to objectContaining, not \''+this.sample+'\'.'); }
-
- mismatchKeys = mismatchKeys || [];
- mismatchValues = mismatchValues || [];
-
- var hasKey = function(obj, keyName) {
- return obj !== null && !j$.util.isUndefined(obj[keyName]);
- };
-
- for (var property in this.sample) {
- if (!hasKey(other, property) && hasKey(this.sample, property)) {
- mismatchKeys.push('expected has key \'' + property + '\', but missing from actual.');
- }
- else if (!j$.matchersUtil.equals(other[property], this.sample[property])) {
- mismatchValues.push('\'' + property + '\' was \'' + (other[property] ? j$.util.htmlEscape(other[property].toString()) : other[property]) + '\' in actual, but was \'' + (this.sample[property] ? j$.util.htmlEscape(this.sample[property].toString()) : this.sample[property]) + '\' in expected.');
- }
- }
-
- return (mismatchKeys.length === 0 && mismatchValues.length === 0);
- };
-
- ObjectContaining.prototype.jasmineToString = function() {
- return '<jasmine.objectContaining(' + j$.pp(this.sample) + ')>';
- };
-
- return ObjectContaining;
-};
-
getJasmineRequireObj().pp = function(j$) {
function PrettyPrinter() {
@@ -1668,13 +1646,15 @@ getJasmineRequireObj().pp = function(j$) {
};
StringPrettyPrinter.prototype.emitObject = function(obj) {
+ var constructorName = obj.constructor ? j$.fnNameFor(obj.constructor) : 'null';
+ this.append(constructorName);
+
if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) {
- this.append('Object');
return;
}
var self = this;
- this.append('{ ');
+ this.append('({ ');
var first = true;
this.iterateObject(obj, function(property, isGetter) {
@@ -1693,7 +1673,7 @@ getJasmineRequireObj().pp = function(j$) {
}
});
- this.append(' }');
+ this.append(' })');
};
StringPrettyPrinter.prototype.append = function(value) {
@@ -1743,7 +1723,8 @@ getJasmineRequireObj().QueueRunner = function(j$) {
for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) {
var queueableFn = queueableFns[iterativeIndex];
if (queueableFn.fn.length > 0) {
- return attemptAsync(queueableFn);
+ attemptAsync(queueableFn);
+ return;
} else {
attemptSync(queueableFn);
}
@@ -1858,6 +1839,10 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
throw new Error('spyOn could not find an object to spy upon for ' + methodName + '()');
}
+ if (j$.util.isUndefined(methodName)) {
+ throw new Error('No method name supplied');
+ }
+
if (j$.util.isUndefined(obj[methodName])) {
throw new Error(methodName + '() method does not exist');
}
@@ -1964,6 +1949,7 @@ getJasmineRequireObj().Suite = function() {
this.clearStack = attrs.clearStack || function(fn) {fn();};
this.expectationFactory = attrs.expectationFactory;
this.expectationResultFactory = attrs.expectationResultFactory;
+ this.runnablesExplictlySetGetter = attrs.runnablesExplictlySetGetter || function() {};
this.beforeFns = [];
this.afterFns = [];
@@ -2075,14 +2061,8 @@ getJasmineRequireObj().Suite = function() {
};
Suite.prototype.isExecutable = function() {
- var foundActive = false;
- for(var i = 0; i < this.children.length; i++) {
- if(this.children[i].isExecutable()) {
- foundActive = true;
- break;
- }
- }
- return foundActive;
+ var runnablesExplicitlySet = this.runnablesExplictlySetGetter();
+ return !runnablesExplicitlySet && hasExecutableChild(this.children);
};
Suite.prototype.sharedUserContext = function() {
@@ -2135,6 +2115,17 @@ getJasmineRequireObj().Suite = function() {
return !args[0];
}
+ function hasExecutableChild(children) {
+ var foundActive = false;
+ for (var i = 0; i < children.length; i++) {
+ if (children[i].isExecutable()) {
+ foundActive = true;
+ break;
+ }
+ }
+ return foundActive;
+ }
+
function clone(obj) {
var clonedObj = {};
for (var prop in obj) {
@@ -2176,6 +2167,131 @@ getJasmineRequireObj().Timer = function() {
return Timer;
};
+getJasmineRequireObj().Any = function() {
+
+ function Any(expectedObject) {
+ this.expectedObject = expectedObject;
+ }
+
+ Any.prototype.asymmetricMatch = function(other) {
+ if (this.expectedObject == String) {
+ return typeof other == 'string' || other instanceof String;
+ }
+
+ if (this.expectedObject == Number) {
+ return typeof other == 'number' || other instanceof Number;
+ }
+
+ if (this.expectedObject == Function) {
+ return typeof other == 'function' || other instanceof Function;
+ }
+
+ if (this.expectedObject == Object) {
+ return typeof other == 'object';
+ }
+
+ if (this.expectedObject == Boolean) {
+ return typeof other == 'boolean';
+ }
+
+ return other instanceof this.expectedObject;
+ };
+
+ Any.prototype.jasmineToString = function() {
+ return '<jasmine.any(' + this.expectedObject + ')>';
+ };
+
+ return Any;
+};
+
+getJasmineRequireObj().Anything = function(j$) {
+
+ function Anything() {}
+
+ Anything.prototype.asymmetricMatch = function(other) {
+ return !j$.util.isUndefined(other) && other !== null;
+ };
+
+ Anything.prototype.jasmineToString = function() {
+ return '<jasmine.anything>';
+ };
+
+ return Anything;
+};
+
+getJasmineRequireObj().ArrayContaining = function(j$) {
+ function ArrayContaining(sample) {
+ this.sample = sample;
+ }
+
+ ArrayContaining.prototype.asymmetricMatch = function(other) {
+ var className = Object.prototype.toString.call(this.sample);
+ if (className !== '[object Array]') { throw new Error('You must provide an array to arrayContaining, not \'' + this.sample + '\'.'); }
+
+ for (var i = 0; i < this.sample.length; i++) {
+ var item = this.sample[i];
+ if (!j$.matchersUtil.contains(other, item)) {
+ return false;
+ }
+ }
+
+ return true;
+ };
+
+ ArrayContaining.prototype.jasmineToString = function () {
+ return '<jasmine.arrayContaining(' + jasmine.pp(this.sample) +')>';
+ };
+
+ return ArrayContaining;
+};
+
+getJasmineRequireObj().ObjectContaining = function(j$) {
+
+ function ObjectContaining(sample) {
+ this.sample = sample;
+ }
+
+ ObjectContaining.prototype.asymmetricMatch = function(other) {
+ if (typeof(this.sample) !== 'object') { throw new Error('You must provide an object to objectContaining, not \''+this.sample+'\'.'); }
+
+ for (var property in this.sample) {
+ if (!Object.prototype.hasOwnProperty.call(other, property) ||
+ !j$.matchersUtil.equals(this.sample[property], other[property])) {
+ return false;
+ }
+ }
+
+ return true;
+ };
+
+ ObjectContaining.prototype.jasmineToString = function() {
+ return '<jasmine.objectContaining(' + j$.pp(this.sample) + ')>';
+ };
+
+ return ObjectContaining;
+};
+
+getJasmineRequireObj().StringMatching = function(j$) {
+
+ function StringMatching(expected) {
+ if (!j$.isString_(expected) && !j$.isA_('RegExp', expected)) {
+ throw new Error('Expected is not a String or a RegExp');
+ }
+
+ this.regexp = new RegExp(expected);
+ }
+
+ StringMatching.prototype.asymmetricMatch = function(other) {
+ return this.regexp.test(other);
+ };
+
+ StringMatching.prototype.jasmineToString = function() {
+ return '<jasmine.stringMatching(' + this.regexp + ')>';
+ };
+
+ return StringMatching;
+};
+
getJasmineRequireObj().matchersUtil = function(j$) {
// TODO: what to do about jasmine.pp not being inject? move to JSON.stringify? gut PrettyPrinter?
@@ -2229,11 +2345,37 @@ getJasmineRequireObj().matchersUtil = function(j$) {
}
};
+ function isAsymmetric(obj) {
+ return obj && j$.isA_('Function', obj.asymmetricMatch);
+ }
+
+ function asymmetricMatch(a, b) {
+ var asymmetricA = isAsymmetric(a),
+ asymmetricB = isAsymmetric(b);
+
+ if (asymmetricA && asymmetricB) {
+ return undefined;
+ }
+
+ if (asymmetricA) {
+ return a.asymmetricMatch(b);
+ }
+
+ if (asymmetricB) {
+ return b.asymmetricMatch(a);
+ }
+ }
+
// Equality function lovingly adapted from isEqual in
// [Underscore](http://underscorejs.org)
function eq(a, b, aStack, bStack, customTesters) {
var result = true;
+ var asymmetricResult = asymmetricMatch(a, b);
+ if (!j$.util.isUndefined(asymmetricResult)) {
+ return asymmetricResult;
+ }
+
for (var i = 0; i < customTesters.length; i++) {
var customTesterResult = customTesters[i](a, b);
if (!j$.util.isUndefined(customTesterResult)) {
@@ -2241,27 +2383,6 @@ getJasmineRequireObj().matchersUtil = function(j$) {
}
}
- if (a instanceof j$.Any) {
- result = a.jasmineMatches(b);
- if (result) {
- return true;
- }
- }
-
- if (b instanceof j$.Any) {
- result = b.jasmineMatches(a);
- if (result) {
- return true;
- }
- }
-
- if (b instanceof j$.ObjectContaining) {
- result = b.jasmineMatches(a);
- if (result) {
- return true;
- }
- }
-
if (a instanceof Error && b instanceof Error) {
return a.message == b.message;
}
@@ -2297,6 +2418,29 @@ getJasmineRequireObj().matchersUtil = function(j$) {
a.ignoreCase == b.ignoreCase;
}
if (typeof a != 'object' || typeof b != 'object') { return false; }
+
+ var aIsDomNode = j$.isDomNode(a);
+ var bIsDomNode = j$.isDomNode(b);
+ if (aIsDomNode && bIsDomNode) {
+ // At first try to use DOM3 method isEqualNode
+ if (a.isEqualNode) {
+ return a.isEqualNode(b);
+ }
+ // IE8 doesn't support isEqualNode, try to use outerHTML && innerText
+ var aIsElement = a instanceof Element;
+ var bIsElement = b instanceof Element;
+ if (aIsElement && bIsElement) {
+ return a.outerHTML == b.outerHTML;
+ }
+ if (aIsElement || bIsElement) {
+ return false;
+ }
+ return a.innerText == b.innerText && a.textContent == b.textContent;
+ }
+ if (aIsDomNode || bIsDomNode) {
+ return false;
+ }
+
// Assume equality for cyclic structures. The algorithm for detecting cyclic
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
var length = aStack.length;
@@ -2310,17 +2454,12 @@ getJasmineRequireObj().matchersUtil = function(j$) {
bStack.push(b);
var size = 0;
// Recursively compare objects and arrays.
- if (className == '[object Array]') {
- // Compare array lengths to determine if a deep comparison is necessary.
- size = a.length;
- result = size == b.length;
- if (result) {
- // Deep compare the contents, ignoring non-numeric properties.
- while (size--) {
- if (!(result = eq(a[size], b[size], aStack, bStack, customTesters))) { break; }
- }
- }
- } else {
+ // Compare array lengths to determine if a deep comparison is necessary.
+ if (className == '[object Array]' && a.length !== b.length) {
+ result = false;
+ }
+
+ if (result) {
// Objects with different constructors are not equivalent, but `Object`s
// from different frames are.
var aCtor = a.constructor, bCtor = b.constructor;
@@ -2352,7 +2491,7 @@ getJasmineRequireObj().matchersUtil = function(j$) {
return result;
function has(obj, key) {
- return obj.hasOwnProperty(key);
+ return Object.prototype.hasOwnProperty.call(obj, key);
}
function isFunction(obj) {
@@ -2621,11 +2760,15 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
return toHaveBeenCalledWith;
};
-getJasmineRequireObj().toMatch = function() {
+getJasmineRequireObj().toMatch = function(j$) {
function toMatch() {
return {
compare: function(actual, expected) {
+ if (!j$.isString_(expected) && !j$.isA_('RegExp', expected)) {
+ throw new Error('Expected is not a String or a RegExp');
+ }
+
var regexp = new RegExp(expected);
return {
@@ -2718,7 +2861,7 @@ getJasmineRequireObj().toThrowError = function(j$) {
}
if (errorMatcher.hasNoSpecifics()) {
- pass.message = 'Expected function not to throw an Error, but it threw ' + fnNameFor(thrown) + '.';
+ pass.message = 'Expected function not to throw an Error, but it threw ' + j$.fnNameFor(thrown) + '.';
return pass;
}
@@ -2772,9 +2915,9 @@ getJasmineRequireObj().toThrowError = function(j$) {
}
return {
- errorTypeDescription: errorType ? fnNameFor(errorType) : 'an exception',
+ errorTypeDescription: errorType ? j$.fnNameFor(errorType) : 'an exception',
thrownDescription: function(thrown) {
- var thrownName = errorType ? fnNameFor(thrown.constructor) : 'an exception',
+ var thrownName = errorType ? j$.fnNameFor(thrown.constructor) : 'an exception',
thrownMessage = '';
if (expected) {
@@ -2802,10 +2945,6 @@ getJasmineRequireObj().toThrowError = function(j$) {
};
}
- function fnNameFor(func) {
- return func.name || func.toString().match(/^\s*function\s*(\w*)\s*\(/)[1];
- }
-
function isStringOrRegExp(potential) {
return potential instanceof RegExp || (typeof potential == 'string');
}
@@ -2838,32 +2977,32 @@ getJasmineRequireObj().interface = function(jasmine, env) {
return env.fdescribe(description, specDefinitions);
},
- it: function(desc, func) {
- return env.it(desc, func);
+ it: function() {
+ return env.it.apply(env, arguments);
},
- xit: function(desc, func) {
- return env.xit(desc, func);
+ xit: function() {
+ return env.xit.apply(env, arguments);
},
- fit: function(desc, func) {
- return env.fit(desc, func);
+ fit: function() {
+ return env.fit.apply(env, arguments);
},
- beforeEach: function(beforeEachFunction) {
- return env.beforeEach(beforeEachFunction);
+ beforeEach: function() {
+ return env.beforeEach.apply(env, arguments);
},
- afterEach: function(afterEachFunction) {
- return env.afterEach(afterEachFunction);
+ afterEach: function() {
+ return env.afterEach.apply(env, arguments);
},
- beforeAll: function(beforeAllFunction) {
- return env.beforeAll(beforeAllFunction);
+ beforeAll: function() {
+ return env.beforeAll.apply(env, arguments);
},
- afterAll: function(afterAllFunction) {
- return env.afterAll(afterAllFunction);
+ afterAll: function() {
+ return env.afterAll.apply(env, arguments);
},
expect: function(actual) {
@@ -2871,7 +3010,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
},
pending: function() {
- return env.pending();
+ return env.pending.apply(env, arguments);
},
fail: function() {
@@ -2905,5 +3044,5 @@ getJasmineRequireObj().interface = function(jasmine, env) {
};
getJasmineRequireObj().version = function() {
- return '2.1.2';
+ return '2.2.0';
};