about summary refs log tree commit diff stats
path: root/forth/foreforthfourth/test-help.js
diff options
context:
space:
mode:
Diffstat (limited to 'forth/foreforthfourth/test-help.js')
-rw-r--r--forth/foreforthfourth/test-help.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/forth/foreforthfourth/test-help.js b/forth/foreforthfourth/test-help.js
new file mode 100644
index 0000000..b3aa28e
--- /dev/null
+++ b/forth/foreforthfourth/test-help.js
@@ -0,0 +1,52 @@
+// 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);