Update generated files.

This commit is contained in:
Christian Williams
2009-12-25 14:19:27 -05:00
parent bef9867b61
commit e986b024bc
21 changed files with 722 additions and 678 deletions

View File

@@ -640,10 +640,7 @@ jasmine.Env = function() {
};
jasmine.util.inherit(this.matchersClass, jasmine.Matchers);
for (var methodName in jasmine.Matchers.prototype) {
var orig = jasmine.Matchers.prototype[methodName];
this.matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig);
}
jasmine.Matchers.wrapInto_(jasmine.Matchers.prototype, this.matchersClass);
};
@@ -1009,13 +1006,18 @@ jasmine.Matchers = function(env, actual, spec) {
this.env = env;
this.actual = actual;
this.spec = spec;
this.reportWasCalled_ = false;
};
jasmine.Matchers.pp = function(str) {
return jasmine.util.htmlEscape(jasmine.pp(str));
};
/** @deprecated */
jasmine.Matchers.prototype.report = function(result, failing_message, details) {
// todo first: report deprecation warning [xw]
// todo later: throw new Error("As of jasmine 0.xx, custom matchers must be implemented differently -- please see jasmine docs");
this.reportWasCalled_ = true;
var expectationResult = new jasmine.ExpectationResult({
passed: result,
message: failing_message,
@@ -1025,10 +1027,20 @@ jasmine.Matchers.prototype.report = function(result, failing_message, details) {
return result;
};
jasmine.Matchers.wrapInto_ = function(prototype, matchersClass) {
for (var methodName in prototype) {
if (methodName == 'report') continue;
var orig = prototype[methodName];
matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig);
}
};
jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
return function() {
var matcherArgs = jasmine.util.argsToArray(arguments);
var result = matcherFunction.apply(this, arguments);
if (this.reportWasCalled_) return result;
var message;
if (!result) {
if (this.message) {
@@ -1064,7 +1076,6 @@ jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
* toBe: compares the actual to the expected using ===
* @param expected
*/
jasmine.Matchers.prototype.toBe = function(expected) {
return this.actual === expected;
};
@@ -1082,7 +1093,6 @@ jasmine.Matchers.prototype.toNotBe = function(expected) {
*
* @param expected
*/
jasmine.Matchers.prototype.toEqual = function(expected) {
return this.env.equals_(this.actual, expected);
};
@@ -1099,7 +1109,7 @@ jasmine.Matchers.prototype.toNotEqual = function(expected) {
* Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes
* a pattern or a String.
*
* @param reg_exp
* @param expected
*/
jasmine.Matchers.prototype.toMatch = function(expected) {
return new RegExp(expected).test(this.actual);
@@ -1107,7 +1117,7 @@ jasmine.Matchers.prototype.toMatch = function(expected) {
/**
* Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch
* @param reg_exp
* @param expected
*/
jasmine.Matchers.prototype.toNotMatch = function(expected) {
return !(new RegExp(expected).test(this.actual));
@@ -1224,7 +1234,7 @@ jasmine.Matchers.prototype.wasNotCalledWith = function() {
/**
* Matcher that checks that the expected item is an element in the actual Array.
*
* @param {Object} item
* @param {Object} expected
*/
jasmine.Matchers.prototype.toContain = function(expected) {
return this.env.contains_(this.actual, expected);
@@ -1233,7 +1243,7 @@ jasmine.Matchers.prototype.toContain = function(expected) {
/**
* Matcher that checks that the expected item is NOT an element in the actual Array.
*
* @param {Object} item
* @param {Object} expected
*/
jasmine.Matchers.prototype.toNotContain = function(expected) {
return !this.env.contains_(this.actual, expected);
@@ -1250,32 +1260,26 @@ jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
/**
* Matcher that checks that the expected exception was thrown by the actual.
*
* @param {String} expectedException
* @param {String} expected
*/
jasmine.Matchers.prototype.toThrow = function(expected) {
function getException_(actual, expected) {
var exception;
if (typeof actual != 'function') {
throw new Error('Actual is not a function');
}
try {
actual();
} catch (e) {
exception = e;
}
return exception;
}
var result = false;
var exception = getException_(this.actual, expected);
var exception;
if (typeof this.actual != 'function') {
throw new Error('Actual is not a function');
}
try {
this.actual();
} catch (e) {
exception = e;
}
if (exception) {
result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected));
}
this.message = function(expected) {
var exception = getException_(this.actual, expected);
this.message = function() {
if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
return ["Expected function to throw", expected.message || expected, ", but it threw", exception.message || exception ].join(' ');
return ["Expected function to throw", expected.message || expected, ", but it threw", exception.message || exception].join(' ');
} else {
return "Expected function to throw an exception.";
}
@@ -1847,9 +1851,7 @@ jasmine.Spec.prototype.addMatchers = function(matchersPrototype) {
parent.apply(this, arguments);
};
jasmine.util.inherit(newMatchersClass, parent);
for (var method in matchersPrototype) {
newMatchersClass.prototype[method] = matchersPrototype[method];
}
jasmine.Matchers.wrapInto_(matchersPrototype, newMatchersClass);
this.matchersClass = newMatchersClass;
};
@@ -2255,5 +2257,5 @@ jasmine.version_= {
"major": 0,
"minor": 10,
"build": 0,
"revision": 1261632445
"revision": 1261768736
};