Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/isNaN/toprimitive-result-is-object-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.3
6 esid: sec-isnan-number
7 description: >
8 Throws a TypeError if the result of calling number.@@toPrimitive is an Object
9 info: |
10 isNaN (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 isNaN(obj);
32 });