]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - tests/stress/singleton-scope-then-realloc-and-overwrite.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / singleton-scope-then-realloc-and-overwrite.js
diff --git a/tests/stress/singleton-scope-then-realloc-and-overwrite.js b/tests/stress/singleton-scope-then-realloc-and-overwrite.js
new file mode 100644 (file)
index 0000000..d15c579
--- /dev/null
@@ -0,0 +1,20 @@
+function foo(a) {
+    var x = a + 1;
+    return function(a) {
+        return x + a;
+    };
+}
+
+var f = foo(42);
+noInline(f);
+
+for (var i = 0; i < 10000; ++i) {
+    var result = f(i);
+    if (result != 42 + 1 + i)
+        throw "Error: bad result: " + result;
+}
+
+var f = foo(43);
+var result = f(1);
+if (result != 43 + 1 + 1)
+    throw "Error: bad result: " + result;