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_tools_api.h" | 7 #include "include/dart_tools_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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 | 109 |
110 static RawClass* GetClass(const Library& lib, const char* name) { | 110 static RawClass* GetClass(const Library& lib, const char* name) { |
111 const Class& cls = Class::Handle( | 111 const Class& cls = Class::Handle( |
112 lib.LookupClass(String::Handle(Symbols::New(Thread::Current(), name)))); | 112 lib.LookupClass(String::Handle(Symbols::New(Thread::Current(), name)))); |
113 EXPECT(!cls.IsNull()); // No ambiguity error expected. | 113 EXPECT(!cls.IsNull()); // No ambiguity error expected. |
114 return cls.raw(); | 114 return cls.raw(); |
115 } | 115 } |
116 | 116 |
117 | 117 |
| 118 TEST_CASE(Service_IsolateStickyError) { |
| 119 const char* kScript = |
| 120 "main() => throw 'HI THERE STICKY';\n"; |
| 121 |
| 122 Isolate* isolate = thread->isolate(); |
| 123 isolate->set_is_runnable(true); |
| 124 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
| 125 EXPECT_VALID(lib); |
| 126 Library& vmlib = Library::Handle(); |
| 127 vmlib ^= Api::UnwrapHandle(lib); |
| 128 EXPECT(!vmlib.IsNull()); |
| 129 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
| 130 EXPECT(Dart_IsUnhandledExceptionError(result)); |
| 131 EXPECT(!Dart_HasStickyError()); |
| 132 EXPECT(Thread::Current()->sticky_error() == Error::null()); |
| 133 |
| 134 { |
| 135 TransitionNativeToVM transition(thread); |
| 136 |
| 137 JSONStream js; |
| 138 isolate->PrintJSON(&js, false); |
| 139 // No error property and no PauseExit state. |
| 140 EXPECT_NOTSUBSTRING("\"error\":", js.ToCString()); |
| 141 EXPECT_NOTSUBSTRING("HI THERE STICKY", js.ToCString()); |
| 142 EXPECT_NOTSUBSTRING("PauseExit", js.ToCString()); |
| 143 } |
| 144 |
| 145 // Set the sticky error. |
| 146 Dart_SetStickyError(result); |
| 147 EXPECT(Dart_HasStickyError()); |
| 148 |
| 149 { |
| 150 TransitionNativeToVM transition(thread); |
| 151 |
| 152 JSONStream js; |
| 153 isolate->PrintJSON(&js, false); |
| 154 // Error and PauseExit set. |
| 155 EXPECT_SUBSTRING("\"error\":", js.ToCString()); |
| 156 EXPECT_SUBSTRING("HI THERE STICKY", js.ToCString()); |
| 157 EXPECT_SUBSTRING("PauseExit", js.ToCString()); |
| 158 } |
| 159 } |
| 160 |
| 161 |
118 TEST_CASE(Service_IdZones) { | 162 TEST_CASE(Service_IdZones) { |
119 Zone* zone = thread->zone(); | 163 Zone* zone = thread->zone(); |
120 Isolate* isolate = thread->isolate(); | 164 Isolate* isolate = thread->isolate(); |
121 ObjectIdRing* ring = isolate->object_id_ring(); | 165 ObjectIdRing* ring = isolate->object_id_ring(); |
122 | 166 |
123 const String& test_a = String::Handle(zone, String::New("a")); | 167 const String& test_a = String::Handle(zone, String::New("a")); |
124 const String& test_b = String::Handle(zone, String::New("b")); | 168 const String& test_b = String::Handle(zone, String::New("b")); |
125 const String& test_c = String::Handle(zone, String::New("c")); | 169 const String& test_c = String::Handle(zone, String::New("c")); |
126 const String& test_d = String::Handle(zone, String::New("d")); | 170 const String& test_d = String::Handle(zone, String::New("d")); |
127 | 171 |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 EXPECT_EQ(MessageHandler::kOK, handler.HandleNextMessage()); | 765 EXPECT_EQ(MessageHandler::kOK, handler.HandleNextMessage()); |
722 // Expect error. | 766 // Expect error. |
723 EXPECT_SUBSTRING("\"error\"", handler.msg()); | 767 EXPECT_SUBSTRING("\"error\"", handler.msg()); |
724 } | 768 } |
725 | 769 |
726 #endif // !defined(TARGET_ARCH_ARM64) | 770 #endif // !defined(TARGET_ARCH_ARM64) |
727 | 771 |
728 #endif // !PRODUCT | 772 #endif // !PRODUCT |
729 | 773 |
730 } // namespace dart | 774 } // namespace dart |
OLD | NEW |