Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #6 from curious-attempt-bunny/merlyn/test_code_ref…

…actored

Factored out the common test code
  • Loading branch information...
commit c82687d224a5bdb1224d5c7fdd2ef352786d278e 2 parents 08ad654 + 2dc6c80
Chris Dickinson authored

Showing 1 changed file with 9 additions and 18 deletions. Show diff stats Hide diff stats

  1. +9 18 test/test.js
27 test/test.js
@@ -22,14 +22,7 @@ try {
22 22 assert.equal(traced.frames.length, err.stack.split('\n').length - 1);
23 23 assert.ok(!!~['<anonymous>', 'local_unnamed'].indexOf(traced.frames[0].named_location));
24 24
25   - assert.equal(traced.first_line, err.stack.split('\n')[0]);
26   - assert.strictEqual(traced.original_error, err);
27   -
28   - var lines = err.stack.split('\n').slice(1);
29   - for(var i = 0, len = lines.length; i < len; ++i) {
30   - assert.notStrictEqual(lines[i].indexOf(traced.frames[i].line + ':' + traced.frames[i].character), -1);
31   - assert.notStrictEqual(lines[i].indexOf(traced.frames[i].filename), -1);
32   - }
  25 + assert_stacks_equal(err, traced);
33 26 }
34 27
35 28 try {
@@ -38,14 +31,7 @@ try {
38 31 var traced = trace(err);
39 32 assert.equal(traced.frames.length, err.stack.split('\n').length - 1);
40 33
41   - assert.equal(traced.first_line, err.stack.split('\n')[0]);
42   - assert.strictEqual(traced.original_error, err);
43   -
44   - var lines = err.stack.split('\n').slice(1);
45   - for(var i = 0, len = lines.length; i < len; ++i) {
46   - assert.notStrictEqual(lines[i].indexOf(traced.frames[i].line + ':' + traced.frames[i].character), -1);
47   - assert.notStrictEqual(lines[i].indexOf(traced.frames[i].filename), -1);
48   - }
  34 + assert_stacks_equal(err, traced);
49 35 }
50 36
51 37 try {
@@ -54,6 +40,13 @@ try {
54 40 var traced = trace(err);
55 41 assert.equal(traced.frames.length, err.stack.split('\n').length - 1);
56 42
  43 + assert_stacks_equal(err, traced);
  44 +}
  45 +
  46 +console.error('Tests passed');
  47 +return;
  48 +
  49 +function assert_stacks_equal(err, traced) {
57 50 assert.equal(traced.first_line, err.stack.split('\n')[0]);
58 51 assert.strictEqual(traced.original_error, err);
59 52
@@ -63,5 +56,3 @@ try {
63 56 assert.notStrictEqual(lines[i].indexOf(traced.frames[i].filename), -1);
64 57 }
65 58 }
66   -
67   -console.error('Tests passed');

0 comments on commit c82687d

Please sign in to comment.
Something went wrong with that request. Please try again.