summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_7/TypedObject/architecture.js
blob: 4ebaaa9c3dcaceac2073e57f012cb18331a531bc (plain)
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
// |reftest| skip-if(!this.hasOwnProperty("TypedObject"))

var BUGNUMBER = 578700;
var summary = 'Binary Data class diagram';

function assertNotEq(a, b) {
    var ok = false;
    try {
        assertEq(a, b);
    } catch(exc) {
        ok = true;
    }

    if (!ok)
        throw new TypeError("Assertion failed: assertNotEq(" + a + " " + b + ")");
}

function assertThrows(f) {
    var ok = false;
    try {
        f();
    } catch (exc) {
        ok = true;
    }
    if (!ok)
        throw new TypeError("Assertion failed: " + f + " did not throw as expected");
}

function runTests() {
  print(BUGNUMBER + ": " + summary);

  var ArrayType = TypedObject.ArrayType;
  var StructType = TypedObject.StructType;

  assertEq(ArrayType instanceof Function, true);
  assertEq(ArrayType.prototype instanceof Function, true);

  assertEq(ArrayType.__proto__, Function.__proto__);
  assertEq(ArrayType.prototype.__proto__, Function.__proto__);

  assertEq(StructType instanceof Function, true);
  assertEq(StructType.prototype instanceof Function, true);

  assertEq(Object.getPrototypeOf(StructType),
           Object.getPrototypeOf(Function));
  assertEq(Object.getPrototypeOf(StructType.prototype),
           Object.getPrototypeOf(Function));

  if (typeof reportCompare === "function")
    reportCompare(true, true);

  print("Tests complete");
}

runTests();