summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/testMissingProperties.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jit-test/tests/basic/testMissingProperties.js')
-rw-r--r--js/src/jit-test/tests/basic/testMissingProperties.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/basic/testMissingProperties.js b/js/src/jit-test/tests/basic/testMissingProperties.js
new file mode 100644
index 000000000..71512c6f5
--- /dev/null
+++ b/js/src/jit-test/tests/basic/testMissingProperties.js
@@ -0,0 +1,49 @@
+function isnan(n) { return n !== n }
+
+function f(x) {
+ var sum = 0;
+ for (var i = 0; i < 100; ++i)
+ sum += x.x;
+ return sum;
+}
+var o = {};
+assertEq(isnan(f(o)), true);
+o.x = 1;
+assertEq(f(o), 100);
+var o = {a:1, b:2};
+assertEq(isnan(f(o)), true);
+o.x = 2;
+assertEq(f(o), 200);
+
+function g(x) {
+ var sum = 0;
+ for (var i = 0; i < 100; ++i)
+ sum += x.x;
+ return sum;
+}
+var o = {c:1, x:1};
+assertEq(g(o), 100);
+var o = {};
+assertEq(isnan(g(o)), true);
+
+function h(x) {
+ var sum = 0;
+ for (var i = 0; i < 100; ++i)
+ sum += x.x;
+ return sum;
+}
+
+var proto1 = {};
+var proto2 = Object.create(proto1);
+var o = Object.create(proto2);
+assertEq(isnan(f(o)), true);
+assertEq(isnan(g(o)), true);
+assertEq(isnan(h(o)), true);
+proto2.x = 2;
+assertEq(f(o), 200);
+assertEq(g(o), 200);
+assertEq(h(o), 200);
+var o = {}
+assertEq(isnan(f(o)), true);
+assertEq(isnan(g(o)), true);
+assertEq(isnan(h(o)), true);