Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1938)

Side by Side Diff: test/mjsunit/str-to-num.js

Issue 10818003: Interpret negative hexadecimal literals as NaN. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed commented issues Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/conversions-inl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 assertEquals(15, toNumber("0xF")); 140 assertEquals(15, toNumber("0xF"));
141 141
142 assertEquals(0, toNumber("0X0")); 142 assertEquals(0, toNumber("0X0"));
143 assertEquals(9, toNumber("0X9")); 143 assertEquals(9, toNumber("0X9"));
144 assertEquals(10, toNumber("0Xa")); 144 assertEquals(10, toNumber("0Xa"));
145 assertEquals(10, toNumber("0XA")); 145 assertEquals(10, toNumber("0XA"));
146 assertEquals(15, toNumber("0Xf")); 146 assertEquals(15, toNumber("0Xf"));
147 assertEquals(15, toNumber("0XF")); 147 assertEquals(15, toNumber("0XF"));
148 148
149 assertEquals(0, toNumber("0x000")); 149 assertEquals(0, toNumber("0x000"));
150 assertEquals(-Infinity, 1 / toNumber("-0x000"));
151 assertEquals(0, toNumber("0x000" + repeat('0', 1000))); 150 assertEquals(0, toNumber("0x000" + repeat('0', 1000)));
152 assertEquals(9, toNumber("0x009")); 151 assertEquals(9, toNumber("0x009"));
153 assertEquals(10, toNumber("0x00a")); 152 assertEquals(10, toNumber("0x00a"));
154 assertEquals(10, toNumber("0x00A")); 153 assertEquals(10, toNumber("0x00A"));
155 assertEquals(15, toNumber("0x00f")); 154 assertEquals(15, toNumber("0x00f"));
156 assertEquals(15, toNumber("0x00F")); 155 assertEquals(15, toNumber("0x00F"));
157 assertEquals(15, toNumber("0x00F ")); 156 assertEquals(15, toNumber("0x00F "));
158 assertEquals(Infinity, toNumber("0x" + repeat('0', 1000) + '1' 157 assertEquals(Infinity, toNumber("0x" + repeat('0', 1000) + '1'
159 + repeat('0', 1000))); 158 + repeat('0', 1000)));
160 assertEquals(-Infinity, toNumber("-0x1" + repeat('0', 1000)));
161 159
162 assertEquals(0x1000000 * 0x10000000, toNumber("0x10000000000000")); 160 assertEquals(0x1000000 * 0x10000000, toNumber("0x10000000000000"));
163 assertEquals(0x1000000 * 0x10000000 + 1, toNumber("0x10000000000001")); 161 assertEquals(0x1000000 * 0x10000000 + 1, toNumber("0x10000000000001"));
164 assertEquals(0x10 * 0x1000000 * 0x10000000, toNumber("0x100000000000000")); 162 assertEquals(0x10 * 0x1000000 * 0x10000000, toNumber("0x100000000000000"));
165 assertEquals(0x10 * 0x1000000 * 0x10000000, toNumber("0x100000000000001")); 163 assertEquals(0x10 * 0x1000000 * 0x10000000, toNumber("0x100000000000001"));
166 assertEquals(0x10 * 0x1000000 * 0x10000000, toNumber("0x100000000000007")); 164 assertEquals(0x10 * 0x1000000 * 0x10000000, toNumber("0x100000000000007"));
167 assertEquals(0x10 * 0x1000000 * 0x10000000, toNumber("0x100000000000008")); 165 assertEquals(0x10 * 0x1000000 * 0x10000000, toNumber("0x100000000000008"));
168 assertEquals(0x10 * (0x1000000 * 0x10000000 + 1), 166 assertEquals(0x10 * (0x1000000 * 0x10000000 + 1),
169 toNumber("0x100000000000009")); 167 toNumber("0x100000000000009"));
170 assertEquals(0x10 * (0x1000000 * 0x10000000 + 1), 168 assertEquals(0x10 * (0x1000000 * 0x10000000 + 1),
(...skipping 29 matching lines...) Expand all
200 assertTrue(isNaN(toNumber("100.0 junk")), "100.0 junk"); 198 assertTrue(isNaN(toNumber("100.0 junk")), "100.0 junk");
201 assertTrue(isNaN(toNumber(".1e4 junk")), ".1e4 junk"); 199 assertTrue(isNaN(toNumber(".1e4 junk")), ".1e4 junk");
202 assertTrue(isNaN(toNumber("Infinity junk")), "Infinity junk"); 200 assertTrue(isNaN(toNumber("Infinity junk")), "Infinity junk");
203 assertTrue(isNaN(toNumber("1e")), "1e"); 201 assertTrue(isNaN(toNumber("1e")), "1e");
204 assertTrue(isNaN(toNumber("1e ")), "1e_"); 202 assertTrue(isNaN(toNumber("1e ")), "1e_");
205 assertTrue(isNaN(toNumber("1" + repeat('0', 1000) + 'junk')), "1e1000 junk"); 203 assertTrue(isNaN(toNumber("1" + repeat('0', 1000) + 'junk')), "1e1000 junk");
206 204
207 for (var i = 1; i < 12; i++) { 205 for (var i = 1; i < 12; i++) {
208 assertEquals(toNumber('1' + repeat('0', i)), Math.pow(10.0, i)); 206 assertEquals(toNumber('1' + repeat('0', i)), Math.pow(10.0, i));
209 } 207 }
208
209 assertTrue(isNaN(toNumber("+0x0")));
210 assertTrue(isNaN(toNumber("+0xFF")));
211 assertTrue(isNaN(toNumber("+0x012")));
212 assertTrue(isNaN(toNumber("-0x0")));
213 assertTrue(isNaN(toNumber("-0xFF")));
214 assertTrue(isNaN(toNumber("-0x012")));
OLDNEW
« no previous file with comments | « src/conversions-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698