Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move Assertion class to own file

  • Loading branch information...
commit d84aa58d18febf684edf23cb2fa75fcb13864d95 1 parent 2e881ed
@joelplane joelplane authored
Showing with 27 additions and 22 deletions.
  1. +26 −0 assertion.js
  2. +1 −22 noodleTest.js
View
26 assertion.js
@@ -0,0 +1,26 @@
+module.exports = (function(){
+ var sys = require('sys');
+ function Assertion(testCase, assertMethod, args, tester) {
+ this.testCase = testCase;
+ this.assertMethod = assertMethod;
+ this.args = args;
+ this.tester = tester;
+ this.passed = null;
+ var numberOfStackLinesToSkip = 1 /* First line which is just the name of the fake error we created: "Error" */
+ + 1 /* Call to here */
+ + 1 /* The caller (Test#assert) */;
+ this.stack = (new Error).stack.split("\n").map(function(line){
+ return line.trim();
+ }).slice(numberOfStackLinesToSkip);
+ }
+ Assertion.prototype.execute = function() {
+ this.passed = !!this.tester();
+ };
+ Assertion.prototype.failureMessage = function() {
+ return "Expected first argument to evaluate to true";
+ };
+ Assertion.prototype.callString = function() {
+ return this.assertMethod + '(' + sys.inspect(this.args[0]) + ')'
+ };
+ return Assertion;
+})();
View
23 noodleTest.js
@@ -8,28 +8,7 @@ module.exports = (function(config){
var sys = require('sys');
if (!config.timeout) config.timeout = 4000;
- var Assertion = function(testCase, assertMethod, args, tester) {
- this.testCase = testCase;
- this.assertMethod = assertMethod;
- this.args = args;
- this.tester = tester;
- this.passed = null;
- var numberOfStackLinesToSkip = 1 /* First line which is just the name of the fake error we created: "Error" */
- + 1 /* Call to here */
- + 1 /* The caller (Test#assert) */;
- this.stack = (new Error).stack.split("\n").map(function(line){
- return line.trim();
- }).slice(numberOfStackLinesToSkip);
- };
- Assertion.prototype.execute = function() {
- this.passed = !!this.tester();
- };
- Assertion.prototype.failureMessage = function() {
- return "Expected first argument to evaluate to true";
- };
- Assertion.prototype.callString = function() {
- return this.assertMethod + '(' + sys.inspect(this.args[0]) + ')'
- };
+ var Assertion = require('./assertion');
var testQueue = (function() {
var begun = false;
Please sign in to comment.
Something went wrong with that request. Please try again.