Bug 989204 part 1 - Add some arrow function tests. r=jorendorff

--HG--
extra : rebase_source : 0b3c9ddd82621fd76e7d48559f339cdea6c40a76
This commit is contained in:
Jan de Mooij 2014-04-03 11:18:32 +02:00
parent 63d14af0e7
commit 89770a3cea
3 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,4 @@
var f = x => arguments.callee;
for (var i=0; i<5; i++)
assertEq(f(), f);

View File

@ -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);
}

View File

@ -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);