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

Side by Side Diff: test/cctest/compiler/compiler/test-operator.cc

Issue 426233002: Land the Fan (disabled) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback, rebase and "git cl format" Created 6 years, 4 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
OLDNEW
(Empty)
1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "src/v8.h"
6
7 #include "src/compiler/operator.h"
8 #include "test/cctest/cctest.h"
9
10 using namespace v8::internal;
11 using namespace v8::internal::compiler;
12
13 #define NaN (v8::base::OS::nan_value())
14 #define Infinity (std::numeric_limits<double>::infinity())
15
16 TEST(TestOperatorMnemonic) {
17 SimpleOperator op1(10, 0, 0, 0, "ThisOne");
18 CHECK_EQ(0, strcmp(op1.mnemonic(), "ThisOne"));
19
20 SimpleOperator op2(11, 0, 0, 0, "ThatOne");
21 CHECK_EQ(0, strcmp(op2.mnemonic(), "ThatOne"));
22
23 Operator1<int> op3(12, 0, 0, 1, "Mnemonic1", 12333);
24 CHECK_EQ(0, strcmp(op3.mnemonic(), "Mnemonic1"));
25
26 Operator1<double> op4(13, 0, 0, 1, "TheOther", 99.9);
27 CHECK_EQ(0, strcmp(op4.mnemonic(), "TheOther"));
28 }
29
30
31 TEST(TestSimpleOperatorHash) {
32 SimpleOperator op1(17, 0, 0, 0, "Another");
33 CHECK_EQ(17, op1.HashCode());
34
35 SimpleOperator op2(18, 0, 0, 0, "Falsch");
36 CHECK_EQ(18, op2.HashCode());
37 }
38
39
40 TEST(TestSimpleOperatorEquals) {
41 SimpleOperator op1a(19, 0, 0, 0, "Another1");
42 SimpleOperator op1b(19, 2, 2, 2, "Another2");
43
44 CHECK(op1a.Equals(&op1a));
45 CHECK(op1a.Equals(&op1b));
46 CHECK(op1b.Equals(&op1a));
47 CHECK(op1b.Equals(&op1b));
48
49 SimpleOperator op2a(20, 0, 0, 0, "Falsch1");
50 SimpleOperator op2b(20, 1, 1, 1, "Falsch2");
51
52 CHECK(op2a.Equals(&op2a));
53 CHECK(op2a.Equals(&op2b));
54 CHECK(op2b.Equals(&op2a));
55 CHECK(op2b.Equals(&op2b));
56
57 CHECK(!op1a.Equals(&op2a));
58 CHECK(!op1a.Equals(&op2b));
59 CHECK(!op1b.Equals(&op2a));
60 CHECK(!op1b.Equals(&op2b));
61
62 CHECK(!op2a.Equals(&op1a));
63 CHECK(!op2a.Equals(&op1b));
64 CHECK(!op2b.Equals(&op1a));
65 CHECK(!op2b.Equals(&op1b));
66 }
67
68
69 static SmartArrayPointer<const char> OperatorToString(Operator* op) {
70 OStringStream os;
71 os << *op;
72 return SmartArrayPointer<const char>(StrDup(os.c_str()));
73 }
74
75
76 TEST(TestSimpleOperatorPrint) {
77 SimpleOperator op1a(19, 0, 0, 0, "Another1");
78 SimpleOperator op1b(19, 2, 2, 2, "Another2");
79
80 CHECK_EQ("Another1", OperatorToString(&op1a).get());
81 CHECK_EQ("Another2", OperatorToString(&op1b).get());
82
83 SimpleOperator op2a(20, 0, 0, 0, "Flog1");
84 SimpleOperator op2b(20, 1, 1, 1, "Flog2");
85
86 CHECK_EQ("Flog1", OperatorToString(&op2a).get());
87 CHECK_EQ("Flog2", OperatorToString(&op2b).get());
88 }
89
90
91 TEST(TestOperator1intHash) {
92 Operator1<int> op1a(23, 0, 0, 0, "Wolfie", 11);
93 Operator1<int> op1b(23, 2, 2, 2, "Doggie", 11);
94
95 CHECK_EQ(op1a.HashCode(), op1b.HashCode());
96
97 Operator1<int> op2a(24, 0, 0, 0, "Arfie", 3);
98 Operator1<int> op2b(24, 0, 0, 0, "Arfie", 4);
99
100 CHECK_NE(op1a.HashCode(), op2a.HashCode());
101 CHECK_NE(op2a.HashCode(), op2b.HashCode());
102 }
103
104
105 TEST(TestOperator1intEquals) {
106 Operator1<int> op1a(23, 0, 0, 0, "Scratchy", 11);
107 Operator1<int> op1b(23, 2, 2, 2, "Scratchy", 11);
108
109 CHECK(op1a.Equals(&op1a));
110 CHECK(op1a.Equals(&op1b));
111 CHECK(op1b.Equals(&op1a));
112 CHECK(op1b.Equals(&op1b));
113
114 Operator1<int> op2a(24, 0, 0, 0, "Im", 3);
115 Operator1<int> op2b(24, 0, 0, 0, "Im", 4);
116
117 CHECK(op2a.Equals(&op2a));
118 CHECK(!op2a.Equals(&op2b));
119 CHECK(!op2b.Equals(&op2a));
120 CHECK(op2b.Equals(&op2b));
121
122 CHECK(!op1a.Equals(&op2a));
123 CHECK(!op1a.Equals(&op2b));
124 CHECK(!op1b.Equals(&op2a));
125 CHECK(!op1b.Equals(&op2b));
126
127 CHECK(!op2a.Equals(&op1a));
128 CHECK(!op2a.Equals(&op1b));
129 CHECK(!op2b.Equals(&op1a));
130 CHECK(!op2b.Equals(&op1b));
131
132 SimpleOperator op3(25, 0, 0, 0, "Weepy");
133
134 CHECK(!op1a.Equals(&op3));
135 CHECK(!op1b.Equals(&op3));
136 CHECK(!op2a.Equals(&op3));
137 CHECK(!op2b.Equals(&op3));
138
139 CHECK(!op3.Equals(&op1a));
140 CHECK(!op3.Equals(&op1b));
141 CHECK(!op3.Equals(&op2a));
142 CHECK(!op3.Equals(&op2b));
143 }
144
145
146 TEST(TestOperator1intPrint) {
147 Operator1<int> op1(12, 0, 0, 1, "Op1Test", 0);
148 CHECK_EQ("Op1Test[0]", OperatorToString(&op1).get());
149
150 Operator1<int> op2(12, 0, 0, 1, "Op1Test", 66666666);
151 CHECK_EQ("Op1Test[66666666]", OperatorToString(&op2).get());
152
153 Operator1<int> op3(12, 0, 0, 1, "FooBar", 2347);
154 CHECK_EQ("FooBar[2347]", OperatorToString(&op3).get());
155
156 Operator1<int> op4(12, 0, 0, 1, "BarFoo", -879);
157 CHECK_EQ("BarFoo[-879]", OperatorToString(&op4).get());
158 }
159
160
161 TEST(TestOperator1doubleHash) {
162 Operator1<double> op1a(23, 0, 0, 0, "Wolfie", 11.77);
163 Operator1<double> op1b(23, 2, 2, 2, "Doggie", 11.77);
164
165 CHECK_EQ(op1a.HashCode(), op1b.HashCode());
166
167 Operator1<double> op2a(24, 0, 0, 0, "Arfie", -6.7);
168 Operator1<double> op2b(24, 0, 0, 0, "Arfie", -6.8);
169
170 CHECK_NE(op1a.HashCode(), op2a.HashCode());
171 CHECK_NE(op2a.HashCode(), op2b.HashCode());
172 }
173
174
175 TEST(TestOperator1doubleEquals) {
176 Operator1<double> op1a(23, 0, 0, 0, "Scratchy", 11.77);
177 Operator1<double> op1b(23, 2, 2, 2, "Scratchy", 11.77);
178
179 CHECK(op1a.Equals(&op1a));
180 CHECK(op1a.Equals(&op1b));
181 CHECK(op1b.Equals(&op1a));
182 CHECK(op1b.Equals(&op1b));
183
184 Operator1<double> op2a(24, 0, 0, 0, "Im", 3.1);
185 Operator1<double> op2b(24, 0, 0, 0, "Im", 3.2);
186
187 CHECK(op2a.Equals(&op2a));
188 CHECK(!op2a.Equals(&op2b));
189 CHECK(!op2b.Equals(&op2a));
190 CHECK(op2b.Equals(&op2b));
191
192 CHECK(!op1a.Equals(&op2a));
193 CHECK(!op1a.Equals(&op2b));
194 CHECK(!op1b.Equals(&op2a));
195 CHECK(!op1b.Equals(&op2b));
196
197 CHECK(!op2a.Equals(&op1a));
198 CHECK(!op2a.Equals(&op1b));
199 CHECK(!op2b.Equals(&op1a));
200 CHECK(!op2b.Equals(&op1b));
201
202 SimpleOperator op3(25, 0, 0, 0, "Weepy");
203
204 CHECK(!op1a.Equals(&op3));
205 CHECK(!op1b.Equals(&op3));
206 CHECK(!op2a.Equals(&op3));
207 CHECK(!op2b.Equals(&op3));
208
209 CHECK(!op3.Equals(&op1a));
210 CHECK(!op3.Equals(&op1b));
211 CHECK(!op3.Equals(&op2a));
212 CHECK(!op3.Equals(&op2b));
213
214 Operator1<double> op4a(24, 0, 0, 0, "Bashful", NaN);
215 Operator1<double> op4b(24, 0, 0, 0, "Bashful", NaN);
216
217 CHECK(op4a.Equals(&op4a));
218 CHECK(op4a.Equals(&op4b));
219 CHECK(op4b.Equals(&op4a));
220 CHECK(op4b.Equals(&op4b));
221
222 CHECK(!op3.Equals(&op4a));
223 CHECK(!op3.Equals(&op4b));
224 CHECK(!op3.Equals(&op4a));
225 CHECK(!op3.Equals(&op4b));
226 }
227
228
229 TEST(TestOperator1doublePrint) {
230 Operator1<double> op1(12, 0, 0, 1, "Op1Test", 0);
231 CHECK_EQ("Op1Test[0]", OperatorToString(&op1).get());
232
233 Operator1<double> op2(12, 0, 0, 1, "Op1Test", 7.3);
234 CHECK_EQ("Op1Test[7.3]", OperatorToString(&op2).get());
235
236 Operator1<double> op3(12, 0, 0, 1, "FooBar", 2e+123);
237 CHECK_EQ("FooBar[2e+123]", OperatorToString(&op3).get());
238
239 Operator1<double> op4(12, 0, 0, 1, "BarFoo", Infinity);
240 CHECK_EQ("BarFoo[inf]", OperatorToString(&op4).get());
241
242 Operator1<double> op5(12, 0, 0, 1, "BarFoo", NaN);
243 CHECK_EQ("BarFoo[nan]", OperatorToString(&op5).get());
244 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/compiler/test-node-cache.cc ('k') | test/cctest/compiler/compiler/test-phi-reducer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698