mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43: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"
|
say -o cyan "Testing interactive functionality"
|
||||||
if not type -q expect
|
if not type -q expect
|
||||||
say red "Tests disabled: `expect` not found"
|
say red "Tests disabled: `expect` not found"
|
||||||
exit 0
|
exit 1
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_file
|
function test_file
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
# Test behavior related to the locale.
|
# Test behavior related to the locale.
|
||||||
|
|
||||||
# Verify that our UTF-8 locale produces the expected output.
|
# 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.
|
# 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.
|
# The output should include the literal byte \xFC rather than the UTF-8 sequence for \u00FC.
|
||||||
begin
|
begin
|
||||||
set -lx LC_ALL C
|
set -lx LC_ALL C
|
||||||
echo -n B\u00FCB | xxd --plain
|
echo -n B\u00FCB | display_bytes
|
||||||
end
|
end
|
||||||
|
|
||||||
# Since the previous change was localized to a block it should no
|
# 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.
|
# 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.
|
# 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.
|
# The output should include the UTF-8 sequence for \u00FC rather than that literal byte.
|
||||||
# Just like the previous test.
|
# Just like the previous test.
|
||||||
begin
|
begin
|
||||||
set -l LC_ALL C
|
set -l LC_ALL C
|
||||||
echo -n D\u00FCD | xxd --plain
|
echo -n D\u00FCD | display_bytes
|
||||||
end
|
end
|
||||||
|
|
||||||
# Verify that fish can pass through non-ASCII characters in the C/POSIX
|
# 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
|
# 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
|
# output should be "58c3bb58" for the first statement and "58c3bc58" for the
|
||||||
# second.
|
# second.
|
||||||
echo -n X\u00FBX | \
|
echo -n X\u00FBX | display_bytes
|
||||||
xxd --plain
|
echo X\u00FCX | env LC_ALL=C ../test/root/bin/fish -c 'read foo; echo -n $foo' | display_bytes
|
||||||
echo X\u00FCX | env LC_ALL=C ../test/root/bin/fish -c 'read foo; echo -n $foo' | \
|
|
||||||
xxd --plain
|
|
||||||
|
|
||||||
# The next tests deliberately spawn another fish instance to test inheritence of env vars.
|
# 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
|
# 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
|
# ISO 8859-x char sets which are encompassed by the C locale. The output should
|
||||||
# be "59fc59".
|
# be "59fc59".
|
||||||
env LC_ALL=C ../test/root/bin/fish -c 'echo -n Y\u00FCY' | \
|
env LC_ALL=C ../test/root/bin/fish -c 'echo -n Y\u00FCY' | display_bytes
|
||||||
xxd --plain
|
|
||||||
|
|
||||||
# The user can specify a wide unicode character (one requiring more than a
|
# 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
|
# single byte). In the C/POSIX locales we substitute a question-mark for the
|
||||||
# unencodable wide char. The output should be "543f54".
|
# unencodable wide char. The output should be "543f54".
|
||||||
env LC_ALL=C ../test/root/bin/fish -c 'echo -n T\u01FDT' | \
|
env LC_ALL=C ../test/root/bin/fish -c 'echo -n T\u01FDT' | display_bytes
|
||||||
xxd --plain
|
|
||||||
|
|
|
@ -1,8 +1,16 @@
|
||||||
41c3bc41
|
0000000 101 303 274 101
|
||||||
42fc42
|
0000004
|
||||||
43c3bc43
|
0000000 102 374 102
|
||||||
44c3bc44
|
0000003
|
||||||
58c3bb58
|
0000000 103 303 274 103
|
||||||
58c3bc58
|
0000004
|
||||||
59fc59
|
0000000 104 303 274 104
|
||||||
543f54
|
0000004
|
||||||
|
0000000 130 303 273 130
|
||||||
|
0000004
|
||||||
|
0000000 130 303 274 130
|
||||||
|
0000004
|
||||||
|
0000000 131 374 131
|
||||||
|
0000003
|
||||||
|
0000000 124 077 124
|
||||||
|
0000003
|
||||||
|
|
|
@ -32,7 +32,7 @@ printf "%5" 10 ^ /dev/null
|
||||||
|
|
||||||
# Octal escapes produce literal bytes, not characters
|
# Octal escapes produce literal bytes, not characters
|
||||||
# \376 is 0xFE
|
# \376 is 0xFE
|
||||||
printf '\376' | xxd -p
|
printf '\376' | display_bytes
|
||||||
|
|
||||||
# Verify that floating point conversions and output work correctly with
|
# Verify that floating point conversions and output work correctly with
|
||||||
# different combinations of locales and floating point strings. See issue
|
# different combinations of locales and floating point strings. See issue
|
||||||
|
|
|
@ -13,7 +13,8 @@ foobarbaz
|
||||||
I P Q R
|
I P Q R
|
||||||
Test escapes
|
Test escapes
|
||||||
a
|
a
|
||||||
fe
|
0000000 376
|
||||||
|
0000001
|
||||||
1.230000e+00
|
1.230000e+00
|
||||||
3,450000e+00
|
3,450000e+00
|
||||||
4,560000e+00
|
4,560000e+00
|
||||||
|
|
|
@ -126,7 +126,7 @@ echo -e 'abc\cdef' # won't output a newline!
|
||||||
echo ''
|
echo ''
|
||||||
echo -
|
echo -
|
||||||
|
|
||||||
echo -ne '\376' | xxd -p
|
echo -ne '\376' | display_bytes
|
||||||
|
|
||||||
echo -e Catch your breath
|
echo -e Catch your breath
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,8 @@ abcQdef
|
||||||
abcQ2def
|
abcQ2def
|
||||||
abc
|
abc
|
||||||
-
|
-
|
||||||
fe
|
0000000 376
|
||||||
|
0000001
|
||||||
Catch your breath
|
Catch your breath
|
||||||
abc!def
|
abc!def
|
||||||
abc!1def
|
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