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