mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 23:09:08 +00:00
51 lines
811 B
JavaScript
51 lines
811 B
JavaScript
load("test-common.js");
|
|
|
|
try {
|
|
function Foo() { this.x = 1; }
|
|
|
|
let foo = new Foo();
|
|
assert(foo.x === 1);
|
|
|
|
foo = new Foo
|
|
assert(foo.x === 1);
|
|
|
|
foo = new
|
|
Foo
|
|
()
|
|
assert(foo.x === 1);
|
|
|
|
foo = new Foo + 2
|
|
assert(foo === "[object Object]2");
|
|
|
|
let a = {
|
|
b: function() {
|
|
this.x = 2;
|
|
},
|
|
};
|
|
|
|
foo = new a.b();
|
|
assert(foo.x === 2);
|
|
|
|
foo = new a.b;
|
|
assert(foo.x === 2);
|
|
|
|
foo = new
|
|
a.b();
|
|
assert(foo.x === 2);
|
|
|
|
function funcGetter() {
|
|
return function(a, b) {
|
|
this.x = a + b;
|
|
};
|
|
};
|
|
|
|
foo = new funcGetter()(1, 5);
|
|
assert(foo === undefined);
|
|
|
|
foo = new (funcGetter())(1, 5);
|
|
assert(foo.x === 6);
|
|
|
|
console.log("PASS");
|
|
} catch (e) {
|
|
console.log("FAIL: " + e);
|
|
}
|