Debian Codegraph @

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