OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --allow-natives-syntax --expose-gc --stress-compaction --gc-interval=2
55 | 5 // Flags: --allow-natives-syntax --expose-gc --stress-compaction --gc-interval=2
55 |
6 | 6 |
7 function deepEquals(a, b) { if (a === b) { if (a === 0) return (1 / a) === (1 /
b); return true; } if (typeof a != typeof b) return false; if (typeof a == "numb
er") return isNaN(a) && isNaN(b); if (typeof a !== "object" && typeof a !== "fun
ction") return false; var objectClass = classOf(a); if (objectClass !== classOf(
b)) return false; if (objectClass === "RegExp") { return (a.toString() === b.toS
tring()); } if (objectClass === "Function") return false; if (objectClass === "A
rray") { var elementCount = 0; if (a.length != b.length) { return false; } for (
var i = 0; i < a.length; i++) { if (!deepEquals(a[i], b[i])) return false; } ret
urn true; } if (objectClass == "String" || objectClass == "Number" || objectClas
s == "Boolean" || objectClass == "Date") { if (a.valueOf() !== b.valueOf()) retu
rn false; } return deepObjectEquals(a, b); } | 7 function deepEquals(a, b) { if (a === b) { if (a === 0) return (1 / a) === (1 /
b); return true; } if (typeof a != typeof b) return false; if (typeof a == "numb
er") return isNaN(a) && isNaN(b); if (typeof a !== "object" && typeof a !== "fun
ction") return false; var objectClass = classOf(a); if (objectClass !== classOf(
b)) return false; if (objectClass === "RegExp") { return (a.toString() === b.toS
tring()); } if (objectClass === "Function") return false; if (objectClass === "A
rray") { var elementCount = 0; if (a.length != b.length) { return false; } for (
var i = 0; i < a.length; i++) { if (!deepEquals(a[i], b[i])) return false; } ret
urn true; } if (objectClass == "String" || objectClass == "Number" || objectClas
s == "Boolean" || objectClass == "Date") { if (a.valueOf() !== b.valueOf()) retu
rn false; } return deepObjectEquals(a, b); } |
8 assertSame = function assertSame(expected, found, name_opt) { if (found === expe
cted) { if (expected !== 0 || (1 / expected) == (1 / found)) return; } else if (
(expected !== expected) && (found !== found)) { return; } fail(PrettyPrint(expec
ted), found, name_opt); }; assertEquals = function assertEquals(expected, found,
name_opt) { if (!deepEquals(found, expected)) { fail(PrettyPrint(expected), fou
nd, name_opt); } }; | 8 assertSame = function assertSame(expected, found, name_opt) { if (found === expe
cted) { if (expected !== 0 || (1 / expected) == (1 / found)) return; } else if (
(expected !== expected) && (found !== found)) { return; } fail(PrettyPrint(expec
ted), found, name_opt); }; assertEquals = function assertEquals(expected, found,
name_opt) { if (!deepEquals(found, expected)) { fail(PrettyPrint(expected), fou
nd, name_opt); } }; |
9 assertEqualsDelta = function assertEqualsDelta(expected, found, delta, name_opt)
{ assertTrue(Math.abs(expected - found) <= delta, name_opt); }; assertArrayEqua
ls = function assertArrayEquals(expected, found, name_opt) { var start = ""; if
(name_opt) { start = name_opt + " - "; } assertEquals(expected.length, found.len
gth, start + "array length"); if (expected.length == found.length) { for (var i
= 0; i < expected.length; ++i) { assertEquals(expected[i], found[i], start + "ar
ray element at index " + i); } } }; | 9 assertEqualsDelta = function assertEqualsDelta(expected, found, delta, name_opt)
{ assertTrue(Math.abs(expected - found) <= delta, name_opt); }; assertArrayEqua
ls = function assertArrayEquals(expected, found, name_opt) { var start = ""; if
(name_opt) { start = name_opt + " - "; } assertEquals(expected.length, found.len
gth, start + "array length"); if (expected.length == found.length) { for (var i
= 0; i < expected.length; ++i) { assertEquals(expected[i], found[i], start + "ar
ray element at index " + i); } } }; |
10 assertTrue = function assertTrue(value, name_opt) { assertEquals(true, value, na
me_opt); }; | 10 assertTrue = function assertTrue(value, name_opt) { assertEquals(true, value, na
me_opt); }; |
(...skipping 12 matching lines...) Expand all Loading... |
23 (new __f_3()).__proto__ = __v_1; | 23 (new __f_3()).__proto__ = __v_1; |
24 } | 24 } |
25 %DebugPrint(undefined); | 25 %DebugPrint(undefined); |
26 function __f_1(__v_4, add_first, __v_6, same_map_as) { | 26 function __f_1(__v_4, add_first, __v_6, same_map_as) { |
27 var __v_1 = __v_4 ? new __f_3() : {}; | 27 var __v_1 = __v_4 ? new __f_3() : {}; |
28 assertTrue(%HasFastProperties(__v_1)); | 28 assertTrue(%HasFastProperties(__v_1)); |
29 if (add_first) { | 29 if (add_first) { |
30 __f_4(__v_1); | 30 __f_4(__v_1); |
31 assertFalse(%HasFastProperties(__v_1)); | 31 assertFalse(%HasFastProperties(__v_1)); |
32 __f_0(__v_1, __v_6); | 32 __f_0(__v_1, __v_6); |
33 assertTrue(%HasFastProperties(__v_1)); | 33 assertFalse(%HasFastProperties(__v_1)); |
34 } else { | 34 } else { |
35 __f_0(__v_1, __v_6); | 35 __f_0(__v_1, __v_6); |
36 assertTrue(%HasFastProperties(__v_1)); | 36 assertTrue(%HasFastProperties(__v_1)); |
37 __f_4(__v_1); | 37 __f_4(__v_1); |
38 assertTrue(%HasFastProperties(__v_1)); | 38 assertTrue(%HasFastProperties(__v_1)); |
39 } | 39 } |
40 } | 40 } |
41 gc(); | 41 gc(); |
42 for (var __v_2 = 0; __v_2 < 4; __v_2++) { | 42 for (var __v_2 = 0; __v_2 < 4; __v_2++) { |
43 var __v_6 = ((__v_2 & 2) != 7); | 43 var __v_6 = ((__v_2 & 2) != 7); |
44 var __v_4 = ((__v_2 & 2) != 0); | 44 var __v_4 = ((__v_2 & 2) != 0); |
45 __f_1(__v_4, true, __v_6); | 45 __f_1(__v_4, true, __v_6); |
46 var __v_0 = __f_1(__v_4, false, __v_6); | 46 var __v_0 = __f_1(__v_4, false, __v_6); |
47 __f_1(__v_4, false, __v_6, __v_0); | 47 __f_1(__v_4, false, __v_6, __v_0); |
48 } | 48 } |
49 __v_5 = {a: 1, b: 2, c: 3}; | 49 __v_5 = {a: 1, b: 2, c: 3}; |
OLD | NEW |