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

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

Issue 351373002: Coverage API revamp (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: handle scripts via url instead of object Created 6 years, 5 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
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 10 matching lines...) Expand all
21 21
22 TEST_CASE(Coverage_Empty) { 22 TEST_CASE(Coverage_Empty) {
23 const char* kScript = 23 const char* kScript =
24 "main() {\n" 24 "main() {\n"
25 "}"; 25 "}";
26 26
27 Isolate* isolate = Isolate::Current(); 27 Isolate* isolate = Isolate::Current();
28 ExecuteScript(kScript); 28 ExecuteScript(kScript);
29 29
30 JSONStream js; 30 JSONStream js;
31 CodeCoverage::PrintJSON(isolate, &js); 31 CodeCoverage::PrintJSON(isolate, &js, NULL);
32 32
33 EXPECT_SUBSTRING( 33 EXPECT_SUBSTRING(
34 "{\"source\":\"test-lib\",\"script\":{" 34 "{\"source\":\"test-lib\",\"script\":{"
35 "\"type\":\"@Script\",\"id\":\"scripts\\/test-lib\"," 35 "\"type\":\"@Script\",\"id\":\"scripts\\/test-lib\","
36 "\"name\":\"test-lib\",\"user_name\":\"test-lib\"," 36 "\"name\":\"test-lib\",\"user_name\":\"test-lib\","
37 "\"kind\":\"script\"},\"hits\":[]}", js.ToCString()); 37 "\"kind\":\"script\"},\"hits\":[]}", js.ToCString());
38 } 38 }
39 39
40 40
41 TEST_CASE(Coverage_MainWithClass) { 41 TEST_CASE(Coverage_MainWithClass) {
42 const char* kScript = 42 const char* kScript =
43 "class Foo {\n" 43 "class Foo {\n"
44 " var x;\n" 44 " var x;\n"
45 " Foo(this.x);\n" 45 " Foo(this.x);\n"
46 " bar() {\n" 46 " bar() {\n"
47 " x = x * x;\n" 47 " x = x * x;\n"
48 " x = x / 13;\n" 48 " x = x / 13;\n"
49 " }\n" 49 " }\n"
50 "}\n" 50 "}\n"
51 "main() {\n" 51 "main() {\n"
52 " var foo = new Foo(7);\n" 52 " var foo = new Foo(7);\n"
53 " foo.bar();\n" 53 " foo.bar();\n"
54 "}\n"; 54 "}\n";
55 55
56 Isolate* isolate = Isolate::Current(); 56 Isolate* isolate = Isolate::Current();
57 ExecuteScript(kScript); 57 ExecuteScript(kScript);
58 58
59 JSONStream js; 59 JSONStream js;
60 CodeCoverage::PrintJSON(isolate, &js); 60 CodeCoverage::PrintJSON(isolate, &js, NULL);
61 61
62 // Coverage data is printed per class, i.e., there should be two sections 62 // Coverage data is printed per class, i.e., there should be two sections
63 // for test-lib in the JSON data. 63 // for test-lib in the JSON data.
64 64
65 // Data for the actual class Foo. 65 // Data for the actual class Foo.
66 EXPECT_SUBSTRING( 66 EXPECT_SUBSTRING(
67 "{\"source\":\"test-lib\",\"script\":{" 67 "{\"source\":\"test-lib\",\"script\":{"
68 "\"type\":\"@Script\",\"id\":\"scripts\\/test-lib\"," 68 "\"type\":\"@Script\",\"id\":\"scripts\\/test-lib\","
69 "\"name\":\"test-lib\",\"user_name\":\"test-lib\"," 69 "\"name\":\"test-lib\",\"user_name\":\"test-lib\","
70 "\"kind\":\"script\"},\"hits\":[3,1,5,4,6,3]}", js.ToCString()); 70 "\"kind\":\"script\"},\"hits\":[3,1,5,4,6,3]}", js.ToCString());
71 71
72 // Data for the fake class containing main(). 72 // Data for the fake class containing main().
73 EXPECT_SUBSTRING( 73 EXPECT_SUBSTRING(
74 "{\"source\":\"test-lib\",\"script\":{" 74 "{\"source\":\"test-lib\",\"script\":{"
75 "\"type\":\"@Script\",\"id\":\"scripts\\/test-lib\"," 75 "\"type\":\"@Script\",\"id\":\"scripts\\/test-lib\","
76 "\"name\":\"test-lib\",\"user_name\":\"test-lib\"," 76 "\"name\":\"test-lib\",\"user_name\":\"test-lib\","
77 "\"kind\":\"script\"},\"hits\":[10,1,11,1]}", js.ToCString()); 77 "\"kind\":\"script\"},\"hits\":[10,1,11,1]}", js.ToCString());
78 } 78 }
79 79
80 } // namespace dart 80 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698