File: require.html

package info (click to toggle)
node-seedrandom 2.4.3%2Bdfsg-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 488 kB
  • sloc: javascript: 5,392; sh: 3; makefile: 2
file content (57 lines) | stat: -rw-r--r-- 1,351 bytes parent folder | download | duplicates (3)
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>
<link rel="stylesheet" href="lib/qunit.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="lib/require.js"></script>

<script>

require.config({
  paths: {
    'qunit': 'lib/qunit',
    'seedrandom': '/seedrandom.min'
  }
});

require(['qunit', 'seedrandom'], function(QUnit, seedrandom) {
  QUnit.start();
  QUnit.module('require.js test');
  QUnit.test('some normal test', function(assert) {
    assert.ok(true, "Seeded random created using module:");
    var check = [];
    var prng = seedrandom('predictable.');
    var r;
    for (var j = 0; j < 5; ++j) {
      r = prng();
      assert.ok(true, r + "");
      check.push(r);
    }
    assert.ok(true, "Native random:");
    for (var j = 0; j < 5; ++j) {
      r = Math.random();
      assert.ok(true, r + "");
      check.push(r);
    }
    // Verify against Math.seedrandom.
    var seed = Math.seedrandom('predictable.');
    assert.equal(seed, 'predictable.',
        "Seed should be returned from Math.seedrandom.");
    for (var j = 0; j < 10; ++j) {
      r = Math.random();
      if (j < 5) {
        assert.equal(check[j], r, "Equal: " + r + " vs " + check[j]);
      } else {
        assert.ok(check[j] != r, "Unqual: " + r + " vs " + check[j]);
      }
    }
    document.close();
  });
});

</script>
</body>
</html>