]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - tests/stress/fold-multi-get-by-offset-to-get-by-offset-without-folding-the-structure-check.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / fold-multi-get-by-offset-to-get-by-offset-without-folding-the-structure-check.js
diff --git a/tests/stress/fold-multi-get-by-offset-to-get-by-offset-without-folding-the-structure-check.js b/tests/stress/fold-multi-get-by-offset-to-get-by-offset-without-folding-the-structure-check.js
new file mode 100644 (file)
index 0000000..56c35a0
--- /dev/null
@@ -0,0 +1,50 @@
+function foo(o) {
+    return o.f;
+}
+
+function fu(o) {
+    return o.e;
+}
+
+function bar(f, o) {
+    return f(o);
+}
+
+function baz(f, o) {
+    return f(o);
+}
+
+for (var i = 0; i < 100; ++i) {
+    foo({f:1, e:2});
+    foo({e:1, f:2});
+    foo({d:1, e:2, f:3});
+    fu({f:1, e:2});
+    fu({e:1, f:2, g:3});
+    fu({d:1, e:2, f:3, g:4});
+}
+    
+for (var i = 0; i < 100; ++i) {
+    bar(foo, {f:1});
+    bar(function() { }, null);
+    bar(function() { return 42; }, null);
+    baz(fu, {e:1});
+    baz(function() { }, null);
+    baz(function() { return 42; }, null);
+}
+    
+(function(f, g, o, p) {
+    var result = 0;
+    var n = 1000000;
+    for (var i = 0; i < n; ++i) {
+        var q;
+        if (i == n - 1)
+            q = p;
+        else
+            q = o;
+        result += baz(g, q);
+        result += bar(f, q);
+    }
+    if (result != (n - 1) * (o.f + o.e) + 12 + 13)
+        throw "Error: bad result: " + result;
+})(foo, fu, {f:42, e:2}, {e:12, f:13, g:14});
+