2016-04-22 22:14:29 +02:00
|
|
|
#!/usr/bin/env zsh
|
|
|
|
|
|
|
|
source "${0:a:h}/test_helper.zsh"
|
|
|
|
|
|
|
|
oneTimeSetUp() {
|
|
|
|
source_autosuggestions
|
|
|
|
}
|
|
|
|
|
|
|
|
assertBackslashSuggestion() {
|
|
|
|
set_history <<-'EOF'
|
|
|
|
echo "hello\nworld"
|
|
|
|
EOF
|
|
|
|
|
|
|
|
assertSuggestion \
|
|
|
|
'echo "hello\' \
|
|
|
|
'echo "hello\nworld"'
|
|
|
|
}
|
|
|
|
|
|
|
|
assertDoubleBackslashSuggestion() {
|
|
|
|
set_history <<-'EOF'
|
|
|
|
echo "\\"
|
|
|
|
EOF
|
|
|
|
|
|
|
|
assertSuggestion \
|
|
|
|
'echo "\\' \
|
|
|
|
'echo "\\"'
|
|
|
|
}
|
|
|
|
|
|
|
|
assertTildeSuggestion() {
|
|
|
|
set_history <<-'EOF'
|
|
|
|
cd ~/something
|
|
|
|
EOF
|
|
|
|
|
|
|
|
assertSuggestion \
|
|
|
|
'cd' \
|
|
|
|
'cd ~/something'
|
|
|
|
|
|
|
|
assertSuggestion \
|
|
|
|
'cd ~' \
|
|
|
|
'cd ~/something'
|
|
|
|
|
|
|
|
assertSuggestion \
|
|
|
|
'cd ~/s' \
|
|
|
|
'cd ~/something'
|
|
|
|
}
|
|
|
|
|
|
|
|
assertParenthesesSuggestion() {
|
|
|
|
set_history <<-'EOF'
|
|
|
|
echo "$(ls foo)"
|
|
|
|
EOF
|
|
|
|
|
|
|
|
assertSuggestion \
|
|
|
|
'echo "$(' \
|
|
|
|
'echo "$(ls foo)"'
|
|
|
|
}
|
|
|
|
|
|
|
|
assertSquareBracketsSuggestion() {
|
|
|
|
set_history <<-'EOF'
|
|
|
|
echo "$history[123]"
|
|
|
|
EOF
|
|
|
|
|
|
|
|
assertSuggestion \
|
|
|
|
'echo "$history[' \
|
|
|
|
'echo "$history[123]"'
|
|
|
|
}
|
|
|
|
|
2016-04-25 22:19:26 +02:00
|
|
|
assertHashSuggestion() {
|
|
|
|
set_history <<-'EOF'
|
|
|
|
echo "#yolo"
|
|
|
|
EOF
|
|
|
|
|
|
|
|
assertSuggestion \
|
|
|
|
'echo "#' \
|
|
|
|
'echo "#yolo"'
|
|
|
|
}
|
|
|
|
|
2016-04-22 22:14:29 +02:00
|
|
|
testSpecialCharsForAllStrategies() {
|
|
|
|
local strategies
|
|
|
|
strategies=(
|
|
|
|
"default"
|
|
|
|
"match_prev_cmd"
|
|
|
|
)
|
|
|
|
|
|
|
|
for s in $strategies; do
|
|
|
|
ZSH_AUTOSUGGEST_STRATEGY="$s"
|
|
|
|
|
|
|
|
assertBackslashSuggestion
|
|
|
|
assertDoubleBackslashSuggestion
|
|
|
|
assertTildeSuggestion
|
|
|
|
assertParenthesesSuggestion
|
|
|
|
assertSquareBracketsSuggestion
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
run_tests "$0"
|