This directory contains tests for the zsh-like history expansion features implemented in the KAI Console.
For complete documentation of all features, see:
- TestConsoleZshFeatures.cpp - C++ unit tests using Google Test framework
- RunConsoleTests.sh - Bash script for automated testing
- TestConsoleZsh.py - Python script for comprehensive automated testing
- InteractiveTests.txt - Manual test cases for interactive testing
!!- Repeat last command!n- Execute nth command from history (1-based)!-n- Execute nth command from end!string- Execute last command starting with string
:0- The command word:^- First argument (same as:1):$- Last argument:*- All arguments (words 1 through end):n- The nth word (0-based):n-m- Words n through m:n*- Words n through end
!-3:4*- Words 4 through end from 3 commands ago- History expansion within commands:
!! * 2 - Multiple history references:
!-2 + !-1
- Backtick execution:
`echo hello` - Embedded shell commands:
print "date"
$prefix disables all zsh expansion- Quoted strings are preserved in word splitting
- Error handling for non-existent history
# Build the tests
cd $KAI_ROOT
make TestConsole
# Run the tests
./Bin/Test/TestConsolecd $KAI_ROOT/Test/Console
./RunConsoleTests.shcd $KAI_ROOT/Test/Console
./TestConsoleZsh.py# Start the console
$KAI_ROOT/Bin/Console
# Copy and paste commands from InteractiveTests.txtThe test suite covers:
- All basic history operators (!!, !n, !-n, !string)
- All word designators (:0, :^, :$, :, :n, :n-m, :n)
- Complex multi-part expressions
- Shell command integration
- Edge cases and error conditions
- Integration with Pi and Rho languages
- Window App compatibility
- History expansions show the expanded command with "=> " prefix
- Word designators extract the correct portions of commands
- Shell commands execute and return output
- $ prefix prevents any expansion
- Non-existent history references show "No matching command in history"
- Invalid word designators return empty strings
- Shell command failures show error messages
To add new tests:
- C++ Tests: Add new TEST_F cases to TestConsoleZshFeatures.cpp
- Shell Tests: Add new run_test calls to RunConsoleTests.sh
- Python Tests: Add new self.test() calls to TestConsoleZsh.py
- Interactive Tests: Add new test cases to InteractiveTests.txt
- History modifiers (:h, :t, :r, :e, :p, :s/old/new/) are not yet implemented
- Command history is not persisted between sessions
- Some complex nested expansions may not work as expected