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

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

Issue 1154163004: Libraries have uris not urls. Scripts have uris not names. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: sync Created 5 years, 7 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/observatory/tests/service/get_object_rpc_test.dart ('k') | runtime/vm/debugger_test.cc » ('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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 lib ^= ExecuteScript(kScript); 44 lib ^= ExecuteScript(kScript);
45 ASSERT(!lib.IsNull()); 45 ASSERT(!lib.IsNull());
46 46
47 JSONStream js; 47 JSONStream js;
48 CodeCoverage::PrintJSON(isolate, &js, NULL, false); 48 CodeCoverage::PrintJSON(isolate, &js, NULL, false);
49 49
50 char buf[1024]; 50 char buf[1024];
51 OS::SNPrint(buf, sizeof(buf), 51 OS::SNPrint(buf, sizeof(buf),
52 "{\"source\":\"test-lib\",\"script\":{\"type\":\"@Script\"," 52 "{\"source\":\"test-lib\",\"script\":{\"type\":\"@Script\","
53 "\"id\":\"libraries\\/%" Pd "\\/scripts\\/test-lib\"," 53 "\"id\":\"libraries\\/%" Pd "\\/scripts\\/test-lib\","
54 "\"name\":\"test-lib\"," 54 "\"uri\":\"test-lib\","
55 "\"kind\":\"script\"},\"hits\":[]}", lib.index()); 55 "\"kind\":\"script\"},\"hits\":[]}", lib.index());
56 EXPECT_SUBSTRING(buf, js.ToCString()); 56 EXPECT_SUBSTRING(buf, js.ToCString());
57 } 57 }
58 58
59 59
60 TEST_CASE(Coverage_MainWithClass) { 60 TEST_CASE(Coverage_MainWithClass) {
61 const char* kScript = 61 const char* kScript =
62 "class Foo {\n" 62 "class Foo {\n"
63 " var x;\n" 63 " var x;\n"
64 " Foo(this.x);\n" 64 " Foo(this.x);\n"
(...skipping 16 matching lines...) Expand all
81 CodeCoverage::PrintJSON(isolate, &js, NULL, false); 81 CodeCoverage::PrintJSON(isolate, &js, NULL, false);
82 82
83 char buf[1024]; 83 char buf[1024];
84 // Coverage data is printed per class, i.e., there should be two sections 84 // Coverage data is printed per class, i.e., there should be two sections
85 // for test-lib in the JSON data. 85 // for test-lib in the JSON data.
86 86
87 // Data for the actual class Foo. 87 // Data for the actual class Foo.
88 OS::SNPrint(buf, sizeof(buf), 88 OS::SNPrint(buf, sizeof(buf),
89 "{\"source\":\"test-lib\",\"script\":{\"type\":\"@Script\"," 89 "{\"source\":\"test-lib\",\"script\":{\"type\":\"@Script\","
90 "\"id\":\"libraries\\/%" Pd "\\/scripts\\/test-lib\"," 90 "\"id\":\"libraries\\/%" Pd "\\/scripts\\/test-lib\","
91 "\"name\":\"test-lib\"," 91 "\"uri\":\"test-lib\","
92 "\"kind\":\"script\"},\"hits\":[3,1,5,4,6,3]}", lib.index()); 92 "\"kind\":\"script\"},\"hits\":[3,1,5,4,6,3]}", lib.index());
93 EXPECT_SUBSTRING(buf, js.ToCString()); 93 EXPECT_SUBSTRING(buf, js.ToCString());
94 94
95 // Data for the fake class containing main(). 95 // Data for the fake class containing main().
96 OS::SNPrint(buf, sizeof(buf), 96 OS::SNPrint(buf, sizeof(buf),
97 "{\"source\":\"test-lib\",\"script\":{\"type\":\"@Script\"," 97 "{\"source\":\"test-lib\",\"script\":{\"type\":\"@Script\","
98 "\"id\":\"libraries\\/%" Pd "\\/scripts\\/test-lib\"," 98 "\"id\":\"libraries\\/%" Pd "\\/scripts\\/test-lib\","
99 "\"name\":\"test-lib\"," 99 "\"uri\":\"test-lib\","
100 "\"kind\":\"script\"},\"hits\":[10,1,11,1]}", lib.index()); 100 "\"kind\":\"script\"},\"hits\":[10,1,11,1]}", lib.index());
101 EXPECT_SUBSTRING(buf, js.ToCString()); 101 EXPECT_SUBSTRING(buf, js.ToCString());
102 } 102 }
103 103
104 104
105 TEST_CASE(Coverage_FilterFunction) { 105 TEST_CASE(Coverage_FilterFunction) {
106 const char* kScript = 106 const char* kScript =
107 "class Foo {\n" 107 "class Foo {\n"
108 " var x;\n" 108 " var x;\n"
109 " var y;\n" 109 " var y;\n"
(...skipping 17 matching lines...) Expand all
127 ASSERT(!func.IsNull()); 127 ASSERT(!func.IsNull());
128 128
129 JSONStream js; 129 JSONStream js;
130 FunctionCoverageFilter filter(func); 130 FunctionCoverageFilter filter(func);
131 CodeCoverage::PrintJSON(isolate, &js, &filter, false); 131 CodeCoverage::PrintJSON(isolate, &js, &filter, false);
132 // Only expect coverage data for Foo.yetAnother() on line 6. 132 // Only expect coverage data for Foo.yetAnother() on line 6.
133 char buf[1024]; 133 char buf[1024];
134 OS::SNPrint(buf, sizeof(buf), 134 OS::SNPrint(buf, sizeof(buf),
135 "{\"source\":\"test-lib\",\"script\":{\"type\":\"@Script\"," 135 "{\"source\":\"test-lib\",\"script\":{\"type\":\"@Script\","
136 "\"id\":\"libraries\\/%" Pd "\\/scripts\\/test-lib\"," 136 "\"id\":\"libraries\\/%" Pd "\\/scripts\\/test-lib\","
137 "\"name\":\"test-lib\"," 137 "\"uri\":\"test-lib\","
138 "\"kind\":\"script\"},\"hits\":[6,0]}", lib.index()); 138 "\"kind\":\"script\"},\"hits\":[6,0]}", lib.index());
139 EXPECT_SUBSTRING(buf, js.ToCString()); 139 EXPECT_SUBSTRING(buf, js.ToCString());
140 } 140 }
141 141
142 } // namespace dart 142 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/observatory/tests/service/get_object_rpc_test.dart ('k') | runtime/vm/debugger_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698