mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
parent
2b13472419
commit
44cfe3e340
8 changed files with 43 additions and 26 deletions
|
@ -33,7 +33,7 @@ cat interactive.config >> $XDG_CONFIG_HOME/fish/config.fish
|
|||
say -o cyan "Testing interactive functionality"
|
||||
if not type -q expect
|
||||
say red "Tests disabled: `expect` not found"
|
||||
exit 0
|
||||
exit 1
|
||||
end
|
||||
|
||||
function test_file
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
# Test behavior related to the locale.
|
||||
|
||||
# Verify that our UTF-8 locale produces the expected output.
|
||||
echo -n A\u00FCA | xxd --plain
|
||||
echo -n A\u00FCA | display_bytes
|
||||
|
||||
# Verify that exporting a change to the C locale produces the expected output.
|
||||
# The output should include the literal byte \xFC rather than the UTF-8 sequence for \u00FC.
|
||||
begin
|
||||
set -lx LC_ALL C
|
||||
echo -n B\u00FCB | xxd --plain
|
||||
echo -n B\u00FCB | display_bytes
|
||||
end
|
||||
|
||||
# Since the previous change was localized to a block it should no
|
||||
# longer be in effect and we should be back to a UTF-8 locale.
|
||||
echo -n C\u00FCC | xxd --plain
|
||||
echo -n C\u00FCC | display_bytes
|
||||
|
||||
# Verify that setting a non-exported locale var doesn't affect the behavior.
|
||||
# The output should include the UTF-8 sequence for \u00FC rather than that literal byte.
|
||||
# Just like the previous test.
|
||||
begin
|
||||
set -l LC_ALL C
|
||||
echo -n D\u00FCD | xxd --plain
|
||||
echo -n D\u00FCD | display_bytes
|
||||
end
|
||||
|
||||
# Verify that fish can pass through non-ASCII characters in the C/POSIX
|
||||
|
@ -38,10 +38,8 @@ end
|
|||
# echo output directly to the `xxd` program then via a fish instance. The
|
||||
# output should be "58c3bb58" for the first statement and "58c3bc58" for the
|
||||
# second.
|
||||
echo -n X\u00FBX | \
|
||||
xxd --plain
|
||||
echo X\u00FCX | env LC_ALL=C ../test/root/bin/fish -c 'read foo; echo -n $foo' | \
|
||||
xxd --plain
|
||||
echo -n X\u00FBX | display_bytes
|
||||
echo X\u00FCX | env LC_ALL=C ../test/root/bin/fish -c 'read foo; echo -n $foo' | display_bytes
|
||||
|
||||
# The next tests deliberately spawn another fish instance to test inheritence of env vars.
|
||||
|
||||
|
@ -51,11 +49,9 @@ echo X\u00FCX | env LC_ALL=C ../test/root/bin/fish -c 'read foo; echo -n $foo' |
|
|||
# few single-byte unicode chars (that are not ASCII) are generally in the
|
||||
# ISO 8859-x char sets which are encompassed by the C locale. The output should
|
||||
# be "59fc59".
|
||||
env LC_ALL=C ../test/root/bin/fish -c 'echo -n Y\u00FCY' | \
|
||||
xxd --plain
|
||||
env LC_ALL=C ../test/root/bin/fish -c 'echo -n Y\u00FCY' | display_bytes
|
||||
|
||||
# The user can specify a wide unicode character (one requiring more than a
|
||||
# single byte). In the C/POSIX locales we substitute a question-mark for the
|
||||
# unencodable wide char. The output should be "543f54".
|
||||
env LC_ALL=C ../test/root/bin/fish -c 'echo -n T\u01FDT' | \
|
||||
xxd --plain
|
||||
env LC_ALL=C ../test/root/bin/fish -c 'echo -n T\u01FDT' | display_bytes
|
||||
|
|
|
@ -1,8 +1,16 @@
|
|||
41c3bc41
|
||||
42fc42
|
||||
43c3bc43
|
||||
44c3bc44
|
||||
58c3bb58
|
||||
58c3bc58
|
||||
59fc59
|
||||
543f54
|
||||
0000000 101 303 274 101
|
||||
0000004
|
||||
0000000 102 374 102
|
||||
0000003
|
||||
0000000 103 303 274 103
|
||||
0000004
|
||||
0000000 104 303 274 104
|
||||
0000004
|
||||
0000000 130 303 273 130
|
||||
0000004
|
||||
0000000 130 303 274 130
|
||||
0000004
|
||||
0000000 131 374 131
|
||||
0000003
|
||||
0000000 124 077 124
|
||||
0000003
|
||||
|
|
|
@ -28,11 +28,11 @@ printf 'a\cb'
|
|||
echo
|
||||
|
||||
# Bogus printf specifier, should produce no stdout
|
||||
printf "%5" 10 ^ /dev/null
|
||||
printf "%5" 10 ^/dev/null
|
||||
|
||||
# Octal escapes produce literal bytes, not characters
|
||||
# \376 is 0xFE
|
||||
printf '\376' | xxd -p
|
||||
printf '\376' | display_bytes
|
||||
|
||||
# Verify that floating point conversions and output work correctly with
|
||||
# different combinations of locales and floating point strings. See issue
|
||||
|
|
|
@ -13,7 +13,8 @@ foobarbaz
|
|||
I P Q R
|
||||
Test escapes
|
||||
a
|
||||
fe
|
||||
0000000 376
|
||||
0000001
|
||||
1.230000e+00
|
||||
3,450000e+00
|
||||
4,560000e+00
|
||||
|
|
|
@ -126,7 +126,7 @@ echo -e 'abc\cdef' # won't output a newline!
|
|||
echo ''
|
||||
echo -
|
||||
|
||||
echo -ne '\376' | xxd -p
|
||||
echo -ne '\376' | display_bytes
|
||||
|
||||
echo -e Catch your breath
|
||||
|
||||
|
|
|
@ -37,7 +37,8 @@ abcQdef
|
|||
abcQ2def
|
||||
abc
|
||||
-
|
||||
fe
|
||||
0000000 376
|
||||
0000001
|
||||
Catch your breath
|
||||
abc!def
|
||||
abc!1def
|
||||
|
|
11
tests/test_functions/display_bytes.fish
Normal file
11
tests/test_functions/display_bytes.fish
Normal file
|
@ -0,0 +1,11 @@
|
|||
# This is needed because GNU and BSD implementations of `od` differ in the whitespace they emit.
|
||||
# In the past we used the `xxd` command which doesn't suffer from such idiosyncrasies but it isn't
|
||||
# available on some systems unless you install the Vim editor. Whereas `od` is pretty much
|
||||
# universally available. See issue #3797.
|
||||
#
|
||||
# We use the lowest common denominator format, `-b`, because it should work in all implementations.
|
||||
# I wish we could use the `-t` flag but it isn't available in every OS we're likely to run on.
|
||||
#
|
||||
function display_bytes
|
||||
od -b | sed -e 's/ */ /g' -e 's/ *$//'
|
||||
end
|
Loading…
Reference in a new issue