| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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/assert.h" | 5 #include "platform/assert.h" |
| 6 #include "vm/report.h" | 6 #include "vm/report.h" |
| 7 #include "vm/unit_test.h" | 7 #include "vm/unit_test.h" |
| 8 | 8 |
| 9 namespace dart { | 9 namespace dart { |
| 10 | 10 |
| 11 TEST_CASE(TraceJSWarning) { | 11 TEST_CASE(TraceJSWarning) { |
| 12 Isolate* isolate = Isolate::Current(); | 12 Zone* zone = thread->zone(); |
| 13 Isolate* isolate = thread->isolate(); |
| 13 TraceBuffer::Init(isolate, 3); | 14 TraceBuffer::Init(isolate, 3); |
| 14 TraceBuffer* trace_buffer = isolate->trace_buffer(); | 15 TraceBuffer* trace_buffer = isolate->trace_buffer(); |
| 15 const String& url = String::Handle(isolate, String::New("Plug")); | 16 const String& url = String::Handle(zone, String::New("Plug")); |
| 16 const String& source = String::Handle(isolate, String::New("240 100")); | 17 const String& source = String::Handle(zone, String::New("240 100")); |
| 17 const Script& script = Script::Handle(isolate, | 18 const Script& script = Script::Handle(zone, |
| 18 Script::New(url, source, RawScript::kEvaluateTag)); | 19 Script::New(url, source, RawScript::kEvaluateTag)); |
| 19 script.Tokenize(String::Handle(String::New(""))); | 20 script.Tokenize(String::Handle(String::New(""))); |
| 20 { | 21 { |
| 21 const intptr_t token_pos = 0; | 22 const intptr_t token_pos = 0; |
| 22 const char* message = "High Voltage"; | 23 const char* message = "High Voltage"; |
| 23 Report::MessageF(Report::kJSWarning, script, token_pos, "%s", message); | 24 Report::MessageF(Report::kJSWarning, script, token_pos, "%s", message); |
| 24 { | 25 { |
| 25 JSONStream js; | 26 JSONStream js; |
| 26 trace_buffer->PrintToJSONStream(&js); | 27 trace_buffer->PrintToJSONStream(&js); |
| 27 EXPECT_SUBSTRING("{\"type\":\"TraceBuffer\",\"members\":[" | 28 EXPECT_SUBSTRING("{\"type\":\"TraceBuffer\",\"members\":[" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 "\"message\":{\"type\":\"@Instance\"", | 69 "\"message\":{\"type\":\"@Instance\"", |
| 69 trace_buffer->At(1)->message); | 70 trace_buffer->At(1)->message); |
| 70 // Skip private _OneByteString. | 71 // Skip private _OneByteString. |
| 71 EXPECT_SUBSTRING("\"valueAsString\":\"Low Voltage\"", | 72 EXPECT_SUBSTRING("\"valueAsString\":\"Low Voltage\"", |
| 72 trace_buffer->At(1)->message); | 73 trace_buffer->At(1)->message); |
| 73 | 74 |
| 74 delete trace_buffer; | 75 delete trace_buffer; |
| 75 } | 76 } |
| 76 | 77 |
| 77 } // namespace dart | 78 } // namespace dart |
| OLD | NEW |