jshint passes - run 'node jshint/run.js'. running jshint with a couple jshint options and workarounds to allow certain jasmine-specific styles. many actual style problems are fixed. the jshint run is integrated into rake jasmine:lint.
This commit is contained in:
parent
9f90c4eca5
commit
f41af6c2d0
4
Rakefile
4
Rakefile
@ -44,7 +44,7 @@ namespace :jasmine do
|
|||||||
passed = false
|
passed = false
|
||||||
end
|
end
|
||||||
|
|
||||||
if line.scan(/window/).length > 0
|
if line.scan(/window/).length > 0 && !line.include?("typeof")
|
||||||
puts "Dangerous window at #{src}:#{i}:\n > #{line}"
|
puts "Dangerous window at #{src}:#{i}:\n > #{line}"
|
||||||
passed = false
|
passed = false
|
||||||
end
|
end
|
||||||
@ -55,6 +55,8 @@ namespace :jasmine do
|
|||||||
puts "Lint failed!"
|
puts "Lint failed!"
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
system("node jshint/run.js") || exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Builds lib/jasmine from source'
|
desc 'Builds lib/jasmine from source'
|
||||||
|
@ -2,8 +2,8 @@ beforeEach(function() {
|
|||||||
this.addMatchers({
|
this.addMatchers({
|
||||||
toBePlaying: function(expectedSong) {
|
toBePlaying: function(expectedSong) {
|
||||||
var player = this.actual;
|
var player = this.actual;
|
||||||
return player.currentlyPlayingSong === expectedSong
|
return player.currentlyPlayingSong === expectedSong &&
|
||||||
&& player.isPlaying;
|
player.isPlaying;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
@ -221,7 +221,7 @@
|
|||||||
lightseagreen, lightskyblue, lightslategray, lightsteelblue,
|
lightseagreen, lightskyblue, lightslategray, lightsteelblue,
|
||||||
lightyellow, lime, limegreen, line, "line-height", linen, link,
|
lightyellow, lime, limegreen, line, "line-height", linen, link,
|
||||||
"list-style", "list-style-image", "list-style-position",
|
"list-style", "list-style-image", "list-style-position",
|
||||||
"list-style-type", load, loadClass, localStorage, location, log, m, magenta,
|
"list-style-type", load, loadClass, localStorage, location, log, loopfunc, m, magenta,
|
||||||
map, margin, "margin-bottom", "margin-left", "margin-right", "margin-top",
|
map, margin, "margin-bottom", "margin-left", "margin-right", "margin-top",
|
||||||
mark, "marker-offset", maroon, match, "max-height", "max-width", maxerr,
|
mark, "marker-offset", maroon, match, "max-height", "max-width", maxerr,
|
||||||
maxlen, md5, mediumaquamarine, mediumblue, mediumorchid, mediumpurple,
|
maxlen, md5, mediumaquamarine, mediumblue, mediumorchid, mediumpurple,
|
||||||
@ -314,9 +314,9 @@ var JSHINT = (function () {
|
|||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
// These are the JSHint options.
|
// These are the JSHint boolean options.
|
||||||
|
|
||||||
options = {
|
boolOptions = {
|
||||||
adsafe : true, // if ADsafe should be enforced
|
adsafe : true, // if ADsafe should be enforced
|
||||||
asi : true, // if automatic semicolon insertion should be tolerated
|
asi : true, // if automatic semicolon insertion should be tolerated
|
||||||
bitwise : true, // if bitwise operators should not be allowed
|
bitwise : true, // if bitwise operators should not be allowed
|
||||||
@ -336,6 +336,7 @@ var JSHINT = (function () {
|
|||||||
immed : true, // if immediate invocations must be wrapped in parens
|
immed : true, // if immediate invocations must be wrapped in parens
|
||||||
jquery : true, // if jQuery globals should be predefined
|
jquery : true, // if jQuery globals should be predefined
|
||||||
laxbreak : true, // if line breaks should not be checked
|
laxbreak : true, // if line breaks should not be checked
|
||||||
|
loopfunc : true, // if functions should be allowed to be defined within loops
|
||||||
newcap : true, // if constructor names must be capitalized
|
newcap : true, // if constructor names must be capitalized
|
||||||
noarg : true, // if arguments.caller and arguments.callee should be disallowed
|
noarg : true, // if arguments.caller and arguments.callee should be disallowed
|
||||||
node : true, // if the Node.js environment globals should be predefined
|
node : true, // if the Node.js environment globals should be predefined
|
||||||
@ -2017,7 +2018,7 @@ klass: do {
|
|||||||
warning("ADsafe restriction.");
|
warning("ADsafe restriction.");
|
||||||
}
|
}
|
||||||
obj = option;
|
obj = option;
|
||||||
filter = options;
|
filter = boolOptions;
|
||||||
break;
|
break;
|
||||||
case '/*global':
|
case '/*global':
|
||||||
if (option.safe) {
|
if (option.safe) {
|
||||||
@ -4896,7 +4897,7 @@ loop: for (;;) {
|
|||||||
t = nexttoken;
|
t = nexttoken;
|
||||||
adjacent(token, nexttoken);
|
adjacent(token, nexttoken);
|
||||||
f = doFunction(i);
|
f = doFunction(i);
|
||||||
if (funct['(loopage)']) {
|
if (!option.loopfunc && funct['(loopage)']) {
|
||||||
warning("Don't make functions within a loop.", t);
|
warning("Don't make functions within a loop.", t);
|
||||||
}
|
}
|
||||||
p = f['(params)'];
|
p = f['(params)'];
|
||||||
@ -5032,7 +5033,7 @@ loop: for (;;) {
|
|||||||
nonadjacent(token, nexttoken);
|
nonadjacent(token, nexttoken);
|
||||||
}
|
}
|
||||||
doFunction(i);
|
doFunction(i);
|
||||||
if (funct['(loopage)']) {
|
if (!option.loopfunc && funct['(loopage)']) {
|
||||||
warning("Don't make functions within a loop.");
|
warning("Don't make functions within a loop.");
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
@ -5529,11 +5530,10 @@ loop: for (;;) {
|
|||||||
|
|
||||||
// The actual JSHINT function itself.
|
// The actual JSHINT function itself.
|
||||||
|
|
||||||
var itself = function (s, o, g) {
|
var itself = function (s, o) {
|
||||||
var a, i, k;
|
var a, i, k;
|
||||||
JSHINT.errors = [];
|
JSHINT.errors = [];
|
||||||
predefined = Object.create(standard);
|
predefined = Object.create(standard);
|
||||||
combine(predefined, g || {});
|
|
||||||
if (o) {
|
if (o) {
|
||||||
a = o.predef;
|
a = o.predef;
|
||||||
if (a) {
|
if (a) {
|
||||||
@ -5552,22 +5552,23 @@ loop: for (;;) {
|
|||||||
o.safe = true;
|
o.safe = true;
|
||||||
}
|
}
|
||||||
if (o.safe) {
|
if (o.safe) {
|
||||||
o.browser =
|
o.browser =
|
||||||
o.css =
|
o.css =
|
||||||
o.debug =
|
o.debug =
|
||||||
o.devel =
|
o.devel =
|
||||||
o.evil =
|
o.evil =
|
||||||
o.forin =
|
o.forin =
|
||||||
o.on =
|
o.loopfunc =
|
||||||
o.rhino =
|
o.on =
|
||||||
o.windows =
|
o.rhino =
|
||||||
o.sub =
|
o.windows =
|
||||||
o.widget = false;
|
o.sub =
|
||||||
|
o.widget = false;
|
||||||
|
|
||||||
o.eqeqeq =
|
o.eqeqeq =
|
||||||
o.nomen =
|
o.nomen =
|
||||||
o.safe =
|
o.safe =
|
||||||
o.undef = true;
|
o.undef = true;
|
||||||
|
|
||||||
predefined.Date =
|
predefined.Date =
|
||||||
predefined['eval'] =
|
predefined['eval'] =
|
||||||
|
@ -1,42 +1,70 @@
|
|||||||
var fs = require("fs")
|
var fs = require("fs");
|
||||||
var sys = require("sys")
|
var sys = require("sys");
|
||||||
var path = require("path")
|
var path = require("path");
|
||||||
var JSHINT = require("./jshint").JSHINT;
|
var JSHINT = require("./jshint").JSHINT;
|
||||||
|
|
||||||
function isVendorFile(fullPath) {
|
function isExcluded(fullPath) {
|
||||||
var fileName = path.basename(fullPath)
|
var fileName = path.basename(fullPath);
|
||||||
var vendorFiles = ["json2.js", "jshint.js", "publish.js"]
|
var excludeFiles = ["json2.js", "jshint.js", "publish.js", "node_suite.js", "jasmine.js", "jasmine-html.js"];
|
||||||
for (var i=0; i<vendorFiles.length; i++) if (fileName==vendorFiles[i]) return true
|
for (var i=0; i<excludeFiles.length; i++) if (fileName==excludeFiles[i]) return true;
|
||||||
return false
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function allJasmineJsFiles(rootDir) {
|
function allJasmineJsFiles(rootDir) {
|
||||||
var files = []
|
var files = [];
|
||||||
var things = fs.readdirSync(rootDir)
|
var things = fs.readdirSync(rootDir);
|
||||||
for (var i=0; i<things.length; i++) {
|
for (var i=0; i<things.length; i++) {
|
||||||
var thing = things[i]
|
var thing = things[i];
|
||||||
var fullPath = rootDir + "/" + thing
|
var fullPath = rootDir + "/" + thing;
|
||||||
if (fs.statSync(fullPath).isDirectory()) {
|
if (fs.statSync(fullPath).isDirectory()) {
|
||||||
files = files.concat(allJasmineJsFiles(fullPath))
|
files = files.concat(allJasmineJsFiles(fullPath));
|
||||||
} else {
|
} else {
|
||||||
if (fullPath.match(/\.js$/) && !isVendorFile(fullPath)) files.push(fullPath)
|
if (fullPath.match(/\.js$/) && !isExcluded(fullPath)) files.push(fullPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return files
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
var jasmineJsFiles = allJasmineJsFiles(".")
|
var jasmineJsFiles = allJasmineJsFiles(".");
|
||||||
|
jasmineJsFiles.reverse(); //cheap way to do the stuff in src stuff first
|
||||||
|
|
||||||
var jasmineJsHintConfig = {}
|
var jasmineJsHintConfig = {
|
||||||
var jasmineGlobals = {}
|
|
||||||
|
|
||||||
|
forin:true, //while it's possible that we could be
|
||||||
|
//considering unwanted prototype methods, mostly
|
||||||
|
//we're doing this because the jsobjects are being
|
||||||
|
//used as maps.
|
||||||
|
|
||||||
|
loopfunc:true //we're fine with functions defined inside loops (setTimeout functions, etc)
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
var jasmineGlobals = {};
|
||||||
|
|
||||||
|
|
||||||
|
//jasmine.undefined is a jasmine-ism, let's let it go...
|
||||||
|
function removeJasmineUndefinedErrors(errors) {
|
||||||
|
var keepErrors = [];
|
||||||
|
for(var i=0; i<errors.length; i++) {
|
||||||
|
if (!(errors[i] &&
|
||||||
|
errors[i].raw &&
|
||||||
|
errors[i].evidence &&
|
||||||
|
( errors[i].evidence.match(/jasmine\.undefined/) ||
|
||||||
|
errors[i].evidence.match(/diz be undefined yo/) )
|
||||||
|
)) keepErrors.push(errors[i]);
|
||||||
|
}
|
||||||
|
return keepErrors;
|
||||||
|
}
|
||||||
|
|
||||||
for(var i=0; i<jasmineJsFiles.length; i++) {
|
for(var i=0; i<jasmineJsFiles.length; i++) {
|
||||||
var file = jasmineJsFiles[i]
|
var file = jasmineJsFiles[i];
|
||||||
var result = JSHINT(fs.readFileSync(file, "utf8"))
|
JSHINT(fs.readFileSync(file, "utf8"), jasmineJsHintConfig);
|
||||||
if (!result) {
|
var errors = JSHINT.data().errors || [];
|
||||||
console.log("JSHINT failure: ", file)
|
errors = removeJasmineUndefinedErrors(errors);
|
||||||
console.log(JSHINT.data().errors)
|
|
||||||
process.exit(1)
|
if (errors.length>=1) {
|
||||||
|
console.log("JSHINT failure: ", file);
|
||||||
|
console.log(errors);
|
||||||
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -110,7 +110,7 @@ jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
|||||||
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
||||||
var results = suite.results();
|
var results = suite.results();
|
||||||
var status = results.passed() ? 'passed' : 'failed';
|
var status = results.passed() ? 'passed' : 'failed';
|
||||||
if (results.totalCount == 0) { // todo: change this to check results.skipped
|
if (results.totalCount === 0) { // todo: change this to check results.skipped
|
||||||
status = 'skipped';
|
status = 'skipped';
|
||||||
}
|
}
|
||||||
this.suiteDivs[suite.id].className += " " + status;
|
this.suiteDivs[suite.id].className += " " + status;
|
||||||
@ -183,6 +183,6 @@ jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
|||||||
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!paramMap["spec"]) return true;
|
if (!paramMap.spec) return true;
|
||||||
return spec.getFullName().indexOf(paramMap["spec"]) == 0;
|
return spec.getFullName().indexOf(paramMap.spec) === 0;
|
||||||
};
|
};
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
|
var isCommonJS = typeof window == "undefined";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.
|
* Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.
|
||||||
*
|
*
|
||||||
* @namespace
|
* @namespace
|
||||||
*/
|
*/
|
||||||
var jasmine = {};
|
var jasmine = {};
|
||||||
|
if (isCommonJS) exports.jasmine = jasmine;
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
@ -106,7 +108,8 @@ jasmine.ExpectationResult.prototype.passed = function () {
|
|||||||
* Getter for the Jasmine environment. Ensures one gets created
|
* Getter for the Jasmine environment. Ensures one gets created
|
||||||
*/
|
*/
|
||||||
jasmine.getEnv = function() {
|
jasmine.getEnv = function() {
|
||||||
return jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env();
|
var env = jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env();
|
||||||
|
return env;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -169,7 +172,7 @@ jasmine.pp = function(value) {
|
|||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
jasmine.isDomNode = function(obj) {
|
jasmine.isDomNode = function(obj) {
|
||||||
return obj['nodeType'] > 0;
|
return obj.nodeType > 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -405,7 +408,7 @@ jasmine.isSpy = function(putativeSpy) {
|
|||||||
* @param {Array} methodNames array of names of methods to make spies
|
* @param {Array} methodNames array of names of methods to make spies
|
||||||
*/
|
*/
|
||||||
jasmine.createSpyObj = function(baseName, methodNames) {
|
jasmine.createSpyObj = function(baseName, methodNames) {
|
||||||
if (!jasmine.isArray_(methodNames) || methodNames.length == 0) {
|
if (!jasmine.isArray_(methodNames) || methodNames.length === 0) {
|
||||||
throw new Error('createSpyObj requires a non-empty array of method names to create spies for');
|
throw new Error('createSpyObj requires a non-empty array of method names to create spies for');
|
||||||
}
|
}
|
||||||
var obj = {};
|
var obj = {};
|
||||||
@ -443,6 +446,7 @@ jasmine.log = function() {
|
|||||||
var spyOn = function(obj, methodName) {
|
var spyOn = function(obj, methodName) {
|
||||||
return jasmine.getEnv().currentSpec.spyOn(obj, methodName);
|
return jasmine.getEnv().currentSpec.spyOn(obj, methodName);
|
||||||
};
|
};
|
||||||
|
if (isCommonJS) exports.spyOn = spyOn;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a Jasmine spec that will be added to the current suite.
|
* Creates a Jasmine spec that will be added to the current suite.
|
||||||
@ -460,6 +464,7 @@ var spyOn = function(obj, methodName) {
|
|||||||
var it = function(desc, func) {
|
var it = function(desc, func) {
|
||||||
return jasmine.getEnv().it(desc, func);
|
return jasmine.getEnv().it(desc, func);
|
||||||
};
|
};
|
||||||
|
if (isCommonJS) exports.it = it;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a <em>disabled</em> Jasmine spec.
|
* Creates a <em>disabled</em> Jasmine spec.
|
||||||
@ -472,6 +477,7 @@ var it = function(desc, func) {
|
|||||||
var xit = function(desc, func) {
|
var xit = function(desc, func) {
|
||||||
return jasmine.getEnv().xit(desc, func);
|
return jasmine.getEnv().xit(desc, func);
|
||||||
};
|
};
|
||||||
|
if (isCommonJS) exports.xit = xit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts a chain for a Jasmine expectation.
|
* Starts a chain for a Jasmine expectation.
|
||||||
@ -484,6 +490,7 @@ var xit = function(desc, func) {
|
|||||||
var expect = function(actual) {
|
var expect = function(actual) {
|
||||||
return jasmine.getEnv().currentSpec.expect(actual);
|
return jasmine.getEnv().currentSpec.expect(actual);
|
||||||
};
|
};
|
||||||
|
if (isCommonJS) exports.expect = expect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs.
|
* Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs.
|
||||||
@ -493,6 +500,7 @@ var expect = function(actual) {
|
|||||||
var runs = function(func) {
|
var runs = function(func) {
|
||||||
jasmine.getEnv().currentSpec.runs(func);
|
jasmine.getEnv().currentSpec.runs(func);
|
||||||
};
|
};
|
||||||
|
if (isCommonJS) exports.runs = runs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Waits a fixed time period before moving to the next block.
|
* Waits a fixed time period before moving to the next block.
|
||||||
@ -503,6 +511,7 @@ var runs = function(func) {
|
|||||||
var waits = function(timeout) {
|
var waits = function(timeout) {
|
||||||
jasmine.getEnv().currentSpec.waits(timeout);
|
jasmine.getEnv().currentSpec.waits(timeout);
|
||||||
};
|
};
|
||||||
|
if (isCommonJS) exports.waits = waits;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Waits for the latchFunction to return true before proceeding to the next block.
|
* Waits for the latchFunction to return true before proceeding to the next block.
|
||||||
@ -514,6 +523,7 @@ var waits = function(timeout) {
|
|||||||
var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {
|
var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {
|
||||||
jasmine.getEnv().currentSpec.waitsFor.apply(jasmine.getEnv().currentSpec, arguments);
|
jasmine.getEnv().currentSpec.waitsFor.apply(jasmine.getEnv().currentSpec, arguments);
|
||||||
};
|
};
|
||||||
|
if (isCommonJS) exports.waitsFor = waitsFor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A function that is called before each spec in a suite.
|
* A function that is called before each spec in a suite.
|
||||||
@ -525,6 +535,7 @@ var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout
|
|||||||
var beforeEach = function(beforeEachFunction) {
|
var beforeEach = function(beforeEachFunction) {
|
||||||
jasmine.getEnv().beforeEach(beforeEachFunction);
|
jasmine.getEnv().beforeEach(beforeEachFunction);
|
||||||
};
|
};
|
||||||
|
if (isCommonJS) exports.beforeEach = beforeEach;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A function that is called after each spec in a suite.
|
* A function that is called after each spec in a suite.
|
||||||
@ -536,6 +547,7 @@ var beforeEach = function(beforeEachFunction) {
|
|||||||
var afterEach = function(afterEachFunction) {
|
var afterEach = function(afterEachFunction) {
|
||||||
jasmine.getEnv().afterEach(afterEachFunction);
|
jasmine.getEnv().afterEach(afterEachFunction);
|
||||||
};
|
};
|
||||||
|
if (isCommonJS) exports.afterEach = afterEach;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a suite of specifications.
|
* Defines a suite of specifications.
|
||||||
@ -555,6 +567,7 @@ var afterEach = function(afterEachFunction) {
|
|||||||
var describe = function(description, specDefinitions) {
|
var describe = function(description, specDefinitions) {
|
||||||
return jasmine.getEnv().describe(description, specDefinitions);
|
return jasmine.getEnv().describe(description, specDefinitions);
|
||||||
};
|
};
|
||||||
|
if (isCommonJS) exports.describe = describe;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development.
|
* Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development.
|
||||||
@ -565,27 +578,27 @@ var describe = function(description, specDefinitions) {
|
|||||||
var xdescribe = function(description, specDefinitions) {
|
var xdescribe = function(description, specDefinitions) {
|
||||||
return jasmine.getEnv().xdescribe(description, specDefinitions);
|
return jasmine.getEnv().xdescribe(description, specDefinitions);
|
||||||
};
|
};
|
||||||
|
if (isCommonJS) exports.xdescribe = xdescribe;
|
||||||
|
|
||||||
|
|
||||||
// Provide the XMLHttpRequest class for IE 5.x-6.x:
|
// Provide the XMLHttpRequest class for IE 5.x-6.x:
|
||||||
jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
|
jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
|
||||||
try {
|
function tryIt(f) {
|
||||||
return new ActiveXObject("Msxml2.XMLHTTP.6.0");
|
try {
|
||||||
} catch(e) {
|
return f();
|
||||||
|
} catch(e) {
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
return new ActiveXObject("Msxml2.XMLHTTP.3.0");
|
var xhr = tryIt(function(){return new ActiveXObject("Msxml2.XMLHTTP.6.0");}) ||
|
||||||
} catch(e) {
|
tryIt(function(){return new ActiveXObject("Msxml2.XMLHTTP.3.0");}) ||
|
||||||
}
|
tryIt(function(){return new ActiveXObject("Msxml2.XMLHTTP");}) ||
|
||||||
try {
|
tryIt(function(){return new ActiveXObject("Microsoft.XMLHTTP");});
|
||||||
return new ActiveXObject("Msxml2.XMLHTTP");
|
|
||||||
} catch(e) {
|
if (!xhr) throw new Error("This browser does not support XMLHttpRequest.");
|
||||||
}
|
|
||||||
try {
|
return xhr;
|
||||||
return new ActiveXObject("Microsoft.XMLHTTP");
|
|
||||||
} catch(e) {
|
|
||||||
}
|
|
||||||
throw new Error("This browser does not support XMLHttpRequest.");
|
|
||||||
} : XMLHttpRequest;
|
} : XMLHttpRequest;
|
||||||
/**
|
/**
|
||||||
* @namespace
|
* @namespace
|
||||||
@ -606,7 +619,7 @@ jasmine.util.inherit = function(childClass, parentClass) {
|
|||||||
var subclass = function() {
|
var subclass = function() {
|
||||||
};
|
};
|
||||||
subclass.prototype = parentClass.prototype;
|
subclass.prototype = parentClass.prototype;
|
||||||
childClass.prototype = new subclass;
|
childClass.prototype = new subclass();
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.util.formatException = function(e) {
|
jasmine.util.formatException = function(e) {
|
||||||
@ -828,7 +841,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] !== jasmine.undefined;
|
return obj !== null && obj[keyName] !== jasmine.undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
for (var property in b) {
|
for (var property in b) {
|
||||||
@ -854,7 +867,7 @@ jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchVal
|
|||||||
|
|
||||||
delete a.__Jasmine_been_here_before__;
|
delete a.__Jasmine_been_here_before__;
|
||||||
delete b.__Jasmine_been_here_before__;
|
delete b.__Jasmine_been_here_before__;
|
||||||
return (mismatchKeys.length == 0 && mismatchValues.length == 0);
|
return (mismatchKeys.length === 0 && mismatchValues.length === 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
|
jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
|
||||||
@ -1302,7 +1315,7 @@ jasmine.Matchers.prototype.toHaveBeenCalledWith = function() {
|
|||||||
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
|
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
|
||||||
}
|
}
|
||||||
this.message = function() {
|
this.message = function() {
|
||||||
if (this.actual.callCount == 0) {
|
if (this.actual.callCount === 0) {
|
||||||
// todo: what should the failure message for .not.toHaveBeenCalledWith() be? is this right? test better. [xw]
|
// todo: what should the failure message for .not.toHaveBeenCalledWith() be? is this right? test better. [xw]
|
||||||
return [
|
return [
|
||||||
"Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.",
|
"Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.",
|
||||||
@ -1333,7 +1346,7 @@ jasmine.Matchers.prototype.wasNotCalledWith = function() {
|
|||||||
return [
|
return [
|
||||||
"Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was",
|
"Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was",
|
||||||
"Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was"
|
"Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was"
|
||||||
]
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
return !this.env.contains_(this.actual.argsForCall, expectedArgs);
|
return !this.env.contains_(this.actual.argsForCall, expectedArgs);
|
||||||
@ -1390,7 +1403,7 @@ jasmine.Matchers.prototype.toThrow = function(expected) {
|
|||||||
|
|
||||||
this.message = function() {
|
this.message = function() {
|
||||||
if (exception && (expected === jasmine.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 " + not + "to throw", expected ? expected.message || expected : " an exception", ", but it threw", exception.message || exception].join(' ');
|
return ["Expected function " + not + "to throw", expected ? expected.message || expected : "an exception", ", but it threw", exception.message || exception].join(' ');
|
||||||
} else {
|
} else {
|
||||||
return "Expected function to throw an exception.";
|
return "Expected function to throw an exception.";
|
||||||
}
|
}
|
||||||
@ -1602,7 +1615,8 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
|
|||||||
jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
|
jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
|
||||||
for (var property in obj) {
|
for (var property in obj) {
|
||||||
if (property == '__Jasmine_been_here_before__') continue;
|
if (property == '__Jasmine_been_here_before__') continue;
|
||||||
fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) != null) : false);
|
fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined &&
|
||||||
|
obj.__lookupGetter__(property) !== null) : false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2417,5 +2431,5 @@ jasmine.version_= {
|
|||||||
"major": 1,
|
"major": 1,
|
||||||
"minor": 0,
|
"minor": 0,
|
||||||
"build": 1,
|
"build": 1,
|
||||||
"revision": 1286311016
|
"revision": 1298761339
|
||||||
};
|
};
|
||||||
|
@ -3,10 +3,10 @@ var sys = require('sys');
|
|||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
|
||||||
// yes, really keep this here to keep us honest, but only for jasmine's own runner! [xw]
|
// yes, really keep this here to keep us honest, but only for jasmine's own runner! [xw]
|
||||||
undefined = "diz be undefined yo";
|
// undefined = "diz be undefined yo";
|
||||||
|
|
||||||
var jasmineGlobals = require("../src/base");
|
var jasmineGlobals = require("../src/base");
|
||||||
for(var k in jasmineGlobals) {global[k] = jasmineGlobals[k]};
|
for(var k in jasmineGlobals) {global[k] = jasmineGlobals[k];}
|
||||||
|
|
||||||
//load jasmine src files based on the order in runner.html
|
//load jasmine src files based on the order in runner.html
|
||||||
var srcFilesInProperRequireOrder = [];
|
var srcFilesInProperRequireOrder = [];
|
||||||
@ -15,7 +15,7 @@ var srcFileLines = [];
|
|||||||
for (var i=0; i<runnerHtmlLines.length; i++)
|
for (var i=0; i<runnerHtmlLines.length; i++)
|
||||||
if (runnerHtmlLines[i].match(/script(.*?)\/src\//))
|
if (runnerHtmlLines[i].match(/script(.*?)\/src\//))
|
||||||
srcFileLines.push(runnerHtmlLines[i]);
|
srcFileLines.push(runnerHtmlLines[i]);
|
||||||
for (i=0; i<srcFileLines.length; i++) srcFilesInProperRequireOrder.push(/src=\"(.*?)\"/(srcFileLines[i])[1]);
|
for (i=0; i<srcFileLines.length; i++) srcFilesInProperRequireOrder.push(srcFileLines[i].match(/src=\"(.*?)\"/)[1]);
|
||||||
for (i=0; i<srcFilesInProperRequireOrder.length; i++) require(srcFilesInProperRequireOrder[i]);
|
for (i=0; i<srcFilesInProperRequireOrder.length; i++) require(srcFilesInProperRequireOrder[i]);
|
||||||
|
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ jasmine.executeSpecs = function(specs, done, isVerbose, showColors){
|
|||||||
|
|
||||||
reportRunnerStarting: function(runner) {
|
reportRunnerStarting: function(runner) {
|
||||||
sys.puts('Started');
|
sys.puts('Started');
|
||||||
start = Number(new Date);
|
start = new Date().getTime();
|
||||||
},
|
},
|
||||||
|
|
||||||
reportSuiteResults: function(suite) {
|
reportSuiteResults: function(suite) {
|
||||||
@ -112,7 +112,7 @@ jasmine.executeSpecs = function(specs, done, isVerbose, showColors){
|
|||||||
|
|
||||||
|
|
||||||
reportRunnerResults: function(runner) {
|
reportRunnerResults: function(runner) {
|
||||||
elapsed = (Number(new Date) - start) / 1000;
|
elapsed = (new Date().getTime() - start) / 1000;
|
||||||
sys.puts('\n');
|
sys.puts('\n');
|
||||||
log.forEach(function(log){
|
log.forEach(function(log){
|
||||||
sys.puts(log);
|
sys.puts(log);
|
||||||
@ -216,16 +216,16 @@ process.argv.forEach(function(arg){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var specs = jasmine.getAllSpecFiles(__dirname + '/suites', new RegExp("^.+\.(js|coffee)$"));
|
var specs = jasmine.getAllSpecFiles(__dirname + '/suites', new RegExp(".js$"));
|
||||||
var domIndependentSpecs = [];
|
var domIndependentSpecs = [];
|
||||||
for(var i=0; i<specs.length; i++) {
|
for(var i=0; i<specs.length; i++) {
|
||||||
if (fs.readFileSync(specs[i], "utf8").indexOf("document.createElement")<0) {
|
if (fs.readFileSync(specs[i], "utf8").indexOf("document.createElement")<0) {
|
||||||
domIndependentSpecs.push(specs[i]);
|
domIndependentSpecs.push(specs[i]);
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
jasmine.executeSpecs(domIndependentSpecs, function(runner, log){
|
jasmine.executeSpecs(domIndependentSpecs, function(runner, log){
|
||||||
if (runner.results().failedCount == 0) {
|
if (runner.results().failedCount === 0) {
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
} else {
|
} else {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
@ -108,7 +108,7 @@ describe("jasmine.Env", function() {
|
|||||||
|
|
||||||
it("should give custom equality testers precedence", function() {
|
it("should give custom equality testers precedence", function() {
|
||||||
expect(env.equals_('abc', 'abc')).toBeFalsy();
|
expect(env.equals_('abc', 'abc')).toBeFalsy();
|
||||||
var o = new Object();
|
var o = {};
|
||||||
expect(env.equals_(o, o)).toBeFalsy();
|
expect(env.equals_(o, o)).toBeFalsy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -89,9 +89,9 @@ describe('Exceptions:', function() {
|
|||||||
expect(blockResults[0].message).toMatch(/fake error 1/);
|
expect(blockResults[0].message).toMatch(/fake error 1/);
|
||||||
|
|
||||||
expect(specResults[1].passed()).toEqual(false);
|
expect(specResults[1].passed()).toEqual(false);
|
||||||
var blockResults = specResults[1].getItems();
|
blockResults = specResults[1].getItems();
|
||||||
expect(blockResults[0].passed()).toEqual(false);
|
expect(blockResults[0].passed()).toEqual(false);
|
||||||
expect(blockResults[0].message).toMatch(/fake error 2/),
|
expect(blockResults[0].message).toMatch(/fake error 2/);
|
||||||
expect(blockResults[1].passed()).toEqual(true);
|
expect(blockResults[1].passed()).toEqual(true);
|
||||||
|
|
||||||
expect(specResults[2].passed()).toEqual(true);
|
expect(specResults[2].passed()).toEqual(true);
|
||||||
|
@ -21,7 +21,7 @@ describe('jasmine.jsApiReporter', function() {
|
|||||||
nestedSuite = env.describe("nested suite", function() {
|
nestedSuite = env.describe("nested suite", function() {
|
||||||
nestedSpec = env.it("nested spec", function() {
|
nestedSpec = env.it("nested spec", function() {
|
||||||
expect(true).toEqual(true);
|
expect(true).toEqual(true);
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
spec3 = env.it("spec 3", function() {
|
spec3 = env.it("spec 3", function() {
|
||||||
|
@ -18,7 +18,7 @@ describe("jasmine.Matchers", function() {
|
|||||||
toFail: function() {
|
toFail: function() {
|
||||||
return !lastResult().passed();
|
return !lastResult().passed();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function match(value) {
|
function match(value) {
|
||||||
@ -68,13 +68,13 @@ describe("jasmine.Matchers", function() {
|
|||||||
expect((match(['a', 'b']).toEqual(['a', jasmine.undefined]))).toFail();
|
expect((match(['a', 'b']).toEqual(['a', jasmine.undefined]))).toFail();
|
||||||
expect((match(['a', 'b']).toEqual(['a', 'b', jasmine.undefined]))).toFail();
|
expect((match(['a', 'b']).toEqual(['a', 'b', jasmine.undefined]))).toFail();
|
||||||
|
|
||||||
expect((match(new String("cat")).toEqual("cat"))).toPass();
|
expect((match("cat").toEqual("cat"))).toPass();
|
||||||
expect((match(new String("cat")).toNotEqual("cat"))).toFail();
|
expect((match("cat").toNotEqual("cat"))).toFail();
|
||||||
|
|
||||||
expect((match(new Number(5)).toEqual(5))).toPass();
|
expect((match(5).toEqual(5))).toPass();
|
||||||
expect((match(new Number('5')).toEqual(5))).toPass();
|
expect((match(parseInt('5', 10)).toEqual(5))).toPass();
|
||||||
expect((match(new Number(5)).toNotEqual(5))).toFail();
|
expect((match(5).toNotEqual(5))).toFail();
|
||||||
expect((match(new Number('5')).toNotEqual(5))).toFail();
|
expect((match(parseInt('5', 10)).toNotEqual(5))).toFail();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("toEqual with DOM nodes", function() {
|
it("toEqual with DOM nodes", function() {
|
||||||
@ -500,7 +500,7 @@ describe("jasmine.Matchers", function() {
|
|||||||
describe("and matcher is inverted with .not", function() {
|
describe("and matcher is inverted with .not", function() {
|
||||||
it("should match any exception", function() {
|
it("should match any exception", function() {
|
||||||
expect(match(throwingFn).not.toThrow()).toFail();
|
expect(match(throwingFn).not.toThrow()).toFail();
|
||||||
expect(lastResult().message).toMatch(/Expected function not to throw an exception/);
|
expect(lastResult().message).toMatch(/Expected function not to throw an exception/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should match exceptions specified by message", function() {
|
it("should match exceptions specified by message", function() {
|
||||||
|
@ -18,9 +18,9 @@ describe("jasmine.MultiReporter", function() {
|
|||||||
delegate[methodName] = jasmine.createSpy(methodName);
|
delegate[methodName] = jasmine.createSpy(methodName);
|
||||||
this.actual[methodName]("whatever argument");
|
this.actual[methodName]("whatever argument");
|
||||||
|
|
||||||
return delegate[methodName].wasCalled
|
return delegate[methodName].wasCalled &&
|
||||||
&& delegate[methodName].mostRecentCall.args.length == 1
|
delegate[methodName].mostRecentCall.args.length == 1 &&
|
||||||
&& delegate[methodName].mostRecentCall.args[0] == "whatever argument";
|
delegate[methodName].mostRecentCall.args[0] == "whatever argument";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ describe('Spec', function () {
|
|||||||
|
|
||||||
it('getFullName returns suite & spec description', function () {
|
it('getFullName returns suite & spec description', function () {
|
||||||
var spec = new jasmine.Spec(env, suite, 'spec 1');
|
var spec = new jasmine.Spec(env, suite, 'spec 1');
|
||||||
expect(spec.getFullName()).toEqual('suite 1 spec 1.')
|
expect(spec.getFullName()).toEqual('suite 1 spec 1.');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('results', function () {
|
describe('results', function () {
|
||||||
|
@ -25,7 +25,6 @@ describe("jasmine.util", function() {
|
|||||||
it("should return true if the argument is an array", function() {
|
it("should return true if the argument is an array", function() {
|
||||||
expect(jasmine.isArray_([])).toBe(true);
|
expect(jasmine.isArray_([])).toBe(true);
|
||||||
expect(jasmine.isArray_(['a'])).toBe(true);
|
expect(jasmine.isArray_(['a'])).toBe(true);
|
||||||
expect(jasmine.isArray_(new Array())).toBe(true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return false if the argument is not an array", function() {
|
it("should return false if the argument is not an array", function() {
|
||||||
|
@ -172,7 +172,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] !== jasmine.undefined;
|
return obj !== null && obj[keyName] !== jasmine.undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
for (var property in b) {
|
for (var property in b) {
|
||||||
@ -198,7 +198,7 @@ jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchVal
|
|||||||
|
|
||||||
delete a.__Jasmine_been_here_before__;
|
delete a.__Jasmine_been_here_before__;
|
||||||
delete b.__Jasmine_been_here_before__;
|
delete b.__Jasmine_been_here_before__;
|
||||||
return (mismatchKeys.length == 0 && mismatchValues.length == 0);
|
return (mismatchKeys.length === 0 && mismatchValues.length === 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
|
jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
|
||||||
|
@ -227,7 +227,7 @@ jasmine.Matchers.prototype.toHaveBeenCalledWith = function() {
|
|||||||
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
|
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
|
||||||
}
|
}
|
||||||
this.message = function() {
|
this.message = function() {
|
||||||
if (this.actual.callCount == 0) {
|
if (this.actual.callCount === 0) {
|
||||||
// todo: what should the failure message for .not.toHaveBeenCalledWith() be? is this right? test better. [xw]
|
// todo: what should the failure message for .not.toHaveBeenCalledWith() be? is this right? test better. [xw]
|
||||||
return [
|
return [
|
||||||
"Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.",
|
"Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.",
|
||||||
@ -258,7 +258,7 @@ jasmine.Matchers.prototype.wasNotCalledWith = function() {
|
|||||||
return [
|
return [
|
||||||
"Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was",
|
"Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was",
|
||||||
"Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was"
|
"Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was"
|
||||||
]
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
return !this.env.contains_(this.actual.argsForCall, expectedArgs);
|
return !this.env.contains_(this.actual.argsForCall, expectedArgs);
|
||||||
@ -315,7 +315,7 @@ jasmine.Matchers.prototype.toThrow = function(expected) {
|
|||||||
|
|
||||||
this.message = function() {
|
this.message = function() {
|
||||||
if (exception && (expected === jasmine.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 " + not + "to throw", expected ? expected.message || expected : " an exception", ", but it threw", exception.message || exception].join(' ');
|
return ["Expected function " + not + "to throw", expected ? expected.message || expected : "an exception", ", but it threw", exception.message || exception].join(' ');
|
||||||
} else {
|
} else {
|
||||||
return "Expected function to throw an exception.";
|
return "Expected function to throw an exception.";
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,8 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
|
|||||||
jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
|
jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
|
||||||
for (var property in obj) {
|
for (var property in obj) {
|
||||||
if (property == '__Jasmine_been_here_before__') continue;
|
if (property == '__Jasmine_been_here_before__') continue;
|
||||||
fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) != null) : false);
|
fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined &&
|
||||||
|
obj.__lookupGetter__(property) !== null) : false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
38
src/base.js
38
src/base.js
@ -108,7 +108,8 @@ jasmine.ExpectationResult.prototype.passed = function () {
|
|||||||
* Getter for the Jasmine environment. Ensures one gets created
|
* Getter for the Jasmine environment. Ensures one gets created
|
||||||
*/
|
*/
|
||||||
jasmine.getEnv = function() {
|
jasmine.getEnv = function() {
|
||||||
return jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env();
|
var env = jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env();
|
||||||
|
return env;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -171,7 +172,7 @@ jasmine.pp = function(value) {
|
|||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
jasmine.isDomNode = function(obj) {
|
jasmine.isDomNode = function(obj) {
|
||||||
return obj['nodeType'] > 0;
|
return obj.nodeType > 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -407,7 +408,7 @@ jasmine.isSpy = function(putativeSpy) {
|
|||||||
* @param {Array} methodNames array of names of methods to make spies
|
* @param {Array} methodNames array of names of methods to make spies
|
||||||
*/
|
*/
|
||||||
jasmine.createSpyObj = function(baseName, methodNames) {
|
jasmine.createSpyObj = function(baseName, methodNames) {
|
||||||
if (!jasmine.isArray_(methodNames) || methodNames.length == 0) {
|
if (!jasmine.isArray_(methodNames) || methodNames.length === 0) {
|
||||||
throw new Error('createSpyObj requires a non-empty array of method names to create spies for');
|
throw new Error('createSpyObj requires a non-empty array of method names to create spies for');
|
||||||
}
|
}
|
||||||
var obj = {};
|
var obj = {};
|
||||||
@ -582,21 +583,20 @@ if (isCommonJS) exports.xdescribe = xdescribe;
|
|||||||
|
|
||||||
// Provide the XMLHttpRequest class for IE 5.x-6.x:
|
// Provide the XMLHttpRequest class for IE 5.x-6.x:
|
||||||
jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
|
jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
|
||||||
try {
|
function tryIt(f) {
|
||||||
return new ActiveXObject("Msxml2.XMLHTTP.6.0");
|
try {
|
||||||
} catch(e) {
|
return f();
|
||||||
|
} catch(e) {
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
return new ActiveXObject("Msxml2.XMLHTTP.3.0");
|
var xhr = tryIt(function(){return new ActiveXObject("Msxml2.XMLHTTP.6.0");}) ||
|
||||||
} catch(e) {
|
tryIt(function(){return new ActiveXObject("Msxml2.XMLHTTP.3.0");}) ||
|
||||||
}
|
tryIt(function(){return new ActiveXObject("Msxml2.XMLHTTP");}) ||
|
||||||
try {
|
tryIt(function(){return new ActiveXObject("Microsoft.XMLHTTP");});
|
||||||
return new ActiveXObject("Msxml2.XMLHTTP");
|
|
||||||
} catch(e) {
|
if (!xhr) throw new Error("This browser does not support XMLHttpRequest.");
|
||||||
}
|
|
||||||
try {
|
return xhr;
|
||||||
return new ActiveXObject("Microsoft.XMLHTTP");
|
|
||||||
} catch(e) {
|
|
||||||
}
|
|
||||||
throw new Error("This browser does not support XMLHttpRequest.");
|
|
||||||
} : XMLHttpRequest;
|
} : XMLHttpRequest;
|
@ -110,7 +110,7 @@ jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
|||||||
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
||||||
var results = suite.results();
|
var results = suite.results();
|
||||||
var status = results.passed() ? 'passed' : 'failed';
|
var status = results.passed() ? 'passed' : 'failed';
|
||||||
if (results.totalCount == 0) { // todo: change this to check results.skipped
|
if (results.totalCount === 0) { // todo: change this to check results.skipped
|
||||||
status = 'skipped';
|
status = 'skipped';
|
||||||
}
|
}
|
||||||
this.suiteDivs[suite.id].className += " " + status;
|
this.suiteDivs[suite.id].className += " " + status;
|
||||||
@ -183,6 +183,6 @@ jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
|||||||
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!paramMap["spec"]) return true;
|
if (!paramMap.spec) return true;
|
||||||
return spec.getFullName().indexOf(paramMap["spec"]) == 0;
|
return spec.getFullName().indexOf(paramMap.spec) === 0;
|
||||||
};
|
};
|
||||||
|
@ -17,7 +17,7 @@ jasmine.util.inherit = function(childClass, parentClass) {
|
|||||||
var subclass = function() {
|
var subclass = function() {
|
||||||
};
|
};
|
||||||
subclass.prototype = parentClass.prototype;
|
subclass.prototype = parentClass.prototype;
|
||||||
childClass.prototype = new subclass;
|
childClass.prototype = new subclass();
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.util.formatException = function(e) {
|
jasmine.util.formatException = function(e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user