1'use strict'; 2const http = require('node:http'); // node:* should be filtered out. 3 4try { 5 // This block does not throw. 6} catch { /* node:coverage ignore next 3 */ 7 // So this block is uncovered. 8 9 /* node:coverage disable */ 10 11 /* node:coverage enable */ 12 13 /* node:coverage ignore next */ 14} 15 16function uncalledTopLevelFunction() { 17 if (true) { 18 return 5; 19 } 20 21 return 9; 22} 23 24const test = require('node:test'); 25 26if (false) { 27 console.log('this does not execute'); 28} else { 29 require('./invalid-tap.js'); 30} 31 32test('a test', () => { 33 const uncalled = () => {}; 34 35 function fnWithControlFlow(val) { 36 if (val < 0) { 37 return -1; 38 } else if (val === 0) { 39 return 0; 40 } else if (val < 100) { 41 return 1; 42 } else { 43 return Infinity; 44 } 45 } 46 47 fnWithControlFlow(-10); 48 fnWithControlFlow(99); 49}); 50 51try { 52 require('test-nm'); // node_modules should be filtered out. 53} catch { 54 55} 56 57async function main() { 58 if (false) { console.log('boo'); } else { /* console.log('yay'); */ } 59 60 if (false) { 61 console.log('not happening'); 62 } 63 64 if (true) { 65 if (false) { 66 console.log('not printed'); 67 } 68 69 // Nothing to see here. 70 } else { 71 console.log('also not printed'); 72 } 73 74 try { 75 const foo = {}; 76 77 foo.x = 1; 78 require('../v8-coverage/throw.js'); 79 foo.y = 2; 80 return foo; 81 } catch (err) { 82 let bar = []; 83 bar.push(5); 84 } finally { 85 const baz = 1; 86 } 87} 88 89main(); 90