1f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org // Copyright 2014 the V8 project authors. All rights reserved.
2f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org// Use of this source code is governed by a BSD-style license that can be
3f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org// found in the LICENSE file.
4f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org
5f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org// Flags: --allow-natives-syntax --debug-code --gc-interval=201 --verify-heap --max-inlined-source-size=999999 --max-inlined-nodes=999999 --max-inlined-nodes-cumulative=999999
6f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org
7f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org// Begin stripped down and modified version of mjsunit.js for easy minimization in CF.
8f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgfunction MjsUnitAssertionError(message) {}
9f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgMjsUnitAssertionError.prototype.toString = function () { return this.message; };
10f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar assertSame;
11f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar assertEquals;
12f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar assertEqualsDelta;
13f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar assertArrayEquals;
14f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar assertPropertiesEqual;
15f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar assertToStringEquals;
16f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar assertTrue;
17f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar assertFalse;
18f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar triggerAssertFalse;
19f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar assertNull;
20f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar assertNotNull;
21f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar assertThrows;
22f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar assertDoesNotThrow;
23f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar assertInstanceof;
24f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar assertUnreachable;
25f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar assertOptimized;
26f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar assertUnoptimized;
27f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgfunction classOf(object) { var string = Object.prototype.toString.call(object); return string.substring(8, string.length - 1); }
28f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgfunction PrettyPrint(value) { return ""; }
29f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgfunction PrettyPrintArrayElement(value, index, array) { return ""; }
30f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgfunction fail(expectedText, found, name_opt) { }
31f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgfunction deepObjectEquals(a, b) { var aProps = Object.keys(a); aProps.sort(); var bProps = Object.keys(b); bProps.sort(); if (!deepEquals(aProps, bProps)) { return false; } for (var i = 0; i < aProps.length; i++) { if (!deepEquals(a[aProps[i]], b[aProps[i]])) { return false; } } return true; }
32f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgfunction 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 == "number") return isNaN(a) && isNaN(b); if (typeof a !== "object" && typeof a !== "function") return false; var objectClass = classOf(a); if (objectClass !== classOf(b)) return false; if (objectClass === "RegExp") { return (a.toString() === b.toString()); } if (objectClass === "Function") return false; if (objectClass === "Array") { 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; } return true; } if (objectClass == "String" || objectClass == "Number" || objectClass == "Boolean" || objectClass == "Date") { if (a.valueOf() !== b.valueOf()) return false; } return deepObjectEquals(a, b); }
33f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgassertSame = function assertSame(expected, found, name_opt) { if (found === expected) { if (expected !== 0 || (1 / expected) == (1 / found)) return; } else if ((expected !== expected) && (found !== found)) { return; } fail(PrettyPrint(expected), found, name_opt); }; assertEquals = function assertEquals(expected, found, name_opt) { if (!deepEquals(found, expected)) { fail(PrettyPrint(expected), found, name_opt); } };
34f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgassertEqualsDelta = function assertEqualsDelta(expected, found, delta, name_opt) { assertTrue(Math.abs(expected - found) <= delta, name_opt); }; assertArrayEquals = function assertArrayEquals(expected, found, name_opt) { var start = ""; if (name_opt) { start = name_opt + " - "; } assertEquals(expected.length, found.length, start + "array length"); if (expected.length == found.length) { for (var i = 0; i < expected.length; ++i) { assertEquals(expected[i], found[i], start + "array element at index " + i); } } };
35f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgassertPropertiesEqual = function assertPropertiesEqual(expected, found, name_opt) { if (!deepObjectEquals(expected, found)) { fail(expected, found, name_opt); } };
36f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgassertToStringEquals = function assertToStringEquals(expected, found, name_opt) { if (expected != String(found)) { fail(expected, found, name_opt); } };
37f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgassertTrue = function assertTrue(value, name_opt) { assertEquals(true, value, name_opt); };
38f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgassertFalse = function assertFalse(value, name_opt) { assertEquals(false, value, name_opt); };
39f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org
40f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgassertNull = function assertNull(value, name_opt) { if (value !== null) { fail("null", value, name_opt); } };
41f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgassertNotNull = function assertNotNull(value, name_opt) { if (value === null) { fail("not null", value, name_opt); } };
42f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgas1sertThrows = function assertThrows(code, type_opt, cause_opt) { var threwException = true; try { if (typeof code == 'function') { code(); } else { eval(code); } threwException = false; } catch (e) { if (typeof type_opt == 'function') { assertInstanceof(e, type_opt); } if (arguments.length >= 3) { assertEquals(e.type, cause_opt); } return; } };
43f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgassertInstanceof = function assertInstanceof(obj, type) { if (!(obj instanceof type)) { var actualTypeName = null; var actualConstructor = Object.getPrototypeOf(obj).constructor; if (typeof actualConstructor == "function") { actualTypeName = actualConstructor.name || String(actualConstructor); } fail("Object <" + PrettyPrint(obj) + "> is not an instance of <" + (type.name || type) + ">" + (actualTypeName ? " but of < " + actualTypeName + ">" : "")); } };
44f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgassertDoesNotThrow = function assertDoesNotThrow(code, name_opt) { try { if (typeof code == 'function') { code(); } else { eval(code); } } catch (e) { fail("threw an exception: ", e.message || e, name_opt); } };
45f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgassertUnreachable = function assertUnreachable(name_opt) { var message = "Fail" + "ure: unreachable"; if (name_opt) { message += " - " + name_opt; } };
46f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar OptimizationStatus;
47f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgtry { OptimizationStatus = new Function("fun", "sync", "return %GetOptimizationStatus(fun, sync);"); } catch (e) { OptimizationStatus = function() { } }
48f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgassertUnoptimized = function assertUnoptimized(fun, sync_opt, name_opt) { if (sync_opt === undefined) sync_opt = ""; assertTrue(OptimizationStatus(fun, sync_opt) != 1, name_opt); }
49f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgassertOptimized = function assertOptimized(fun, sync_opt, name_opt) { if (sync_opt === undefined) sync_opt = "";  assertTrue(OptimizationStatus(fun, sync_opt) != 2, name_opt); }
50f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgtriggerAssertFalse = function() { }
51f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org// End stripped down and modified version of mjsunit.js.
52f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org
53f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar __v_1 = {};
54f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar __v_2 = {};
55f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar __v_3 = {};
56f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar __v_4 = {};
57f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar __v_5 = {};
58f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar __v_6 = {};
59f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar __v_7 = {};
60f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar __v_8 = {};
61f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar __v_9 = {};
62f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar __v_10 = {};
63f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar __v_0 = 'fisk';
64f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgassertEquals('fisk', __v_0);
65f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar __v_0;
66f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgassertEquals('fisk', __v_0);
67f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgvar __v_6 = 'hest';
68f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgassertEquals('hest', __v_0);
69f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgthis.bar = 'fisk';
70f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgassertEquals('fisk', __v_1);
71f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org__v_1;
72f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgassertEquals('fisk', __v_1);
73f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org__v_1 = 'hest';
74f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgassertEquals('hest', __v_1);
75f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org
76f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgfunction __f_0(o) {
77f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org  o.g();
78f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org  if (!o.g()) {
79f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org    assertTrue(false);
80f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org  }
81f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org}
82f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org__v_4 = {};
83f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org__v_4.size = function() { return 42; }
84f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org__v_4.g = function() { return this.size(); };
85f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org__f_0({g: __v_4.g, size:__v_4.size});
86f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.orgfor (var __v_0 = 0; __v_0 < 5; __v_0++) __f_0(__v_4);
87f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org%OptimizeFunctionOnNextCall(__f_0);
88f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org__f_0(__v_4);
89f5a24546072ecdbbd6372c85c42157e01e913561titzer@chromium.org__f_0({g: __v_4.g, size:__v_4.size});
90