| 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 27 matching lines...) Expand all Loading... |
| 38 TestCoverage( | 38 TestCoverage( |
| 39 "call simple function twice", | 39 "call simple function twice", |
| 40 ` | 40 ` |
| 41 function f() {} | 41 function f() {} |
| 42 f(); | 42 f(); |
| 43 f(); | 43 f(); |
| 44 `, | 44 `, |
| 45 ` | 45 ` |
| 46 [[function f() {}](f:2) | 46 [[function f() {}](f:2) |
| 47 f(); | 47 f(); |
| 48 f();](anonymous:1) | 48 f();](:1) |
| 49 ` | 49 ` |
| 50 ); | 50 ); |
| 51 | 51 |
| 52 TestCoverage( | 52 TestCoverage( |
| 53 "call arrow function twice", | 53 "call arrow function twice", |
| 54 ` | 54 ` |
| 55 var f = () => 1; | 55 var f = () => 1; |
| 56 f(); | 56 f(); |
| 57 f(); | 57 f(); |
| 58 `, | 58 `, |
| 59 ` | 59 ` |
| 60 [var f = [() => 1](f:2); | 60 [var f = [() => 1](f:2); |
| 61 f(); | 61 f(); |
| 62 f();](anonymous:1) | 62 f();](:1) |
| 63 ` | 63 ` |
| 64 ); | 64 ); |
| 65 | 65 |
| 66 TestCoverage( | 66 TestCoverage( |
| 67 "call nested function", | 67 "call nested function", |
| 68 ` | 68 ` |
| 69 function f() { | 69 function f() { |
| 70 function g() {} | 70 function g() {} |
| 71 g(); | 71 g(); |
| 72 g(); | 72 g(); |
| 73 } | 73 } |
| 74 f(); | 74 f(); |
| 75 f(); | 75 f(); |
| 76 `, | 76 `, |
| 77 ` | 77 ` |
| 78 [[function f() { | 78 [[function f() { |
| 79 [function g() {}](g:4) | 79 [function g() {}](g:4) |
| 80 g(); | 80 g(); |
| 81 g(); | 81 g(); |
| 82 }](f:2) | 82 }](f:2) |
| 83 f(); | 83 f(); |
| 84 f();](anonymous:1) | 84 f();](:1) |
| 85 | 85 |
| 86 ` | 86 ` |
| 87 ); | 87 ); |
| 88 | 88 |
| 89 TestCoverage( | 89 TestCoverage( |
| 90 "call recursive function", | 90 "call recursive function", |
| 91 ` | 91 ` |
| 92 function fib(x) { | 92 function fib(x) { |
| 93 if (x < 2) return 1; | 93 if (x < 2) return 1; |
| 94 return fib(x-1) + fib(x-2); | 94 return fib(x-1) + fib(x-2); |
| 95 } | 95 } |
| 96 fib(5); | 96 fib(5); |
| 97 `, | 97 `, |
| 98 ` | 98 ` |
| 99 [[function fib(x) { | 99 [[function fib(x) { |
| 100 if (x < 2) return 1; | 100 if (x < 2) return 1; |
| 101 return fib(x-1) + fib(x-2); | 101 return fib(x-1) + fib(x-2); |
| 102 }](fib:15) | 102 }](fib:15) |
| 103 fib(5);](anonymous:1) | 103 fib(5);](:1) |
| 104 ` | 104 ` |
| 105 ); | 105 ); |
| OLD | NEW |