summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_7/TypedObject/structtypeenumerate.js
blob: 3c7bd91a7bf6b7d4078b80a1dd1912b8737e34b2 (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
// |reftest| skip-if(!this.hasOwnProperty("TypedObject"))
var BUGNUMBER = 578700;
var summary = 'TypedObjects StructType propery enumeration';

var ArrayType = TypedObject.ArrayType;
var StructType = TypedObject.StructType;
var uint8 = TypedObject.uint8;
var uint16 = TypedObject.uint16;
var uint32 = TypedObject.uint32;
var uint8Clamped = TypedObject.uint8Clamped;
var int8 = TypedObject.int8;
var int16 = TypedObject.int16;
var int32 = TypedObject.int32;
var float32 = TypedObject.float32;
var float64 = TypedObject.float64;

function runTests() {
  var RgbColor = new StructType({r: uint8, g: uint8, b: uint8});
  var Fade = new StructType({from: RgbColor, to: RgbColor});

  var white = new RgbColor({r: 255, g: 255, b: 255});
  var gray = new RgbColor({r: 129, g: 128, b: 127});
  var fade = new Fade({from: white, to: gray});

  var keys = Object.keys(gray);
  assertEqArray(keys, ["r", "g", "b"]);

  var keys = Object.keys(fade);
  assertEqArray(keys, ["from", "to"]);

  reportCompare(true, true);
  print("Tests complete");
}

runTests();