| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<title>Browser Tests (assertion-error)</title> |
| 5 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| 6 |
</head> |
| 7 |
<body> |
| 8 |
<p>To see results view console.</p> |
| 9 |
<script src="../build/build.js"></script> |
| 10 |
<script> |
| 11 |
AssertionError = require('assertion-error'); |
| 12 |
(function runner (ctx) { |
| 13 |
/*! |
| 14 |
* Simple test runner. |
| 15 |
*/ |
| 16 |
|
| 17 |
var count = 0 |
| 18 |
, failures = [] |
| 19 |
, tests = []; |
| 20 |
|
| 21 |
function test (name, fn) { |
| 22 |
tests.push({ name: name, fn: fn }); |
| 23 |
} |
| 24 |
|
| 25 |
function assert (pass, msg) { |
| 26 |
if (!pass) throw new Error(msg); |
| 27 |
} |
| 28 |
|
| 29 |
ctx.suite = function (fn) { |
| 30 |
fn(test, assert); |
| 31 |
console.log(' Tests (%d)', tests.length); |
| 32 |
|
| 33 |
tests.forEach(function (test) { |
| 34 |
var err = false |
| 35 |
, num = ++count; |
| 36 |
|
| 37 |
try { test.fn(); } |
| 38 |
catch (ex) { err = ex; } |
| 39 |
|
| 40 |
if (err) { |
| 41 |
console.log(' %d. [fail] %s', num, test.name); |
| 42 |
failures.push({ num: num, err: err }); |
| 43 |
} else { |
| 44 |
console.log(' %d. [pass] %s', num, test.name); |
| 45 |
} |
| 46 |
}); |
| 47 |
|
| 48 |
console.log(' Failures (%d)', failures.length); |
| 49 |
failures.forEach(function (failure) { |
| 50 |
console.log(' %d. %s', failure.num, failure.err.message); |
| 51 |
}); |
| 52 |
}; |
| 53 |
})(this); |
| 54 |
</script> |
| 55 |
<script src="./test.js"></script> |
| 56 |
</body> |
| 57 |
</html> |