Commit 71e792a8 authored by ager@chromium.org's avatar ager@chromium.org

Revert revisions 4241, 4243 and 4247 because of Windows build errors

and test failures.

TBR=serya@chromium.org
Review URL: http://codereview.chromium.org/1269003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4249 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 5e4dfe85
This diff is collapsed.
......@@ -41,10 +41,6 @@ TEST(Octal) {
CHECK_EQ(7.0, StringToDouble("07", ALLOW_HEX));
CHECK_EQ(10.0, StringToDouble("010", ALLOW_HEX));
CHECK_EQ(77.0, StringToDouble("077", ALLOW_HEX));
const double x = 010000000000; // Power of 2, no rounding errors.
CHECK_EQ(x * x * x * x * x, StringToDouble("01" "0000000000" "0000000000"
"0000000000" "0000000000" "0000000000", ALLOW_OCTALS));
}
......@@ -84,8 +80,6 @@ TEST(MalformedOctal) {
TEST(TrailingJunk) {
CHECK_EQ(8.0, StringToDouble("8q", ALLOW_TRAILING_JUNK));
CHECK_EQ(63.0, StringToDouble("077qqq", ALLOW_OCTALS | ALLOW_TRAILING_JUNK));
CHECK_EQ(10.0, StringToDouble("10e", ALLOW_OCTALS | ALLOW_TRAILING_JUNK));
CHECK_EQ(10.0, StringToDouble("10e-", ALLOW_OCTALS | ALLOW_TRAILING_JUNK));
}
......@@ -97,80 +91,6 @@ TEST(NonStrDecimalLiteral) {
CHECK_EQ(0.0, StringToDouble(" ", NO_FLAGS));
}
TEST(IntegerStrLiteral) {
CHECK_EQ(0.0, StringToDouble("0.0", NO_FLAGS));
CHECK_EQ(0.0, StringToDouble("0", NO_FLAGS));
CHECK_EQ(0.0, StringToDouble("00", NO_FLAGS));
CHECK_EQ(0.0, StringToDouble("000", NO_FLAGS));
CHECK_EQ(1.0, StringToDouble("1", NO_FLAGS));
CHECK_EQ(-1.0, StringToDouble("-1", NO_FLAGS));
CHECK_EQ(-1.0, StringToDouble(" - 1 ", NO_FLAGS));
CHECK_EQ(1.0, StringToDouble(" + 1 ", NO_FLAGS));
}
TEST(LongNumberStr) {
CHECK_EQ(1e10, StringToDouble("1" "0000000000", NO_FLAGS));
CHECK_EQ(1e20, StringToDouble("1" "0000000000" "0000000000", NO_FLAGS));
CHECK_EQ(1e60, StringToDouble("1" "0000000000" "0000000000" "0000000000"
"0000000000" "0000000000" "0000000000", NO_FLAGS));
CHECK_EQ(1e-2, StringToDouble("." "0" "1", NO_FLAGS));
CHECK_EQ(1e-11, StringToDouble("." "0000000000" "1", NO_FLAGS));
CHECK_EQ(1e-21, StringToDouble("." "0000000000" "0000000000" "1", NO_FLAGS));
CHECK_EQ(1e-61, StringToDouble("." "0000000000" "0000000000" "0000000000"
"0000000000" "0000000000" "0000000000" "1", NO_FLAGS));
// x = 24414062505131248.0 and y = 24414062505131252.0 are representable in
// double. Check chat z = (x + y) / 2 is rounded to x...
CHECK_EQ(24414062505131248.0,
StringToDouble("24414062505131250.0", NO_FLAGS));
// ... and z = (x + y) / 2 + delta is rounded to y.
CHECK_EQ(24414062505131252.0,
StringToDouble("24414062505131250.000000001", NO_FLAGS));
}
TEST(MaximumSignificantDigits) {
// Smallest possible double
double min_double = 1 * pow(2, -1023) * pow(2, -51);
CHECK_NE(min_double, 0.0);
CHECK_EQ(min_double / 2, 0.0);
// Maximum odd double (any breater number is rounded to even).
double big_num = (pow(2, 52) - 1) * 2.0 + 1.0;
CHECK_NE(big_num, big_num - 1.0);
// Numbers with longest possible decimal representation.
long double a = min_double * big_num;
long double b = min_double * (big_num - 1);
CHECK(a != b);
char buffer[1100];
// Construct a number exactly at the middle between 2 possible
// doubles with long decimal representation (~760 significant digits).
int n = snprintf(buffer, sizeof(buffer), "%.1000Le", (a + b) / 2);
CHECK_EQ(strcmp(buffer + n - 10, "00000e-308"), 0);
CHECK_EQ(b, StringToDouble(buffer, NO_FLAGS));
buffer[n - 8] = '1';
CHECK_EQ(a, StringToDouble(buffer, NO_FLAGS));
}
TEST(ExponentNumberStr) {
CHECK_EQ(1e1, StringToDouble("1e1", NO_FLAGS));
CHECK_EQ(1e1, StringToDouble("1e+1", NO_FLAGS));
CHECK_EQ(1e-1, StringToDouble("1e-1", NO_FLAGS));
CHECK_EQ(1e100, StringToDouble("1e+100", NO_FLAGS));
CHECK_EQ(1e-100, StringToDouble("1e-100", NO_FLAGS));
CHECK_EQ(1e-106, StringToDouble(".000001e-100", NO_FLAGS));
}
class OneBit1: public BitField<uint32_t, 0, 1> {};
class OneBit2: public BitField<uint32_t, 7, 1> {};
class EightBit1: public BitField<uint32_t, 0, 8> {};
......
......@@ -29,23 +29,8 @@ function toNumber(val) {
return Number(val);
}
function repeat(s, num) {
var result = '';
while (num > 0) {
if ((num & 1) != 0) result += s;
s += s;
num >>= 1;
}
return result;
}
assertEquals('0000000000', repeat('0', 10));
// assertEquals(, toNumber());
assertEquals(1, 1.);
assertEquals(1, toNumber("1."));
assertEquals(123, toNumber(" 123"));
assertEquals(123, toNumber("\n123"));
......@@ -76,7 +61,6 @@ assertEquals(Infinity, toNumber("+Infinity "), "+Infinity");
assertEquals(0, toNumber("0"));
assertEquals(0, toNumber("+0"));
assertEquals(-0, toNumber("-0"));
assertEquals(-Infinity, 1 / toNumber("-0"));
assertEquals(1, toNumber("1"));
assertEquals(1, toNumber("+1"));
......@@ -146,16 +130,11 @@ assertEquals(15, toNumber("0Xf"));
assertEquals(15, toNumber("0XF"));
assertEquals(0, toNumber("0x000"));
assertEquals(-Infinity, 1 / toNumber("-0x000"));
assertEquals(0, toNumber("0x000" + repeat('0', 1000)));
assertEquals(9, toNumber("0x009"));
assertEquals(10, toNumber("0x00a"));
assertEquals(10, toNumber("0x00A"));
assertEquals(15, toNumber("0x00f"));
assertEquals(15, toNumber("0x00F"));
assertEquals(Infinity, toNumber("0x" + repeat('0', 1000) + '1'
+ repeat('0', 1000)));
assertEquals(-Infinity, toNumber("-0x1" + repeat('0', 1000)));
assertEquals(0, toNumber("00"));
assertEquals(1, toNumber("01"));
......@@ -177,6 +156,3 @@ assertTrue(isNaN(toNumber("0x100 junk")), "0x100 junk");
assertTrue(isNaN(toNumber("100.0 junk")), "100.0 junk");
assertTrue(isNaN(toNumber(".1e4 junk")), ".1e4 junk");
assertTrue(isNaN(toNumber("Infinity junk")), "Infinity junk");
assertTrue(isNaN(toNumber("1e")), "1e");
assertTrue(isNaN(toNumber("1e ")), "1e_");
assertTrue(isNaN(toNumber("1" + repeat('0', 1000) + 'junk')), "1e1000 junk");
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment