OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
6 // are met: | 6 // are met: |
7 // 1. Redistributions of source code must retain the above copyright | 7 // 1. Redistributions of source code must retain the above copyright |
8 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
9 // 2. Redistributions in binary form must reproduce the above copyright | 9 // 2. Redistributions in binary form must reproduce the above copyright |
10 // notice, this list of conditions and the following disclaimer in the | 10 // notice, this list of conditions and the following disclaimer in the |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 shouldThrow('x = class extends', '"SyntaxError: Unexpected end of input"'); | 51 shouldThrow('x = class extends', '"SyntaxError: Unexpected end of input"'); |
52 shouldThrow('x = class extends Base {', '"SyntaxError: Unexpected end of input"'
); | 52 shouldThrow('x = class extends Base {', '"SyntaxError: Unexpected end of input"'
); |
53 shouldNotThrow('x = class extends Base { }'); | 53 shouldNotThrow('x = class extends Base { }'); |
54 shouldNotThrow('x = class extends Base { constructor() { } }'); | 54 shouldNotThrow('x = class extends Base { constructor() { } }'); |
55 shouldBe('x.__proto__', 'Base'); | 55 shouldBe('x.__proto__', 'Base'); |
56 shouldBe('Object.getPrototypeOf(x)', 'Base'); | 56 shouldBe('Object.getPrototypeOf(x)', 'Base'); |
57 shouldBe('x.prototype.__proto__', 'Base.prototype'); | 57 shouldBe('x.prototype.__proto__', 'Base.prototype'); |
58 shouldBe('Object.getPrototypeOf(x.prototype)', 'Base.prototype'); | 58 shouldBe('Object.getPrototypeOf(x.prototype)', 'Base.prototype'); |
59 shouldBe('x = class extends null { constructor() { } }; x.__proto__', 'Function.
prototype'); | 59 shouldBe('x = class extends null { constructor() { } }; x.__proto__', 'Function.
prototype'); |
60 shouldBe('x.__proto__', 'Function.prototype'); | 60 shouldBe('x.__proto__', 'Function.prototype'); |
61 shouldThrow('x = class extends 3 { constructor() { } }; x.__proto__', '"TypeErro
r: Class extends value 3 is not a function or null"'); | 61 shouldThrow('x = class extends 3 { constructor() { } }; x.__proto__', '"TypeErro
r: Class extends value 3 is not a constructor or null"'); |
62 shouldThrow('x = class extends "abc" { constructor() { } }; x.__proto__', '"Type
Error: Class extends value abc is not a function or null"'); | 62 shouldThrow('x = class extends "abc" { constructor() { } }; x.__proto__', '"Type
Error: Class extends value abc is not a constructor or null"'); |
63 shouldNotThrow('baseWithBadPrototype = function () {}; baseWithBadPrototype.prot
otype = 3; new baseWithBadPrototype'); | 63 shouldNotThrow('baseWithBadPrototype = function () {}; baseWithBadPrototype.prot
otype = 3; new baseWithBadPrototype'); |
64 shouldThrow('x = class extends baseWithBadPrototype { constructor() { } }', '"Ty
peError: Class extends value does not have valid prototype property 3"'); | 64 shouldThrow('x = class extends baseWithBadPrototype { constructor() { } }', '"Ty
peError: Class extends value does not have valid prototype property 3"'); |
65 shouldNotThrow('baseWithBadPrototype.prototype = "abc"'); | 65 shouldNotThrow('baseWithBadPrototype.prototype = "abc"'); |
66 shouldThrow('x = class extends baseWithBadPrototype { constructor() { } }', '"Ty
peError: Class extends value does not have valid prototype property abc"'); | 66 shouldThrow('x = class extends baseWithBadPrototype { constructor() { } }', '"Ty
peError: Class extends value does not have valid prototype property abc"'); |
67 shouldNotThrow('baseWithBadPrototype.prototype = null; x = class extends baseWit
hBadPrototype { constructor() { } }'); | 67 shouldNotThrow('baseWithBadPrototype.prototype = null; x = class extends baseWit
hBadPrototype { constructor() { } }'); |
68 | 68 |
69 shouldThrow('x = 1; c = class extends ++x { constructor() { } };'); | 69 shouldThrow('x = 1; c = class extends ++x { constructor() { } };'); |
70 shouldThrow('x = 1; c = class extends x++ { constructor() { } };'); | 70 shouldThrow('x = 1; c = class extends x++ { constructor() { } };'); |
71 shouldThrow('x = 1; c = class extends (++x) { constructor() { } };'); | 71 shouldThrow('x = 1; c = class extends (++x) { constructor() { } };'); |
72 shouldThrow('x = 1; c = class extends (x++) { constructor() { } };'); | 72 shouldThrow('x = 1; c = class extends (x++) { constructor() { } };'); |
(...skipping 12 matching lines...) Expand all Loading... |
85 shouldThrow('namespace = {}; namespace.A = class { constructor() { } }; namespac
e.B = class extends false||null||namespace.A { constructor() { } }'); | 85 shouldThrow('namespace = {}; namespace.A = class { constructor() { } }; namespac
e.B = class extends false||null||namespace.A { constructor() { } }'); |
86 shouldNotThrow('x = 1; namespace = {}; namespace.A = class { constructor() { } }
; namespace.B = class extends (x++, namespace.A) { constructor() { } };'); | 86 shouldNotThrow('x = 1; namespace = {}; namespace.A = class { constructor() { } }
; namespace.B = class extends (x++, namespace.A) { constructor() { } };'); |
87 shouldThrow('x = 1; namespace = {}; namespace.A = class { constructor() { } }; n
amespace.B = class extends (namespace.A, x++) { constructor() { } };'); | 87 shouldThrow('x = 1; namespace = {}; namespace.A = class { constructor() { } }; n
amespace.B = class extends (namespace.A, x++) { constructor() { } };'); |
88 shouldThrow('namespace = {}; namespace.A = class { constructor() { } }; namespac
e.B = class extends new namespace.A { constructor() { } }'); | 88 shouldThrow('namespace = {}; namespace.A = class { constructor() { } }; namespac
e.B = class extends new namespace.A { constructor() { } }'); |
89 shouldThrow('namespace = {}; namespace.A = class { constructor() { } }; namespac
e.B = class extends new namespace.A() { constructor() { } }'); | 89 shouldThrow('namespace = {}; namespace.A = class { constructor() { } }; namespac
e.B = class extends new namespace.A() { constructor() { } }'); |
90 shouldBe('x = 1; namespace = {}; namespace.A = class { constructor() { } }; try
{ namespace.B = class extends (x++, namespace.A) { constructor() { } } } catch (
e) { } x', '2'); | 90 shouldBe('x = 1; namespace = {}; namespace.A = class { constructor() { } }; try
{ namespace.B = class extends (x++, namespace.A) { constructor() { } } } catch (
e) { } x', '2'); |
91 shouldBe('x = 1; namespace = {}; namespace.A = class { constructor() { } }; try
{ namespace.B = class extends (namespace.A, x++) { constructor() { } } } catch (
e) { } x', '2'); | 91 shouldBe('x = 1; namespace = {}; namespace.A = class { constructor() { } }; try
{ namespace.B = class extends (namespace.A, x++) { constructor() { } } } catch (
e) { } x', '2'); |
92 | 92 |
93 shouldBe('Object.getPrototypeOf((class { constructor () { } }).prototype)', 'Obj
ect.prototype'); | 93 shouldBe('Object.getPrototypeOf((class { constructor () { } }).prototype)', 'Obj
ect.prototype'); |
94 shouldBe('Object.getPrototypeOf((class extends null { constructor () { super();
} }).prototype)', 'null'); | 94 shouldBe('Object.getPrototypeOf((class extends null { constructor () { super();
} }).prototype)', 'null'); |
95 shouldThrow('new (class extends undefined { constructor () { this } })', '"TypeE
rror: Class extends value undefined is not a function or null"'); | 95 shouldThrow('new (class extends undefined { constructor () { this } })', '"TypeE
rror: Class extends value undefined is not a constructor or null"'); |
96 shouldThrow('new (class extends undefined { constructor () { super(); } })', '"T
ypeError: Class extends value undefined is not a function or null"'); | 96 shouldThrow('new (class extends undefined { constructor () { super(); } })', '"T
ypeError: Class extends value undefined is not a constructor or null"'); |
97 shouldThrow('x = {}; new (class extends undefined { constructor () { return x; }
})', '"TypeError: Class extends value undefined is not a function or null"'); | 97 shouldThrow('x = {}; new (class extends undefined { constructor () { return x; }
})', '"TypeError: Class extends value undefined is not a constructor or null"')
; |
98 shouldThrow('y = 12; new (class extends undefined { constructor () { return y; }
})', '"TypeError: Class extends value undefined is not a function or null"'); | 98 shouldThrow('y = 12; new (class extends undefined { constructor () { return y; }
})', '"TypeError: Class extends value undefined is not a constructor or null"')
; |
99 shouldBeTrue ('class x {}; new (class extends null { constructor () { return new
x; } }) instanceof x'); | 99 shouldBeTrue ('class x {}; new (class extends null { constructor () { return new
x; } }) instanceof x'); |
100 shouldThrow('new (class extends null { constructor () { this; } })', '"Reference
Error: this is not defined"'); | 100 shouldThrow('new (class extends null { constructor () { this; } })', '"Reference
Error: this is not defined"'); |
101 shouldThrow('new (class extends null { constructor () { super(); } })', '"TypeEr
ror: super is not a constructor"'); | 101 shouldThrow('new (class extends null { constructor () { super(); } })', '"TypeEr
ror: super is not a constructor"'); |
102 shouldBe('x = {}; new (class extends null { constructor () { return x } })', 'x'
); | 102 shouldBe('x = {}; new (class extends null { constructor () { return x } })', 'x'
); |
103 shouldThrow('y = 12; new (class extends null { constructor () { return y; } })',
'"TypeError: Derived constructors may only return object or undefined"'); | 103 shouldThrow('y = 12; new (class extends null { constructor () { return y; } })',
'"TypeError: Derived constructors may only return object or undefined"'); |
104 shouldBeTrue ('class x {}; new (class extends null { constructor () { return new
x; } }) instanceof x'); | 104 shouldBeTrue ('class x {}; new (class extends null { constructor () { return new
x; } }) instanceof x'); |
105 shouldBe('x = null; Object.getPrototypeOf((class extends x { }).prototype)', 'nu
ll'); | 105 shouldBe('x = null; Object.getPrototypeOf((class extends x { }).prototype)', 'nu
ll'); |
106 shouldBeTrue('Object.prototype.isPrototypeOf(class { })'); | 106 shouldBeTrue('Object.prototype.isPrototypeOf(class { })'); |
107 shouldBeTrue('Function.prototype.isPrototypeOf(class { })'); | 107 shouldBeTrue('Function.prototype.isPrototypeOf(class { })'); |
108 | 108 |
109 var successfullyParsed = true; | 109 var successfullyParsed = true; |
OLD | NEW |