diff --git a/tests/locale.in b/tests/checks/locale.fish similarity index 75% rename from tests/locale.in rename to tests/checks/locale.fish index ccdd87439..b0e7a73e8 100644 --- a/tests/locale.in +++ b/tests/checks/locale.fish @@ -1,7 +1,18 @@ -# Test behavior related to the locale. +#RUN: %fish %s +# A function to display bytes, necessary because GNU and BSD implementations of `od` have different output. +# We used to use xxd, but it's not available everywhere. See #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 # Verify that our UTF-8 locale produces the expected output. echo -n A\u00FCA | display_bytes +#CHECK: 0000000 101 303 274 101 +#CHECK: 0000004 # 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. @@ -9,10 +20,14 @@ begin set -lx LC_ALL C echo -n B\u00FCB | display_bytes end +#CHECK: 0000000 102 374 102 +#CHECK: 0000003 # 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 | display_bytes +#CHECK: 0000000 103 303 274 103 +#CHECK: 0000004 # 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. @@ -21,6 +36,8 @@ begin set -l LC_ALL C echo -n D\u00FCD | display_bytes end +#CHECK: 0000000 104 303 274 104 +#CHECK: 0000004 # Verify that fish can pass through non-ASCII characters in the C/POSIX # locale. This is to prevent regression of @@ -40,6 +57,10 @@ end # second. 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 +#CHECK: 0000000 130 303 273 130 +#CHECK: 0000004 +#CHECK: 0000000 130 303 274 130 +#CHECK: 0000004 # The next tests deliberately spawn another fish instance to test inheritance of env vars. @@ -50,8 +71,12 @@ echo X\u00FCX | env LC_ALL=C ../test/root/bin/fish -c 'read foo; echo -n $foo' | # 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' | display_bytes +#CHECK: 0000000 131 374 131 +#CHECK: 0000003 # 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' | display_bytes +#CHECK: 0000000 124 077 124 +#CHECK: 0000003 diff --git a/tests/locale.err b/tests/locale.err deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/locale.out b/tests/locale.out deleted file mode 100644 index 9aa8faf19..000000000 --- a/tests/locale.out +++ /dev/null @@ -1,16 +0,0 @@ -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