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

Side by Side Diff: runtime/vm/dart_api_impl_test.cc

Issue 23587024: Revert revision 27542 "Make Dart_IdentityEqual live up to its spec and not leak boxing implementati… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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 | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/object.h » ('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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/builtin.h" 5 #include "bin/builtin.h"
6 #include "include/dart_api.h" 6 #include "include/dart_api.h"
7 #include "include/dart_mirrors_api.h" 7 #include "include/dart_mirrors_api.h"
8 #include "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/json.h" 10 #include "platform/json.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 192
193 // Same objects. 193 // Same objects.
194 EXPECT(Dart_IdentityEquals(five, five)); 194 EXPECT(Dart_IdentityEquals(five, five));
195 195
196 // Equal objects. 196 // Equal objects.
197 EXPECT(!Dart_IdentityEquals(five, five_again)); 197 EXPECT(!Dart_IdentityEquals(five, five_again));
198 198
199 // Different objects. 199 // Different objects.
200 EXPECT(!Dart_IdentityEquals(five, seven)); 200 EXPECT(!Dart_IdentityEquals(five, seven));
201 201
202 // Case where identical() is not the same as pointer equality.
203 Dart_Handle nan1 = Dart_NewDouble(0.0/0.0);
204 Dart_Handle nan2 = Dart_NewDouble(0.0/0.0);
205 EXPECT(Dart_IdentityEquals(nan1, nan2));
206
207 // Non-instance objects. 202 // Non-instance objects.
208 { 203 {
209 Isolate* isolate = Isolate::Current(); 204 Isolate* isolate = Isolate::Current();
210 DARTSCOPE(isolate); 205 DARTSCOPE(isolate);
211 Dart_Handle class1 = Api::NewHandle(isolate, Object::void_class()); 206 Dart_Handle class1 = Api::NewHandle(isolate, Object::void_class());
212 Dart_Handle class2 = Api::NewHandle(isolate, Object::class_class()); 207 Dart_Handle class2 = Api::NewHandle(isolate, Object::class_class());
213 208
214 EXPECT(Dart_IdentityEquals(class1, class1)); 209 EXPECT(Dart_IdentityEquals(class1, class1));
215 210
216 EXPECT(!Dart_IdentityEquals(class1, class2)); 211 EXPECT(!Dart_IdentityEquals(class1, class2));
217
218 // Mix instance and non-instance.
219 EXPECT(!Dart_IdentityEquals(class1, nan1));
220 EXPECT(!Dart_IdentityEquals(nan1, class1));
221 } 212 }
222 } 213 }
223 214
224 215
225 TEST_CASE(ObjectEquals) { 216 TEST_CASE(ObjectEquals) {
226 bool equal = false; 217 bool equal = false;
227 Dart_Handle five = NewString("5"); 218 Dart_Handle five = NewString("5");
228 Dart_Handle five_again = NewString("5"); 219 Dart_Handle five_again = NewString("5");
229 Dart_Handle seven = NewString("7"); 220 Dart_Handle seven = NewString("7");
230 221
231 // Same objects. 222 // Same objects.
232 EXPECT_VALID(Dart_ObjectEquals(five, five, &equal)); 223 EXPECT_VALID(Dart_ObjectEquals(five, five, &equal));
233 EXPECT(equal); 224 EXPECT(equal);
234 225
235 // Equal objects. 226 // Equal objects.
236 EXPECT_VALID(Dart_ObjectEquals(five, five_again, &equal)); 227 EXPECT_VALID(Dart_ObjectEquals(five, five_again, &equal));
237 EXPECT(equal); 228 EXPECT(equal);
238 229
239 // Different objects. 230 // Different objects.
240 EXPECT_VALID(Dart_ObjectEquals(five, seven, &equal)); 231 EXPECT_VALID(Dart_ObjectEquals(five, seven, &equal));
241 EXPECT(!equal); 232 EXPECT(!equal);
242
243 // Case where == is not the same as pointer equality.
244 Dart_Handle nan = Dart_NewDouble(0.0/0.0);
245 EXPECT_VALID(Dart_ObjectEquals(nan, nan, &equal));
246 EXPECT(!equal);
247 } 233 }
248 234
249 235
250 TEST_CASE(InstanceValues) { 236 TEST_CASE(InstanceValues) {
251 EXPECT(Dart_IsInstance(NewString("test"))); 237 EXPECT(Dart_IsInstance(NewString("test")));
252 EXPECT(Dart_IsInstance(Dart_True())); 238 EXPECT(Dart_IsInstance(Dart_True()));
253 239
254 // By convention, our Is*() functions exclude null. 240 // By convention, our Is*() functions exclude null.
255 EXPECT(!Dart_IsInstance(Dart_Null())); 241 EXPECT(!Dart_IsInstance(Dart_Null()));
256 } 242 }
(...skipping 7080 matching lines...) Expand 10 before | Expand all | Expand 10 after
7337 NewString("main"), 7323 NewString("main"),
7338 0, 7324 0,
7339 NULL); 7325 NULL);
7340 int64_t value = 0; 7326 int64_t value = 0;
7341 result = Dart_IntegerToInt64(result, &value); 7327 result = Dart_IntegerToInt64(result, &value);
7342 EXPECT_VALID(result); 7328 EXPECT_VALID(result);
7343 EXPECT_EQ(8, value); 7329 EXPECT_EQ(8, value);
7344 } 7330 }
7345 7331
7346 } // namespace dart 7332 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698