Bug 989204 part 1 - Add some arrow function tests. r=jorendorff
authorJan de Mooij <jdemooij@mozilla.com>
Thu, 03 Apr 2014 11:18:32 +0200
changeset 176857 8cef7a6e9f7980dfc08a0e8d678e741b9f6c1669
parent 176856 479bf4aa1f975f539e10de6e5c5c6b5b620702ac
child 176858 9517fe15e2c20adc58a200394f8ad6aa8945fdf5
push id41865
push userjandemooij@gmail.com
push dateThu, 03 Apr 2014 09:36:24 +0000
treeherdermozilla-inbound@9517fe15e2c2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs989204
milestone31.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 989204 part 1 - Add some arrow function tests. r=jorendorff
js/src/jit-test/tests/arrow-functions/bug889158.js
js/src/jit-test/tests/arrow-functions/this-5.js
js/src/jit-test/tests/arrow-functions/this-6.js
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/arrow-functions/bug889158.js
@@ -0,0 +1,4 @@
+var f = x => arguments.callee;
+
+for (var i=0; i<5; i++)
+    assertEq(f(), f);
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/arrow-functions/this-5.js
@@ -0,0 +1,12 @@
+// Arrow functions can have primitive |this| values.
+
+Number.prototype.foo = function() {
+    "use strict";
+    return () => this;
+}
+
+for (var i=0; i<5; i++) {
+    var n = i.foo()();
+    assertEq(typeof n, "number");
+    assertEq(n, i);
+}
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/arrow-functions/this-6.js
@@ -0,0 +1,11 @@
+// Eval expressions in arrow functions use the correct |this| value.
+
+function Dog(name) {
+    this.name = name;
+    this.getName = () => eval("this.name");
+    this.getNameHard = () => eval("(() => this.name)()");
+}
+
+var d = new Dog("Max");
+assertEq(d.getName(), d.name);
+assertEq(d.getNameHard(), d.name);