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

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

Issue 340203003: Cleanup of error and warning reporting. (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/report.cc ('k') | runtime/vm/vm_sources.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
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.
4
5 #include "platform/assert.h"
6 #include "vm/report.h"
7 #include "vm/unit_test.h"
8
9 namespace dart {
10
11 TEST_CASE(TraceJSWarning) {
12 Isolate* isolate = Isolate::Current();
13 TraceBuffer::Init(isolate, 3);
14 TraceBuffer* trace_buffer = isolate->trace_buffer();
15 const String& url = String::Handle(isolate, String::New("Plug"));
16 const String& source = String::Handle(isolate, String::New("240 100"));
17 const Script& script = Script::Handle(isolate,
18 Script::New(url, source, RawScript::kScriptTag));
19 script.Tokenize(String::Handle(String::New("")));
20 {
21 const intptr_t token_pos = 0;
22 const char* message = "High Voltage";
23 Report::MessageF(Report::kJSWarning, script, token_pos, "%s", message);
24 {
25 JSONStream js;
26 trace_buffer->PrintToJSONStream(&js);
27 EXPECT_SUBSTRING("{\"type\":\"TraceBuffer\",\"members\":["
28 "{\"type\":\"TraceBufferEntry\",\"time\":",
29 js.ToCString());
30 // Skip time.
31 EXPECT_SUBSTRING("\"message\":{\"type\":\"JSCompatibilityWarning\","
32 "\"script\":{\"type\":\"@Script\",\"id\":"
33 "\"scripts\\/Plug\",\"name\":\"Plug\",\"user_name\":"
34 "\"Plug\",\"kind\":\"script\"},\"tokenPos\":0,"
35 "\"message\":{\"type\":\"@String\"",
36 js.ToCString());
37 // Skip private _OneByteString.
38 EXPECT_SUBSTRING("\"valueAsString\":\"\\\"High Voltage\\\"\"}}",
39 js.ToCString());
40 }
41 }
42 {
43 const intptr_t token_pos = 1;
44 const char* message = "Low Voltage";
45 Report::MessageF(Report::kJSWarning, script, token_pos, "%s", message);
46 }
47 EXPECT_EQ(2, trace_buffer->Length());
48 EXPECT_SUBSTRING("{\"type\":\"JSCompatibilityWarning\",\"script\":{\"type\":"
49 "\"@Script\",\"id\":\"scripts\\/Plug\",\"name\":\"Plug\","
50 "\"user_name\":\"Plug\",\"kind\":\"script\"},\"tokenPos\":0,"
51 "\"message\":{\"type\":\"@String\"",
52 trace_buffer->At(0)->message);
53 // Skip private _OneByteString.
54 EXPECT_SUBSTRING("\"valueAsString\":\"\\\"High Voltage\\\"\"}}",
55 trace_buffer->At(0)->message);
56
57 EXPECT_SUBSTRING("{\"type\":\"JSCompatibilityWarning\",\"script\":{\"type\":"
58 "\"@Script\",\"id\":\"scripts\\/Plug\",\"name\":\"Plug\","
59 "\"user_name\":\"Plug\",\"kind\":\"script\"},\"tokenPos\":1,"
60 "\"message\":{\"type\":\"@String\"",
61 trace_buffer->At(1)->message);
62 // Skip private _OneByteString.
63 EXPECT_SUBSTRING("\"valueAsString\":\"\\\"Low Voltage\\\"\"}}",
64 trace_buffer->At(1)->message);
65
66 delete trace_buffer;
67 }
68
69 } // namespace dart
70
OLDNEW
« no previous file with comments | « runtime/vm/report.cc ('k') | runtime/vm/vm_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698