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

Side by Side Diff: test/cctest/test-conversions.cc

Issue 6824071: Cleanup of ScannerConstants, now named UnicodeCache. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed review comments. Created 9 years, 8 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/scanner-base.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 2
3 #include <stdlib.h> 3 #include <stdlib.h>
4 4
5 #include "v8.h" 5 #include "v8.h"
6 6
7 #include "platform.h" 7 #include "platform.h"
8 #include "cctest.h" 8 #include "cctest.h"
9 9
10 using namespace v8::internal; 10 using namespace v8::internal;
11 11
12 12
13 TEST(Hex) { 13 TEST(Hex) {
14 CHECK_EQ(0.0, StringToDouble("0x0", ALLOW_HEX | ALLOW_OCTALS)); 14 UnicodeCache uc;
15 CHECK_EQ(0.0, StringToDouble("0X0", ALLOW_HEX | ALLOW_OCTALS)); 15 CHECK_EQ(0.0, StringToDouble(&uc, "0x0", ALLOW_HEX | ALLOW_OCTALS));
16 CHECK_EQ(1.0, StringToDouble("0x1", ALLOW_HEX | ALLOW_OCTALS)); 16 CHECK_EQ(0.0, StringToDouble(&uc, "0X0", ALLOW_HEX | ALLOW_OCTALS));
17 CHECK_EQ(16.0, StringToDouble("0x10", ALLOW_HEX | ALLOW_OCTALS)); 17 CHECK_EQ(1.0, StringToDouble(&uc, "0x1", ALLOW_HEX | ALLOW_OCTALS));
18 CHECK_EQ(255.0, StringToDouble("0xff", ALLOW_HEX | ALLOW_OCTALS)); 18 CHECK_EQ(16.0, StringToDouble(&uc, "0x10", ALLOW_HEX | ALLOW_OCTALS));
19 CHECK_EQ(175.0, StringToDouble("0xAF", ALLOW_HEX | ALLOW_OCTALS)); 19 CHECK_EQ(255.0, StringToDouble(&uc, "0xff", ALLOW_HEX | ALLOW_OCTALS));
20 CHECK_EQ(175.0, StringToDouble(&uc, "0xAF", ALLOW_HEX | ALLOW_OCTALS));
20 21
21 CHECK_EQ(0.0, StringToDouble("0x0", ALLOW_HEX)); 22 CHECK_EQ(0.0, StringToDouble(&uc, "0x0", ALLOW_HEX));
22 CHECK_EQ(0.0, StringToDouble("0X0", ALLOW_HEX)); 23 CHECK_EQ(0.0, StringToDouble(&uc, "0X0", ALLOW_HEX));
23 CHECK_EQ(1.0, StringToDouble("0x1", ALLOW_HEX)); 24 CHECK_EQ(1.0, StringToDouble(&uc, "0x1", ALLOW_HEX));
24 CHECK_EQ(16.0, StringToDouble("0x10", ALLOW_HEX)); 25 CHECK_EQ(16.0, StringToDouble(&uc, "0x10", ALLOW_HEX));
25 CHECK_EQ(255.0, StringToDouble("0xff", ALLOW_HEX)); 26 CHECK_EQ(255.0, StringToDouble(&uc, "0xff", ALLOW_HEX));
26 CHECK_EQ(175.0, StringToDouble("0xAF", ALLOW_HEX)); 27 CHECK_EQ(175.0, StringToDouble(&uc, "0xAF", ALLOW_HEX));
27 } 28 }
28 29
29 30
30 TEST(Octal) { 31 TEST(Octal) {
31 CHECK_EQ(0.0, StringToDouble("0", ALLOW_HEX | ALLOW_OCTALS)); 32 UnicodeCache uc;
32 CHECK_EQ(0.0, StringToDouble("00", ALLOW_HEX | ALLOW_OCTALS)); 33 CHECK_EQ(0.0, StringToDouble(&uc, "0", ALLOW_HEX | ALLOW_OCTALS));
33 CHECK_EQ(1.0, StringToDouble("01", ALLOW_HEX | ALLOW_OCTALS)); 34 CHECK_EQ(0.0, StringToDouble(&uc, "00", ALLOW_HEX | ALLOW_OCTALS));
34 CHECK_EQ(7.0, StringToDouble("07", ALLOW_HEX | ALLOW_OCTALS)); 35 CHECK_EQ(1.0, StringToDouble(&uc, "01", ALLOW_HEX | ALLOW_OCTALS));
35 CHECK_EQ(8.0, StringToDouble("010", ALLOW_HEX | ALLOW_OCTALS)); 36 CHECK_EQ(7.0, StringToDouble(&uc, "07", ALLOW_HEX | ALLOW_OCTALS));
36 CHECK_EQ(63.0, StringToDouble("077", ALLOW_HEX | ALLOW_OCTALS)); 37 CHECK_EQ(8.0, StringToDouble(&uc, "010", ALLOW_HEX | ALLOW_OCTALS));
38 CHECK_EQ(63.0, StringToDouble(&uc, "077", ALLOW_HEX | ALLOW_OCTALS));
37 39
38 CHECK_EQ(0.0, StringToDouble("0", ALLOW_HEX)); 40 CHECK_EQ(0.0, StringToDouble(&uc, "0", ALLOW_HEX));
39 CHECK_EQ(0.0, StringToDouble("00", ALLOW_HEX)); 41 CHECK_EQ(0.0, StringToDouble(&uc, "00", ALLOW_HEX));
40 CHECK_EQ(1.0, StringToDouble("01", ALLOW_HEX)); 42 CHECK_EQ(1.0, StringToDouble(&uc, "01", ALLOW_HEX));
41 CHECK_EQ(7.0, StringToDouble("07", ALLOW_HEX)); 43 CHECK_EQ(7.0, StringToDouble(&uc, "07", ALLOW_HEX));
42 CHECK_EQ(10.0, StringToDouble("010", ALLOW_HEX)); 44 CHECK_EQ(10.0, StringToDouble(&uc, "010", ALLOW_HEX));
43 CHECK_EQ(77.0, StringToDouble("077", ALLOW_HEX)); 45 CHECK_EQ(77.0, StringToDouble(&uc, "077", ALLOW_HEX));
44 46
45 const double x = 010000000000; // Power of 2, no rounding errors. 47 const double x = 010000000000; // Power of 2, no rounding errors.
46 CHECK_EQ(x * x * x * x * x, StringToDouble("01" "0000000000" "0000000000" 48 CHECK_EQ(x * x * x * x * x, StringToDouble(&uc, "01" "0000000000" "0000000000"
47 "0000000000" "0000000000" "0000000000", ALLOW_OCTALS)); 49 "0000000000" "0000000000" "0000000000", ALLOW_OCTALS));
48 } 50 }
49 51
50 52
51 TEST(MalformedOctal) { 53 TEST(MalformedOctal) {
52 CHECK_EQ(8.0, StringToDouble("08", ALLOW_HEX | ALLOW_OCTALS)); 54 UnicodeCache uc;
53 CHECK_EQ(81.0, StringToDouble("081", ALLOW_HEX | ALLOW_OCTALS)); 55 CHECK_EQ(8.0, StringToDouble(&uc, "08", ALLOW_HEX | ALLOW_OCTALS));
54 CHECK_EQ(78.0, StringToDouble("078", ALLOW_HEX | ALLOW_OCTALS)); 56 CHECK_EQ(81.0, StringToDouble(&uc, "081", ALLOW_HEX | ALLOW_OCTALS));
57 CHECK_EQ(78.0, StringToDouble(&uc, "078", ALLOW_HEX | ALLOW_OCTALS));
55 58
56 CHECK(isnan(StringToDouble("07.7", ALLOW_HEX | ALLOW_OCTALS))); 59 CHECK(isnan(StringToDouble(&uc, "07.7", ALLOW_HEX | ALLOW_OCTALS)));
57 CHECK(isnan(StringToDouble("07.8", ALLOW_HEX | ALLOW_OCTALS))); 60 CHECK(isnan(StringToDouble(&uc, "07.8", ALLOW_HEX | ALLOW_OCTALS)));
58 CHECK(isnan(StringToDouble("07e8", ALLOW_HEX | ALLOW_OCTALS))); 61 CHECK(isnan(StringToDouble(&uc, "07e8", ALLOW_HEX | ALLOW_OCTALS)));
59 CHECK(isnan(StringToDouble("07e7", ALLOW_HEX | ALLOW_OCTALS))); 62 CHECK(isnan(StringToDouble(&uc, "07e7", ALLOW_HEX | ALLOW_OCTALS)));
60 63
61 CHECK_EQ(8.7, StringToDouble("08.7", ALLOW_HEX | ALLOW_OCTALS)); 64 CHECK_EQ(8.7, StringToDouble(&uc, "08.7", ALLOW_HEX | ALLOW_OCTALS));
62 CHECK_EQ(8e7, StringToDouble("08e7", ALLOW_HEX | ALLOW_OCTALS)); 65 CHECK_EQ(8e7, StringToDouble(&uc, "08e7", ALLOW_HEX | ALLOW_OCTALS));
63 66
64 CHECK_EQ(0.001, StringToDouble("0.001", ALLOW_HEX | ALLOW_OCTALS)); 67 CHECK_EQ(0.001, StringToDouble(&uc, "0.001", ALLOW_HEX | ALLOW_OCTALS));
65 CHECK_EQ(0.713, StringToDouble("0.713", ALLOW_HEX | ALLOW_OCTALS)); 68 CHECK_EQ(0.713, StringToDouble(&uc, "0.713", ALLOW_HEX | ALLOW_OCTALS));
66 69
67 CHECK_EQ(8.0, StringToDouble("08", ALLOW_HEX)); 70 CHECK_EQ(8.0, StringToDouble(&uc, "08", ALLOW_HEX));
68 CHECK_EQ(81.0, StringToDouble("081", ALLOW_HEX)); 71 CHECK_EQ(81.0, StringToDouble(&uc, "081", ALLOW_HEX));
69 CHECK_EQ(78.0, StringToDouble("078", ALLOW_HEX)); 72 CHECK_EQ(78.0, StringToDouble(&uc, "078", ALLOW_HEX));
70 73
71 CHECK_EQ(7.7, StringToDouble("07.7", ALLOW_HEX)); 74 CHECK_EQ(7.7, StringToDouble(&uc, "07.7", ALLOW_HEX));
72 CHECK_EQ(7.8, StringToDouble("07.8", ALLOW_HEX)); 75 CHECK_EQ(7.8, StringToDouble(&uc, "07.8", ALLOW_HEX));
73 CHECK_EQ(7e8, StringToDouble("07e8", ALLOW_HEX)); 76 CHECK_EQ(7e8, StringToDouble(&uc, "07e8", ALLOW_HEX));
74 CHECK_EQ(7e7, StringToDouble("07e7", ALLOW_HEX)); 77 CHECK_EQ(7e7, StringToDouble(&uc, "07e7", ALLOW_HEX));
75 78
76 CHECK_EQ(8.7, StringToDouble("08.7", ALLOW_HEX)); 79 CHECK_EQ(8.7, StringToDouble(&uc, "08.7", ALLOW_HEX));
77 CHECK_EQ(8e7, StringToDouble("08e7", ALLOW_HEX)); 80 CHECK_EQ(8e7, StringToDouble(&uc, "08e7", ALLOW_HEX));
78 81
79 CHECK_EQ(0.001, StringToDouble("0.001", ALLOW_HEX)); 82 CHECK_EQ(0.001, StringToDouble(&uc, "0.001", ALLOW_HEX));
80 CHECK_EQ(0.713, StringToDouble("0.713", ALLOW_HEX)); 83 CHECK_EQ(0.713, StringToDouble(&uc, "0.713", ALLOW_HEX));
81 } 84 }
82 85
83 86
84 TEST(TrailingJunk) { 87 TEST(TrailingJunk) {
85 CHECK_EQ(8.0, StringToDouble("8q", ALLOW_TRAILING_JUNK)); 88 UnicodeCache uc;
86 CHECK_EQ(63.0, StringToDouble("077qqq", ALLOW_OCTALS | ALLOW_TRAILING_JUNK)); 89 CHECK_EQ(8.0, StringToDouble(&uc, "8q", ALLOW_TRAILING_JUNK));
87 CHECK_EQ(10.0, StringToDouble("10e", ALLOW_OCTALS | ALLOW_TRAILING_JUNK)); 90 CHECK_EQ(63.0,
88 CHECK_EQ(10.0, StringToDouble("10e-", ALLOW_OCTALS | ALLOW_TRAILING_JUNK)); 91 StringToDouble(&uc, "077qqq", ALLOW_OCTALS | ALLOW_TRAILING_JUNK));
92 CHECK_EQ(10.0,
93 StringToDouble(&uc, "10e", ALLOW_OCTALS | ALLOW_TRAILING_JUNK));
94 CHECK_EQ(10.0,
95 StringToDouble(&uc, "10e-", ALLOW_OCTALS | ALLOW_TRAILING_JUNK));
89 } 96 }
90 97
91 98
92 TEST(NonStrDecimalLiteral) { 99 TEST(NonStrDecimalLiteral) {
93 CHECK(isnan(StringToDouble(" ", NO_FLAGS, OS::nan_value()))); 100 UnicodeCache uc;
94 CHECK(isnan(StringToDouble("", NO_FLAGS, OS::nan_value()))); 101 CHECK(isnan(StringToDouble(&uc, " ", NO_FLAGS, OS::nan_value())));
95 CHECK(isnan(StringToDouble(" ", NO_FLAGS, OS::nan_value()))); 102 CHECK(isnan(StringToDouble(&uc, "", NO_FLAGS, OS::nan_value())));
96 CHECK_EQ(0.0, StringToDouble("", NO_FLAGS)); 103 CHECK(isnan(StringToDouble(&uc, " ", NO_FLAGS, OS::nan_value())));
97 CHECK_EQ(0.0, StringToDouble(" ", NO_FLAGS)); 104 CHECK_EQ(0.0, StringToDouble(&uc, "", NO_FLAGS));
105 CHECK_EQ(0.0, StringToDouble(&uc, " ", NO_FLAGS));
98 } 106 }
99 107
100 TEST(IntegerStrLiteral) { 108 TEST(IntegerStrLiteral) {
101 CHECK_EQ(0.0, StringToDouble("0.0", NO_FLAGS)); 109 UnicodeCache uc;
102 CHECK_EQ(0.0, StringToDouble("0", NO_FLAGS)); 110 CHECK_EQ(0.0, StringToDouble(&uc, "0.0", NO_FLAGS));
103 CHECK_EQ(0.0, StringToDouble("00", NO_FLAGS)); 111 CHECK_EQ(0.0, StringToDouble(&uc, "0", NO_FLAGS));
104 CHECK_EQ(0.0, StringToDouble("000", NO_FLAGS)); 112 CHECK_EQ(0.0, StringToDouble(&uc, "00", NO_FLAGS));
105 CHECK_EQ(1.0, StringToDouble("1", NO_FLAGS)); 113 CHECK_EQ(0.0, StringToDouble(&uc, "000", NO_FLAGS));
106 CHECK_EQ(-1.0, StringToDouble("-1", NO_FLAGS)); 114 CHECK_EQ(1.0, StringToDouble(&uc, "1", NO_FLAGS));
107 CHECK_EQ(-1.0, StringToDouble(" -1 ", NO_FLAGS)); 115 CHECK_EQ(-1.0, StringToDouble(&uc, "-1", NO_FLAGS));
108 CHECK_EQ(1.0, StringToDouble(" +1 ", NO_FLAGS)); 116 CHECK_EQ(-1.0, StringToDouble(&uc, " -1 ", NO_FLAGS));
109 CHECK(isnan(StringToDouble(" - 1 ", NO_FLAGS))); 117 CHECK_EQ(1.0, StringToDouble(&uc, " +1 ", NO_FLAGS));
110 CHECK(isnan(StringToDouble(" + 1 ", NO_FLAGS))); 118 CHECK(isnan(StringToDouble(&uc, " - 1 ", NO_FLAGS)));
119 CHECK(isnan(StringToDouble(&uc, " + 1 ", NO_FLAGS)));
111 120
112 CHECK_EQ(0.0, StringToDouble("0e0", ALLOW_HEX | ALLOW_OCTALS)); 121 CHECK_EQ(0.0, StringToDouble(&uc, "0e0", ALLOW_HEX | ALLOW_OCTALS));
113 CHECK_EQ(0.0, StringToDouble("0e1", ALLOW_HEX | ALLOW_OCTALS)); 122 CHECK_EQ(0.0, StringToDouble(&uc, "0e1", ALLOW_HEX | ALLOW_OCTALS));
114 CHECK_EQ(0.0, StringToDouble("0e-1", ALLOW_HEX | ALLOW_OCTALS)); 123 CHECK_EQ(0.0, StringToDouble(&uc, "0e-1", ALLOW_HEX | ALLOW_OCTALS));
115 CHECK_EQ(0.0, StringToDouble("0e-100000", ALLOW_HEX | ALLOW_OCTALS)); 124 CHECK_EQ(0.0, StringToDouble(&uc, "0e-100000", ALLOW_HEX | ALLOW_OCTALS));
116 CHECK_EQ(0.0, StringToDouble("0e+100000", ALLOW_HEX | ALLOW_OCTALS)); 125 CHECK_EQ(0.0, StringToDouble(&uc, "0e+100000", ALLOW_HEX | ALLOW_OCTALS));
117 CHECK_EQ(0.0, StringToDouble("0.", ALLOW_HEX | ALLOW_OCTALS)); 126 CHECK_EQ(0.0, StringToDouble(&uc, "0.", ALLOW_HEX | ALLOW_OCTALS));
118 } 127 }
119 128
120 TEST(LongNumberStr) { 129 TEST(LongNumberStr) {
121 CHECK_EQ(1e10, StringToDouble("1" "0000000000", NO_FLAGS)); 130 UnicodeCache uc;
122 CHECK_EQ(1e20, StringToDouble("1" "0000000000" "0000000000", NO_FLAGS)); 131 CHECK_EQ(1e10, StringToDouble(&uc, "1" "0000000000", NO_FLAGS));
132 CHECK_EQ(1e20, StringToDouble(&uc, "1" "0000000000" "0000000000", NO_FLAGS));
123 133
124 CHECK_EQ(1e60, StringToDouble("1" "0000000000" "0000000000" "0000000000" 134 CHECK_EQ(1e60, StringToDouble(&uc, "1" "0000000000" "0000000000" "0000000000"
125 "0000000000" "0000000000" "0000000000", NO_FLAGS)); 135 "0000000000" "0000000000" "0000000000", NO_FLAGS));
126 136
127 CHECK_EQ(1e-2, StringToDouble("." "0" "1", NO_FLAGS)); 137 CHECK_EQ(1e-2, StringToDouble(&uc, "." "0" "1", NO_FLAGS));
128 CHECK_EQ(1e-11, StringToDouble("." "0000000000" "1", NO_FLAGS)); 138 CHECK_EQ(1e-11, StringToDouble(&uc, "." "0000000000" "1", NO_FLAGS));
129 CHECK_EQ(1e-21, StringToDouble("." "0000000000" "0000000000" "1", NO_FLAGS)); 139 CHECK_EQ(1e-21, StringToDouble(&uc, "." "0000000000" "0000000000" "1",
140 NO_FLAGS));
130 141
131 CHECK_EQ(1e-61, StringToDouble("." "0000000000" "0000000000" "0000000000" 142 CHECK_EQ(1e-61, StringToDouble(&uc, "." "0000000000" "0000000000" "0000000000"
132 "0000000000" "0000000000" "0000000000" "1", NO_FLAGS)); 143 "0000000000" "0000000000" "0000000000" "1", NO_FLAGS));
133 144
134 145
135 // x = 24414062505131248.0 and y = 24414062505131252.0 are representable in 146 // x = 24414062505131248.0 and y = 24414062505131252.0 are representable in
136 // double. Check chat z = (x + y) / 2 is rounded to x... 147 // double. Check chat z = (x + y) / 2 is rounded to x...
137 CHECK_EQ(24414062505131248.0, 148 CHECK_EQ(24414062505131248.0,
138 StringToDouble("24414062505131250.0", NO_FLAGS)); 149 StringToDouble(&uc, "24414062505131250.0", NO_FLAGS));
139 150
140 // ... and z = (x + y) / 2 + delta is rounded to y. 151 // ... and z = (x + y) / 2 + delta is rounded to y.
141 CHECK_EQ(24414062505131252.0, 152 CHECK_EQ(24414062505131252.0,
142 StringToDouble("24414062505131250.000000001", NO_FLAGS)); 153 StringToDouble(&uc, "24414062505131250.000000001", NO_FLAGS));
143 } 154 }
144 155
145 156
146 TEST(MaximumSignificantDigits) { 157 TEST(MaximumSignificantDigits) {
158 UnicodeCache uc;
147 char num[] = 159 char num[] =
148 "4.4501477170144020250819966727949918635852426585926051135169509" 160 "4.4501477170144020250819966727949918635852426585926051135169509"
149 "122872622312493126406953054127118942431783801370080830523154578" 161 "122872622312493126406953054127118942431783801370080830523154578"
150 "251545303238277269592368457430440993619708911874715081505094180" 162 "251545303238277269592368457430440993619708911874715081505094180"
151 "604803751173783204118519353387964161152051487413083163272520124" 163 "604803751173783204118519353387964161152051487413083163272520124"
152 "606023105869053620631175265621765214646643181420505164043632222" 164 "606023105869053620631175265621765214646643181420505164043632222"
153 "668006474326056011713528291579642227455489682133472873831754840" 165 "668006474326056011713528291579642227455489682133472873831754840"
154 "341397809846934151055619529382191981473003234105366170879223151" 166 "341397809846934151055619529382191981473003234105366170879223151"
155 "087335413188049110555339027884856781219017754500629806224571029" 167 "087335413188049110555339027884856781219017754500629806224571029"
156 "581637117459456877330110324211689177656713705497387108207822477" 168 "581637117459456877330110324211689177656713705497387108207822477"
157 "584250967061891687062782163335299376138075114200886249979505279" 169 "584250967061891687062782163335299376138075114200886249979505279"
158 "101870966346394401564490729731565935244123171539810221213221201" 170 "101870966346394401564490729731565935244123171539810221213221201"
159 "847003580761626016356864581135848683152156368691976240370422601" 171 "847003580761626016356864581135848683152156368691976240370422601"
160 "6998291015625000000000000000000000000000000000e-308"; 172 "6998291015625000000000000000000000000000000000e-308";
161 173
162 CHECK_EQ(4.4501477170144017780491e-308, StringToDouble(num, NO_FLAGS)); 174 CHECK_EQ(4.4501477170144017780491e-308, StringToDouble(&uc, num, NO_FLAGS));
163 175
164 // Changes the result of strtod (at least in glibc implementation). 176 // Changes the result of strtod (at least in glibc implementation).
165 num[sizeof(num) - 8] = '1'; 177 num[sizeof(num) - 8] = '1';
166 178
167 CHECK_EQ(4.4501477170144022721148e-308, StringToDouble(num, NO_FLAGS)); 179 CHECK_EQ(4.4501477170144022721148e-308, StringToDouble(&uc, num, NO_FLAGS));
168 } 180 }
169 181
170 TEST(MinimumExponent) { 182 TEST(MinimumExponent) {
183 UnicodeCache uc;
171 // Same test but with different point-position. 184 // Same test but with different point-position.
172 char num[] = 185 char num[] =
173 "445014771701440202508199667279499186358524265859260511351695091" 186 "445014771701440202508199667279499186358524265859260511351695091"
174 "228726223124931264069530541271189424317838013700808305231545782" 187 "228726223124931264069530541271189424317838013700808305231545782"
175 "515453032382772695923684574304409936197089118747150815050941806" 188 "515453032382772695923684574304409936197089118747150815050941806"
176 "048037511737832041185193533879641611520514874130831632725201246" 189 "048037511737832041185193533879641611520514874130831632725201246"
177 "060231058690536206311752656217652146466431814205051640436322226" 190 "060231058690536206311752656217652146466431814205051640436322226"
178 "680064743260560117135282915796422274554896821334728738317548403" 191 "680064743260560117135282915796422274554896821334728738317548403"
179 "413978098469341510556195293821919814730032341053661708792231510" 192 "413978098469341510556195293821919814730032341053661708792231510"
180 "873354131880491105553390278848567812190177545006298062245710295" 193 "873354131880491105553390278848567812190177545006298062245710295"
181 "816371174594568773301103242116891776567137054973871082078224775" 194 "816371174594568773301103242116891776567137054973871082078224775"
182 "842509670618916870627821633352993761380751142008862499795052791" 195 "842509670618916870627821633352993761380751142008862499795052791"
183 "018709663463944015644907297315659352441231715398102212132212018" 196 "018709663463944015644907297315659352441231715398102212132212018"
184 "470035807616260163568645811358486831521563686919762403704226016" 197 "470035807616260163568645811358486831521563686919762403704226016"
185 "998291015625000000000000000000000000000000000e-1108"; 198 "998291015625000000000000000000000000000000000e-1108";
186 199
187 CHECK_EQ(4.4501477170144017780491e-308, StringToDouble(num, NO_FLAGS)); 200 CHECK_EQ(4.4501477170144017780491e-308, StringToDouble(&uc, num, NO_FLAGS));
188 201
189 // Changes the result of strtod (at least in glibc implementation). 202 // Changes the result of strtod (at least in glibc implementation).
190 num[sizeof(num) - 8] = '1'; 203 num[sizeof(num) - 8] = '1';
191 204
192 CHECK_EQ(4.4501477170144022721148e-308, StringToDouble(num, NO_FLAGS)); 205 CHECK_EQ(4.4501477170144022721148e-308, StringToDouble(&uc, num, NO_FLAGS));
193 } 206 }
194 207
195 208
196 TEST(MaximumExponent) { 209 TEST(MaximumExponent) {
210 UnicodeCache uc;
197 char num[] = "0.16e309"; 211 char num[] = "0.16e309";
198 212
199 CHECK_EQ(1.59999999999999997765e+308, StringToDouble(num, NO_FLAGS)); 213 CHECK_EQ(1.59999999999999997765e+308, StringToDouble(&uc, num, NO_FLAGS));
200 } 214 }
201 215
202 216
203 TEST(ExponentNumberStr) { 217 TEST(ExponentNumberStr) {
204 CHECK_EQ(1e1, StringToDouble("1e1", NO_FLAGS)); 218 UnicodeCache uc;
205 CHECK_EQ(1e1, StringToDouble("1e+1", NO_FLAGS)); 219 CHECK_EQ(1e1, StringToDouble(&uc, "1e1", NO_FLAGS));
206 CHECK_EQ(1e-1, StringToDouble("1e-1", NO_FLAGS)); 220 CHECK_EQ(1e1, StringToDouble(&uc, "1e+1", NO_FLAGS));
207 CHECK_EQ(1e100, StringToDouble("1e+100", NO_FLAGS)); 221 CHECK_EQ(1e-1, StringToDouble(&uc, "1e-1", NO_FLAGS));
208 CHECK_EQ(1e-100, StringToDouble("1e-100", NO_FLAGS)); 222 CHECK_EQ(1e100, StringToDouble(&uc, "1e+100", NO_FLAGS));
209 CHECK_EQ(1e-106, StringToDouble(".000001e-100", NO_FLAGS)); 223 CHECK_EQ(1e-100, StringToDouble(&uc, "1e-100", NO_FLAGS));
224 CHECK_EQ(1e-106, StringToDouble(&uc, ".000001e-100", NO_FLAGS));
210 } 225 }
211 226
212 class OneBit1: public BitField<uint32_t, 0, 1> {}; 227 class OneBit1: public BitField<uint32_t, 0, 1> {};
213 class OneBit2: public BitField<uint32_t, 7, 1> {}; 228 class OneBit2: public BitField<uint32_t, 7, 1> {};
214 class EightBit1: public BitField<uint32_t, 0, 8> {}; 229 class EightBit1: public BitField<uint32_t, 0, 8> {};
215 class EightBit2: public BitField<uint32_t, 13, 8> {}; 230 class EightBit2: public BitField<uint32_t, 13, 8> {};
216 231
217 TEST(BitField) { 232 TEST(BitField) {
218 uint32_t x; 233 uint32_t x;
219 234
(...skipping 19 matching lines...) Expand all
239 CHECK(EightBit1::is_valid(i)); 254 CHECK(EightBit1::is_valid(i));
240 x = EightBit1::encode(i); 255 x = EightBit1::encode(i);
241 CHECK_EQ(i, EightBit1::decode(x)); 256 CHECK_EQ(i, EightBit1::decode(x));
242 CHECK(EightBit2::is_valid(i)); 257 CHECK(EightBit2::is_valid(i));
243 x = EightBit2::encode(i); 258 x = EightBit2::encode(i);
244 CHECK_EQ(i, EightBit2::decode(x)); 259 CHECK_EQ(i, EightBit2::decode(x));
245 } 260 }
246 CHECK(!EightBit1::is_valid(256)); 261 CHECK(!EightBit1::is_valid(256));
247 CHECK(!EightBit2::is_valid(256)); 262 CHECK(!EightBit2::is_valid(256));
248 } 263 }
OLDNEW
« no previous file with comments | « src/scanner-base.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698