Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/isFinite/toprimitive-result-is-symbol-throws.js

raw
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 a symbol
9 info: |
10 isFinite (number)
11
12 1. Let num be ? ToNumber(number).
13
14 ToNumber ( argument )
15
16 1. Let primValue be ? ToPrimitive(argument, hint Number).
17 2. Return ? ToNumber(primValue).
18
19 ToPrimitive ( input [ , PreferredType ] )
20
21 [...]
22 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
23 5. If exoticToPrim is not undefined, then
24 a. Let result be ? Call(exoticToPrim, input, « hint »).
25 b. If Type(result) is not Object, return result.
26 features: [Symbol.toPrimitive]
27 ---*/
28
29 var obj = {};
30 obj[Symbol.toPrimitive] = function() {
31 return Symbol.toPrimitive;
32 };
33
34 assert.throws(TypeError, function() {
35 isFinite(obj);
36 });