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

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

Issue 913503004: Per isolate Log with block support (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/log.cc ('k') | runtime/vm/service.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) 2015, 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/globals.h"
6
7 #include "include/dart_debugger_api.h"
8 #include "vm/dart_api_impl.h"
9 #include "vm/dart_entry.h"
10 #include "vm/debugger.h"
11 #include "vm/globals.h"
12 #include "vm/isolate.h"
13 #include "vm/log.h"
14 #include "vm/message_handler.h"
15 #include "vm/unit_test.h"
16
17 namespace dart {
18
19 static const char* test_output_;
20 static void TestPrinter(const char* print, ...) {
21 test_output_ = print;
22 }
23
24 class LogTestHelper : public AllStatic {
25 public:
26 static void SetPrinter(Log* log, LogPrinter printer) {
27 ASSERT(log != NULL);
28 ASSERT(printer != NULL);
29 log->printer_ = printer;
30 }
31 };
32
33
34 TEST_CASE(Log_Macro) {
35 test_output_ = NULL;
36 Isolate* isolate = Isolate::Current();
37 Log* log = isolate->Log();
38 LogTestHelper::SetPrinter(log, TestPrinter);
39
40 ISL_Print("Hello %s", "World");
41 EXPECT_STREQ("Hello World", test_output_);
42 ISL_Print("SingleArgument");
43 EXPECT_STREQ("SingleArgument", test_output_);
44 }
45
46
47 TEST_CASE(Log_Basic) {
48 test_output_ = NULL;
49 Log* log = new Log(TestPrinter);
50
51 EXPECT_EQ(reinterpret_cast<const char*>(NULL), test_output_);
52 log->Print("Hello %s", "World");
53 EXPECT_STREQ("Hello World", test_output_);
54 }
55
56
57 TEST_CASE(Log_Block) {
58 test_output_ = NULL;
59 Log* log = new Log(TestPrinter);
60
61 Isolate* isolate = Isolate::Current();
62
63 EXPECT_EQ(reinterpret_cast<const char*>(NULL), test_output_);
64 {
65 LogBlock ba(isolate, log);
66 log->Print("APPLE");
67 EXPECT_EQ(reinterpret_cast<const char*>(NULL), test_output_);
68 {
69 LogBlock ba(isolate, log);
70 log->Print("BANANA");
71 EXPECT_EQ(reinterpret_cast<const char*>(NULL), test_output_);
72 }
73 EXPECT_STREQ("BANANA", test_output_);
74 }
75 EXPECT_STREQ("APPLE", test_output_);
76 }
77
78 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/log.cc ('k') | runtime/vm/service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698