Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Code bitch #54

Closed
wants to merge 1 commit into from

3 participants

@fat
fat commented

code bitttchhhing.

  • normalize whitespace around functions
  • cleans up for loops (decrements when possible)
  • replace splice with unshift
@fat-bot fat-bot code bitttchhhing.
+ normalize whitespace around functions
+ cleans up for loops (decrements when possible)
+ replace splice with unshift
0378f87
@infews infews closed this
@infews
Owner

A lot of the whitespace gripes have been fixed. Leaving the loops alone for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 9, 2011
  1. @fat-bot

    code bitttchhhing.

    fat-bot authored
    + normalize whitespace around functions
    + cleans up for loops (decrements when possible)
    + replace splice with unshift
This page is out of date. Refresh to see the latest.
View
2  src/Block.js
@@ -19,4 +19,4 @@ jasmine.Block.prototype.execute = function(onComplete) {
this.spec.fail(e);
}
onComplete();
-};
+};
View
12 src/Env.js
@@ -39,7 +39,7 @@ jasmine.Env.prototype.clearInterval = jasmine.clearInterval;
/**
* @returns an object containing jasmine version build info, if set.
*/
-jasmine.Env.prototype.version = function () {
+jasmine.Env.prototype.version = function() {
if (jasmine.version_) {
return jasmine.version_;
} else {
@@ -62,14 +62,14 @@ jasmine.Env.prototype.versionString = function() {
/**
* @returns a sequential integer starting at 0
*/
-jasmine.Env.prototype.nextSpecId = function () {
+jasmine.Env.prototype.nextSpecId = function() {
return this.nextSpecId_++;
};
/**
* @returns a sequential integer starting at 0
*/
-jasmine.Env.prototype.nextSuiteId = function () {
+jasmine.Env.prototype.nextSuiteId = function() {
return this.nextSuiteId_++;
};
@@ -123,7 +123,7 @@ jasmine.Env.prototype.beforeEach = function(beforeEachFunction) {
}
};
-jasmine.Env.prototype.currentRunner = function () {
+jasmine.Env.prototype.currentRunner = function() {
return this.currentRunner_;
};
@@ -205,7 +205,7 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
mismatchKeys = mismatchKeys || [];
mismatchValues = mismatchValues || [];
- for (var i = 0; i < this.equalityTesters_.length; i++) {
+ for (var i = 0, l = this.equalityTesters_.length; i < l; i++) {
var equalityTester = this.equalityTesters_[i];
var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
if (result !== jasmine.undefined) return result;
@@ -251,7 +251,7 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
jasmine.Env.prototype.contains_ = function(haystack, needle) {
if (jasmine.isArray_(haystack)) {
- for (var i = 0; i < haystack.length; i++) {
+ for (var i = haystack.length; i--;) {
if (this.equals_(haystack[i], needle)) return true;
}
return false;
View
6 src/JsApiReporter.js
@@ -12,7 +12,7 @@ jasmine.JsApiReporter = function() {
jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) {
this.started = true;
var suites = runner.topLevelSuites();
- for (var i = 0; i < suites.length; i++) {
+ for (var i = suites.length; i--;) {
var suite = suites[i];
this.suites_.push(this.summarize_(suite));
}
@@ -33,7 +33,7 @@ jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {
if (isSuite) {
var children = suiteOrSpec.children();
- for (var i = 0; i < children.length; i++) {
+ for (var i = 0, l = children.length; i < l; i++) {
summary.children.push(this.summarize_(children[i]));
}
}
@@ -71,7 +71,7 @@ jasmine.JsApiReporter.prototype.log = function(str) {
jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds){
var results = {};
- for (var i = 0; i < specIds.length; i++) {
+ for (var i = specIds.length; i--;) {
var specId = specIds[i];
results[specId] = this.summarizeResult_(this.results_[specId]);
}
View
2  src/Matchers.js
@@ -52,7 +52,7 @@ jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
message = "Expected " + jasmine.pp(this.actual) + (this.isNot ? " not " : " ") + englishyPredicate;
if (matcherArgs.length > 0) {
- for (var i = 0; i < matcherArgs.length; i++) {
+ for (var i = 0, l = matcherArgs.length; i < l; i++) {
if (i > 0) message += ",";
message += " " + jasmine.pp(matcherArgs[i]);
}
View
4 src/MultiReporter.js
@@ -19,11 +19,11 @@ jasmine.MultiReporter.prototype.addReporter = function(reporter) {
"reportSpecResults",
"log"
];
- for (var i = 0; i < functionNames.length; i++) {
+ for (var i = functionNames.length; i--;) {
var functionName = functionNames[i];
jasmine.MultiReporter.prototype[functionName] = (function(functionName) {
return function() {
- for (var j = 0; j < this.subReporters_.length; j++) {
+ for (var j = this.subReporters_.length; j--;) {
var subReporter = this.subReporters_[j];
if (subReporter[functionName]) {
subReporter[functionName].apply(subReporter, arguments);
View
2  src/PrettyPrinter.js
@@ -84,7 +84,7 @@ jasmine.StringPrettyPrinter.prototype.emitString = function(value) {
jasmine.StringPrettyPrinter.prototype.emitArray = function(array) {
this.append('[ ');
- for (var i = 0; i < array.length; i++) {
+ for (var i = 0, l = array.length; i < l; i++) {
if (i > 0) {
this.append(', ');
}
View
4 src/Queue.js
@@ -43,7 +43,7 @@ jasmine.Queue.prototype.next_ = function() {
var calledSynchronously = true;
var completedSynchronously = false;
- var onComplete = function () {
+ var onComplete = function() {
if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) {
completedSynchronously = true;
return;
@@ -88,7 +88,7 @@ jasmine.Queue.prototype.next_ = function() {
jasmine.Queue.prototype.results = function() {
var results = new jasmine.NestedResults();
- for (var i = 0; i < this.blocks.length; i++) {
+ for (var i = 0, l = this.blocks.length; i < l; i++) {
if (this.blocks[i].results) {
results.addResult(this.blocks[i].results());
}
View
14 src/Runner.js
@@ -18,19 +18,19 @@ jasmine.Runner.prototype.execute = function() {
if (self.env.reporter.reportRunnerStarting) {
self.env.reporter.reportRunnerStarting(this);
}
- self.queue.start(function () {
+ self.queue.start(function() {
self.finishCallback();
});
};
jasmine.Runner.prototype.beforeEach = function(beforeEachFunction) {
beforeEachFunction.typeName = 'beforeEach';
- this.before_.splice(0,0,beforeEachFunction);
+ this.before_.unshift(beforeEachFunction);
};
jasmine.Runner.prototype.afterEach = function(afterEachFunction) {
afterEachFunction.typeName = 'afterEach';
- this.after_.splice(0,0,afterEachFunction);
+ this.after_.unshift(afterEachFunction);
};
@@ -49,10 +49,10 @@ jasmine.Runner.prototype.add = function(block) {
this.queue.add(block);
};
-jasmine.Runner.prototype.specs = function () {
+jasmine.Runner.prototype.specs = function() {
var suites = this.suites();
var specs = [];
- for (var i = 0; i < suites.length; i++) {
+ for (var i = 0, l = suites.length; i < l; i++) {
specs = specs.concat(suites[i].specs());
}
return specs;
@@ -64,7 +64,7 @@ jasmine.Runner.prototype.suites = function() {
jasmine.Runner.prototype.topLevelSuites = function() {
var topLevelSuites = [];
- for (var i = 0; i < this.suites_.length; i++) {
+ for (var i = 0, l = this.suites_.length; i < l; i++) {
if (!this.suites_[i].parentSuite) {
topLevelSuites.push(this.suites_[i]);
}
@@ -74,4 +74,4 @@ jasmine.Runner.prototype.topLevelSuites = function() {
jasmine.Runner.prototype.results = function() {
return this.queue.results();
-};
+};
View
24 src/Spec.js
@@ -46,13 +46,13 @@ jasmine.Spec.prototype.log = function() {
return this.results_.log(arguments);
};
-jasmine.Spec.prototype.runs = function (func) {
+jasmine.Spec.prototype.runs = function(func) {
var block = new jasmine.Block(this.env, func, this);
this.addToQueue(block);
return this;
};
-jasmine.Spec.prototype.addToQueue = function (block) {
+jasmine.Spec.prototype.addToQueue = function(block) {
if (this.queue.isRunning()) {
this.queue.insertNext(block);
} else {
@@ -97,7 +97,7 @@ jasmine.Spec.prototype.waitsFor = function(latchFunction, optional_timeoutMessag
var optional_timeoutMessage_ = null;
var optional_timeout_ = null;
- for (var i = 0; i < arguments.length; i++) {
+ for (var i = arguments.length; i--;) {
var arg = arguments[i];
switch (typeof arg) {
case 'function':
@@ -117,7 +117,7 @@ jasmine.Spec.prototype.waitsFor = function(latchFunction, optional_timeoutMessag
return this;
};
-jasmine.Spec.prototype.fail = function (e) {
+jasmine.Spec.prototype.fail = function(e) {
var expectationResult = new jasmine.ExpectationResult({
passed: false,
message: e ? jasmine.util.formatException(e) : 'Exception'
@@ -173,32 +173,32 @@ jasmine.Spec.prototype.execute = function(onComplete) {
spec.addBeforesAndAftersToQueue();
- spec.queue.start(function () {
+ spec.queue.start(function() {
spec.finish(onComplete);
});
};
jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() {
var runner = this.env.currentRunner();
- var i;
+ var i, l;
for (var suite = this.suite; suite; suite = suite.parentSuite) {
- for (i = 0; i < suite.before_.length; i++) {
+ for (i = 0, l = suite.before_.length; i < l; i++) {
this.queue.addBefore(new jasmine.Block(this.env, suite.before_[i], this));
}
}
- for (i = 0; i < runner.before_.length; i++) {
+ for (i = 0, l = runner.before_.length; i < l; i++) {
this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this));
}
- for (i = 0; i < this.afterCallbacks.length; i++) {
+ for (i = 0, l = this.afterCallbacks.length; i < l; i++) {
this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this));
}
for (suite = this.suite; suite; suite = suite.parentSuite) {
- for (i = 0; i < suite.after_.length; i++) {
+ for (i = 0, l = suite.after_.length; i < l; i++) {
this.queue.add(new jasmine.Block(this.env, suite.after_[i], this));
}
}
- for (i = 0; i < runner.after_.length; i++) {
+ for (i = 0, l = runner.after_.length; i < l; i++) {
this.queue.add(new jasmine.Block(this.env, runner.after_[i], this));
}
};
@@ -233,7 +233,7 @@ jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist
};
jasmine.Spec.prototype.removeAllSpies = function() {
- for (var i = 0; i < this.spies_.length; i++) {
+ for (var i = this.spies_.length; i--;) {
var spy = this.spies_[i];
spy.baseObj[spy.methodName] = spy.originalValue;
}
View
4 src/Suite.js
@@ -76,7 +76,7 @@ jasmine.Suite.prototype.children = function() {
jasmine.Suite.prototype.execute = function(onComplete) {
var self = this;
- this.queue.start(function () {
+ this.queue.start(function() {
self.finish(onComplete);
});
-};
+};
View
4 src/WaitsBlock.js
@@ -5,9 +5,9 @@ jasmine.WaitsBlock = function(env, timeout, spec) {
jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block);
-jasmine.WaitsBlock.prototype.execute = function (onComplete) {
+jasmine.WaitsBlock.prototype.execute = function(onComplete) {
this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...');
- this.env.setTimeout(function () {
+ this.env.setTimeout(function() {
onComplete();
}, this.timeout);
};
View
2  src/WaitsForBlock.js
@@ -49,4 +49,4 @@ jasmine.WaitsForBlock.prototype.execute = function(onComplete) {
self.execute(onComplete);
}, jasmine.WaitsForBlock.TIMEOUT_INCREMENT);
}
-};
+};
View
6 src/base.js
@@ -94,11 +94,11 @@ jasmine.ExpectationResult = function(params) {
this.trace = this.passed_ ? '' : new Error(this.message);
};
-jasmine.ExpectationResult.prototype.toString = function () {
+jasmine.ExpectationResult.prototype.toString = function() {
return this.message;
};
-jasmine.ExpectationResult.prototype.passed = function () {
+jasmine.ExpectationResult.prototype.passed = function() {
return this.passed_;
};
@@ -409,7 +409,7 @@ jasmine.createSpyObj = function(baseName, methodNames) {
throw new Error('createSpyObj requires a non-empty array of method names to create spies for');
}
var obj = {};
- for (var i = 0; i < methodNames.length; i++) {
+ for (var i = methodNames.length; i--;) {
obj[methodNames[i]] = jasmine.createSpy(baseName + '.' + methodNames[i]);
}
return obj;
View
10 src/html/TrivialReporter.js
@@ -7,7 +7,7 @@ jasmine.TrivialReporter = function(doc) {
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
var el = document.createElement(type);
- for (var i = 2; i < arguments.length; i++) {
+ for (var i = 2, l = arguments.length; i < l; i++) {
var child = arguments[i];
if (typeof child === 'string') {
@@ -54,7 +54,7 @@ jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
this.document.body.appendChild(this.outerDiv);
var suites = runner.suites();
- for (var i = 0; i < suites.length; i++) {
+ for (var i = 0, l = suites.length; i < l; i++) {
var suite = suites[i];
var suiteDiv = this.createDom('div', { className: 'suite' },
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
@@ -95,7 +95,7 @@ jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
this.runnerDiv.setAttribute("className", className);
var specs = runner.specs();
var specCount = 0;
- for (var i = 0; i < specs.length; i++) {
+ for (var i = 0, l = specs.length; i < l; i++) {
if (this.specFilter(specs[i])) {
specCount++;
}
@@ -139,7 +139,7 @@ jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
var resultItems = results.getItems();
var messagesDiv = this.createDom('div', { className: 'messages' });
- for (var i = 0; i < resultItems.length; i++) {
+ for (var i = 0, l = resultItems.length; i < l; i++) {
var result = resultItems[i];
if (result.type == 'log') {
@@ -178,7 +178,7 @@ jasmine.TrivialReporter.prototype.getLocation = function() {
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
var paramMap = {};
var params = this.getLocation().search.substring(1).split('&');
- for (var i = 0; i < params.length; i++) {
+ for (var i = 0, l = params.length; i < l; i++) {
var p = params[i].split('=');
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
}
View
2  src/mock-timeout.js
@@ -57,7 +57,7 @@ jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMil
funcsToRun.sort(function(a, b) {
return a.runAtMillis - b.runAtMillis;
});
- for (var i = 0; i < funcsToRun.length; ++i) {
+ for (var i = 0, l = funcsToRun.length; i < l; i++) {
try {
var funcToRun = funcsToRun[i];
this.nowMillis = funcToRun.runAtMillis;
View
8 src/util.js
@@ -56,12 +56,16 @@ jasmine.util.htmlEscape = function(str) {
jasmine.util.argsToArray = function(args) {
var arrayOfArgs = [];
- for (var i = 0; i < args.length; i++) arrayOfArgs.push(args[i]);
+ for (var i = 0, l = args.length; i < l; i++) {
+ arrayOfArgs.push(args[i]);
+ }
return arrayOfArgs;
};
jasmine.util.extend = function(destination, source) {
- for (var property in source) destination[property] = source[property];
+ for (var property in source) {
+ destination[property] = source[property];
+ }
return destination;
};
Something went wrong with that request. Please try again.