Merge branch 'safe-undefined' of git@github.com:pivotal/jasmine
This commit is contained in:
commit
40ff1cb4c8
43
Rakefile
43
Rakefile
@ -3,6 +3,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "spec/jasmine_helper.
|
||||
def jasmine_sources
|
||||
sources = ["src/base.js", "src/util.js", "src/Env.js", "src/Reporter.js", "src/Block.js"]
|
||||
sources += Dir.glob('src/*.js').reject{|f| f == 'src/base.js' || sources.include?(f)}.sort
|
||||
sources
|
||||
end
|
||||
|
||||
def jasmine_filename(version)
|
||||
@ -26,19 +27,53 @@ def start_jasmine_server(jasmine_includes = nil)
|
||||
:jasmine_files => jasmine_includes)
|
||||
end
|
||||
|
||||
task :default => 'jasmine:dist'
|
||||
|
||||
namespace :jasmine do
|
||||
|
||||
desc 'Prepares for distribution'
|
||||
task :dist => ['jasmine:build', 'jasmine:doc']
|
||||
|
||||
desc 'Check jasmine sources for coding problems'
|
||||
task :lint do
|
||||
passed = true
|
||||
jasmine_sources.each do |src|
|
||||
lines = File.read(src).split(/\n/)
|
||||
lines.each_index do |i|
|
||||
line = lines[i]
|
||||
undefineds = line.scan(/.?undefined/)
|
||||
if undefineds.include?(" undefined") || undefineds.include?("\tundefined")
|
||||
puts "Dangerous undefined at #{src}:#{i}:\n > #{line}"
|
||||
passed = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unless passed
|
||||
puts "Lint failed!"
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Builds lib/jasmine from source'
|
||||
task :build => 'jasmine:doc' do
|
||||
task :build => :lint do
|
||||
puts 'Building Jasmine from source'
|
||||
require 'json'
|
||||
|
||||
sources = jasmine_sources
|
||||
version = version_hash
|
||||
|
||||
old_jasmine_files = Dir.glob('lib/jasmine*.js')
|
||||
old_jasmine_files.each do |file|
|
||||
File.delete(file)
|
||||
end
|
||||
|
||||
jasmine = File.new("lib/#{jasmine_filename version}", 'w')
|
||||
jasmine.puts(File.read(sources.shift))
|
||||
|
||||
sources.each do |source_filename|
|
||||
jasmine.puts(File.read(source_filename))
|
||||
end
|
||||
|
||||
jasmine.puts %{
|
||||
jasmine.version_= {
|
||||
"major": #{version['major']},
|
||||
@ -47,9 +82,7 @@ jasmine.version_= {
|
||||
"revision": #{Time.now.to_i}
|
||||
};
|
||||
}
|
||||
sources.each do |source_filename|
|
||||
jasmine.puts(File.read(source_filename))
|
||||
end
|
||||
|
||||
jasmine.close
|
||||
end
|
||||
|
||||
|
@ -13,13 +13,21 @@ jasmine.unimplementedMethod_ = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
* Large or small values here may result in slow test running & "Too much recursion" errors
|
||||
* Use <code>jasmine.undefined</code> instead of <code>undefined</code>, since <code>undefined</code is just
|
||||
* a plain old variable and may be redefined by somebody else.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
jasmine.undefined = jasmine.___undefined___;
|
||||
|
||||
/**
|
||||
* Default interval for event loop yields. Small values here may result in slow test running. Zero means no updates until all tests have completed.
|
||||
*
|
||||
*/
|
||||
jasmine.DEFAULT_UPDATE_INTERVAL = 250;
|
||||
|
||||
/**
|
||||
* Allows for bound functions to be comapred. Internal use only.
|
||||
* Allows for bound functions to be compared. Internal use only.
|
||||
*
|
||||
* @ignore
|
||||
* @private
|
||||
@ -177,7 +185,7 @@ jasmine.Spy = function(name) {
|
||||
*/
|
||||
this.isSpy = true;
|
||||
/**
|
||||
* The acutal function this spy stubs.
|
||||
* The actual function this spy stubs.
|
||||
*/
|
||||
this.plan = function() {
|
||||
};
|
||||
@ -324,6 +332,16 @@ jasmine.createSpy = function(name) {
|
||||
return spyObj;
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines whether an object is a spy.
|
||||
*
|
||||
* @param {jasmine.Spy|Object} putativeSpy
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
jasmine.isSpy = function(putativeSpy) {
|
||||
return putativeSpy && putativeSpy.isSpy;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a more complicated spy: an Object that has every property a function that is a spy. Used for stubbing something
|
||||
* large in one call.
|
||||
@ -529,26 +547,22 @@ jasmine.include = function(url, opt_global) {
|
||||
return eval(xhr.responseText);
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.version_= {
|
||||
"major": 0,
|
||||
"minor": 10,
|
||||
"build": 0,
|
||||
"revision": 1257050679
|
||||
};
|
||||
/**
|
||||
* @namespace
|
||||
*/
|
||||
jasmine.util = {};
|
||||
|
||||
/**
|
||||
* Declare that a child class inherite it's prototype from the parent class.
|
||||
* Declare that a child class inherit it's prototype from the parent class.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} childClass
|
||||
* @param {Function} parentClass
|
||||
*/
|
||||
jasmine.util.inherit = function(childClass, parentClass) {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
var subclass = function() {
|
||||
};
|
||||
subclass.prototype = parentClass.prototype;
|
||||
@ -612,7 +626,7 @@ jasmine.Env = function() {
|
||||
|
||||
this.reporter = new jasmine.MultiReporter();
|
||||
|
||||
this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL
|
||||
this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL;
|
||||
this.lastUpdate = 0;
|
||||
this.specFilter = function() {
|
||||
return true;
|
||||
@ -621,6 +635,17 @@ jasmine.Env = function() {
|
||||
this.nextSpecId_ = 0;
|
||||
this.nextSuiteId_ = 0;
|
||||
this.equalityTesters_ = [];
|
||||
|
||||
// wrap matchers
|
||||
this.matchersClass = function() {
|
||||
jasmine.Matchers.apply(this, arguments);
|
||||
};
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -742,7 +767,7 @@ jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchVal
|
||||
b.__Jasmine_been_here_before__ = a;
|
||||
|
||||
var hasKey = function(obj, keyName) {
|
||||
return obj != null && obj[keyName] !== undefined;
|
||||
return obj != null && obj[keyName] !== jasmine.undefined;
|
||||
};
|
||||
|
||||
for (var property in b) {
|
||||
@ -777,8 +802,8 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
|
||||
|
||||
if (a === b) return true;
|
||||
|
||||
if (a === undefined || a === null || b === undefined || b === null) {
|
||||
return (a == undefined && b == undefined);
|
||||
if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) {
|
||||
return (a == jasmine.undefined && b == jasmine.undefined);
|
||||
}
|
||||
|
||||
if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) {
|
||||
@ -804,7 +829,7 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
|
||||
for (var i = 0; i < this.equalityTesters_.length; i++) {
|
||||
var equalityTester = this.equalityTesters_[i];
|
||||
var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
|
||||
if (result !== undefined) return result;
|
||||
if (result !== jasmine.undefined) return result;
|
||||
}
|
||||
|
||||
//Straight check
|
||||
@ -898,7 +923,7 @@ jasmine.JsApiReporter.prototype.suites = function() {
|
||||
};
|
||||
|
||||
jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {
|
||||
var isSuite = suiteOrSpec instanceof jasmine.Suite
|
||||
var isSuite = suiteOrSpec instanceof jasmine.Suite;
|
||||
var summary = {
|
||||
id: suiteOrSpec.id,
|
||||
name: suiteOrSpec.description,
|
||||
@ -954,7 +979,8 @@ jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds){
|
||||
|
||||
jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
|
||||
var summaryMessages = [];
|
||||
for (var messageIndex in result.messages) {
|
||||
var messagesLength = result.messages.length
|
||||
for (var messageIndex = 0; messageIndex < messagesLength; messageIndex++) {
|
||||
var resultMessage = result.messages[messageIndex];
|
||||
summaryMessages.push({
|
||||
text: resultMessage.text,
|
||||
@ -962,7 +988,7 @@ jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
|
||||
type: resultMessage.type,
|
||||
message: resultMessage.message,
|
||||
trace: {
|
||||
stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : undefined
|
||||
stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined
|
||||
}
|
||||
});
|
||||
};
|
||||
@ -979,7 +1005,7 @@ jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
|
||||
* @constructor
|
||||
* @param {jasmine.Env} env
|
||||
* @param actual
|
||||
* @param {jasmine.NestedResults} results
|
||||
* @param {jasmine.Spec} spec
|
||||
*/
|
||||
jasmine.Matchers = function(env, actual, spec) {
|
||||
this.env = env;
|
||||
@ -1001,15 +1027,25 @@ jasmine.Matchers.prototype.report = function(result, failing_message, details) {
|
||||
return result;
|
||||
};
|
||||
|
||||
jasmine.Matchers.matcherFn_ = function(matcherName, options) {
|
||||
return function () {
|
||||
jasmine.util.extend(this, options);
|
||||
jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
|
||||
return function() {
|
||||
var matcherArgs = jasmine.util.argsToArray(arguments);
|
||||
var args = [this.actual].concat(matcherArgs);
|
||||
var result = options.test.apply(this, args);
|
||||
var result = matcherFunction.apply(this, arguments);
|
||||
var message;
|
||||
if (!result) {
|
||||
message = options.message.apply(this, args);
|
||||
if (this.message) {
|
||||
message = this.message.apply(this, arguments);
|
||||
} else {
|
||||
var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
|
||||
message = "Expected " + jasmine.pp(this.actual) + " " + englishyPredicate;
|
||||
if (matcherArgs.length > 0) {
|
||||
for (var i = 0; i < matcherArgs.length; i++) {
|
||||
if (i > 0) message += ",";
|
||||
message += " " + jasmine.pp(matcherArgs[i]);
|
||||
}
|
||||
}
|
||||
message += ".";
|
||||
}
|
||||
}
|
||||
var expectationResult = new jasmine.ExpectationResult({
|
||||
matcherName: matcherName,
|
||||
@ -1031,27 +1067,17 @@ jasmine.Matchers.matcherFn_ = function(matcherName, options) {
|
||||
* @param expected
|
||||
*/
|
||||
|
||||
jasmine.Matchers.prototype.toBe = jasmine.Matchers.matcherFn_('toBe', {
|
||||
test: function (actual, expected) {
|
||||
return actual === expected;
|
||||
},
|
||||
message: function(actual, expected) {
|
||||
return "Expected " + jasmine.pp(actual) + " to be " + jasmine.pp(expected);
|
||||
}
|
||||
});
|
||||
jasmine.Matchers.prototype.toBe = function(expected) {
|
||||
return this.actual === expected;
|
||||
};
|
||||
|
||||
/**
|
||||
* toNotBe: compares the actual to the expected using !==
|
||||
* @param expected
|
||||
*/
|
||||
jasmine.Matchers.prototype.toNotBe = jasmine.Matchers.matcherFn_('toNotBe', {
|
||||
test: function (actual, expected) {
|
||||
return actual !== expected;
|
||||
},
|
||||
message: function(actual, expected) {
|
||||
return "Expected " + jasmine.pp(actual) + " to not be " + jasmine.pp(expected);
|
||||
}
|
||||
});
|
||||
jasmine.Matchers.prototype.toNotBe = function(expected) {
|
||||
return this.actual !== expected;
|
||||
};
|
||||
|
||||
/**
|
||||
* toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc.
|
||||
@ -1059,27 +1085,17 @@ jasmine.Matchers.prototype.toNotBe = jasmine.Matchers.matcherFn_('toNotBe', {
|
||||
* @param expected
|
||||
*/
|
||||
|
||||
jasmine.Matchers.prototype.toEqual = jasmine.Matchers.matcherFn_('toEqual', {
|
||||
test: function (actual, expected) {
|
||||
return this.env.equals_(actual, expected);
|
||||
},
|
||||
message: function(actual, expected) {
|
||||
return "Expected " + jasmine.pp(actual) + " to equal " + jasmine.pp(expected);
|
||||
}
|
||||
});
|
||||
jasmine.Matchers.prototype.toEqual = function(expected) {
|
||||
return this.env.equals_(this.actual, expected);
|
||||
};
|
||||
|
||||
/**
|
||||
* toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual
|
||||
* @param expected
|
||||
*/
|
||||
jasmine.Matchers.prototype.toNotEqual = jasmine.Matchers.matcherFn_('toNotEqual', {
|
||||
test: function (actual, expected) {
|
||||
return !this.env.equals_(actual, expected);
|
||||
},
|
||||
message: function(actual, expected) {
|
||||
return "Expected " + jasmine.pp(actual) + " to not equal " + jasmine.pp(expected);
|
||||
}
|
||||
});
|
||||
jasmine.Matchers.prototype.toNotEqual = function(expected) {
|
||||
return !this.env.equals_(this.actual, expected);
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes
|
||||
@ -1087,228 +1103,143 @@ jasmine.Matchers.prototype.toNotEqual = jasmine.Matchers.matcherFn_('toNotEqual'
|
||||
*
|
||||
* @param reg_exp
|
||||
*/
|
||||
jasmine.Matchers.prototype.toMatch = jasmine.Matchers.matcherFn_('toMatch', {
|
||||
test: function(actual, expected) {
|
||||
return new RegExp(expected).test(actual);
|
||||
},
|
||||
message: function(actual, expected) {
|
||||
return jasmine.pp(actual) + " does not match the regular expression " + new RegExp(expected).toString();
|
||||
}
|
||||
});
|
||||
jasmine.Matchers.prototype.toMatch = function(expected) {
|
||||
return new RegExp(expected).test(this.actual);
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch
|
||||
* @param reg_exp
|
||||
*/
|
||||
|
||||
jasmine.Matchers.prototype.toNotMatch = jasmine.Matchers.matcherFn_('toNotMatch', {
|
||||
test: function(actual, expected) {
|
||||
return !(new RegExp(expected).test(actual));
|
||||
},
|
||||
message: function(actual, expected) {
|
||||
return jasmine.pp(actual) + " should not match " + new RegExp(expected).toString();
|
||||
}
|
||||
});
|
||||
jasmine.Matchers.prototype.toNotMatch = function(expected) {
|
||||
return !(new RegExp(expected).test(this.actual));
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that compares the acutal to undefined.
|
||||
* Matcher that compares the actual to jasmine.undefined.
|
||||
*/
|
||||
|
||||
jasmine.Matchers.prototype.toBeDefined = jasmine.Matchers.matcherFn_('toBeDefined', {
|
||||
test: function(actual) {
|
||||
return (actual !== undefined);
|
||||
},
|
||||
message: function() {
|
||||
return 'Expected actual to not be undefined.';
|
||||
}
|
||||
});
|
||||
jasmine.Matchers.prototype.toBeDefined = function() {
|
||||
return (this.actual !== jasmine.undefined);
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that compares the acutal to undefined.
|
||||
* Matcher that compares the actual to jasmine.undefined.
|
||||
*/
|
||||
|
||||
jasmine.Matchers.prototype.toBeUndefined = jasmine.Matchers.matcherFn_('toBeUndefined', {
|
||||
test: function(actual) {
|
||||
return (actual === undefined);
|
||||
},
|
||||
message: function(actual) {
|
||||
return 'Expected ' + jasmine.pp(actual) + ' to be undefined.';
|
||||
}
|
||||
});
|
||||
jasmine.Matchers.prototype.toBeUndefined = function() {
|
||||
return (this.actual === jasmine.undefined);
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that compares the actual to null.
|
||||
*
|
||||
*/
|
||||
jasmine.Matchers.prototype.toBeNull = jasmine.Matchers.matcherFn_('toBeNull', {
|
||||
test: function(actual) {
|
||||
return (actual === null);
|
||||
},
|
||||
message: function(actual) {
|
||||
return 'Expected ' + jasmine.pp(actual) + ' to be null.';
|
||||
}
|
||||
});
|
||||
jasmine.Matchers.prototype.toBeNull = function() {
|
||||
return (this.actual === null);
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that boolean not-nots the actual.
|
||||
*/
|
||||
jasmine.Matchers.prototype.toBeTruthy = jasmine.Matchers.matcherFn_('toBeTruthy', {
|
||||
test: function(actual) {
|
||||
return !!actual;
|
||||
},
|
||||
message: function() {
|
||||
return 'Expected actual to be truthy';
|
||||
}
|
||||
});
|
||||
jasmine.Matchers.prototype.toBeTruthy = function() {
|
||||
return !!this.actual;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Matcher that boolean nots the actual.
|
||||
*/
|
||||
jasmine.Matchers.prototype.toBeFalsy = jasmine.Matchers.matcherFn_('toBeFalsy', {
|
||||
test: function(actual) {
|
||||
return !actual;
|
||||
},
|
||||
message: function(actual) {
|
||||
return 'Expected ' + jasmine.pp(actual) + ' to be falsy';
|
||||
}
|
||||
});
|
||||
jasmine.Matchers.prototype.toBeFalsy = function() {
|
||||
return !this.actual;
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that checks to see if the acutal, a Jasmine spy, was called.
|
||||
* Matcher that checks to see if the actual, a Jasmine spy, was called.
|
||||
*/
|
||||
|
||||
jasmine.Matchers.prototype.wasCalled = jasmine.Matchers.matcherFn_('wasCalled', {
|
||||
getActual_: function() {
|
||||
var args = jasmine.util.argsToArray(arguments);
|
||||
if (args.length > 1) {
|
||||
throw(new Error('wasCalled does not take arguments, use wasCalledWith'));
|
||||
}
|
||||
return args.splice(0, 1)[0];
|
||||
},
|
||||
test: function() {
|
||||
var actual = this.getActual_.apply(this, arguments);
|
||||
if (!actual || !actual.isSpy) {
|
||||
return false;
|
||||
}
|
||||
return actual.wasCalled;
|
||||
},
|
||||
message: function() {
|
||||
var actual = this.getActual_.apply(this, arguments);
|
||||
if (!actual || !actual.isSpy) {
|
||||
return 'Actual is not a spy.';
|
||||
}
|
||||
return "Expected spy " + actual.identity + " to have been called.";
|
||||
jasmine.Matchers.prototype.wasCalled = function() {
|
||||
if (arguments.length > 0) {
|
||||
throw new Error('wasCalled does not take arguments, use wasCalledWith');
|
||||
}
|
||||
});
|
||||
|
||||
if (!jasmine.isSpy(this.actual)) {
|
||||
throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.');
|
||||
}
|
||||
|
||||
this.message = function() {
|
||||
return "Expected spy " + this.actual.identity + " to have been called.";
|
||||
};
|
||||
|
||||
return this.actual.wasCalled;
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that checks to see if the acutal, a Jasmine spy, was not called.
|
||||
* Matcher that checks to see if the actual, a Jasmine spy, was not called.
|
||||
*/
|
||||
jasmine.Matchers.prototype.wasNotCalled = jasmine.Matchers.matcherFn_('wasNotCalled', {
|
||||
getActual_: function() {
|
||||
var args = jasmine.util.argsToArray(arguments);
|
||||
return args.splice(0, 1)[0];
|
||||
},
|
||||
test: function() {
|
||||
var actual = this.getActual_.apply(this, arguments);
|
||||
if (!actual || !actual.isSpy) {
|
||||
return false;
|
||||
}
|
||||
return !actual.wasCalled;
|
||||
},
|
||||
message: function() {
|
||||
var actual = this.getActual_.apply(this, arguments);
|
||||
if (!actual || !actual.isSpy) {
|
||||
return 'Actual is not a spy.';
|
||||
}
|
||||
return "Expected spy " + actual.identity + " to not have been called.";
|
||||
jasmine.Matchers.prototype.wasNotCalled = function() {
|
||||
if (arguments.length > 0) {
|
||||
throw new Error('wasNotCalled does not take arguments');
|
||||
}
|
||||
});
|
||||
|
||||
jasmine.Matchers.prototype.wasCalledWith = jasmine.Matchers.matcherFn_('wasCalledWith', {
|
||||
test: function() {
|
||||
var args = jasmine.util.argsToArray(arguments);
|
||||
var actual = args.splice(0, 1)[0];
|
||||
if (!actual || !actual.isSpy) {
|
||||
return false;
|
||||
}
|
||||
return this.env.contains_(actual.argsForCall, args);
|
||||
},
|
||||
message: function() {
|
||||
var args = jasmine.util.argsToArray(arguments);
|
||||
var actual = args.splice(0, 1)[0];
|
||||
var message;
|
||||
if (!actual || !actual.isSpy) {
|
||||
message = 'Actual is not a spy';
|
||||
} else {
|
||||
message = "Expected spy to have been called with " + jasmine.pp(args) + " but was called with " + actual.argsForCall;
|
||||
}
|
||||
return message;
|
||||
if (!jasmine.isSpy(this.actual)) {
|
||||
throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.');
|
||||
}
|
||||
});
|
||||
|
||||
this.message = function() {
|
||||
return "Expected spy " + this.actual.identity + " to not have been called.";
|
||||
};
|
||||
|
||||
return !this.actual.wasCalled;
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that checks to see if the acutal, a Jasmine spy, was called with a set of parameters.
|
||||
* Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
*/
|
||||
jasmine.Matchers.prototype.wasCalledWith = function() {
|
||||
if (!jasmine.isSpy(this.actual)) {
|
||||
throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.');
|
||||
}
|
||||
|
||||
this.message = function() {
|
||||
return "Expected spy to have been called with " + jasmine.pp(arguments) + " but was called with " + jasmine.pp(this.actual.argsForCall);
|
||||
};
|
||||
|
||||
return this.env.contains_(this.actual.argsForCall, jasmine.util.argsToArray(arguments));
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that checks that the expected item is an element in the actual Array.
|
||||
*
|
||||
* @param {Object} item
|
||||
*/
|
||||
|
||||
jasmine.Matchers.prototype.toContain = jasmine.Matchers.matcherFn_('toContain', {
|
||||
test: function(actual, expected) {
|
||||
return this.env.contains_(actual, expected);
|
||||
},
|
||||
message: function(actual, expected) {
|
||||
return 'Expected ' + jasmine.pp(actual) + ' to contain ' + jasmine.pp(expected);
|
||||
}
|
||||
});
|
||||
jasmine.Matchers.prototype.toContain = function(expected) {
|
||||
return this.env.contains_(this.actual, expected);
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that checks that the expected item is NOT an element in the actual Array.
|
||||
*
|
||||
* @param {Object} item
|
||||
*/
|
||||
jasmine.Matchers.prototype.toNotContain = jasmine.Matchers.matcherFn_('toNotContain', {
|
||||
test: function(actual, expected) {
|
||||
return !this.env.contains_(actual, expected);
|
||||
},
|
||||
message: function(actual, expected) {
|
||||
return 'Expected ' + jasmine.pp(actual) + ' to not contain ' + jasmine.pp(expected);
|
||||
}
|
||||
});
|
||||
jasmine.Matchers.prototype.toNotContain = function(expected) {
|
||||
return !this.env.contains_(this.actual, expected);
|
||||
};
|
||||
|
||||
jasmine.Matchers.prototype.toBeLessThan = jasmine.Matchers.matcherFn_('toBeLessThan', {
|
||||
test: function(actual, expected) {
|
||||
return actual < expected;
|
||||
},
|
||||
message: function(actual, expected) {
|
||||
return 'Expected ' + jasmine.pp(actual) + ' to be less than ' + jasmine.pp(expected);
|
||||
}
|
||||
});
|
||||
jasmine.Matchers.prototype.toBeLessThan = function(expected) {
|
||||
return this.actual < expected;
|
||||
};
|
||||
|
||||
jasmine.Matchers.prototype.toBeGreaterThan = jasmine.Matchers.matcherFn_('toBeGreaterThan', {
|
||||
test: function(actual, expected) {
|
||||
return actual > expected;
|
||||
},
|
||||
message: function(actual, expected) {
|
||||
return 'Expected ' + jasmine.pp(actual) + ' to be greater than ' + jasmine.pp(expected);
|
||||
}
|
||||
});
|
||||
jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
|
||||
return this.actual > expected;
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that checks that the expected exception was thrown by the actual.
|
||||
*
|
||||
* @param {String} expectedException
|
||||
*/
|
||||
jasmine.Matchers.prototype.toThrow = jasmine.Matchers.matcherFn_('toThrow', {
|
||||
getException_: function(actual, 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');
|
||||
@ -1319,24 +1250,25 @@ jasmine.Matchers.prototype.toThrow = jasmine.Matchers.matcherFn_('toThrow', {
|
||||
exception = e;
|
||||
}
|
||||
return exception;
|
||||
},
|
||||
test: function(actual, expected) {
|
||||
var result = false;
|
||||
var exception = this.getException_(actual, expected);
|
||||
if (exception) {
|
||||
result = (expected === undefined || this.env.equals_(exception.message || exception, expected.message || expected));
|
||||
}
|
||||
return result;
|
||||
},
|
||||
message: function(actual, expected) {
|
||||
var exception = this.getException_(actual, expected);
|
||||
if (exception && (expected === undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
|
||||
}
|
||||
|
||||
var result = false;
|
||||
var exception = getException_(this.actual, expected);
|
||||
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);
|
||||
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(' ');
|
||||
} else {
|
||||
return "Expected function to throw an exception.";
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
jasmine.Matchers.Any = function(expectedClass) {
|
||||
this.expectedClass = expectedClass;
|
||||
@ -1485,17 +1417,15 @@ jasmine.PrettyPrinter = function() {
|
||||
* Formats a value in a nice, human-readable string.
|
||||
*
|
||||
* @param value
|
||||
* @returns {String}
|
||||
*/
|
||||
jasmine.PrettyPrinter.prototype.format = function(value) {
|
||||
if (this.ppNestLevel_ > 40) {
|
||||
// return '(jasmine.pp nested too deeply!)';
|
||||
throw new Error('jasmine.PrettyPrinter: format() nested too deeply!');
|
||||
}
|
||||
|
||||
this.ppNestLevel_++;
|
||||
try {
|
||||
if (value === undefined) {
|
||||
if (value === jasmine.undefined) {
|
||||
this.emitScalar('undefined');
|
||||
} else if (value === null) {
|
||||
this.emitScalar('null');
|
||||
@ -1505,12 +1435,16 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
|
||||
this.emitScalar(value.toString());
|
||||
} else if (typeof value === 'string') {
|
||||
this.emitString(value);
|
||||
} else if (jasmine.isSpy(value)) {
|
||||
this.emitScalar("spy on " + value.identity);
|
||||
} else if (typeof value === 'function') {
|
||||
this.emitScalar('Function');
|
||||
} else if (typeof value.nodeType === 'number') {
|
||||
this.emitScalar('HTMLNode');
|
||||
} else if (value instanceof Date) {
|
||||
this.emitScalar('Date(' + value + ')');
|
||||
} else if (value instanceof RegExp) {
|
||||
this.emitScalar(value.toString());
|
||||
} else if (value.__Jasmine_been_here_before__) {
|
||||
this.emitScalar('<circular reference: ' + (jasmine.isArray_(value) ? 'Array' : 'Object') + '>');
|
||||
} else if (jasmine.isArray_(value) || typeof value == 'object') {
|
||||
@ -1688,13 +1622,23 @@ jasmine.Queue.prototype.results = function() {
|
||||
};
|
||||
|
||||
|
||||
/* JasmineReporters.reporter
|
||||
/** JasmineReporters.reporter
|
||||
* Base object that will get called whenever a Spec, Suite, or Runner is done. It is up to
|
||||
* descendants of this object to do something with the results (see json_reporter.js)
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
jasmine.Reporters = {};
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @param callbacks
|
||||
*/
|
||||
jasmine.Reporters.reporter = function(callbacks) {
|
||||
/**
|
||||
* @deprecated
|
||||
* @param callbacks
|
||||
*/
|
||||
var that = {
|
||||
callbacks: callbacks || {},
|
||||
|
||||
@ -1801,11 +1745,9 @@ jasmine.Spec = function(env, suite, description) {
|
||||
if (!env) {
|
||||
throw new Error('jasmine.Env() required');
|
||||
}
|
||||
;
|
||||
if (!suite) {
|
||||
throw new Error('jasmine.Suite() required');
|
||||
}
|
||||
;
|
||||
var spec = this;
|
||||
spec.id = env.nextSpecId ? env.nextSpecId() : null;
|
||||
spec.env = env;
|
||||
@ -1882,7 +1824,7 @@ jasmine.Spec.prototype.fail = function (e) {
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.getMatchersClass_ = function() {
|
||||
return this.matchersClass || jasmine.Matchers;
|
||||
return this.matchersClass || this.env.matchersClass;
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.addMatchers = function(matchersPrototype) {
|
||||
@ -1964,11 +1906,11 @@ jasmine.Spec.prototype.explodes = function() {
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) {
|
||||
if (obj == undefined) {
|
||||
if (obj == jasmine.undefined) {
|
||||
throw "spyOn could not find an object to spy upon for " + methodName + "()";
|
||||
}
|
||||
|
||||
if (!ignoreMethodDoesntExist && obj[methodName] === undefined) {
|
||||
if (!ignoreMethodDoesntExist && obj[methodName] === jasmine.undefined) {
|
||||
throw methodName + '() method does not exist';
|
||||
}
|
||||
|
||||
@ -2137,11 +2079,11 @@ jasmine.FakeTimer = function() {
|
||||
};
|
||||
|
||||
self.clearTimeout = function(timeoutKey) {
|
||||
self.scheduledFunctions[timeoutKey] = undefined;
|
||||
self.scheduledFunctions[timeoutKey] = jasmine.undefined;
|
||||
};
|
||||
|
||||
self.clearInterval = function(timeoutKey) {
|
||||
self.scheduledFunctions[timeoutKey] = undefined;
|
||||
self.scheduledFunctions[timeoutKey] = jasmine.undefined;
|
||||
};
|
||||
|
||||
};
|
||||
@ -2164,11 +2106,11 @@ jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMil
|
||||
var funcsToRun = [];
|
||||
for (var timeoutKey in this.scheduledFunctions) {
|
||||
scheduledFunc = this.scheduledFunctions[timeoutKey];
|
||||
if (scheduledFunc != undefined &&
|
||||
if (scheduledFunc != jasmine.undefined &&
|
||||
scheduledFunc.runAtMillis >= oldMillis &&
|
||||
scheduledFunc.runAtMillis <= nowMillis) {
|
||||
funcsToRun.push(scheduledFunc);
|
||||
this.scheduledFunctions[timeoutKey] = undefined;
|
||||
this.scheduledFunctions[timeoutKey] = jasmine.undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2204,7 +2146,9 @@ jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @namespace
|
||||
*/
|
||||
jasmine.Clock = {
|
||||
defaultFakeTimer: new jasmine.FakeTimer(),
|
||||
|
||||
@ -2292,3 +2236,10 @@ window.clearInterval = function(timeoutKey) {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
jasmine.version_= {
|
||||
"major": 0,
|
||||
"minor": 10,
|
||||
"build": 0,
|
||||
"revision": 1259251766
|
||||
};
|
||||
|
@ -4,6 +4,10 @@
|
||||
<head>
|
||||
<title>Jasmine Test Runner</title>
|
||||
|
||||
<script type="text/javascript">
|
||||
undefined = "diz be undefined yo";
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="../src/base.js"></script>
|
||||
<script type="text/javascript" src="../src/util.js"></script>
|
||||
<script type="text/javascript" src="../src/Env.js"></script>
|
||||
|
@ -60,8 +60,8 @@ describe('jasmine.jsApiReporter', function() {
|
||||
expect(summarizedResult.messages[0].message).toEqual(result.messages[0].message);
|
||||
expect(summarizedResult.messages[0].passed).toBeTruthy();
|
||||
expect(summarizedResult.messages[0].type).toEqual('ExpectationResult');
|
||||
expect(summarizedResult.messages[0].text).toEqual(undefined);
|
||||
expect(summarizedResult.messages[0].trace.stack).toEqual(undefined);
|
||||
expect(summarizedResult.messages[0].text).toEqual(jasmine.undefined);
|
||||
expect(summarizedResult.messages[0].trace.stack).toEqual(jasmine.undefined);
|
||||
});
|
||||
|
||||
it("should have a stack trace for failing specs", function() {
|
||||
|
@ -43,8 +43,8 @@ describe("jasmine.Matchers", function() {
|
||||
expect(match(true).toNotEqual(false)).toEqual(true);
|
||||
expect((match(true).toNotEqual(true))).toEqual(false);
|
||||
|
||||
expect((match(['a', 'b']).toEqual(['a', undefined]))).toEqual(false);
|
||||
expect((match(['a', 'b']).toEqual(['a', 'b', undefined]))).toEqual(false);
|
||||
expect((match(['a', 'b']).toEqual(['a', jasmine.undefined]))).toEqual(false);
|
||||
expect((match(['a', 'b']).toEqual(['a', 'b', jasmine.undefined]))).toEqual(false);
|
||||
});
|
||||
|
||||
it("toEqual to build an Expectation Result", function() {
|
||||
@ -197,11 +197,11 @@ describe("jasmine.Matchers", function() {
|
||||
|
||||
it("toBeDefined", function() {
|
||||
expect(match('foo').toBeDefined()).toEqual(true);
|
||||
expect(match(undefined).toBeDefined()).toEqual(false);
|
||||
expect(match(jasmine.undefined).toBeDefined()).toEqual(false);
|
||||
});
|
||||
|
||||
it("toBeDefined to build an ExpectationResult", function() {
|
||||
var matcher = match(undefined);
|
||||
var matcher = match(jasmine.undefined);
|
||||
matcher.toBeDefined();
|
||||
|
||||
var result = mockSpec.addMatcherResult.mostRecentCall.args[0];
|
||||
@ -209,17 +209,17 @@ describe("jasmine.Matchers", function() {
|
||||
expect(result.matcherName).toEqual("toBeDefined");
|
||||
expect(result.passed()).toEqual(false);
|
||||
expect(result.message).toEqual('Expected undefined to be defined.');
|
||||
expect(result.actual).toEqual(undefined);
|
||||
expect(result.actual).toEqual(jasmine.undefined);
|
||||
});
|
||||
|
||||
it("toBeUndefined", function() {
|
||||
expect(match('foo').toBeUndefined()).toEqual(false);
|
||||
expect(match(undefined).toBeUndefined()).toEqual(true);
|
||||
expect(match(jasmine.undefined).toBeUndefined()).toEqual(true);
|
||||
});
|
||||
|
||||
it("toBeNull", function() {
|
||||
expect(match(null).toBeNull()).toEqual(true);
|
||||
expect(match(undefined).toBeNull()).toEqual(false);
|
||||
expect(match(jasmine.undefined).toBeNull()).toEqual(false);
|
||||
expect(match("foo").toBeNull()).toEqual(false);
|
||||
});
|
||||
|
||||
@ -254,7 +254,7 @@ describe("jasmine.Matchers", function() {
|
||||
it("toBeFalsy", function() {
|
||||
expect(match(false).toBeFalsy()).toEqual(true);
|
||||
expect(match(true).toBeFalsy()).toEqual(false);
|
||||
expect(match(undefined).toBeFalsy()).toEqual(true);
|
||||
expect(match(jasmine.undefined).toBeFalsy()).toEqual(true);
|
||||
expect(match(0).toBeFalsy()).toEqual(true);
|
||||
expect(match("").toBeFalsy()).toEqual(true);
|
||||
});
|
||||
@ -276,7 +276,7 @@ describe("jasmine.Matchers", function() {
|
||||
it("toBeTruthy", function() {
|
||||
expect(match(false).toBeTruthy()).toEqual(false);
|
||||
expect(match(true).toBeTruthy()).toEqual(true);
|
||||
expect(match(undefined).toBeTruthy()).toEqual(false);
|
||||
expect(match(jasmine.undefined).toBeTruthy()).toEqual(false);
|
||||
expect(match(0).toBeTruthy()).toEqual(false);
|
||||
expect(match("").toBeTruthy()).toEqual(false);
|
||||
expect(match("hi").toBeTruthy()).toEqual(true);
|
||||
@ -297,11 +297,11 @@ describe("jasmine.Matchers", function() {
|
||||
});
|
||||
|
||||
it("toEqual", function() {
|
||||
expect(match(undefined).toEqual(undefined)).toEqual(true);
|
||||
expect(match(jasmine.undefined).toEqual(jasmine.undefined)).toEqual(true);
|
||||
expect(match({foo:'bar'}).toEqual({foo:'bar'})).toEqual(true);
|
||||
expect(match("foo").toEqual({bar: undefined})).toEqual(false);
|
||||
expect(match({foo: undefined}).toEqual("goo")).toEqual(false);
|
||||
expect(match({foo: {bar :undefined}}).toEqual("goo")).toEqual(false);
|
||||
expect(match("foo").toEqual({bar: jasmine.undefined})).toEqual(false);
|
||||
expect(match({foo: jasmine.undefined}).toEqual("goo")).toEqual(false);
|
||||
expect(match({foo: {bar :jasmine.undefined}}).toEqual("goo")).toEqual(false);
|
||||
});
|
||||
|
||||
it("toEqual with jasmine.any()", function() {
|
||||
@ -321,7 +321,7 @@ describe("jasmine.Matchers", function() {
|
||||
});
|
||||
|
||||
it("toEqual handles circular objects ok", function() {
|
||||
expect(match({foo: "bar", baz: undefined}).toEqual({foo: "bar", baz: undefined})).toEqual(true);
|
||||
expect(match({foo: "bar", baz: jasmine.undefined}).toEqual({foo: "bar", baz: jasmine.undefined})).toEqual(true);
|
||||
expect(match({foo:['bar','baz','quux']}).toEqual({foo:['bar','baz','quux']})).toEqual(true);
|
||||
expect(match({foo: {bar:'baz'}, quux:'corge'}).toEqual({foo:{bar:'baz'}, quux:'corge'})).toEqual(true);
|
||||
|
||||
@ -488,7 +488,7 @@ describe("jasmine.Matchers", function() {
|
||||
}).toThrow('Expected a spy, but got Function.');
|
||||
|
||||
expect(function() {
|
||||
match(undefined)[methodName]();
|
||||
match(jasmine.undefined)[methodName]();
|
||||
}).toThrow('Expected a spy, but got undefined.');
|
||||
|
||||
expect(function() {
|
||||
|
@ -8,14 +8,14 @@ describe("jasmine.pp", function () {
|
||||
expect(jasmine.pp(true)).toEqual("true");
|
||||
expect(jasmine.pp(false)).toEqual("false");
|
||||
expect(jasmine.pp(null)).toEqual("null");
|
||||
expect(jasmine.pp(undefined)).toEqual("undefined");
|
||||
expect(jasmine.pp(jasmine.undefined)).toEqual("undefined");
|
||||
expect(jasmine.pp(3)).toEqual("3");
|
||||
expect(jasmine.pp(-3.14)).toEqual("-3.14");
|
||||
});
|
||||
|
||||
it("should stringify arrays properly", function() {
|
||||
expect(jasmine.pp([1, 2])).toEqual("[ 1, 2 ]");
|
||||
expect(jasmine.pp([1, 'foo', {}, undefined, null])).toEqual("[ 1, 'foo', { }, undefined, null ]");
|
||||
expect(jasmine.pp([1, 'foo', {}, jasmine.undefined, null])).toEqual("[ 1, 'foo', { }, undefined, null ]");
|
||||
});
|
||||
|
||||
it("should indicate circular array references", function() {
|
||||
@ -27,7 +27,7 @@ describe("jasmine.pp", function () {
|
||||
|
||||
it("should stringify objects properly", function() {
|
||||
expect(jasmine.pp({foo: 'bar'})).toEqual("{ foo : 'bar' }");
|
||||
expect(jasmine.pp({foo:'bar', baz:3, nullValue: null, undefinedValue: undefined})).toEqual("{ foo : 'bar', baz : 3, nullValue : null, undefinedValue : undefined }");
|
||||
expect(jasmine.pp({foo:'bar', baz:3, nullValue: null, undefinedValue: jasmine.undefined})).toEqual("{ foo : 'bar', baz : 3, nullValue : null, undefinedValue : undefined }");
|
||||
expect(jasmine.pp({foo: function () {
|
||||
}, bar: [1, 2, 3]})).toEqual("{ foo : Function, bar : [ 1, 2, 3 ] }");
|
||||
});
|
||||
|
@ -1111,7 +1111,7 @@ describe("jasmine spec running", function () {
|
||||
expect(spec1Matcher.matcherForSpec("expected")).toEqual("matcherForSpec: actual: xxx; expected: expected");
|
||||
|
||||
expect(spec2Matcher.matcherForSuite("expected")).toEqual("matcherForSuite: actual: yyy; expected: expected");
|
||||
expect(spec2Matcher.matcherForSpec).toBe(undefined);
|
||||
expect(spec2Matcher.matcherForSpec).toBe(jasmine.undefined);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -151,7 +151,7 @@ jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchVal
|
||||
b.__Jasmine_been_here_before__ = a;
|
||||
|
||||
var hasKey = function(obj, keyName) {
|
||||
return obj != null && obj[keyName] !== undefined;
|
||||
return obj != null && obj[keyName] !== jasmine.undefined;
|
||||
};
|
||||
|
||||
for (var property in b) {
|
||||
@ -186,8 +186,8 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
|
||||
|
||||
if (a === b) return true;
|
||||
|
||||
if (a === undefined || a === null || b === undefined || b === null) {
|
||||
return (a == undefined && b == undefined);
|
||||
if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) {
|
||||
return (a == jasmine.undefined && b == jasmine.undefined);
|
||||
}
|
||||
|
||||
if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) {
|
||||
@ -213,7 +213,7 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
|
||||
for (var i = 0; i < this.equalityTesters_.length; i++) {
|
||||
var equalityTester = this.equalityTesters_[i];
|
||||
var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
|
||||
if (result !== undefined) return result;
|
||||
if (result !== jasmine.undefined) return result;
|
||||
}
|
||||
|
||||
//Straight check
|
||||
|
@ -88,7 +88,7 @@ jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
|
||||
type: resultMessage.type,
|
||||
message: resultMessage.message,
|
||||
trace: {
|
||||
stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : undefined
|
||||
stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -113,17 +113,17 @@ jasmine.Matchers.prototype.toNotMatch = function(expected) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that compares the actual to undefined.
|
||||
* Matcher that compares the actual to jasmine.undefined.
|
||||
*/
|
||||
jasmine.Matchers.prototype.toBeDefined = function() {
|
||||
return (this.actual !== undefined);
|
||||
return (this.actual !== jasmine.undefined);
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that compares the actual to undefined.
|
||||
* Matcher that compares the actual to jasmine.undefined.
|
||||
*/
|
||||
jasmine.Matchers.prototype.toBeUndefined = function() {
|
||||
return (this.actual === undefined);
|
||||
return (this.actual === jasmine.undefined);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -252,12 +252,12 @@ jasmine.Matchers.prototype.toThrow = function(expected) {
|
||||
var result = false;
|
||||
var exception = getException_(this.actual, expected);
|
||||
if (exception) {
|
||||
result = (expected === undefined || this.env.equals_(exception.message || exception, expected.message || expected));
|
||||
result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected));
|
||||
}
|
||||
|
||||
this.message = function(expected) {
|
||||
var exception = getException_(this.actual, expected);
|
||||
if (exception && (expected === undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
|
||||
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(' ');
|
||||
} else {
|
||||
return "Expected function to throw an exception.";
|
||||
|
@ -17,7 +17,7 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
|
||||
|
||||
this.ppNestLevel_++;
|
||||
try {
|
||||
if (value === undefined) {
|
||||
if (value === jasmine.undefined) {
|
||||
this.emitScalar('undefined');
|
||||
} else if (value === null) {
|
||||
this.emitScalar('null');
|
||||
|
@ -171,11 +171,11 @@ jasmine.Spec.prototype.explodes = function() {
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) {
|
||||
if (obj == undefined) {
|
||||
if (obj == jasmine.undefined) {
|
||||
throw "spyOn could not find an object to spy upon for " + methodName + "()";
|
||||
}
|
||||
|
||||
if (!ignoreMethodDoesntExist && obj[methodName] === undefined) {
|
||||
if (!ignoreMethodDoesntExist && obj[methodName] === jasmine.undefined) {
|
||||
throw methodName + '() method does not exist';
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,14 @@ jasmine.unimplementedMethod_ = function() {
|
||||
throw new Error("unimplemented method");
|
||||
};
|
||||
|
||||
/**
|
||||
* Use <code>jasmine.undefined</code> instead of <code>undefined</code>, since <code>undefined</code is just
|
||||
* a plain old variable and may be redefined by somebody else.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
jasmine.undefined = jasmine.___undefined___;
|
||||
|
||||
/**
|
||||
* Default interval for event loop yields. Small values here may result in slow test running. Zero means no updates until all tests have completed.
|
||||
*
|
||||
|
@ -18,11 +18,11 @@ jasmine.FakeTimer = function() {
|
||||
};
|
||||
|
||||
self.clearTimeout = function(timeoutKey) {
|
||||
self.scheduledFunctions[timeoutKey] = undefined;
|
||||
self.scheduledFunctions[timeoutKey] = jasmine.undefined;
|
||||
};
|
||||
|
||||
self.clearInterval = function(timeoutKey) {
|
||||
self.scheduledFunctions[timeoutKey] = undefined;
|
||||
self.scheduledFunctions[timeoutKey] = jasmine.undefined;
|
||||
};
|
||||
|
||||
};
|
||||
@ -45,11 +45,11 @@ jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMil
|
||||
var funcsToRun = [];
|
||||
for (var timeoutKey in this.scheduledFunctions) {
|
||||
scheduledFunc = this.scheduledFunctions[timeoutKey];
|
||||
if (scheduledFunc != undefined &&
|
||||
if (scheduledFunc != jasmine.undefined &&
|
||||
scheduledFunc.runAtMillis >= oldMillis &&
|
||||
scheduledFunc.runAtMillis <= nowMillis) {
|
||||
funcsToRun.push(scheduledFunc);
|
||||
this.scheduledFunctions[timeoutKey] = undefined;
|
||||
this.scheduledFunctions[timeoutKey] = jasmine.undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user