| 1 |
// Copyright (C) 2016 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
/*--- |
| 4 |
esid: sec-date-value |
| 5 |
es6id: 20.3.2.2 |
| 6 |
description: Error retrieving `Symbol.toPrimitive` method from object value |
| 7 |
info: | |
| 8 |
3. If NewTarget is not undefined, then |
| 9 |
[...] |
| 10 |
c. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%DatePrototype%", |
| 11 |
« [[DateValue]] »). |
| 12 |
[...] |
| 13 |
|
| 14 |
OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , |
| 15 |
internalSlotsList ] ) |
| 16 |
|
| 17 |
[...] |
| 18 |
2. Let proto be ? GetPrototypeFromConstructor(constructor, |
| 19 |
intrinsicDefaultProto). |
| 20 |
3. Return ObjectCreate(proto, internalSlotsList). |
| 21 |
features: [Reflect] |
| 22 |
---*/ |
| 23 |
|
| 24 |
var callCount = 0; |
| 25 |
var Ctor = function() { |
| 26 |
callCount += 1; |
| 27 |
}; |
| 28 |
var instance; |
| 29 |
|
| 30 |
instance = Reflect.construct(Date, [64], Ctor); |
| 31 |
|
| 32 |
assert.sameValue( |
| 33 |
Object.getPrototypeOf(instance), |
| 34 |
Ctor.prototype, |
| 35 |
'constructor defines an object `prototype` property' |
| 36 |
); |
| 37 |
assert.sameValue(callCount, 0, 'constructor not invoked'); |
| 38 |
assert.sameValue( |
| 39 |
Date.prototype.getTime.call(instance), |
| 40 |
64, |
| 41 |
'proper subclass has a [[DateValue]] slot' |
| 42 |
); |
| 43 |
|
| 44 |
Ctor.prototype = null; |
| 45 |
instance = Reflect.construct(Date, [64], Ctor); |
| 46 |
|
| 47 |
assert.sameValue( |
| 48 |
Object.getPrototypeOf(instance), |
| 49 |
Date.prototype, |
| 50 |
'constructor does not defines an object `prototype` property' |
| 51 |
); |
| 52 |
assert.sameValue(callCount, 0, 'constructor not invoked'); |
| 53 |
assert.sameValue( |
| 54 |
instance.getTime(), 64, 'direct instance has a [[DateValue]] slot' |
| 55 |
); |