// Test the new help system const ForthInterpreter = require('./forth.js'); console.log('🧪 Testing Help System\n'); let state = ForthInterpreter.createInitialState(); // Test 1: Basic help command console.log('Test 1: Basic help command'); state = ForthInterpreter.parseAndExecute(state, 'help'); console.log('Help output (first 10 lines):'); state.output.slice(-10).forEach((line, i) => { console.log(`${i + 1}. ${line}`); }); // Test 2: Document specific word console.log('\nTest 2: Document specific word'); state = ForthInterpreter.parseAndExecute(state, 's" dup"'); state = ForthInterpreter.parseAndExecute(state, 'doc'); console.log('Doc output:'); state.output.slice(-5).forEach((line, i) => { console.log(`${i + 1}. ${line}`); }); // Test 3: Document another word console.log('\nTest 3: Document another word'); state = ForthInterpreter.parseAndExecute(state, 's" +"'); state = ForthInterpreter.parseAndExecute(state, 'doc'); console.log('Doc output:'); state.output.slice(-5).forEach((line, i) => { console.log(`${i + 1}. ${line}`); }); // Test 4: Document non-existent word console.log('\nTest 4: Document non-existent word'); state = ForthInterpreter.parseAndExecute(state, 's" nonexistent"'); state = ForthInterpreter.parseAndExecute(state, 'doc'); console.log('Doc output:'); state.output.slice(-3).forEach((line, i) => { console.log(`${i + 1}. ${line}`); }); // Test 5: Words command console.log('\nTest 5: Words command'); state = ForthInterpreter.parseAndExecute(state, 'words'); console.log('Words output:'); state.output.slice(-3).forEach((line, i) => { console.log(`${i + 1}. ${line}`); }); console.log('\n✅ Help system tests completed!'); console.log('Total output lines:', state.output.length);