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

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

Issue 1401643002: Remove isolate parameter when allocating handles (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Sync Created 5 years, 2 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/coverage.cc ('k') | runtime/vm/dart_api_impl.h » ('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) 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 "vm/coverage.h" 5 #include "vm/coverage.h"
6 #include "vm/dart_api_impl.h" 6 #include "vm/dart_api_impl.h"
7 #include "vm/unit_test.h" 7 #include "vm/unit_test.h"
8 8
9 namespace dart { 9 namespace dart {
10 10
(...skipping 21 matching lines...) Expand all
32 private: 32 private:
33 const Function& func_; 33 const Function& func_;
34 }; 34 };
35 35
36 36
37 TEST_CASE(Coverage_Empty) { 37 TEST_CASE(Coverage_Empty) {
38 const char* kScript = 38 const char* kScript =
39 "main() {\n" 39 "main() {\n"
40 "}"; 40 "}";
41 41
42 Isolate* isolate = Isolate::Current();
43 Library& lib = Library::Handle(); 42 Library& lib = Library::Handle();
44 lib ^= ExecuteScript(kScript); 43 lib ^= ExecuteScript(kScript);
45 ASSERT(!lib.IsNull()); 44 ASSERT(!lib.IsNull());
46 45
47 JSONStream js; 46 JSONStream js;
48 CodeCoverage::PrintJSON(isolate, &js, NULL, false); 47 CodeCoverage::PrintJSON(thread, &js, NULL, false);
49 48
50 char buf[1024]; 49 char buf[1024];
51 OS::SNPrint(buf, sizeof(buf), 50 OS::SNPrint(buf, sizeof(buf),
52 "{\"source\":\"test-lib\",\"script\":{\"type\":\"@Script\"," 51 "{\"source\":\"test-lib\",\"script\":{\"type\":\"@Script\","
53 "\"fixedId\":true,\"id\":\"libraries\\/%" Pd "\\/scripts\\/test-lib\"," 52 "\"fixedId\":true,\"id\":\"libraries\\/%" Pd "\\/scripts\\/test-lib\","
54 "\"uri\":\"test-lib\"," 53 "\"uri\":\"test-lib\","
55 "\"_kind\":\"script\"},\"hits\":[]}", lib.index()); 54 "\"_kind\":\"script\"},\"hits\":[]}", lib.index());
56 EXPECT_SUBSTRING(buf, js.ToCString()); 55 EXPECT_SUBSTRING(buf, js.ToCString());
57 } 56 }
58 57
59 58
60 TEST_CASE(Coverage_MainWithClass) { 59 TEST_CASE(Coverage_MainWithClass) {
61 const char* kScript = 60 const char* kScript =
62 "class Foo {\n" 61 "class Foo {\n"
63 " var x;\n" 62 " var x;\n"
64 " Foo(this.x);\n" 63 " Foo(this.x);\n"
65 " bar() {\n" 64 " bar() {\n"
66 " x = x * x;\n" 65 " x = x * x;\n"
67 " x = x / 13;\n" 66 " x = x / 13;\n"
68 " }\n" 67 " }\n"
69 "}\n" 68 "}\n"
70 "main() {\n" 69 "main() {\n"
71 " var foo = new Foo(7);\n" 70 " var foo = new Foo(7);\n"
72 " foo.bar();\n" 71 " foo.bar();\n"
73 "}\n"; 72 "}\n";
74 73
75 Isolate* isolate = Isolate::Current();
76 Library& lib = Library::Handle(); 74 Library& lib = Library::Handle();
77 lib ^= ExecuteScript(kScript); 75 lib ^= ExecuteScript(kScript);
78 ASSERT(!lib.IsNull()); 76 ASSERT(!lib.IsNull());
79 77
80 JSONStream js; 78 JSONStream js;
81 CodeCoverage::PrintJSON(isolate, &js, NULL, false); 79 CodeCoverage::PrintJSON(thread, &js, NULL, false);
82 80
83 char buf[1024]; 81 char buf[1024];
84 // Coverage data is printed per class, i.e., there should be two sections 82 // Coverage data is printed per class, i.e., there should be two sections
85 // for test-lib in the JSON data. 83 // for test-lib in the JSON data.
86 84
87 // Data for the actual class Foo. 85 // Data for the actual class Foo.
88 OS::SNPrint(buf, sizeof(buf), 86 OS::SNPrint(buf, sizeof(buf),
89 "{\"source\":\"test-lib\",\"script\":{\"type\":\"@Script\"," 87 "{\"source\":\"test-lib\",\"script\":{\"type\":\"@Script\","
90 "\"fixedId\":true,\"id\":\"libraries\\/%" Pd "\\/scripts\\/test-lib\"," 88 "\"fixedId\":true,\"id\":\"libraries\\/%" Pd "\\/scripts\\/test-lib\","
91 "\"uri\":\"test-lib\"," 89 "\"uri\":\"test-lib\","
(...skipping 16 matching lines...) Expand all
108 " var x;\n" 106 " var x;\n"
109 " var y;\n" 107 " var y;\n"
110 " Foo(this.x);\n" 108 " Foo(this.x);\n"
111 " Foo.other(this.x, this.y);\n" 109 " Foo.other(this.x, this.y);\n"
112 " Foo.yetAnother();\n" 110 " Foo.yetAnother();\n"
113 "}\n" 111 "}\n"
114 "main() {\n" 112 "main() {\n"
115 " var foo = new Foo(7);\n" 113 " var foo = new Foo(7);\n"
116 "}\n"; 114 "}\n";
117 115
118 Isolate* isolate = Isolate::Current();
119 Library& lib = Library::Handle(); 116 Library& lib = Library::Handle();
120 lib ^= ExecuteScript(kScript); 117 lib ^= ExecuteScript(kScript);
121 ASSERT(!lib.IsNull()); 118 ASSERT(!lib.IsNull());
122 const Class& cls = Class::Handle( 119 const Class& cls = Class::Handle(
123 lib.LookupClass(String::Handle(String::New("Foo")))); 120 lib.LookupClass(String::Handle(String::New("Foo"))));
124 ASSERT(!cls.IsNull()); 121 ASSERT(!cls.IsNull());
125 const Function& func = Function::Handle( 122 const Function& func = Function::Handle(
126 cls.LookupFunction(String::Handle(String::New("Foo.yetAnother")))); 123 cls.LookupFunction(String::Handle(String::New("Foo.yetAnother"))));
127 ASSERT(!func.IsNull()); 124 ASSERT(!func.IsNull());
128 125
129 JSONStream js; 126 JSONStream js;
130 FunctionCoverageFilter filter(func); 127 FunctionCoverageFilter filter(func);
131 CodeCoverage::PrintJSON(isolate, &js, &filter, false); 128 CodeCoverage::PrintJSON(thread, &js, &filter, false);
132 // Only expect coverage data for Foo.yetAnother() on line 6. 129 // Only expect coverage data for Foo.yetAnother() on line 6.
133 char buf[1024]; 130 char buf[1024];
134 OS::SNPrint(buf, sizeof(buf), 131 OS::SNPrint(buf, sizeof(buf),
135 "{\"source\":\"test-lib\",\"script\":{\"type\":\"@Script\"," 132 "{\"source\":\"test-lib\",\"script\":{\"type\":\"@Script\","
136 "\"fixedId\":true,\"id\":\"libraries\\/%" Pd "\\/scripts\\/test-lib\"," 133 "\"fixedId\":true,\"id\":\"libraries\\/%" Pd "\\/scripts\\/test-lib\","
137 "\"uri\":\"test-lib\"," 134 "\"uri\":\"test-lib\","
138 "\"_kind\":\"script\"},\"hits\":[6,0]}", lib.index()); 135 "\"_kind\":\"script\"},\"hits\":[6,0]}", lib.index());
139 EXPECT_SUBSTRING(buf, js.ToCString()); 136 EXPECT_SUBSTRING(buf, js.ToCString());
140 } 137 }
141 138
142 } // namespace dart 139 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/coverage.cc ('k') | runtime/vm/dart_api_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698