| 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 |
/*--- |
| 5 |
es6id: 18.2.2 |
| 6 |
esid: sec-isfinite-number |
| 7 |
description: > |
| 8 |
Throws a TypeError if the result of calling number.@@toPrimitive is an Object |
| 9 |
info: | |
| 10 |
isFinite (number) |
| 11 |
|
| 12 |
1. Let num be ? ToNumber(number). |
| 13 |
|
| 14 |
ToPrimitive ( input [ , PreferredType ] ) |
| 15 |
|
| 16 |
[...] |
| 17 |
4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). |
| 18 |
5. If exoticToPrim is not undefined, then |
| 19 |
a. Let result be ? Call(exoticToPrim, input, « hint »). |
| 20 |
b. If Type(result) is not Object, return result. |
| 21 |
c. Throw a TypeError exception. |
| 22 |
features: [Symbol.toPrimitive] |
| 23 |
---*/ |
| 24 |
|
| 25 |
var obj = {}; |
| 26 |
obj[Symbol.toPrimitive] = function() { |
| 27 |
return [42]; |
| 28 |
}; |
| 29 |
|
| 30 |
assert.throws(TypeError, function() { |
| 31 |
isFinite(obj); |
| 32 |
}); |