| OLD | NEW |
| 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 Loading... |
| 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 |
| 202 // Non-instance objects. | 207 // Non-instance objects. |
| 203 { | 208 { |
| 204 Isolate* isolate = Isolate::Current(); | 209 Isolate* isolate = Isolate::Current(); |
| 205 DARTSCOPE(isolate); | 210 DARTSCOPE(isolate); |
| 206 Dart_Handle class1 = Api::NewHandle(isolate, Object::void_class()); | 211 Dart_Handle class1 = Api::NewHandle(isolate, Object::void_class()); |
| 207 Dart_Handle class2 = Api::NewHandle(isolate, Object::class_class()); | 212 Dart_Handle class2 = Api::NewHandle(isolate, Object::class_class()); |
| 208 | 213 |
| 209 EXPECT(Dart_IdentityEquals(class1, class1)); | 214 EXPECT(Dart_IdentityEquals(class1, class1)); |
| 210 | 215 |
| 211 EXPECT(!Dart_IdentityEquals(class1, class2)); | 216 EXPECT(!Dart_IdentityEquals(class1, class2)); |
| 217 |
| 218 // Mix instance and non-instance. |
| 219 EXPECT(!Dart_IdentityEquals(class1, nan1)); |
| 220 EXPECT(!Dart_IdentityEquals(nan1, class1)); |
| 212 } | 221 } |
| 213 } | 222 } |
| 214 | 223 |
| 215 | 224 |
| 216 TEST_CASE(ObjectEquals) { | 225 TEST_CASE(ObjectEquals) { |
| 217 bool equal = false; | 226 bool equal = false; |
| 218 Dart_Handle five = NewString("5"); | 227 Dart_Handle five = NewString("5"); |
| 219 Dart_Handle five_again = NewString("5"); | 228 Dart_Handle five_again = NewString("5"); |
| 220 Dart_Handle seven = NewString("7"); | 229 Dart_Handle seven = NewString("7"); |
| 221 | 230 |
| 222 // Same objects. | 231 // Same objects. |
| 223 EXPECT_VALID(Dart_ObjectEquals(five, five, &equal)); | 232 EXPECT_VALID(Dart_ObjectEquals(five, five, &equal)); |
| 224 EXPECT(equal); | 233 EXPECT(equal); |
| 225 | 234 |
| 226 // Equal objects. | 235 // Equal objects. |
| 227 EXPECT_VALID(Dart_ObjectEquals(five, five_again, &equal)); | 236 EXPECT_VALID(Dart_ObjectEquals(five, five_again, &equal)); |
| 228 EXPECT(equal); | 237 EXPECT(equal); |
| 229 | 238 |
| 230 // Different objects. | 239 // Different objects. |
| 231 EXPECT_VALID(Dart_ObjectEquals(five, seven, &equal)); | 240 EXPECT_VALID(Dart_ObjectEquals(five, seven, &equal)); |
| 232 EXPECT(!equal); | 241 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); |
| 233 } | 247 } |
| 234 | 248 |
| 235 | 249 |
| 236 TEST_CASE(InstanceValues) { | 250 TEST_CASE(InstanceValues) { |
| 237 EXPECT(Dart_IsInstance(NewString("test"))); | 251 EXPECT(Dart_IsInstance(NewString("test"))); |
| 238 EXPECT(Dart_IsInstance(Dart_True())); | 252 EXPECT(Dart_IsInstance(Dart_True())); |
| 239 | 253 |
| 240 // By convention, our Is*() functions exclude null. | 254 // By convention, our Is*() functions exclude null. |
| 241 EXPECT(!Dart_IsInstance(Dart_Null())); | 255 EXPECT(!Dart_IsInstance(Dart_Null())); |
| 242 } | 256 } |
| (...skipping 7074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7317 NewString("main"), | 7331 NewString("main"), |
| 7318 0, | 7332 0, |
| 7319 NULL); | 7333 NULL); |
| 7320 int64_t value = 0; | 7334 int64_t value = 0; |
| 7321 result = Dart_IntegerToInt64(result, &value); | 7335 result = Dart_IntegerToInt64(result, &value); |
| 7322 EXPECT_VALID(result); | 7336 EXPECT_VALID(result); |
| 7323 EXPECT_EQ(8, value); | 7337 EXPECT_EQ(8, value); |
| 7324 } | 7338 } |
| 7325 | 7339 |
| 7326 } // namespace dart | 7340 } // namespace dart |
| OLD | NEW |