1a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Copyright 2008 the V8 project authors. All rights reserved.
2a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Redistribution and use in source and binary forms, with or without
3a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// modification, are permitted provided that the following conditions are
4a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// met:
5a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//
6a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//     * Redistributions of source code must retain the above copyright
7a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       notice, this list of conditions and the following disclaimer.
8a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//     * Redistributions in binary form must reproduce the above
9a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       copyright notice, this list of conditions and the following
10a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       disclaimer in the documentation and/or other materials provided
11a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       with the distribution.
12a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//     * Neither the name of Google Inc. nor the names of its
13a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       contributors may be used to endorse or promote products derived
14a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       from this software without specific prior written permission.
15a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//
16a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
28a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockfunction toNumber(val) {
29a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  return Number(val);
30a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}
31a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
326ded16be15dd865a9b21ea304d5273c8be299c87Steve Blockfunction repeat(s, num) {
336ded16be15dd865a9b21ea304d5273c8be299c87Steve Block  var result = '';
346ded16be15dd865a9b21ea304d5273c8be299c87Steve Block  while (num > 0) {
356ded16be15dd865a9b21ea304d5273c8be299c87Steve Block    if ((num & 1) != 0) result += s;
366ded16be15dd865a9b21ea304d5273c8be299c87Steve Block    s += s;
376ded16be15dd865a9b21ea304d5273c8be299c87Steve Block    num >>= 1;
386ded16be15dd865a9b21ea304d5273c8be299c87Steve Block  }
396ded16be15dd865a9b21ea304d5273c8be299c87Steve Block
406ded16be15dd865a9b21ea304d5273c8be299c87Steve Block  return result;
416ded16be15dd865a9b21ea304d5273c8be299c87Steve Block}
42a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
436ded16be15dd865a9b21ea304d5273c8be299c87Steve BlockassertEquals('0000000000', repeat('0', 10));
446ded16be15dd865a9b21ea304d5273c8be299c87Steve Block
456ded16be15dd865a9b21ea304d5273c8be299c87Steve Block// assertEquals(, toNumber());
46a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
47a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(123, toNumber(" 123"));
48a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(123, toNumber("\n123"));
49a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(123, toNumber("\r123"));
50a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(123, toNumber("\t123"));
51a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(123, toNumber("\f123"));
52a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
53a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(123, toNumber("123 "));
54a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(123, toNumber("123\n"));
55a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(123, toNumber("123\r"));
56a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(123, toNumber("123\t"));
57a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(123, toNumber("123\f"));
58a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
59a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(123, toNumber(" 123 "));
60a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(123, toNumber("\n123\n"));
61a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(123, toNumber("\r123\r"));
62a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(123, toNumber("\t123\t"));
63a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(123, toNumber("\f123\f"));
64a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
656ded16be15dd865a9b21ea304d5273c8be299c87Steve BlockassertEquals(16, toNumber(" 0x10 "));
666ded16be15dd865a9b21ea304d5273c8be299c87Steve BlockassertEquals(NaN, toNumber("0x"));
676ded16be15dd865a9b21ea304d5273c8be299c87Steve BlockassertEquals(NaN, toNumber("0x "));
686ded16be15dd865a9b21ea304d5273c8be299c87Steve Block
69a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertTrue(isNaN(toNumber(" NaN ")));
70a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(Infinity,  toNumber(" Infinity ") ," Infinity");
71a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(-Infinity, toNumber(" -Infinity "));
72a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(Infinity,  toNumber(" +Infinity "), " +Infinity");
73a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(Infinity,  toNumber("Infinity ") ,"Infinity");
74a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(-Infinity, toNumber("-Infinity "));
75a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(Infinity,  toNumber("+Infinity "), "+Infinity");
76a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
77a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(0,  toNumber("0"));
78a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(0,  toNumber("+0"));
79a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(-0, toNumber("-0"));
806ded16be15dd865a9b21ea304d5273c8be299c87Steve BlockassertEquals(-Infinity, 1 / toNumber("-0"));
81a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
82a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(1,  toNumber("1"));
83a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(1,  toNumber("+1"));
84a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(-1, toNumber("-1"));
85a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
86a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(2,  toNumber("2"));
87a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(2,  toNumber("+2"));
88a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(-2, toNumber("-2"));
89a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
90a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(3.1415926,  toNumber("3.1415926"));
91a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(3.1415926,  toNumber("+3.1415926"));
92a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(-3.1415926, toNumber("-3.1415926"));
93a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
94a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(5,  toNumber("5."));
95a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(5,  toNumber("+5."));
96a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(-5, toNumber("-5."));
97a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
98a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(500,   toNumber("5e2"));
99a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(500,   toNumber("+5e2"));
100a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(-500,  toNumber("-5e2"));
101a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(500,   toNumber("5e+2"));
102a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(500,   toNumber("+5e+2"));
103a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(-500,  toNumber("-5e+2"));
104a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(0.05,  toNumber("5e-2"));
105a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(0.05,  toNumber("+5e-2"));
106a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(-0.05, toNumber("-5e-2"));
107a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
108a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(0.00001,   toNumber(".00001"));
109a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(0.00001,   toNumber("+.00001"));
110a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(-0.00001,  toNumber("-.00001"));
111a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(1,         toNumber(".00001e5"));
112a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(1,         toNumber("+.00001e5"));
113a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(-1,        toNumber("-.00001e5"));
114a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(1,         toNumber(".00001e+5"));
115a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(1,         toNumber("+.00001e+5"));
116a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(-1,        toNumber("-.00001e+5"));
117a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(0.00001,   toNumber(".001e-2"));
118a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(0.00001,   toNumber("+.001e-2"));
119a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(-0.00001,  toNumber("-.001e-2"));
120a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
121a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(12340000,   toNumber("1234e4"));
122a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(12340000,   toNumber("+1234e4"));
123a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(-12340000,  toNumber("-1234e4"));
124a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(12340000,   toNumber("1234e+4"));
125a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(12340000,   toNumber("+1234e+4"));
126a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(-12340000,  toNumber("-1234e+4"));
127a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(0.1234,     toNumber("1234e-4"));
128a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(0.1234,     toNumber("+1234e-4"));
129a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(-0.1234,    toNumber("-1234e-4"));
130a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
131a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(0,  toNumber("0x0"));
132a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(1,  toNumber("0x1"));
133a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(2,  toNumber("0x2"));
134a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(9,  toNumber("0x9"));
135a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(10, toNumber("0xa"));
136a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(11, toNumber("0xb"));
137a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(15, toNumber("0xf"));
138a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(10, toNumber("0xA"));
139a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(11, toNumber("0xB"));
140a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(15, toNumber("0xF"));
141a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
142a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(0,  toNumber("0X0"));
143a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(9,  toNumber("0X9"));
144a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(10, toNumber("0Xa"));
145a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(10, toNumber("0XA"));
146a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(15, toNumber("0Xf"));
147a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(15, toNumber("0XF"));
148a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
149a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(0,  toNumber("0x000"));
1506ded16be15dd865a9b21ea304d5273c8be299c87Steve BlockassertEquals(0,  toNumber("0x000" + repeat('0', 1000)));
151a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(9,  toNumber("0x009"));
152a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(10, toNumber("0x00a"));
153a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(10, toNumber("0x00A"));
154a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(15, toNumber("0x00f"));
155a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(15, toNumber("0x00F"));
1566ded16be15dd865a9b21ea304d5273c8be299c87Steve BlockassertEquals(15, toNumber("0x00F "));
1576ded16be15dd865a9b21ea304d5273c8be299c87Steve BlockassertEquals(Infinity,  toNumber("0x" + repeat('0', 1000) + '1'
1586ded16be15dd865a9b21ea304d5273c8be299c87Steve Block                        + repeat('0', 1000)));
1596ded16be15dd865a9b21ea304d5273c8be299c87Steve Block
1606ded16be15dd865a9b21ea304d5273c8be299c87Steve BlockassertEquals(0x1000000 * 0x10000000, toNumber("0x10000000000000"));
1616ded16be15dd865a9b21ea304d5273c8be299c87Steve BlockassertEquals(0x1000000 * 0x10000000 + 1, toNumber("0x10000000000001"));
1626ded16be15dd865a9b21ea304d5273c8be299c87Steve BlockassertEquals(0x10 * 0x1000000 * 0x10000000, toNumber("0x100000000000000"));
1636ded16be15dd865a9b21ea304d5273c8be299c87Steve BlockassertEquals(0x10 * 0x1000000 * 0x10000000, toNumber("0x100000000000001"));
1646ded16be15dd865a9b21ea304d5273c8be299c87Steve BlockassertEquals(0x10 * 0x1000000 * 0x10000000, toNumber("0x100000000000007"));
1656ded16be15dd865a9b21ea304d5273c8be299c87Steve BlockassertEquals(0x10 * 0x1000000 * 0x10000000, toNumber("0x100000000000008"));
1666ded16be15dd865a9b21ea304d5273c8be299c87Steve BlockassertEquals(0x10 * (0x1000000 * 0x10000000 + 1),
1676ded16be15dd865a9b21ea304d5273c8be299c87Steve Block             toNumber("0x100000000000009"));
1686ded16be15dd865a9b21ea304d5273c8be299c87Steve BlockassertEquals(0x10 * (0x1000000 * 0x10000000 + 1),
1696ded16be15dd865a9b21ea304d5273c8be299c87Steve Block             toNumber("0x10000000000000F"));
1706ded16be15dd865a9b21ea304d5273c8be299c87Steve BlockassertEquals(0x10 * (0x1000000 * 0x10000000 + 1),
1716ded16be15dd865a9b21ea304d5273c8be299c87Steve Block             toNumber("0x100000000000010"));
1726ded16be15dd865a9b21ea304d5273c8be299c87Steve BlockassertEquals(0x100000000000 * 0x1000000 * 0x10000000,
1736ded16be15dd865a9b21ea304d5273c8be299c87Steve Block             toNumber("0x1000000000000000000000000"));
1746ded16be15dd865a9b21ea304d5273c8be299c87Steve BlockassertEquals(0x100000000000 * 0x1000000 * 0x10000000,
1756ded16be15dd865a9b21ea304d5273c8be299c87Steve Block             toNumber("0x1000000000000080000000000"));
1766ded16be15dd865a9b21ea304d5273c8be299c87Steve BlockassertEquals(0x100000000000 * (0x1000000 * 0x10000000 + 1),
1776ded16be15dd865a9b21ea304d5273c8be299c87Steve Block             toNumber("0x1000000000000080000000001"));
1786ded16be15dd865a9b21ea304d5273c8be299c87Steve BlockassertEquals(0x100000000000 * 0x1000000 * 0x10000000,
1796ded16be15dd865a9b21ea304d5273c8be299c87Steve Block             toNumber("  0x1000000000000000000000000  "));
180a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
181a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(0, toNumber("00"));
182a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(1, toNumber("01"));
183a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(2, toNumber("02"));
184a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(10, toNumber("010"));
185a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(100, toNumber("0100"));
186a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(100, toNumber("000100"));
187a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
188a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(Infinity,  toNumber("1e999"), "1e999");
189a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(-Infinity, toNumber("-1e999"));
190a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(0,         toNumber("1e-999"));
19144f0eee88ff00398ff7f715fab053374d808c90dSteve BlockassertEquals(-0,        toNumber("-1e-999"));
192a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(Infinity,  1 / toNumber("1e-999"), "1e-999");
193a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertEquals(-Infinity, 1 / toNumber("-1e-999"));
194a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
195a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertTrue(isNaN(toNumber("junk")), "junk");
196a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertTrue(isNaN(toNumber("100 junk")), "100 junk");
197a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertTrue(isNaN(toNumber("0x100 junk")), "0x100 junk");
198a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertTrue(isNaN(toNumber("100.0 junk")), "100.0 junk");
199a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertTrue(isNaN(toNumber(".1e4 junk")), ".1e4 junk");
200a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockassertTrue(isNaN(toNumber("Infinity junk")), "Infinity junk");
2016ded16be15dd865a9b21ea304d5273c8be299c87Steve BlockassertTrue(isNaN(toNumber("1e")), "1e");
2026ded16be15dd865a9b21ea304d5273c8be299c87Steve BlockassertTrue(isNaN(toNumber("1e ")), "1e_");
2036ded16be15dd865a9b21ea304d5273c8be299c87Steve BlockassertTrue(isNaN(toNumber("1" + repeat('0', 1000) + 'junk')), "1e1000 junk");
2049ac36c9faca11611ada13b4054edbaa0738661d0Iain Merrick
2059ac36c9faca11611ada13b4054edbaa0738661d0Iain Merrickfor (var i = 1; i < 12; i++) {
2069ac36c9faca11611ada13b4054edbaa0738661d0Iain Merrick  assertEquals(toNumber('1' + repeat('0', i)), Math.pow(10.0, i));
2079ac36c9faca11611ada13b4054edbaa0738661d0Iain Merrick}
208b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch
209b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochassertTrue(isNaN(toNumber("+0x0")));
210b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochassertTrue(isNaN(toNumber("+0xFF")));
211b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochassertTrue(isNaN(toNumber("+0x012")));
212b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochassertTrue(isNaN(toNumber("-0x0")));
213b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochassertTrue(isNaN(toNumber("-0xFF")));
214b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochassertTrue(isNaN(toNumber("-0x012")));
215