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

Side by Side Diff: test/cctest/test-code-stubs.cc

Issue 892603002: Fix the test-code-stubs tests. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Stupid Windows! Created 5 years, 10 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
« no previous file with comments | « no previous file | 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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 return (0 - result); 70 return (0 - result);
71 } else { 71 } else {
72 return result; 72 return result;
73 } 73 }
74 } 74 }
75 75
76 76
77 void RunOneTruncationTestWithTest(ConvertDToICallWrapper callWrapper, 77 void RunOneTruncationTestWithTest(ConvertDToICallWrapper callWrapper,
78 ConvertDToIFunc func, 78 ConvertDToIFunc func,
79 double from, 79 double from,
80 double raw) { 80 int32_t to) {
81 uint64_t to = static_cast<int64_t>(raw); 81 int32_t result = (*callWrapper)(func, from);
82 int result = (*callWrapper)(func, from); 82 CHECK_EQ(to, result);
83 CHECK_EQ(static_cast<int>(to), result);
84 } 83 }
85 84
86 85
87 int32_t DefaultCallWrapper(ConvertDToIFunc func, 86 int32_t DefaultCallWrapper(ConvertDToIFunc func,
88 double from) { 87 double from) {
89 return (*func)(from); 88 return (*func)(from);
90 } 89 }
91 90
92 91
93 // #define NaN and Infinity so that it's possible to cut-and-paste these tests 92 // #define NaN and Infinity so that it's possible to cut-and-paste these tests
(...skipping 22 matching lines...) Expand all
116 RunOneTruncationTest(Infinity, 0); 115 RunOneTruncationTest(Infinity, 0);
117 RunOneTruncationTest(-NaN, 0); 116 RunOneTruncationTest(-NaN, 0);
118 RunOneTruncationTest(-Infinity, 0); 117 RunOneTruncationTest(-Infinity, 0);
119 RunOneTruncationTest(4.94065645841e-324, 0); 118 RunOneTruncationTest(4.94065645841e-324, 0);
120 RunOneTruncationTest(-4.94065645841e-324, 0); 119 RunOneTruncationTest(-4.94065645841e-324, 0);
121 120
122 RunOneTruncationTest(0.9999999999999999, 0); 121 RunOneTruncationTest(0.9999999999999999, 0);
123 RunOneTruncationTest(-0.9999999999999999, 0); 122 RunOneTruncationTest(-0.9999999999999999, 0);
124 RunOneTruncationTest(4294967296.0, 0); 123 RunOneTruncationTest(4294967296.0, 0);
125 RunOneTruncationTest(-4294967296.0, 0); 124 RunOneTruncationTest(-4294967296.0, 0);
126 RunOneTruncationTest(9223372036854775000.0, 4294966272.0); 125 RunOneTruncationTest(9223372036854775000.0, -1024);
127 RunOneTruncationTest(-9223372036854775000.0, -4294966272.0); 126 RunOneTruncationTest(-9223372036854775000.0, 1024);
128 RunOneTruncationTest(4.5036e+15, 372629504); 127 RunOneTruncationTest(4.5036e+15, 372629504);
129 RunOneTruncationTest(-4.5036e+15, -372629504); 128 RunOneTruncationTest(-4.5036e+15, -372629504);
130 129
131 RunOneTruncationTest(287524199.5377777, 0x11234567); 130 RunOneTruncationTest(287524199.5377777, 0x11234567);
132 RunOneTruncationTest(-287524199.5377777, -0x11234567); 131 RunOneTruncationTest(-287524199.5377777, -0x11234567);
133 RunOneTruncationTest(2300193596.302222, 2300193596.0); 132 RunOneTruncationTest(2300193596.302222, -1994773700);
134 RunOneTruncationTest(-2300193596.302222, -2300193596.0); 133 RunOneTruncationTest(-2300193596.302222, 1994773700);
135 RunOneTruncationTest(4600387192.604444, 305419896); 134 RunOneTruncationTest(4600387192.604444, 305419896);
136 RunOneTruncationTest(-4600387192.604444, -305419896); 135 RunOneTruncationTest(-4600387192.604444, -305419896);
137 RunOneTruncationTest(4823855600872397.0, 1737075661); 136 RunOneTruncationTest(4823855600872397.0, 1737075661);
138 RunOneTruncationTest(-4823855600872397.0, -1737075661); 137 RunOneTruncationTest(-4823855600872397.0, -1737075661);
139 138
140 RunOneTruncationTest(4503603922337791.0, -1); 139 RunOneTruncationTest(4503603922337791.0, -1);
141 RunOneTruncationTest(-4503603922337791.0, 1); 140 RunOneTruncationTest(-4503603922337791.0, 1);
142 RunOneTruncationTest(4503601774854143.0, 2147483647); 141 RunOneTruncationTest(4503601774854143.0, 2147483647);
143 RunOneTruncationTest(-4503601774854143.0, -2147483647); 142 RunOneTruncationTest(-4503601774854143.0, -2147483647);
144 RunOneTruncationTest(9007207844675582.0, -2); 143 RunOneTruncationTest(9007207844675582.0, -2);
145 RunOneTruncationTest(-9007207844675582.0, 2); 144 RunOneTruncationTest(-9007207844675582.0, 2);
146 145
147 RunOneTruncationTest(2.4178527921507624e+24, -536870912); 146 RunOneTruncationTest(2.4178527921507624e+24, -536870912);
148 RunOneTruncationTest(-2.4178527921507624e+24, 536870912); 147 RunOneTruncationTest(-2.4178527921507624e+24, 536870912);
149 RunOneTruncationTest(2.417853945072267e+24, -536870912); 148 RunOneTruncationTest(2.417853945072267e+24, -536870912);
150 RunOneTruncationTest(-2.417853945072267e+24, 536870912); 149 RunOneTruncationTest(-2.417853945072267e+24, 536870912);
151 150
152 RunOneTruncationTest(4.8357055843015248e+24, -1073741824); 151 RunOneTruncationTest(4.8357055843015248e+24, -1073741824);
153 RunOneTruncationTest(-4.8357055843015248e+24, 1073741824); 152 RunOneTruncationTest(-4.8357055843015248e+24, 1073741824);
154 RunOneTruncationTest(4.8357078901445341e+24, -1073741824); 153 RunOneTruncationTest(4.8357078901445341e+24, -1073741824);
155 RunOneTruncationTest(-4.8357078901445341e+24, 1073741824); 154 RunOneTruncationTest(-4.8357078901445341e+24, 1073741824);
156 155
157 RunOneTruncationTest(2147483647.0, 2147483647.0); 156 RunOneTruncationTest(2147483647.0, 2147483647);
158 RunOneTruncationTest(-2147483648.0, -2147483648.0); 157 RunOneTruncationTest(-2147483648.0, -2147483647-1);
159 RunOneTruncationTest(9.6714111686030497e+24, -2147483648.0); 158 RunOneTruncationTest(9.6714111686030497e+24, -2147483647-1);
160 RunOneTruncationTest(-9.6714111686030497e+24, -2147483648.0); 159 RunOneTruncationTest(-9.6714111686030497e+24, -2147483647-1);
161 RunOneTruncationTest(9.6714157802890681e+24, -2147483648.0); 160 RunOneTruncationTest(9.6714157802890681e+24, -2147483647-1);
162 RunOneTruncationTest(-9.6714157802890681e+24, -2147483648.0); 161 RunOneTruncationTest(-9.6714157802890681e+24, -2147483647-1);
163 RunOneTruncationTest(1.9342813113834065e+25, 2147483648.0); 162 RunOneTruncationTest(1.9342813113834065e+25, -2147483647-1);
164 RunOneTruncationTest(-1.9342813113834065e+25, 2147483648.0); 163 RunOneTruncationTest(-1.9342813113834065e+25, -2147483647-1);
165 164
166 RunOneTruncationTest(3.868562622766813e+25, 0); 165 RunOneTruncationTest(3.868562622766813e+25, 0);
167 RunOneTruncationTest(-3.868562622766813e+25, 0); 166 RunOneTruncationTest(-3.868562622766813e+25, 0);
168 RunOneTruncationTest(1.7976931348623157e+308, 0); 167 RunOneTruncationTest(1.7976931348623157e+308, 0);
169 RunOneTruncationTest(-1.7976931348623157e+308, 0); 168 RunOneTruncationTest(-1.7976931348623157e+308, 0);
170 } 169 }
171 170
172 #undef NaN 171 #undef NaN
173 #undef Infinity 172 #undef Infinity
174 #undef RunOneTruncationTest 173 #undef RunOneTruncationTest
175 174
176 175
177 TEST(CodeStubMajorKeys) { 176 TEST(CodeStubMajorKeys) {
178 CcTest::InitializeVM(); 177 CcTest::InitializeVM();
179 LocalContext context; 178 LocalContext context;
180 Isolate* isolate = CcTest::i_isolate(); 179 Isolate* isolate = CcTest::i_isolate();
181 180
182 #define CHECK_STUB(NAME) \ 181 #define CHECK_STUB(NAME) \
183 { \ 182 { \
184 HandleScope scope(isolate); \ 183 HandleScope scope(isolate); \
185 NAME##Stub stub_impl(0xabcd, isolate); \ 184 NAME##Stub stub_impl(0xabcd, isolate); \
186 CodeStub* stub = &stub_impl; \ 185 CodeStub* stub = &stub_impl; \
187 CHECK_EQ(stub->MajorKey(), CodeStub::NAME); \ 186 CHECK_EQ(stub->MajorKey(), CodeStub::NAME); \
188 } 187 }
189 CODE_STUB_LIST(CHECK_STUB); 188 CODE_STUB_LIST(CHECK_STUB);
190 } 189 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698