diff options
Diffstat (limited to 'deps/v8/test/mjsunit/harmony/computed-property-names-classes.js')
-rw-r--r-- | deps/v8/test/mjsunit/harmony/computed-property-names-classes.js | 131 |
1 files changed, 103 insertions, 28 deletions
diff --git a/deps/v8/test/mjsunit/harmony/computed-property-names-classes.js b/deps/v8/test/mjsunit/harmony/computed-property-names-classes.js index 4e50f8a461..ab5d39e867 100644 --- a/deps/v8/test/mjsunit/harmony/computed-property-names-classes.js +++ b/deps/v8/test/mjsunit/harmony/computed-property-names-classes.js @@ -312,41 +312,74 @@ function assertIteratorResult(value, done, result) { (function TestPrototype() { - // Normally a static prototype property is not allowed. - class C { - static ['prototype']() { - return 1; + assertThrows(function() { + class C { + static ['prototype']() { + return 1; + } } - } - assertEquals(1, C.prototype()); + }, TypeError); - class C2 { - static get ['prototype']() { - return 2; + assertThrows(function() { + class C2 { + static get ['prototype']() { + return 2; + } } - } - assertEquals(2, C2.prototype); + }, TypeError); - var calls = 0; - class C3 { - static set ['prototype'](x) { - assertEquals(3, x); - calls++; + assertThrows(function() { + class C3 { + static set ['prototype'](x) { + assertEquals(3, x); + } } - } - C3.prototype = 3; - assertEquals(1, calls); + }, TypeError); + + assertThrows(function() { + class C4 { + static *['prototype']() { + yield 1; + yield 2; + } + } + }, TypeError); +})(); - class C4 { - static *['prototype']() { - yield 1; - yield 2; + +(function TestPrototypeConcat() { + assertThrows(function() { + class C { + static ['pro' + 'tot' + 'ype']() { + return 1; + } } - } - var iter = C4.prototype(); - assertIteratorResult(1, false, iter.next()); - assertIteratorResult(2, false, iter.next()); - assertIteratorResult(undefined, true, iter.next()); + }, TypeError); + + assertThrows(function() { + class C2 { + static get ['pro' + 'tot' + 'ype']() { + return 2; + } + } + }, TypeError); + + assertThrows(function() { + class C3 { + static set ['pro' + 'tot' + 'ype'](x) { + assertEquals(3, x); + } + } + }, TypeError); + + assertThrows(function() { + class C4 { + static *['pro' + 'tot' + 'ype']() { + yield 1; + yield 2; + } + } + }, TypeError); })(); @@ -388,3 +421,45 @@ function assertIteratorResult(value, done, result) { assertIteratorResult(2, false, iter.next()); assertIteratorResult(undefined, true, iter.next()); })(); + + +(function TestExceptionInName() { + function MyError() {}; + function throwMyError() { + throw new MyError(); + } + assertThrows(function() { + class C { + [throwMyError()]() {} + } + }, MyError); + assertThrows(function() { + class C { + get [throwMyError()]() { return 42; } + } + }, MyError); + assertThrows(function() { + class C { + set [throwMyError()](_) { } + } + }, MyError); +})(); + + +(function TestTdzName() { + assertThrows(function() { + class C { + [C]() {} + } + }, ReferenceError); + assertThrows(function() { + class C { + get [C]() { return 42; } + } + }, ReferenceError); + assertThrows(function() { + class C { + set [C](_) { } + } + }, ReferenceError); +})(); |