File: index.html

package info (click to toggle)
node-assertion-error 1.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 216 kB
  • sloc: javascript: 129; makefile: 24
file content (57 lines) | stat: -rw-r--r-- 1,496 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<html>
  <head>
    <title>Browser Tests (assertion-error)</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>To see results view console.</p>
    <script src="../build/build.js"></script>
    <script>
      AssertionError = require('assertion-error');
      (function runner (ctx) {
        /*!
         * Simple test runner.
         */

        var count = 0
          , failures = []
          , tests = [];

        function test (name, fn) {
          tests.push({ name: name, fn: fn });
        }

        function assert (pass, msg) {
          if (!pass) throw new Error(msg);
        }

        ctx.suite = function (fn) {
          fn(test, assert);
          console.log('  Tests (%d)', tests.length);

          tests.forEach(function (test) {
            var err = false
              , num = ++count;

            try { test.fn(); }
            catch (ex) { err = ex; }

            if (err) {
              console.log('  %d. [fail] %s', num, test.name);
              failures.push({ num: num, err: err });
            } else {
              console.log('  %d. [pass] %s', num, test.name);
            }
          });

          console.log('  Failures (%d)', failures.length);
          failures.forEach(function (failure) {
            console.log('  %d. %s', failure.num, failure.err.message);
          });
        };
      })(this);
    </script>
    <script src="./test.js"></script>
  </body>
</html>