| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --expose-debug-as debug --harmony-simd |
| 6 // Test the mirror objects for SIMD values. |
| 7 |
| 8 function testMirror(simd_name, type_name, value_as_string) { |
| 9 // Create mirror and JSON representation. |
| 10 var value = eval(value_as_string); |
| 11 var mirror = debug.MakeMirror(value); |
| 12 for (var prop in mirror) |
| 13 print(prop, mirror[prop]); |
| 14 var serializer = debug.MakeMirrorSerializer(); |
| 15 var json = JSON.stringify(serializer.serializeValue(mirror)); |
| 16 |
| 17 // Check the mirror hierachy. |
| 18 assertTrue(mirror instanceof debug.Mirror); |
| 19 assertTrue(mirror instanceof debug.ValueMirror); |
| 20 assertTrue(mirror instanceof debug[simd_name + 'Mirror']); |
| 21 |
| 22 // Check the mirror properties. |
| 23 assertTrue(mirror['is' + simd_name]()); |
| 24 assertEquals(type_name, mirror.type()); |
| 25 assertTrue(mirror.isPrimitive()); |
| 26 assertSame(value, mirror.value()); |
| 27 assertEquals(value_as_string, mirror.toText()); |
| 28 |
| 29 // Parse JSON representation and check. |
| 30 var fromJSON = eval('(' + json + ')'); |
| 31 assertEquals(simd_name, fromJSON.type); |
| 32 } |
| 33 |
| 34 testMirror('Float32x4', 'float32x4', 'SIMD.Float32x4(1.25, 2.5, 3, 4)'); |
| 35 testMirror('Float32x4', 'float32x4', 'SIMD.Float32x4(0, 0, NaN, 1)'); |
| 36 |
| 37 testMirror('Int32x4', 'int32x4', 'SIMD.Int32x4(1, 2, 3, 4)'); |
| 38 testMirror('Int16x8', 'int16x8', |
| 39 'SIMD.Int16x8(1, 2, 3, 4, 5, 6, 7, 8)'); |
| 40 testMirror('Int8x16', 'int8x16', |
| 41 'SIMD.Int8x16(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)'); |
| 42 |
| 43 testMirror('Uint32x4', 'uint32x4', 'SIMD.Uint32x4(1, 2, 3, 4)'); |
| 44 testMirror('Uint16x8', 'uint16x8', |
| 45 'SIMD.Uint16x8(1, 2, 3, 4, 5, 6, 7, 8)'); |
| 46 testMirror('Uint8x16', 'uint8x16', |
| 47 'SIMD.Uint8x16(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)'); |
| 48 |
| 49 testMirror('Bool32x4', 'bool32x4', 'SIMD.Bool32x4(true, false, true, false)'); |
| 50 testMirror('Bool16x8', 'bool16x8', |
| 51 'SIMD.Bool16x8(true, false, true, false, true, false, true, false)'); |
| 52 testMirror('Bool8x16', 'bool8x16', |
| 53 'SIMD.Bool8x16(true, false, true, false, true, false, true, false, ' + |
| 54 'true, false, true, false, true, false, true, false)'); |
| OLD | NEW |