diff options
Diffstat (limited to 'js/src/tests/ecma_7/TypedObject/arrayequiv.js')
-rw-r--r-- | js/src/tests/ecma_7/TypedObject/arrayequiv.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/js/src/tests/ecma_7/TypedObject/arrayequiv.js b/js/src/tests/ecma_7/TypedObject/arrayequiv.js new file mode 100644 index 000000000..e6a89586d --- /dev/null +++ b/js/src/tests/ecma_7/TypedObject/arrayequiv.js @@ -0,0 +1,59 @@ +// |reftest| skip-if(!this.hasOwnProperty("TypedObject")) +var BUGNUMBER = 922216; +var summary = 'TypedObjects Equivalent ArrayTypes'; + +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 assertEquivalent(t1, t2) { + assertEq(true, t1.equivalent(t2)); + assertEq(true, t2.equivalent(t1)); +} + +function assertNotEquivalent(t1, t2) { + assertEq(false, t1.equivalent(t2)); + assertEq(false, t2.equivalent(t1)); +} + +function runTests() { + print(BUGNUMBER + ": " + summary); + + // Create a line: + var PixelType1 = new StructType({x: uint8, y: uint8}); + var PixelsType1 = PixelType1.array(22); + + // Sanity checks about type equivalence: + assertEquivalent(PixelType1, PixelType1); + assertEquivalent(PixelsType1, PixelsType1); + assertNotEquivalent(PixelType1, PixelsType1); + + // Define the same two types again. Equivalent. + var PixelType2 = new StructType({x: uint8, y: uint8}); + var PixelsType2 = PixelType2.array(22); + assertEquivalent(PixelType1, PixelType2); + assertEquivalent(PixelsType1, PixelsType2); + + // Define the pixel type with field order reversed. Not equivalent. + var PixelType3 = new StructType({y: uint8, x: uint8}); + var PixelsType3 = PixelType3.array(22); + assertNotEquivalent(PixelType1, PixelType3); + assertNotEquivalent(PixelsType1, PixelsType3); + + // Define the pixels type with different number of elements. Not equivalent. + var PixelsType3 = PixelType1.array(23); + assertNotEquivalent(PixelsType1, PixelsType3); + + reportCompare(true, true); + print("Tests complete"); +} + +runTests(); |