зеркало из https://github.com/mozilla/gecko-dev.git
Bug 989204 part 1 - Add some arrow function tests. r=jorendorff
--HG-- extra : rebase_source : 0b3c9ddd82621fd76e7d48559f339cdea6c40a76
This commit is contained in:
Родитель
c30f51eb9e
Коммит
85c24c792c
|
@ -0,0 +1,4 @@
|
||||||
|
var f = x => arguments.callee;
|
||||||
|
|
||||||
|
for (var i=0; i<5; i++)
|
||||||
|
assertEq(f(), f);
|
|
@ -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);
|
||||||
|
}
|
|
@ -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);
|
Загрузка…
Ссылка в новой задаче