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
|
def jasmine_sources
|
||||||
sources = ["src/base.js", "src/util.js", "src/Env.js", "src/Reporter.js", "src/Block.js"]
|
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 += Dir.glob('src/*.js').reject{|f| f == 'src/base.js' || sources.include?(f)}.sort
|
||||||
|
sources
|
||||||
end
|
end
|
||||||
|
|
||||||
def jasmine_filename(version)
|
def jasmine_filename(version)
|
||||||
|
@ -26,19 +27,53 @@ def start_jasmine_server(jasmine_includes = nil)
|
||||||
:jasmine_files => jasmine_includes)
|
:jasmine_files => jasmine_includes)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
task :default => 'jasmine:dist'
|
||||||
|
|
||||||
namespace :jasmine do
|
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'
|
desc 'Builds lib/jasmine from source'
|
||||||
task :build => 'jasmine:doc' do
|
task :build => :lint do
|
||||||
puts 'Building Jasmine from source'
|
puts 'Building Jasmine from source'
|
||||||
require 'json'
|
require 'json'
|
||||||
|
|
||||||
sources = jasmine_sources
|
sources = jasmine_sources
|
||||||
version = version_hash
|
version = version_hash
|
||||||
|
|
||||||
old_jasmine_files = Dir.glob('lib/jasmine*.js')
|
old_jasmine_files = Dir.glob('lib/jasmine*.js')
|
||||||
old_jasmine_files.each do |file|
|
old_jasmine_files.each do |file|
|
||||||
File.delete(file)
|
File.delete(file)
|
||||||
end
|
end
|
||||||
|
|
||||||
jasmine = File.new("lib/#{jasmine_filename version}", 'w')
|
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.puts %{
|
||||||
jasmine.version_= {
|
jasmine.version_= {
|
||||||
"major": #{version['major']},
|
"major": #{version['major']},
|
||||||
|
@ -47,9 +82,7 @@ jasmine.version_= {
|
||||||
"revision": #{Time.now.to_i}
|
"revision": #{Time.now.to_i}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
sources.each do |source_filename|
|
|
||||||
jasmine.puts(File.read(source_filename))
|
|
||||||
end
|
|
||||||
jasmine.close
|
jasmine.close
|
||||||
end
|
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;
|
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
|
* @ignore
|
||||||
* @private
|
* @private
|
||||||
|
@ -177,7 +185,7 @@ jasmine.Spy = function(name) {
|
||||||
*/
|
*/
|
||||||
this.isSpy = true;
|
this.isSpy = true;
|
||||||
/**
|
/**
|
||||||
* The acutal function this spy stubs.
|
* The actual function this spy stubs.
|
||||||
*/
|
*/
|
||||||
this.plan = function() {
|
this.plan = function() {
|
||||||
};
|
};
|
||||||
|
@ -324,6 +332,16 @@ jasmine.createSpy = function(name) {
|
||||||
return spyObj;
|
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
|
* 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.
|
* large in one call.
|
||||||
|
@ -529,26 +547,22 @@ jasmine.include = function(url, opt_global) {
|
||||||
return eval(xhr.responseText);
|
return eval(xhr.responseText);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.version_= {
|
|
||||||
"major": 0,
|
|
||||||
"minor": 10,
|
|
||||||
"build": 0,
|
|
||||||
"revision": 1257050679
|
|
||||||
};
|
|
||||||
/**
|
/**
|
||||||
* @namespace
|
* @namespace
|
||||||
*/
|
*/
|
||||||
jasmine.util = {};
|
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
|
* @private
|
||||||
* @param {Function} childClass
|
* @param {Function} childClass
|
||||||
* @param {Function} parentClass
|
* @param {Function} parentClass
|
||||||
*/
|
*/
|
||||||
jasmine.util.inherit = function(childClass, parentClass) {
|
jasmine.util.inherit = function(childClass, parentClass) {
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
var subclass = function() {
|
var subclass = function() {
|
||||||
};
|
};
|
||||||
subclass.prototype = parentClass.prototype;
|
subclass.prototype = parentClass.prototype;
|
||||||
|
@ -612,7 +626,7 @@ jasmine.Env = function() {
|
||||||
|
|
||||||
this.reporter = new jasmine.MultiReporter();
|
this.reporter = new jasmine.MultiReporter();
|
||||||
|
|
||||||
this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL
|
this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL;
|
||||||
this.lastUpdate = 0;
|
this.lastUpdate = 0;
|
||||||
this.specFilter = function() {
|
this.specFilter = function() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -621,6 +635,17 @@ jasmine.Env = function() {
|
||||||
this.nextSpecId_ = 0;
|
this.nextSpecId_ = 0;
|
||||||
this.nextSuiteId_ = 0;
|
this.nextSuiteId_ = 0;
|
||||||
this.equalityTesters_ = [];
|
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;
|
b.__Jasmine_been_here_before__ = a;
|
||||||
|
|
||||||
var hasKey = function(obj, keyName) {
|
var hasKey = function(obj, keyName) {
|
||||||
return obj != null && obj[keyName] !== undefined;
|
return obj != null && obj[keyName] !== jasmine.undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
for (var property in b) {
|
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 === b) return true;
|
||||||
|
|
||||||
if (a === undefined || a === null || b === undefined || b === null) {
|
if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) {
|
||||||
return (a == undefined && b == undefined);
|
return (a == jasmine.undefined && b == jasmine.undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) {
|
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++) {
|
for (var i = 0; i < this.equalityTesters_.length; i++) {
|
||||||
var equalityTester = this.equalityTesters_[i];
|
var equalityTester = this.equalityTesters_[i];
|
||||||
var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
|
var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
|
||||||
if (result !== undefined) return result;
|
if (result !== jasmine.undefined) return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Straight check
|
//Straight check
|
||||||
|
@ -898,7 +923,7 @@ jasmine.JsApiReporter.prototype.suites = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {
|
jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {
|
||||||
var isSuite = suiteOrSpec instanceof jasmine.Suite
|
var isSuite = suiteOrSpec instanceof jasmine.Suite;
|
||||||
var summary = {
|
var summary = {
|
||||||
id: suiteOrSpec.id,
|
id: suiteOrSpec.id,
|
||||||
name: suiteOrSpec.description,
|
name: suiteOrSpec.description,
|
||||||
|
@ -954,7 +979,8 @@ jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds){
|
||||||
|
|
||||||
jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
|
jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
|
||||||
var summaryMessages = [];
|
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];
|
var resultMessage = result.messages[messageIndex];
|
||||||
summaryMessages.push({
|
summaryMessages.push({
|
||||||
text: resultMessage.text,
|
text: resultMessage.text,
|
||||||
|
@ -962,7 +988,7 @@ jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
|
||||||
type: resultMessage.type,
|
type: resultMessage.type,
|
||||||
message: resultMessage.message,
|
message: resultMessage.message,
|
||||||
trace: {
|
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
|
* @constructor
|
||||||
* @param {jasmine.Env} env
|
* @param {jasmine.Env} env
|
||||||
* @param actual
|
* @param actual
|
||||||
* @param {jasmine.NestedResults} results
|
* @param {jasmine.Spec} spec
|
||||||
*/
|
*/
|
||||||
jasmine.Matchers = function(env, actual, spec) {
|
jasmine.Matchers = function(env, actual, spec) {
|
||||||
this.env = env;
|
this.env = env;
|
||||||
|
@ -1001,15 +1027,25 @@ jasmine.Matchers.prototype.report = function(result, failing_message, details) {
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.Matchers.matcherFn_ = function(matcherName, options) {
|
jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
|
||||||
return function() {
|
return function() {
|
||||||
jasmine.util.extend(this, options);
|
|
||||||
var matcherArgs = jasmine.util.argsToArray(arguments);
|
var matcherArgs = jasmine.util.argsToArray(arguments);
|
||||||
var args = [this.actual].concat(matcherArgs);
|
var result = matcherFunction.apply(this, arguments);
|
||||||
var result = options.test.apply(this, args);
|
|
||||||
var message;
|
var message;
|
||||||
if (!result) {
|
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({
|
var expectationResult = new jasmine.ExpectationResult({
|
||||||
matcherName: matcherName,
|
matcherName: matcherName,
|
||||||
|
@ -1031,27 +1067,17 @@ jasmine.Matchers.matcherFn_ = function(matcherName, options) {
|
||||||
* @param expected
|
* @param expected
|
||||||
*/
|
*/
|
||||||
|
|
||||||
jasmine.Matchers.prototype.toBe = jasmine.Matchers.matcherFn_('toBe', {
|
jasmine.Matchers.prototype.toBe = function(expected) {
|
||||||
test: function (actual, expected) {
|
return this.actual === expected;
|
||||||
return actual === expected;
|
};
|
||||||
},
|
|
||||||
message: function(actual, expected) {
|
|
||||||
return "Expected " + jasmine.pp(actual) + " to be " + jasmine.pp(expected);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* toNotBe: compares the actual to the expected using !==
|
* toNotBe: compares the actual to the expected using !==
|
||||||
* @param expected
|
* @param expected
|
||||||
*/
|
*/
|
||||||
jasmine.Matchers.prototype.toNotBe = jasmine.Matchers.matcherFn_('toNotBe', {
|
jasmine.Matchers.prototype.toNotBe = function(expected) {
|
||||||
test: function (actual, expected) {
|
return this.actual !== expected;
|
||||||
return actual !== expected;
|
};
|
||||||
},
|
|
||||||
message: function(actual, expected) {
|
|
||||||
return "Expected " + jasmine.pp(actual) + " to not be " + jasmine.pp(expected);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc.
|
* 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
|
* @param expected
|
||||||
*/
|
*/
|
||||||
|
|
||||||
jasmine.Matchers.prototype.toEqual = jasmine.Matchers.matcherFn_('toEqual', {
|
jasmine.Matchers.prototype.toEqual = function(expected) {
|
||||||
test: function (actual, expected) {
|
return this.env.equals_(this.actual, expected);
|
||||||
return this.env.equals_(actual, expected);
|
};
|
||||||
},
|
|
||||||
message: function(actual, expected) {
|
|
||||||
return "Expected " + jasmine.pp(actual) + " to equal " + jasmine.pp(expected);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual
|
* toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual
|
||||||
* @param expected
|
* @param expected
|
||||||
*/
|
*/
|
||||||
jasmine.Matchers.prototype.toNotEqual = jasmine.Matchers.matcherFn_('toNotEqual', {
|
jasmine.Matchers.prototype.toNotEqual = function(expected) {
|
||||||
test: function (actual, expected) {
|
return !this.env.equals_(this.actual, expected);
|
||||||
return !this.env.equals_(actual, expected);
|
};
|
||||||
},
|
|
||||||
message: function(actual, expected) {
|
|
||||||
return "Expected " + jasmine.pp(actual) + " to not equal " + jasmine.pp(expected);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes
|
* 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
|
* @param reg_exp
|
||||||
*/
|
*/
|
||||||
jasmine.Matchers.prototype.toMatch = jasmine.Matchers.matcherFn_('toMatch', {
|
jasmine.Matchers.prototype.toMatch = function(expected) {
|
||||||
test: function(actual, expected) {
|
return new RegExp(expected).test(this.actual);
|
||||||
return new RegExp(expected).test(actual);
|
};
|
||||||
},
|
|
||||||
message: function(actual, expected) {
|
|
||||||
return jasmine.pp(actual) + " does not match the regular expression " + new RegExp(expected).toString();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch
|
* Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch
|
||||||
* @param reg_exp
|
* @param reg_exp
|
||||||
*/
|
*/
|
||||||
|
jasmine.Matchers.prototype.toNotMatch = function(expected) {
|
||||||
jasmine.Matchers.prototype.toNotMatch = jasmine.Matchers.matcherFn_('toNotMatch', {
|
return !(new RegExp(expected).test(this.actual));
|
||||||
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();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matcher that compares the acutal to undefined.
|
* Matcher that compares the actual to jasmine.undefined.
|
||||||
*/
|
*/
|
||||||
|
jasmine.Matchers.prototype.toBeDefined = function() {
|
||||||
jasmine.Matchers.prototype.toBeDefined = jasmine.Matchers.matcherFn_('toBeDefined', {
|
return (this.actual !== jasmine.undefined);
|
||||||
test: function(actual) {
|
};
|
||||||
return (actual !== undefined);
|
|
||||||
},
|
|
||||||
message: function() {
|
|
||||||
return 'Expected actual to not be undefined.';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matcher that compares the acutal to undefined.
|
* Matcher that compares the actual to jasmine.undefined.
|
||||||
*/
|
*/
|
||||||
|
jasmine.Matchers.prototype.toBeUndefined = function() {
|
||||||
jasmine.Matchers.prototype.toBeUndefined = jasmine.Matchers.matcherFn_('toBeUndefined', {
|
return (this.actual === jasmine.undefined);
|
||||||
test: function(actual) {
|
};
|
||||||
return (actual === undefined);
|
|
||||||
},
|
|
||||||
message: function(actual) {
|
|
||||||
return 'Expected ' + jasmine.pp(actual) + ' to be undefined.';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matcher that compares the actual to null.
|
* Matcher that compares the actual to null.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
jasmine.Matchers.prototype.toBeNull = jasmine.Matchers.matcherFn_('toBeNull', {
|
jasmine.Matchers.prototype.toBeNull = function() {
|
||||||
test: function(actual) {
|
return (this.actual === null);
|
||||||
return (actual === null);
|
};
|
||||||
},
|
|
||||||
message: function(actual) {
|
|
||||||
return 'Expected ' + jasmine.pp(actual) + ' to be null.';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matcher that boolean not-nots the actual.
|
* Matcher that boolean not-nots the actual.
|
||||||
*/
|
*/
|
||||||
jasmine.Matchers.prototype.toBeTruthy = jasmine.Matchers.matcherFn_('toBeTruthy', {
|
jasmine.Matchers.prototype.toBeTruthy = function() {
|
||||||
test: function(actual) {
|
return !!this.actual;
|
||||||
return !!actual;
|
};
|
||||||
},
|
|
||||||
message: function() {
|
|
||||||
return 'Expected actual to be truthy';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matcher that boolean nots the actual.
|
* Matcher that boolean nots the actual.
|
||||||
*/
|
*/
|
||||||
jasmine.Matchers.prototype.toBeFalsy = jasmine.Matchers.matcherFn_('toBeFalsy', {
|
jasmine.Matchers.prototype.toBeFalsy = function() {
|
||||||
test: function(actual) {
|
return !this.actual;
|
||||||
return !actual;
|
};
|
||||||
},
|
|
||||||
message: function(actual) {
|
|
||||||
return 'Expected ' + jasmine.pp(actual) + ' to be falsy';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 = function() {
|
||||||
|
if (arguments.length > 0) {
|
||||||
|
throw new Error('wasCalled does not take arguments, use wasCalledWith');
|
||||||
|
}
|
||||||
|
|
||||||
jasmine.Matchers.prototype.wasCalled = jasmine.Matchers.matcherFn_('wasCalled', {
|
if (!jasmine.isSpy(this.actual)) {
|
||||||
getActual_: function() {
|
throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.');
|
||||||
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];
|
|
||||||
},
|
this.message = function() {
|
||||||
test: function() {
|
return "Expected spy " + this.actual.identity + " to have been called.";
|
||||||
var actual = this.getActual_.apply(this, arguments);
|
};
|
||||||
if (!actual || !actual.isSpy) {
|
|
||||||
return false;
|
return this.actual.wasCalled;
|
||||||
}
|
};
|
||||||
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.";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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', {
|
jasmine.Matchers.prototype.wasNotCalled = function() {
|
||||||
getActual_: function() {
|
if (arguments.length > 0) {
|
||||||
var args = jasmine.util.argsToArray(arguments);
|
throw new Error('wasNotCalled does not take 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.wasCalledWith = jasmine.Matchers.matcherFn_('wasCalledWith', {
|
if (!jasmine.isSpy(this.actual)) {
|
||||||
test: function() {
|
throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.');
|
||||||
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);
|
|
||||||
},
|
this.message = function() {
|
||||||
message: function() {
|
return "Expected spy " + this.actual.identity + " to not have been called.";
|
||||||
var args = jasmine.util.argsToArray(arguments);
|
};
|
||||||
var actual = args.splice(0, 1)[0];
|
|
||||||
var message;
|
return !this.actual.wasCalled;
|
||||||
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;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
* @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.
|
* Matcher that checks that the expected item is an element in the actual Array.
|
||||||
*
|
*
|
||||||
* @param {Object} item
|
* @param {Object} item
|
||||||
*/
|
*/
|
||||||
|
jasmine.Matchers.prototype.toContain = function(expected) {
|
||||||
jasmine.Matchers.prototype.toContain = jasmine.Matchers.matcherFn_('toContain', {
|
return this.env.contains_(this.actual, expected);
|
||||||
test: function(actual, expected) {
|
};
|
||||||
return this.env.contains_(actual, expected);
|
|
||||||
},
|
|
||||||
message: function(actual, expected) {
|
|
||||||
return 'Expected ' + jasmine.pp(actual) + ' to contain ' + jasmine.pp(expected);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matcher that checks that the expected item is NOT an element in the actual Array.
|
* Matcher that checks that the expected item is NOT an element in the actual Array.
|
||||||
*
|
*
|
||||||
* @param {Object} item
|
* @param {Object} item
|
||||||
*/
|
*/
|
||||||
jasmine.Matchers.prototype.toNotContain = jasmine.Matchers.matcherFn_('toNotContain', {
|
jasmine.Matchers.prototype.toNotContain = function(expected) {
|
||||||
test: function(actual, expected) {
|
return !this.env.contains_(this.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.toBeLessThan = jasmine.Matchers.matcherFn_('toBeLessThan', {
|
jasmine.Matchers.prototype.toBeLessThan = function(expected) {
|
||||||
test: function(actual, expected) {
|
return this.actual < expected;
|
||||||
return actual < expected;
|
};
|
||||||
},
|
|
||||||
message: function(actual, expected) {
|
|
||||||
return 'Expected ' + jasmine.pp(actual) + ' to be less than ' + jasmine.pp(expected);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
jasmine.Matchers.prototype.toBeGreaterThan = jasmine.Matchers.matcherFn_('toBeGreaterThan', {
|
jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
|
||||||
test: function(actual, expected) {
|
return this.actual > expected;
|
||||||
return actual > expected;
|
};
|
||||||
},
|
|
||||||
message: function(actual, expected) {
|
|
||||||
return 'Expected ' + jasmine.pp(actual) + ' to be greater than ' + jasmine.pp(expected);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matcher that checks that the expected exception was thrown by the actual.
|
* Matcher that checks that the expected exception was thrown by the actual.
|
||||||
*
|
*
|
||||||
* @param {String} expectedException
|
* @param {String} expectedException
|
||||||
*/
|
*/
|
||||||
jasmine.Matchers.prototype.toThrow = jasmine.Matchers.matcherFn_('toThrow', {
|
jasmine.Matchers.prototype.toThrow = function(expected) {
|
||||||
getException_: function(actual, expected) {
|
function getException_(actual, expected) {
|
||||||
var exception;
|
var exception;
|
||||||
if (typeof actual != 'function') {
|
if (typeof actual != 'function') {
|
||||||
throw new Error('Actual is not a function');
|
throw new Error('Actual is not a function');
|
||||||
|
@ -1319,24 +1250,25 @@ jasmine.Matchers.prototype.toThrow = jasmine.Matchers.matcherFn_('toThrow', {
|
||||||
exception = e;
|
exception = e;
|
||||||
}
|
}
|
||||||
return exception;
|
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;
|
|
||||||
},
|
var result = false;
|
||||||
message: function(actual, expected) {
|
var exception = getException_(this.actual, expected);
|
||||||
var exception = this.getException_(actual, expected);
|
if (exception) {
|
||||||
if (exception && (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 === 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 {
|
} else {
|
||||||
return "Expected function to throw an exception.";
|
return "Expected function to throw an exception.";
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
});
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
jasmine.Matchers.Any = function(expectedClass) {
|
jasmine.Matchers.Any = function(expectedClass) {
|
||||||
this.expectedClass = expectedClass;
|
this.expectedClass = expectedClass;
|
||||||
|
@ -1485,17 +1417,15 @@ jasmine.PrettyPrinter = function() {
|
||||||
* Formats a value in a nice, human-readable string.
|
* Formats a value in a nice, human-readable string.
|
||||||
*
|
*
|
||||||
* @param value
|
* @param value
|
||||||
* @returns {String}
|
|
||||||
*/
|
*/
|
||||||
jasmine.PrettyPrinter.prototype.format = function(value) {
|
jasmine.PrettyPrinter.prototype.format = function(value) {
|
||||||
if (this.ppNestLevel_ > 40) {
|
if (this.ppNestLevel_ > 40) {
|
||||||
// return '(jasmine.pp nested too deeply!)';
|
|
||||||
throw new Error('jasmine.PrettyPrinter: format() nested too deeply!');
|
throw new Error('jasmine.PrettyPrinter: format() nested too deeply!');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ppNestLevel_++;
|
this.ppNestLevel_++;
|
||||||
try {
|
try {
|
||||||
if (value === undefined) {
|
if (value === jasmine.undefined) {
|
||||||
this.emitScalar('undefined');
|
this.emitScalar('undefined');
|
||||||
} else if (value === null) {
|
} else if (value === null) {
|
||||||
this.emitScalar('null');
|
this.emitScalar('null');
|
||||||
|
@ -1505,12 +1435,16 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
|
||||||
this.emitScalar(value.toString());
|
this.emitScalar(value.toString());
|
||||||
} else if (typeof value === 'string') {
|
} else if (typeof value === 'string') {
|
||||||
this.emitString(value);
|
this.emitString(value);
|
||||||
|
} else if (jasmine.isSpy(value)) {
|
||||||
|
this.emitScalar("spy on " + value.identity);
|
||||||
} else if (typeof value === 'function') {
|
} else if (typeof value === 'function') {
|
||||||
this.emitScalar('Function');
|
this.emitScalar('Function');
|
||||||
} else if (typeof value.nodeType === 'number') {
|
} else if (typeof value.nodeType === 'number') {
|
||||||
this.emitScalar('HTMLNode');
|
this.emitScalar('HTMLNode');
|
||||||
} else if (value instanceof Date) {
|
} else if (value instanceof Date) {
|
||||||
this.emitScalar('Date(' + value + ')');
|
this.emitScalar('Date(' + value + ')');
|
||||||
|
} else if (value instanceof RegExp) {
|
||||||
|
this.emitScalar(value.toString());
|
||||||
} else if (value.__Jasmine_been_here_before__) {
|
} else if (value.__Jasmine_been_here_before__) {
|
||||||
this.emitScalar('<circular reference: ' + (jasmine.isArray_(value) ? 'Array' : 'Object') + '>');
|
this.emitScalar('<circular reference: ' + (jasmine.isArray_(value) ? 'Array' : 'Object') + '>');
|
||||||
} else if (jasmine.isArray_(value) || typeof value == '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
|
* 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)
|
* descendants of this object to do something with the results (see json_reporter.js)
|
||||||
|
*
|
||||||
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
jasmine.Reporters = {};
|
jasmine.Reporters = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @param callbacks
|
||||||
|
*/
|
||||||
jasmine.Reporters.reporter = function(callbacks) {
|
jasmine.Reporters.reporter = function(callbacks) {
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @param callbacks
|
||||||
|
*/
|
||||||
var that = {
|
var that = {
|
||||||
callbacks: callbacks || {},
|
callbacks: callbacks || {},
|
||||||
|
|
||||||
|
@ -1801,11 +1745,9 @@ jasmine.Spec = function(env, suite, description) {
|
||||||
if (!env) {
|
if (!env) {
|
||||||
throw new Error('jasmine.Env() required');
|
throw new Error('jasmine.Env() required');
|
||||||
}
|
}
|
||||||
;
|
|
||||||
if (!suite) {
|
if (!suite) {
|
||||||
throw new Error('jasmine.Suite() required');
|
throw new Error('jasmine.Suite() required');
|
||||||
}
|
}
|
||||||
;
|
|
||||||
var spec = this;
|
var spec = this;
|
||||||
spec.id = env.nextSpecId ? env.nextSpecId() : null;
|
spec.id = env.nextSpecId ? env.nextSpecId() : null;
|
||||||
spec.env = env;
|
spec.env = env;
|
||||||
|
@ -1882,7 +1824,7 @@ jasmine.Spec.prototype.fail = function (e) {
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.Spec.prototype.getMatchersClass_ = function() {
|
jasmine.Spec.prototype.getMatchersClass_ = function() {
|
||||||
return this.matchersClass || jasmine.Matchers;
|
return this.matchersClass || this.env.matchersClass;
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.Spec.prototype.addMatchers = function(matchersPrototype) {
|
jasmine.Spec.prototype.addMatchers = function(matchersPrototype) {
|
||||||
|
@ -1964,11 +1906,11 @@ jasmine.Spec.prototype.explodes = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) {
|
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 + "()";
|
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';
|
throw methodName + '() method does not exist';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2137,11 +2079,11 @@ jasmine.FakeTimer = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
self.clearTimeout = function(timeoutKey) {
|
self.clearTimeout = function(timeoutKey) {
|
||||||
self.scheduledFunctions[timeoutKey] = undefined;
|
self.scheduledFunctions[timeoutKey] = jasmine.undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
self.clearInterval = function(timeoutKey) {
|
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 = [];
|
var funcsToRun = [];
|
||||||
for (var timeoutKey in this.scheduledFunctions) {
|
for (var timeoutKey in this.scheduledFunctions) {
|
||||||
scheduledFunc = this.scheduledFunctions[timeoutKey];
|
scheduledFunc = this.scheduledFunctions[timeoutKey];
|
||||||
if (scheduledFunc != undefined &&
|
if (scheduledFunc != jasmine.undefined &&
|
||||||
scheduledFunc.runAtMillis >= oldMillis &&
|
scheduledFunc.runAtMillis >= oldMillis &&
|
||||||
scheduledFunc.runAtMillis <= nowMillis) {
|
scheduledFunc.runAtMillis <= nowMillis) {
|
||||||
funcsToRun.push(scheduledFunc);
|
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 = {
|
jasmine.Clock = {
|
||||||
defaultFakeTimer: new jasmine.FakeTimer(),
|
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>
|
<head>
|
||||||
<title>Jasmine Test Runner</title>
|
<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/base.js"></script>
|
||||||
<script type="text/javascript" src="../src/util.js"></script>
|
<script type="text/javascript" src="../src/util.js"></script>
|
||||||
<script type="text/javascript" src="../src/Env.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].message).toEqual(result.messages[0].message);
|
||||||
expect(summarizedResult.messages[0].passed).toBeTruthy();
|
expect(summarizedResult.messages[0].passed).toBeTruthy();
|
||||||
expect(summarizedResult.messages[0].type).toEqual('ExpectationResult');
|
expect(summarizedResult.messages[0].type).toEqual('ExpectationResult');
|
||||||
expect(summarizedResult.messages[0].text).toEqual(undefined);
|
expect(summarizedResult.messages[0].text).toEqual(jasmine.undefined);
|
||||||
expect(summarizedResult.messages[0].trace.stack).toEqual(undefined);
|
expect(summarizedResult.messages[0].trace.stack).toEqual(jasmine.undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should have a stack trace for failing specs", function() {
|
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(false)).toEqual(true);
|
||||||
expect((match(true).toNotEqual(true))).toEqual(false);
|
expect((match(true).toNotEqual(true))).toEqual(false);
|
||||||
|
|
||||||
expect((match(['a', 'b']).toEqual(['a', undefined]))).toEqual(false);
|
expect((match(['a', 'b']).toEqual(['a', jasmine.undefined]))).toEqual(false);
|
||||||
expect((match(['a', 'b']).toEqual(['a', 'b', undefined]))).toEqual(false);
|
expect((match(['a', 'b']).toEqual(['a', 'b', jasmine.undefined]))).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("toEqual to build an Expectation Result", function() {
|
it("toEqual to build an Expectation Result", function() {
|
||||||
|
@ -197,11 +197,11 @@ describe("jasmine.Matchers", function() {
|
||||||
|
|
||||||
it("toBeDefined", function() {
|
it("toBeDefined", function() {
|
||||||
expect(match('foo').toBeDefined()).toEqual(true);
|
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() {
|
it("toBeDefined to build an ExpectationResult", function() {
|
||||||
var matcher = match(undefined);
|
var matcher = match(jasmine.undefined);
|
||||||
matcher.toBeDefined();
|
matcher.toBeDefined();
|
||||||
|
|
||||||
var result = mockSpec.addMatcherResult.mostRecentCall.args[0];
|
var result = mockSpec.addMatcherResult.mostRecentCall.args[0];
|
||||||
|
@ -209,17 +209,17 @@ describe("jasmine.Matchers", function() {
|
||||||
expect(result.matcherName).toEqual("toBeDefined");
|
expect(result.matcherName).toEqual("toBeDefined");
|
||||||
expect(result.passed()).toEqual(false);
|
expect(result.passed()).toEqual(false);
|
||||||
expect(result.message).toEqual('Expected undefined to be defined.');
|
expect(result.message).toEqual('Expected undefined to be defined.');
|
||||||
expect(result.actual).toEqual(undefined);
|
expect(result.actual).toEqual(jasmine.undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("toBeUndefined", function() {
|
it("toBeUndefined", function() {
|
||||||
expect(match('foo').toBeUndefined()).toEqual(false);
|
expect(match('foo').toBeUndefined()).toEqual(false);
|
||||||
expect(match(undefined).toBeUndefined()).toEqual(true);
|
expect(match(jasmine.undefined).toBeUndefined()).toEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("toBeNull", function() {
|
it("toBeNull", function() {
|
||||||
expect(match(null).toBeNull()).toEqual(true);
|
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);
|
expect(match("foo").toBeNull()).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ describe("jasmine.Matchers", function() {
|
||||||
it("toBeFalsy", function() {
|
it("toBeFalsy", function() {
|
||||||
expect(match(false).toBeFalsy()).toEqual(true);
|
expect(match(false).toBeFalsy()).toEqual(true);
|
||||||
expect(match(true).toBeFalsy()).toEqual(false);
|
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(0).toBeFalsy()).toEqual(true);
|
||||||
expect(match("").toBeFalsy()).toEqual(true);
|
expect(match("").toBeFalsy()).toEqual(true);
|
||||||
});
|
});
|
||||||
|
@ -276,7 +276,7 @@ describe("jasmine.Matchers", function() {
|
||||||
it("toBeTruthy", function() {
|
it("toBeTruthy", function() {
|
||||||
expect(match(false).toBeTruthy()).toEqual(false);
|
expect(match(false).toBeTruthy()).toEqual(false);
|
||||||
expect(match(true).toBeTruthy()).toEqual(true);
|
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(0).toBeTruthy()).toEqual(false);
|
||||||
expect(match("").toBeTruthy()).toEqual(false);
|
expect(match("").toBeTruthy()).toEqual(false);
|
||||||
expect(match("hi").toBeTruthy()).toEqual(true);
|
expect(match("hi").toBeTruthy()).toEqual(true);
|
||||||
|
@ -297,11 +297,11 @@ describe("jasmine.Matchers", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("toEqual", 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:'bar'}).toEqual({foo:'bar'})).toEqual(true);
|
||||||
expect(match("foo").toEqual({bar: undefined})).toEqual(false);
|
expect(match("foo").toEqual({bar: jasmine.undefined})).toEqual(false);
|
||||||
expect(match({foo: undefined}).toEqual("goo")).toEqual(false);
|
expect(match({foo: jasmine.undefined}).toEqual("goo")).toEqual(false);
|
||||||
expect(match({foo: {bar :undefined}}).toEqual("goo")).toEqual(false);
|
expect(match({foo: {bar :jasmine.undefined}}).toEqual("goo")).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("toEqual with jasmine.any()", function() {
|
it("toEqual with jasmine.any()", function() {
|
||||||
|
@ -321,7 +321,7 @@ describe("jasmine.Matchers", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("toEqual handles circular objects ok", 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']}).toEqual({foo:['bar','baz','quux']})).toEqual(true);
|
||||||
expect(match({foo: {bar:'baz'}, quux:'corge'}).toEqual({foo:{bar:'baz'}, quux:'corge'})).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.');
|
}).toThrow('Expected a spy, but got Function.');
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
match(undefined)[methodName]();
|
match(jasmine.undefined)[methodName]();
|
||||||
}).toThrow('Expected a spy, but got undefined.');
|
}).toThrow('Expected a spy, but got undefined.');
|
||||||
|
|
||||||
expect(function() {
|
expect(function() {
|
||||||
|
|
|
@ -8,14 +8,14 @@ describe("jasmine.pp", function () {
|
||||||
expect(jasmine.pp(true)).toEqual("true");
|
expect(jasmine.pp(true)).toEqual("true");
|
||||||
expect(jasmine.pp(false)).toEqual("false");
|
expect(jasmine.pp(false)).toEqual("false");
|
||||||
expect(jasmine.pp(null)).toEqual("null");
|
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)).toEqual("3");
|
||||||
expect(jasmine.pp(-3.14)).toEqual("-3.14");
|
expect(jasmine.pp(-3.14)).toEqual("-3.14");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should stringify arrays properly", function() {
|
it("should stringify arrays properly", function() {
|
||||||
expect(jasmine.pp([1, 2])).toEqual("[ 1, 2 ]");
|
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() {
|
it("should indicate circular array references", function() {
|
||||||
|
@ -27,7 +27,7 @@ describe("jasmine.pp", function () {
|
||||||
|
|
||||||
it("should stringify objects properly", function() {
|
it("should stringify objects properly", function() {
|
||||||
expect(jasmine.pp({foo: 'bar'})).toEqual("{ foo : 'bar' }");
|
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 () {
|
expect(jasmine.pp({foo: function () {
|
||||||
}, bar: [1, 2, 3]})).toEqual("{ foo : Function, bar : [ 1, 2, 3 ] }");
|
}, 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(spec1Matcher.matcherForSpec("expected")).toEqual("matcherForSpec: actual: xxx; expected: expected");
|
||||||
|
|
||||||
expect(spec2Matcher.matcherForSuite("expected")).toEqual("matcherForSuite: actual: yyy; 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;
|
b.__Jasmine_been_here_before__ = a;
|
||||||
|
|
||||||
var hasKey = function(obj, keyName) {
|
var hasKey = function(obj, keyName) {
|
||||||
return obj != null && obj[keyName] !== undefined;
|
return obj != null && obj[keyName] !== jasmine.undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
for (var property in b) {
|
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 === b) return true;
|
||||||
|
|
||||||
if (a === undefined || a === null || b === undefined || b === null) {
|
if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) {
|
||||||
return (a == undefined && b == undefined);
|
return (a == jasmine.undefined && b == jasmine.undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) {
|
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++) {
|
for (var i = 0; i < this.equalityTesters_.length; i++) {
|
||||||
var equalityTester = this.equalityTesters_[i];
|
var equalityTester = this.equalityTesters_[i];
|
||||||
var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
|
var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
|
||||||
if (result !== undefined) return result;
|
if (result !== jasmine.undefined) return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Straight check
|
//Straight check
|
||||||
|
|
|
@ -88,7 +88,7 @@ jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
|
||||||
type: resultMessage.type,
|
type: resultMessage.type,
|
||||||
message: resultMessage.message,
|
message: resultMessage.message,
|
||||||
trace: {
|
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() {
|
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() {
|
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 result = false;
|
||||||
var exception = getException_(this.actual, expected);
|
var exception = getException_(this.actual, expected);
|
||||||
if (exception) {
|
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) {
|
this.message = function(expected) {
|
||||||
var exception = getException_(this.actual, 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(' ');
|
return ["Expected function to throw", expected.message || expected, ", but it threw", exception.message || exception ].join(' ');
|
||||||
} else {
|
} else {
|
||||||
return "Expected function to throw an exception.";
|
return "Expected function to throw an exception.";
|
||||||
|
|
|
@ -17,7 +17,7 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
|
||||||
|
|
||||||
this.ppNestLevel_++;
|
this.ppNestLevel_++;
|
||||||
try {
|
try {
|
||||||
if (value === undefined) {
|
if (value === jasmine.undefined) {
|
||||||
this.emitScalar('undefined');
|
this.emitScalar('undefined');
|
||||||
} else if (value === null) {
|
} else if (value === null) {
|
||||||
this.emitScalar('null');
|
this.emitScalar('null');
|
||||||
|
|
|
@ -171,11 +171,11 @@ jasmine.Spec.prototype.explodes = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) {
|
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 + "()";
|
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';
|
throw methodName + '() method does not exist';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,14 @@ jasmine.unimplementedMethod_ = function() {
|
||||||
throw new Error("unimplemented method");
|
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.
|
* 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.clearTimeout = function(timeoutKey) {
|
||||||
self.scheduledFunctions[timeoutKey] = undefined;
|
self.scheduledFunctions[timeoutKey] = jasmine.undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
self.clearInterval = function(timeoutKey) {
|
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 = [];
|
var funcsToRun = [];
|
||||||
for (var timeoutKey in this.scheduledFunctions) {
|
for (var timeoutKey in this.scheduledFunctions) {
|
||||||
scheduledFunc = this.scheduledFunctions[timeoutKey];
|
scheduledFunc = this.scheduledFunctions[timeoutKey];
|
||||||
if (scheduledFunc != undefined &&
|
if (scheduledFunc != jasmine.undefined &&
|
||||||
scheduledFunc.runAtMillis >= oldMillis &&
|
scheduledFunc.runAtMillis >= oldMillis &&
|
||||||
scheduledFunc.runAtMillis <= nowMillis) {
|
scheduledFunc.runAtMillis <= nowMillis) {
|
||||||
funcsToRun.push(scheduledFunc);
|
funcsToRun.push(scheduledFunc);
|
||||||
this.scheduledFunctions[timeoutKey] = undefined;
|
this.scheduledFunctions[timeoutKey] = jasmine.undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue