| 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 "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 27 matching lines...) Expand all Loading... |
| 38 const char* kScript = | 38 const char* kScript = |
| 39 "main() {\n" | 39 "main() {\n" |
| 40 "}"; | 40 "}"; |
| 41 | 41 |
| 42 Isolate* isolate = Isolate::Current(); | 42 Isolate* isolate = Isolate::Current(); |
| 43 Library& lib = Library::Handle(); | 43 Library& lib = Library::Handle(); |
| 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); | 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 "\"name\":\"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 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 71 " var foo = new Foo(7);\n" | 71 " var foo = new Foo(7);\n" |
| 72 " foo.bar();\n" | 72 " foo.bar();\n" |
| 73 "}\n"; | 73 "}\n"; |
| 74 | 74 |
| 75 Isolate* isolate = Isolate::Current(); | 75 Isolate* isolate = Isolate::Current(); |
| 76 Library& lib = Library::Handle(); | 76 Library& lib = Library::Handle(); |
| 77 lib ^= ExecuteScript(kScript); | 77 lib ^= ExecuteScript(kScript); |
| 78 ASSERT(!lib.IsNull()); | 78 ASSERT(!lib.IsNull()); |
| 79 | 79 |
| 80 JSONStream js; | 80 JSONStream js; |
| 81 CodeCoverage::PrintJSON(isolate, &js, NULL); | 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 "\"name\":\"test-lib\"," |
| (...skipping 29 matching lines...) Expand all Loading... |
| 121 ASSERT(!lib.IsNull()); | 121 ASSERT(!lib.IsNull()); |
| 122 const Class& cls = Class::Handle( | 122 const Class& cls = Class::Handle( |
| 123 lib.LookupClass(String::Handle(String::New("Foo")))); | 123 lib.LookupClass(String::Handle(String::New("Foo")))); |
| 124 ASSERT(!cls.IsNull()); | 124 ASSERT(!cls.IsNull()); |
| 125 const Function& func = Function::Handle( | 125 const Function& func = Function::Handle( |
| 126 cls.LookupFunction(String::Handle(String::New("Foo.yetAnother")))); | 126 cls.LookupFunction(String::Handle(String::New("Foo.yetAnother")))); |
| 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); | 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 "\"name\":\"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 |
| OLD | NEW |