11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_cicommon.skipIfInspectorDisabled(); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 71cb0ef41Sopenharmony_ciconst startCLI = require('../common/debugger'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciconst assert = require('assert'); 101cb0ef41Sopenharmony_ciconst path = require('path'); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciconst scriptFullPath = fixtures.path('debugger', 'three-lines.js'); 131cb0ef41Sopenharmony_ciconst script = path.relative(process.cwd(), scriptFullPath); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci// Run after quit. 161cb0ef41Sopenharmony_ciconst runTest = async () => { 171cb0ef41Sopenharmony_ci const cli = startCLI(['--port=0', script]); 181cb0ef41Sopenharmony_ci try { 191cb0ef41Sopenharmony_ci await cli.waitForInitialBreak(); 201cb0ef41Sopenharmony_ci await cli.waitForPrompt(); 211cb0ef41Sopenharmony_ci await cli.command('breakpoints'); 221cb0ef41Sopenharmony_ci assert.match(cli.output, /No breakpoints yet/); 231cb0ef41Sopenharmony_ci await cli.command('sb(2)'); 241cb0ef41Sopenharmony_ci await cli.command('sb(3)'); 251cb0ef41Sopenharmony_ci await cli.command('breakpoints'); 261cb0ef41Sopenharmony_ci assert.ok(cli.output.includes(`#0 ${script}:2`)); 271cb0ef41Sopenharmony_ci assert.ok(cli.output.includes(`#1 ${script}:3`)); 281cb0ef41Sopenharmony_ci await cli.stepCommand('c'); // hit line 2 291cb0ef41Sopenharmony_ci await cli.stepCommand('c'); // hit line 3 301cb0ef41Sopenharmony_ci assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 3 }); 311cb0ef41Sopenharmony_ci await cli.command('restart'); 321cb0ef41Sopenharmony_ci await cli.waitForInitialBreak(); 331cb0ef41Sopenharmony_ci assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 1 }); 341cb0ef41Sopenharmony_ci await cli.stepCommand('c'); 351cb0ef41Sopenharmony_ci assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 2 }); 361cb0ef41Sopenharmony_ci await cli.stepCommand('c'); 371cb0ef41Sopenharmony_ci assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 3 }); 381cb0ef41Sopenharmony_ci await cli.command('breakpoints'); 391cb0ef41Sopenharmony_ci const msg = `SCRIPT: ${script}, OUTPUT: ${cli.output}`; 401cb0ef41Sopenharmony_ci assert.ok(cli.output.includes(`#0 ${script}:2`), msg); 411cb0ef41Sopenharmony_ci assert.ok(cli.output.includes(`#1 ${script}:3`), msg); 421cb0ef41Sopenharmony_ci } finally { 431cb0ef41Sopenharmony_ci await cli.quit(); 441cb0ef41Sopenharmony_ci } 451cb0ef41Sopenharmony_ci}; 461cb0ef41Sopenharmony_ci 471cb0ef41Sopenharmony_cirunTest(); 48