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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 194 |
195 // Same objects. | 195 // Same objects. |
196 EXPECT(Dart_IdentityEquals(five, five)); | 196 EXPECT(Dart_IdentityEquals(five, five)); |
197 | 197 |
198 // Equal objects. | 198 // Equal objects. |
199 EXPECT(!Dart_IdentityEquals(five, five_again)); | 199 EXPECT(!Dart_IdentityEquals(five, five_again)); |
200 | 200 |
201 // Different objects. | 201 // Different objects. |
202 EXPECT(!Dart_IdentityEquals(five, seven)); | 202 EXPECT(!Dart_IdentityEquals(five, seven)); |
203 | 203 |
| 204 // Case where identical() is not the same as pointer equality. |
| 205 Dart_Handle nan1 = Dart_NewDouble(NAN); |
| 206 Dart_Handle nan2 = Dart_NewDouble(NAN); |
| 207 EXPECT(Dart_IdentityEquals(nan1, nan2)); |
| 208 |
204 // Non-instance objects. | 209 // Non-instance objects. |
205 { | 210 { |
206 Isolate* isolate = Isolate::Current(); | 211 Isolate* isolate = Isolate::Current(); |
207 DARTSCOPE(isolate); | 212 DARTSCOPE(isolate); |
208 Dart_Handle lib1 = Dart_LookupLibrary(dart_core); | 213 Dart_Handle lib1 = Dart_LookupLibrary(dart_core); |
209 Dart_Handle lib2 = Dart_LookupLibrary(dart_mirrors); | 214 Dart_Handle lib2 = Dart_LookupLibrary(dart_mirrors); |
210 | 215 |
211 EXPECT(Dart_IdentityEquals(lib1, lib1)); | 216 EXPECT(Dart_IdentityEquals(lib1, lib1)); |
212 EXPECT(Dart_IdentityEquals(lib2, lib2)); | 217 EXPECT(Dart_IdentityEquals(lib2, lib2)); |
213 EXPECT(!Dart_IdentityEquals(lib1, lib2)); | 218 EXPECT(!Dart_IdentityEquals(lib1, lib2)); |
| 219 |
| 220 // Mix instance and non-instance. |
| 221 EXPECT(!Dart_IdentityEquals(lib1, nan1)); |
| 222 EXPECT(!Dart_IdentityEquals(nan1, lib1)); |
214 } | 223 } |
215 } | 224 } |
216 | 225 |
217 | 226 |
218 TEST_CASE(ObjectEquals) { | 227 TEST_CASE(ObjectEquals) { |
219 bool equal = false; | 228 bool equal = false; |
220 Dart_Handle five = NewString("5"); | 229 Dart_Handle five = NewString("5"); |
221 Dart_Handle five_again = NewString("5"); | 230 Dart_Handle five_again = NewString("5"); |
222 Dart_Handle seven = NewString("7"); | 231 Dart_Handle seven = NewString("7"); |
223 | 232 |
(...skipping 7086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7310 NewString("main"), | 7319 NewString("main"), |
7311 0, | 7320 0, |
7312 NULL); | 7321 NULL); |
7313 int64_t value = 0; | 7322 int64_t value = 0; |
7314 result = Dart_IntegerToInt64(result, &value); | 7323 result = Dart_IntegerToInt64(result, &value); |
7315 EXPECT_VALID(result); | 7324 EXPECT_VALID(result); |
7316 EXPECT_EQ(8, value); | 7325 EXPECT_EQ(8, value); |
7317 } | 7326 } |
7318 | 7327 |
7319 } // namespace dart | 7328 } // namespace dart |
OLD | NEW |