• Home
  • Raw
  • Download

Lines Matching refs:toNumber

28 function toNumber(val) {  function
47 assertEquals(123, toNumber(" 123"));
48 assertEquals(123, toNumber("\n123"));
49 assertEquals(123, toNumber("\r123"));
50 assertEquals(123, toNumber("\t123"));
51 assertEquals(123, toNumber("\f123"));
53 assertEquals(123, toNumber("123 "));
54 assertEquals(123, toNumber("123\n"));
55 assertEquals(123, toNumber("123\r"));
56 assertEquals(123, toNumber("123\t"));
57 assertEquals(123, toNumber("123\f"));
59 assertEquals(123, toNumber(" 123 "));
60 assertEquals(123, toNumber("\n123\n"));
61 assertEquals(123, toNumber("\r123\r"));
62 assertEquals(123, toNumber("\t123\t"));
63 assertEquals(123, toNumber("\f123\f"));
65 assertEquals(16, toNumber(" 0x10 "));
66 assertEquals(NaN, toNumber("0x"));
67 assertEquals(NaN, toNumber("0x "));
69 assertTrue(isNaN(toNumber(" NaN ")));
70 assertEquals(Infinity, toNumber(" Infinity ") ," Infinity");
71 assertEquals(-Infinity, toNumber(" -Infinity "));
72 assertEquals(Infinity, toNumber(" +Infinity "), " +Infinity");
73 assertEquals(Infinity, toNumber("Infinity ") ,"Infinity");
74 assertEquals(-Infinity, toNumber("-Infinity "));
75 assertEquals(Infinity, toNumber("+Infinity "), "+Infinity");
77 assertEquals(0, toNumber("0"));
78 assertEquals(0, toNumber("+0"));
79 assertEquals(-0, toNumber("-0"));
80 assertEquals(-Infinity, 1 / toNumber("-0"));
82 assertEquals(1, toNumber("1"));
83 assertEquals(1, toNumber("+1"));
84 assertEquals(-1, toNumber("-1"));
86 assertEquals(2, toNumber("2"));
87 assertEquals(2, toNumber("+2"));
88 assertEquals(-2, toNumber("-2"));
90 assertEquals(3.1415926, toNumber("3.1415926"));
91 assertEquals(3.1415926, toNumber("+3.1415926"));
92 assertEquals(-3.1415926, toNumber("-3.1415926"));
94 assertEquals(5, toNumber("5."));
95 assertEquals(5, toNumber("+5."));
96 assertEquals(-5, toNumber("-5."));
98 assertEquals(500, toNumber("5e2"));
99 assertEquals(500, toNumber("+5e2"));
100 assertEquals(-500, toNumber("-5e2"));
101 assertEquals(500, toNumber("5e+2"));
102 assertEquals(500, toNumber("+5e+2"));
103 assertEquals(-500, toNumber("-5e+2"));
104 assertEquals(0.05, toNumber("5e-2"));
105 assertEquals(0.05, toNumber("+5e-2"));
106 assertEquals(-0.05, toNumber("-5e-2"));
108 assertEquals(0.00001, toNumber(".00001"));
109 assertEquals(0.00001, toNumber("+.00001"));
110 assertEquals(-0.00001, toNumber("-.00001"));
111 assertEquals(1, toNumber(".00001e5"));
112 assertEquals(1, toNumber("+.00001e5"));
113 assertEquals(-1, toNumber("-.00001e5"));
114 assertEquals(1, toNumber(".00001e+5"));
115 assertEquals(1, toNumber("+.00001e+5"));
116 assertEquals(-1, toNumber("-.00001e+5"));
117 assertEquals(0.00001, toNumber(".001e-2"));
118 assertEquals(0.00001, toNumber("+.001e-2"));
119 assertEquals(-0.00001, toNumber("-.001e-2"));
121 assertEquals(12340000, toNumber("1234e4"));
122 assertEquals(12340000, toNumber("+1234e4"));
123 assertEquals(-12340000, toNumber("-1234e4"));
124 assertEquals(12340000, toNumber("1234e+4"));
125 assertEquals(12340000, toNumber("+1234e+4"));
126 assertEquals(-12340000, toNumber("-1234e+4"));
127 assertEquals(0.1234, toNumber("1234e-4"));
128 assertEquals(0.1234, toNumber("+1234e-4"));
129 assertEquals(-0.1234, toNumber("-1234e-4"));
131 assertEquals(0, toNumber("0x0"));
132 assertEquals(1, toNumber("0x1"));
133 assertEquals(2, toNumber("0x2"));
134 assertEquals(9, toNumber("0x9"));
135 assertEquals(10, toNumber("0xa"));
136 assertEquals(11, toNumber("0xb"));
137 assertEquals(15, toNumber("0xf"));
138 assertEquals(10, toNumber("0xA"));
139 assertEquals(11, toNumber("0xB"));
140 assertEquals(15, toNumber("0xF"));
142 assertEquals(0, toNumber("0X0"));
143 assertEquals(9, toNumber("0X9"));
144 assertEquals(10, toNumber("0Xa"));
145 assertEquals(10, toNumber("0XA"));
146 assertEquals(15, toNumber("0Xf"));
147 assertEquals(15, toNumber("0XF"));
149 assertEquals(0, toNumber("0x000"));
150 assertEquals(-Infinity, 1 / toNumber("-0x000"));
151 assertEquals(0, toNumber("0x000" + repeat('0', 1000)));
152 assertEquals(9, toNumber("0x009"));
153 assertEquals(10, toNumber("0x00a"));
154 assertEquals(10, toNumber("0x00A"));
155 assertEquals(15, toNumber("0x00f"));
156 assertEquals(15, toNumber("0x00F"));
157 assertEquals(15, toNumber("0x00F "));
158 assertEquals(Infinity, toNumber("0x" + repeat('0', 1000) + '1'
160 assertEquals(-Infinity, toNumber("-0x1" + repeat('0', 1000)));
162 assertEquals(0x1000000 * 0x10000000, toNumber("0x10000000000000"));
163 assertEquals(0x1000000 * 0x10000000 + 1, toNumber("0x10000000000001"));
164 assertEquals(0x10 * 0x1000000 * 0x10000000, toNumber("0x100000000000000"));
165 assertEquals(0x10 * 0x1000000 * 0x10000000, toNumber("0x100000000000001"));
166 assertEquals(0x10 * 0x1000000 * 0x10000000, toNumber("0x100000000000007"));
167 assertEquals(0x10 * 0x1000000 * 0x10000000, toNumber("0x100000000000008"));
169 toNumber("0x100000000000009"));
171 toNumber("0x10000000000000F"));
173 toNumber("0x100000000000010"));
175 toNumber("0x1000000000000000000000000"));
177 toNumber("0x1000000000000080000000000"));
179 toNumber("0x1000000000000080000000001"));
181 toNumber(" 0x1000000000000000000000000 "));
183 assertEquals(0, toNumber("00"));
184 assertEquals(1, toNumber("01"));
185 assertEquals(2, toNumber("02"));
186 assertEquals(10, toNumber("010"));
187 assertEquals(100, toNumber("0100"));
188 assertEquals(100, toNumber("000100"));
190 assertEquals(Infinity, toNumber("1e999"), "1e999");
191 assertEquals(-Infinity, toNumber("-1e999"));
192 assertEquals(0, toNumber("1e-999"));
193 assertEquals(-0, toNumber("-1e-999"));
194 assertEquals(Infinity, 1 / toNumber("1e-999"), "1e-999");
195 assertEquals(-Infinity, 1 / toNumber("-1e-999"));
197 assertTrue(isNaN(toNumber("junk")), "junk");
198 assertTrue(isNaN(toNumber("100 junk")), "100 junk");
199 assertTrue(isNaN(toNumber("0x100 junk")), "0x100 junk");
200 assertTrue(isNaN(toNumber("100.0 junk")), "100.0 junk");
201 assertTrue(isNaN(toNumber(".1e4 junk")), ".1e4 junk");
202 assertTrue(isNaN(toNumber("Infinity junk")), "Infinity junk");
203 assertTrue(isNaN(toNumber("1e")), "1e");
204 assertTrue(isNaN(toNumber("1e ")), "1e_");
205 assertTrue(isNaN(toNumber("1" + repeat('0', 1000) + 'junk')), "1e1000 junk");
208 assertEquals(toNumber('1' + repeat('0', i)), Math.pow(10.0, i));