| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "platform/globals.h" | 5 #include "platform/globals.h" |
| 6 | 6 |
| 7 #include "include/dart_debugger_api.h" | 7 #include "include/dart_debugger_api.h" |
| 8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/debugger.h" | 10 #include "vm/debugger.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 | 102 |
| 103 static RawClass* GetClass(const Library& lib, const char* name) { | 103 static RawClass* GetClass(const Library& lib, const char* name) { |
| 104 const Class& cls = Class::Handle( | 104 const Class& cls = Class::Handle( |
| 105 lib.LookupClass(String::Handle(Symbols::New(name)))); | 105 lib.LookupClass(String::Handle(Symbols::New(name)))); |
| 106 EXPECT(!cls.IsNull()); // No ambiguity error expected. | 106 EXPECT(!cls.IsNull()); // No ambiguity error expected. |
| 107 return cls.raw(); | 107 return cls.raw(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 | 110 |
| 111 TEST_CASE(Service_IdZones) { |
| 112 Isolate* isolate = Isolate::Current(); |
| 113 |
| 114 const String& test_a = String::Handle(isolate, String::New("a")); |
| 115 const String& test_b = String::Handle(isolate, String::New("b")); |
| 116 const String& test_c = String::Handle(isolate, String::New("c")); |
| 117 const String& test_d = String::Handle(isolate, String::New("d")); |
| 118 |
| 119 // Both RingServiceIdZones share the same backing store and id space. |
| 120 |
| 121 // Always allocate a new id. |
| 122 RingServiceIdZone always_new_zone(ObjectIdRing::kAllocateId); |
| 123 EXPECT_STREQ("objects/0", always_new_zone.GetServiceId(test_a)); |
| 124 EXPECT_STREQ("objects/1", always_new_zone.GetServiceId(test_a)); |
| 125 EXPECT_STREQ("objects/2", always_new_zone.GetServiceId(test_a)); |
| 126 EXPECT_STREQ("objects/3", always_new_zone.GetServiceId(test_b)); |
| 127 EXPECT_STREQ("objects/4", always_new_zone.GetServiceId(test_c)); |
| 128 |
| 129 // Reuse an existing id or allocate a new id. |
| 130 RingServiceIdZone reuse_zone(ObjectIdRing::kReuseId); |
| 131 EXPECT_STREQ("objects/0", reuse_zone.GetServiceId(test_a)); |
| 132 EXPECT_STREQ("objects/0", reuse_zone.GetServiceId(test_a)); |
| 133 EXPECT_STREQ("objects/3", reuse_zone.GetServiceId(test_b)); |
| 134 EXPECT_STREQ("objects/3", reuse_zone.GetServiceId(test_b)); |
| 135 EXPECT_STREQ("objects/4", reuse_zone.GetServiceId(test_c)); |
| 136 EXPECT_STREQ("objects/4", reuse_zone.GetServiceId(test_c)); |
| 137 EXPECT_STREQ("objects/5", reuse_zone.GetServiceId(test_d)); |
| 138 EXPECT_STREQ("objects/5", reuse_zone.GetServiceId(test_d)); |
| 139 } |
| 140 |
| 141 |
| 111 TEST_CASE(Service_Code) { | 142 TEST_CASE(Service_Code) { |
| 112 const char* kScript = | 143 const char* kScript = |
| 113 "var port;\n" // Set to our mock port by C++. | 144 "var port;\n" // Set to our mock port by C++. |
| 114 "\n" | 145 "\n" |
| 115 "class A {\n" | 146 "class A {\n" |
| 116 " var a;\n" | 147 " var a;\n" |
| 117 " dynamic b() {}\n" | 148 " dynamic b() {}\n" |
| 118 " dynamic c() {\n" | 149 " dynamic c() {\n" |
| 119 " var d = () { b(); };\n" | 150 " var d = () { b(); };\n" |
| 120 " return d;\n" | 151 " return d;\n" |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 Eval(lib, "[0, port, '0', 'getCpuProfile', ['tags'], ['Bogus']]"); | 619 Eval(lib, "[0, port, '0', 'getCpuProfile', ['tags'], ['Bogus']]"); |
| 589 Service::HandleIsolateMessage(isolate, service_msg); | 620 Service::HandleIsolateMessage(isolate, service_msg); |
| 590 handler.HandleNextMessage(); | 621 handler.HandleNextMessage(); |
| 591 // Expect error. | 622 // Expect error. |
| 592 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); | 623 EXPECT_SUBSTRING("\"type\":\"Error\"", handler.msg()); |
| 593 } | 624 } |
| 594 | 625 |
| 595 #endif // !defined(TARGET_ARCH_ARM64) | 626 #endif // !defined(TARGET_ARCH_ARM64) |
| 596 | 627 |
| 597 } // namespace dart | 628 } // namespace dart |
| OLD | NEW |