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 176951 8cef7a6e9f7980dfc08a0e8d678e741b9f6c1669
parent 176950 479bf4aa1f975f539e10de6e5c5c6b5b620702ac
child 176952 9517fe15e2c20adc58a200394f8ad6aa8945fdf5
push id26538
push userryanvm@gmail.com
push dateThu, 03 Apr 2014 19:23:59 +0000
treeherdermozilla-central@6c924a018540 [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);