Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1 | // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | |
| 6 | (function TestGetter() { |
| 7 | var o = { |
| 8 | get x() {} |
| 9 | }; |
| 10 | var desc = Object.getOwnPropertyDescriptor(o, 'x'); |
| 11 | assertEquals('function', typeof desc.get); |
| 12 | assertFalse('prototype' in desc.get); |
| 13 | |
| 14 | assertThrows(function() { |
| 15 | new desc.get(); |
| 16 | }, TypeError); |
| 17 | })(); |
| 18 | |
| 19 | |
| 20 | (function TestSetter() { |
| 21 | var o = { |
| 22 | set x(_) {} |
| 23 | }; |
| 24 | var desc = Object.getOwnPropertyDescriptor(o, 'x'); |
| 25 | assertEquals('function', typeof desc.set); |
| 26 | assertFalse('prototype' in desc.set); |
| 27 | |
| 28 | assertThrows(function() { |
| 29 | new desc.set(); |
| 30 | }, TypeError); |
| 31 | })(); |
| 32 | |
| 33 | |
| 34 | (function TestBoth() { |
| 35 | var o = { |
| 36 | get x() {}, |
| 37 | set x(_) {} |
| 38 | }; |
| 39 | var desc = Object.getOwnPropertyDescriptor(o, 'x'); |
| 40 | assertEquals('function', typeof desc.get); |
| 41 | assertEquals('function', typeof desc.set); |
| 42 | assertFalse('prototype' in desc.get); |
| 43 | assertFalse('prototype' in desc.set); |
| 44 | |
| 45 | assertThrows(function() { |
| 46 | new desc.get(); |
| 47 | }, TypeError); |
| 48 | assertThrows(function() { |
| 49 | new desc.set(); |
| 50 | }, TypeError); |
| 51 | })(); |