| OLD | NEW |
| 1 // Copyright 2017 the V8 project authors. All rights reserved. | 1 // Copyright 2017 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Flags: --allow-natives-syntax --no-always-opt | 5 // Flags: --allow-natives-syntax --no-always-opt |
| 6 | 6 |
| 7 // Test code coverage without explicitly activating it upfront. | 7 // Test code coverage without explicitly activating it upfront. |
| 8 | 8 |
| 9 function GetCoverage(source) { | 9 function GetCoverage(source) { |
| 10 for (var script of %DebugCollectCoverage()) { | 10 for (var script of %DebugCollectCoverage()) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 } | 23 } |
| 24 | 24 |
| 25 TestCoverage( | 25 TestCoverage( |
| 26 "call simple function twice", | 26 "call simple function twice", |
| 27 ` | 27 ` |
| 28 function f() {} | 28 function f() {} |
| 29 f(); | 29 f(); |
| 30 f(); | 30 f(); |
| 31 `, | 31 `, |
| 32 [{"start":0,"end":25,"count":1}, | 32 [{"start":0,"end":25,"count":1}, |
| 33 {"start":0,"end":15,"count":2}] | 33 {"start":0,"end":15,"count":1}] |
| 34 ); | 34 ); |
| 35 | 35 |
| 36 TestCoverage( | 36 TestCoverage( |
| 37 "call arrow function twice", | 37 "call arrow function twice", |
| 38 ` | 38 ` |
| 39 var f = () => 1; | 39 var f = () => 1; |
| 40 f(); | 40 f(); |
| 41 f(); | 41 f(); |
| 42 `, | 42 `, |
| 43 [{"start":0,"end":26,"count":1}, | 43 [{"start":0,"end":26,"count":1}, |
| 44 {"start":8,"end":15,"count":2}] | 44 {"start":8,"end":15,"count":1}] |
| 45 ); | 45 ); |
| 46 | 46 |
| 47 TestCoverage( | 47 TestCoverage( |
| 48 "call nested function", | 48 "call nested function", |
| 49 ` | 49 ` |
| 50 function f() { | 50 function f() { |
| 51 function g() {} | 51 function g() {} |
| 52 g(); | 52 g(); |
| 53 g(); | 53 g(); |
| 54 } | 54 } |
| 55 f(); | 55 f(); |
| 56 f(); | 56 f(); |
| 57 `, | 57 `, |
| 58 [{"start":0,"end":58,"count":1}, | 58 [{"start":0,"end":58,"count":1}, |
| 59 {"start":0,"end":48,"count":2}, | 59 {"start":0,"end":48,"count":1}, |
| 60 {"start":17,"end":32,"count":4}] | 60 {"start":17,"end":32,"count":1}] |
| 61 ); | 61 ); |
| 62 | 62 |
| 63 TestCoverage( | 63 TestCoverage( |
| 64 "call recursive function", | 64 "call recursive function", |
| 65 ` | 65 ` |
| 66 function fib(x) { | 66 function fib(x) { |
| 67 if (x < 2) return 1; | 67 if (x < 2) return 1; |
| 68 return fib(x-1) + fib(x-2); | 68 return fib(x-1) + fib(x-2); |
| 69 } | 69 } |
| 70 fib(5); | 70 fib(5); |
| 71 `, | 71 `, |
| 72 [{"start":0,"end":80,"count":1}, | 72 [{"start":0,"end":80,"count":1}, |
| 73 {"start":0,"end":72,"count":15}] | 73 {"start":0,"end":72,"count":1}] |
| 74 ); | 74 ); |
| OLD | NEW |