Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Number/S9.3.1_A3_T2_U180E.js

raw
1 // Copyright 2016 André Bargull. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-tonumber-applied-to-the-string-type
6 description: >
7 Ensure U+180E is not recognized as whitespace, test ToNumber with dynamic string
8 info: |
9 7.1.3.1 ToNumber Applied to the String Type
10
11 If the grammar cannot interpret the String as an expansion of
12 StringNumericLiteral, then the result of ToNumber is NaN.
13
14 StringNumericLiteral :::
15 StrWhiteSpace_opt StrNumericLiteral StrWhiteSpace_opt
16 StrWhiteSpace :::
17 StrWhiteSpaceChar StrWhiteSpace_opt
18 StrWhiteSpaceChar :::
19 WhiteSpace
20 LineTerminator
21 WhiteSpace ::
22 <TAB>
23 <VT>
24 <FF>
25 <SP>
26 <NBSP>
27 <ZWNBSP>
28 <USP>
29 <USP> ::
30 Other category “Zs” code points
31 features: [u180e]
32 ---*/
33
34 function dynaString(s1, s2) {
35 return String(s1) + String(s2);
36 }
37
38 // CHECK#1
39 assert.sameValue(Number(dynaString("", "\u180E")), NaN, 'Number(dynaString("", "\u180E")) === NaN');
40
41 // CHECK#2
42 assert.sameValue(+(dynaString("12345", "67890\u180E")), NaN, '+(dynaString("12345", "67890\u180E")) === NaN');
43
44 // CHECK#3
45 assert.sameValue(Number(dynaString("Infi", "nity\u180E")), NaN, 'Number(dynaString("Infi", "nity\u180E")) === NaN');
46
47 // CHECK#4
48 assert.sameValue(Number(dynaString("-Infi", "nity\u180E")), NaN, 'Number(dynaString("-Infi", "nity\u180E")) === NaN');