OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 | 85 |
86 TEST(NonStrDecimalLiteral) { | 86 TEST(NonStrDecimalLiteral) { |
87 CHECK(isnan(StringToDouble(" ", NO_FLAGS, OS::nan_value()))); | 87 CHECK(isnan(StringToDouble(" ", NO_FLAGS, OS::nan_value()))); |
88 CHECK(isnan(StringToDouble("", NO_FLAGS, OS::nan_value()))); | 88 CHECK(isnan(StringToDouble("", NO_FLAGS, OS::nan_value()))); |
89 CHECK(isnan(StringToDouble(" ", NO_FLAGS, OS::nan_value()))); | 89 CHECK(isnan(StringToDouble(" ", NO_FLAGS, OS::nan_value()))); |
90 CHECK_EQ(0.0, StringToDouble("", NO_FLAGS)); | 90 CHECK_EQ(0.0, StringToDouble("", NO_FLAGS)); |
91 CHECK_EQ(0.0, StringToDouble(" ", NO_FLAGS)); | 91 CHECK_EQ(0.0, StringToDouble(" ", NO_FLAGS)); |
92 } | 92 } |
93 | 93 |
| 94 class OneBit1: public BitField<uint32_t, 0, 1> {}; |
| 95 class OneBit2: public BitField<uint32_t, 7, 1> {}; |
| 96 class EightBit1: public BitField<uint32_t, 0, 8> {}; |
| 97 class EightBit2: public BitField<uint32_t, 13, 8> {}; |
94 | 98 |
95 TEST(BitField) { | 99 TEST(BitField) { |
96 uint32_t x; | 100 uint32_t x; |
97 | 101 |
98 // One bit bit field can hold values 0 and 1. | 102 // One bit bit field can hold values 0 and 1. |
99 class OneBit1: public BitField<uint32_t, 0, 1> {}; | |
100 class OneBit2: public BitField<uint32_t, 7, 1> {}; | |
101 CHECK(!OneBit1::is_valid(static_cast<uint32_t>(-1))); | 103 CHECK(!OneBit1::is_valid(static_cast<uint32_t>(-1))); |
102 CHECK(!OneBit2::is_valid(static_cast<uint32_t>(-1))); | 104 CHECK(!OneBit2::is_valid(static_cast<uint32_t>(-1))); |
103 for (int i = 0; i < 2; i++) { | 105 for (int i = 0; i < 2; i++) { |
104 CHECK(OneBit1::is_valid(i)); | 106 CHECK(OneBit1::is_valid(i)); |
105 x = OneBit1::encode(i); | 107 x = OneBit1::encode(i); |
106 CHECK_EQ(i, OneBit1::decode(x)); | 108 CHECK_EQ(i, OneBit1::decode(x)); |
107 | 109 |
108 CHECK(OneBit2::is_valid(i)); | 110 CHECK(OneBit2::is_valid(i)); |
109 x = OneBit2::encode(i); | 111 x = OneBit2::encode(i); |
110 CHECK_EQ(i, OneBit2::decode(x)); | 112 CHECK_EQ(i, OneBit2::decode(x)); |
111 } | 113 } |
112 CHECK(!OneBit1::is_valid(2)); | 114 CHECK(!OneBit1::is_valid(2)); |
113 CHECK(!OneBit2::is_valid(2)); | 115 CHECK(!OneBit2::is_valid(2)); |
114 | 116 |
115 // Eight bit bit field can hold values from 0 tp 255. | 117 // Eight bit bit field can hold values from 0 tp 255. |
116 class EightBit1: public BitField<uint32_t, 0, 8> {}; | |
117 class EightBit2: public BitField<uint32_t, 13, 8> {}; | |
118 CHECK(!EightBit1::is_valid(static_cast<uint32_t>(-1))); | 118 CHECK(!EightBit1::is_valid(static_cast<uint32_t>(-1))); |
119 CHECK(!EightBit2::is_valid(static_cast<uint32_t>(-1))); | 119 CHECK(!EightBit2::is_valid(static_cast<uint32_t>(-1))); |
120 for (int i = 0; i < 256; i++) { | 120 for (int i = 0; i < 256; i++) { |
121 CHECK(EightBit1::is_valid(i)); | 121 CHECK(EightBit1::is_valid(i)); |
122 x = EightBit1::encode(i); | 122 x = EightBit1::encode(i); |
123 CHECK_EQ(i, EightBit1::decode(x)); | 123 CHECK_EQ(i, EightBit1::decode(x)); |
124 CHECK(EightBit2::is_valid(i)); | 124 CHECK(EightBit2::is_valid(i)); |
125 x = EightBit2::encode(i); | 125 x = EightBit2::encode(i); |
126 CHECK_EQ(i, EightBit2::decode(x)); | 126 CHECK_EQ(i, EightBit2::decode(x)); |
127 } | 127 } |
128 CHECK(!EightBit1::is_valid(256)); | 128 CHECK(!EightBit1::is_valid(256)); |
129 CHECK(!EightBit2::is_valid(256)); | 129 CHECK(!EightBit2::is_valid(256)); |
130 } | 130 } |
OLD | NEW |