Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: runtime/vm/exceptions_test.cc

Issue 328663008: Add support to trace warnings in TraceBuffer. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/exceptions.cc ('k') | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "platform/assert.h" 6 #include "platform/assert.h"
7 #include "vm/dart_api_impl.h" 7 #include "vm/dart_api_impl.h"
8 #include "vm/unit_test.h" 8 #include "vm/unit_test.h"
9 9
10 namespace dart { 10 namespace dart {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 "testMain() {\n" 125 "testMain() {\n"
126 " UnhandledExceptions.equals(2, Second.method1(1));\n" 126 " UnhandledExceptions.equals(2, Second.method1(1));\n"
127 " UnhandledExceptions.equals(3, Second.method3(1));\n" 127 " UnhandledExceptions.equals(3, Second.method3(1));\n"
128 "}"; 128 "}";
129 Dart_Handle lib = TestCase::LoadTestScript( 129 Dart_Handle lib = TestCase::LoadTestScript(
130 kScriptChars, 130 kScriptChars,
131 reinterpret_cast<Dart_NativeEntryResolver>(native_lookup)); 131 reinterpret_cast<Dart_NativeEntryResolver>(native_lookup));
132 EXPECT_VALID(Dart_Invoke(lib, NewString("testMain"), 0, NULL)); 132 EXPECT_VALID(Dart_Invoke(lib, NewString("testMain"), 0, NULL));
133 } 133 }
134 134
135
136 TEST_CASE(TraceJSWarning) {
137 Isolate* isolate = Isolate::Current();
138 TraceBuffer::Init(isolate, 3);
139 TraceBuffer* trace_buffer = isolate->trace_buffer();
140 const String& url = String::Handle(isolate, String::New("Plug"));
141 const String& source = String::Handle(isolate, String::New("240V"));
142 const Script& script = Script::Handle(isolate,
143 Script::New(url, source, RawScript::kScriptTag));
144 {
145 const intptr_t token_pos = 0;
146 const char* message = "High Voltage";
147 Exceptions::TraceJSWarningF(script, token_pos, "%s", message);
148 {
149 JSONStream js;
150 trace_buffer->PrintToJSONStream(&js);
151 EXPECT_SUBSTRING("{\"type\":\"TraceBuffer\",\"members\":["
152 "{\"type\":\"TraceBufferEntry\",\"time\":",
153 js.ToCString());
154 // Skip time.
155 EXPECT_SUBSTRING("\"message\":{\"type\":\"JSCompatibilityWarning\","
156 "\"script\":{\"type\":\"@Script\",\"id\":"
157 "\"scripts\\/Plug\",\"name\":\"Plug\",\"user_name\":"
158 "\"Plug\",\"kind\":\"script\"},\"tokenPos\":0,"
159 "\"message\":\"High Voltage\"}}]}",
160 js.ToCString());
161 }
162 }
163 {
164 const intptr_t token_pos = 1;
165 const char* message = "Low Voltage";
166 Exceptions::TraceJSWarningF(script, token_pos, "%s", message);
167 }
168 EXPECT_EQ(2, trace_buffer->Length());
169 EXPECT_STREQ("{\"type\":\"JSCompatibilityWarning\",\"script\":{\"type\":"
170 "\"@Script\",\"id\":\"scripts\\/Plug\",\"name\":\"Plug\","
171 "\"user_name\":\"Plug\",\"kind\":\"script\"},\"tokenPos\":0,"
172 "\"message\":\"High Voltage\"}",
173 trace_buffer->At(0)->message);
174 EXPECT_STREQ("{\"type\":\"JSCompatibilityWarning\",\"script\":{\"type\":"
175 "\"@Script\",\"id\":\"scripts\\/Plug\",\"name\":\"Plug\","
176 "\"user_name\":\"Plug\",\"kind\":\"script\"},\"tokenPos\":1,"
177 "\"message\":\"Low Voltage\"}",
178 trace_buffer->At(1)->message);
179
180 delete trace_buffer;
181 }
182
135 } // namespace dart 183 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/exceptions.cc ('k') | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698