11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst ArrayStream = require('../common/arraystream'); 51cb0ef41Sopenharmony_ciconst assert = require('assert'); 61cb0ef41Sopenharmony_ciconst repl = require('repl'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_cicommon.skipIfInspectorDisabled(); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ci// This test verifies that the V8 inspector API is usable in the REPL. 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciconst putIn = new ArrayStream(); 131cb0ef41Sopenharmony_cilet output = ''; 141cb0ef41Sopenharmony_ciputIn.write = function(data) { 151cb0ef41Sopenharmony_ci output += data; 161cb0ef41Sopenharmony_ci}; 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ciconst testMe = repl.start('', putIn); 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ciputIn.run(['const myVariable = 42']); 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_citestMe.complete('myVar', common.mustCall((error, data) => { 231cb0ef41Sopenharmony_ci assert.deepStrictEqual(data, [['myVariable'], 'myVar']); 241cb0ef41Sopenharmony_ci})); 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ciputIn.run([ 271cb0ef41Sopenharmony_ci 'const inspector = require("inspector")', 281cb0ef41Sopenharmony_ci 'const session = new inspector.Session()', 291cb0ef41Sopenharmony_ci 'session.connect()', 301cb0ef41Sopenharmony_ci 'session.post("Runtime.evaluate", { expression: "1 + 1" }, console.log)', 311cb0ef41Sopenharmony_ci 'session.disconnect()', 321cb0ef41Sopenharmony_ci]); 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ciassert(output.includes( 351cb0ef41Sopenharmony_ci "null { result: { type: 'number', value: 2, description: '2' } }")); 36