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

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

Issue 1683363002: Remove support for Javascript warnings in the VM. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address comment Created 4 years, 10 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
« no previous file with comments | « runtime/vm/report.cc ('k') | runtime/vm/stub_code_arm64.cc » ('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 #ifndef PRODUCT
12
13 TEST_CASE(TraceJSWarning) {
14 Zone* zone = thread->zone();
15 Isolate* isolate = thread->isolate();
16 TraceBuffer::Init(isolate, 3);
17 TraceBuffer* trace_buffer = isolate->trace_buffer();
18 const String& url = String::Handle(zone, String::New("Plug"));
19 const String& source = String::Handle(zone, String::New("240 100"));
20 const Script& script = Script::Handle(zone,
21 Script::New(url, source, RawScript::kEvaluateTag));
22 script.Tokenize(String::Handle(String::New("")));
23 {
24 const TokenPosition token_pos = TokenPosition(0);
25 const char* message = "High Voltage";
26 Report::MessageF(Report::kJSWarning,
27 script, token_pos, Report::AtLocation, "%s", message);
28 {
29 JSONStream js;
30 trace_buffer->PrintToJSONStream(&js);
31 EXPECT_SUBSTRING("{\"type\":\"TraceBuffer\",\"members\":["
32 "{\"type\":\"TraceBufferEntry\",\"time\":",
33 js.ToCString());
34 // Skip time.
35 EXPECT_SUBSTRING("\"message\":{\"type\":\"JSCompatibilityWarning\","
36 "\"script\":{\"type\":\"@Script\"",
37 js.ToCString());
38 // Skip object ring id.
39 EXPECT_SUBSTRING("\"uri\":\"Plug\","
40 "\"_kind\":\"evaluate\"},\"tokenPos\":0,"
41 "\"message\":{\"type\":\"@Instance\"",
42 js.ToCString());
43 // Skip private _OneByteString.
44 EXPECT_SUBSTRING("\"valueAsString\":\"High Voltage\"",
45 js.ToCString());
46 }
47 }
48 {
49 const TokenPosition token_pos = TokenPosition(1);
50 const char* message = "Low Voltage";
51 Report::MessageF(Report::kJSWarning,
52 script, token_pos, Report::AtLocation, "%s", message);
53 }
54 EXPECT_EQ(2, trace_buffer->Length());
55 EXPECT_SUBSTRING("{\"type\":\"JSCompatibilityWarning\",\"script\":{\"type\":"
56 "\"@Script\"",
57 trace_buffer->At(0)->message);
58 // Skip object ring id.
59 EXPECT_SUBSTRING("\"uri\":\"Plug\","
60 "\"_kind\":\"evaluate\"},\"tokenPos\":0,"
61 "\"message\":{\"type\":\"@Instance\"",
62 trace_buffer->At(0)->message);
63 // Skip private _OneByteString.
64 EXPECT_SUBSTRING("\"valueAsString\":\"High Voltage\"",
65 trace_buffer->At(0)->message);
66
67 EXPECT_SUBSTRING("{\"type\":\"JSCompatibilityWarning\",\"script\":{\"type\":"
68 "\"@Script\"",
69 trace_buffer->At(1)->message);
70 // Skip object ring id.
71 EXPECT_SUBSTRING("\"uri\":\"Plug\","
72 "\"_kind\":\"evaluate\"},\"tokenPos\":1,"
73 "\"message\":{\"type\":\"@Instance\"",
74 trace_buffer->At(1)->message);
75 // Skip private _OneByteString.
76 EXPECT_SUBSTRING("\"valueAsString\":\"Low Voltage\"",
77 trace_buffer->At(1)->message);
78
79 delete trace_buffer;
80 }
81
82 #endif // !PRODUCT
83
84 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/report.cc ('k') | runtime/vm/stub_code_arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698