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 // TODO(zra): Remove when tests are ready to enable. | 5 // TODO(zra): Remove when tests are ready to enable. |
6 #include "platform/globals.h" | 6 #include "platform/globals.h" |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
(...skipping 4072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4083 EXPECT(!clazz.IsNull()); | 4083 EXPECT(!clazz.IsNull()); |
4084 const Instance& a0 = Instance::Handle(Instance::New(clazz)); | 4084 const Instance& a0 = Instance::Handle(Instance::New(clazz)); |
4085 const Instance& a1 = Instance::Handle(Instance::New(clazz)); | 4085 const Instance& a1 = Instance::Handle(Instance::New(clazz)); |
4086 EXPECT(a0.raw() != a1.raw()); | 4086 EXPECT(a0.raw() != a1.raw()); |
4087 EXPECT(a0.OperatorEquals(a0)); | 4087 EXPECT(a0.OperatorEquals(a0)); |
4088 EXPECT(a0.OperatorEquals(a1)); | 4088 EXPECT(a0.OperatorEquals(a1)); |
4089 EXPECT(a0.IsIdenticalTo(a0)); | 4089 EXPECT(a0.IsIdenticalTo(a0)); |
4090 EXPECT(!a0.IsIdenticalTo(a1)); | 4090 EXPECT(!a0.IsIdenticalTo(a1)); |
4091 } | 4091 } |
4092 | 4092 |
| 4093 |
| 4094 TEST_CASE(HashCode) { |
| 4095 // Ensure C++ overrides of Instance::HashCode match the Dart implementations. |
| 4096 const char* kScript = |
| 4097 "foo() {\n" |
| 4098 " return \"foo\".hashCode;\n" |
| 4099 "}"; |
| 4100 |
| 4101 Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL); |
| 4102 EXPECT_VALID(h_lib); |
| 4103 Library& lib = Library::Handle(); |
| 4104 lib ^= Api::UnwrapHandle(h_lib); |
| 4105 EXPECT(!lib.IsNull()); |
| 4106 Dart_Handle h_result = Dart_Invoke(h_lib, NewString("foo"), 0, NULL); |
| 4107 EXPECT_VALID(h_result); |
| 4108 Integer& result = Integer::Handle(); |
| 4109 result ^= Api::UnwrapHandle(h_result); |
| 4110 String& foo = String::Handle(String::New("foo")); |
| 4111 Integer& expected = Integer::Handle(); |
| 4112 expected ^= foo.HashCode(); |
| 4113 EXPECT(result.IsIdenticalTo(expected)); |
| 4114 } |
| 4115 |
4093 } // namespace dart | 4116 } // namespace dart |
OLD | NEW |