From: Bruno Haible Date: Tue, 18 Jan 2005 11:44:09 +0000 (+0000) Subject: Test for Scheme format strings. X-Git-Tag: v0.14.2~123 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c54e0fa12be9c14ff2714a66368c9540f6d9c3dd;p=thirdparty%2Fgettext.git Test for Scheme format strings. --- diff --git a/gettext-tools/tests/format-scheme-1 b/gettext-tools/tests/format-scheme-1 new file mode 100755 index 000000000..41f10aff1 --- /dev/null +++ b/gettext-tools/tests/format-scheme-1 @@ -0,0 +1,293 @@ +#! /bin/sh + +# Test recognition of Scheme format strings. + +tmpfiles="" +trap 'rm -fr $tmpfiles' 1 2 3 15 + +tmpfiles="$tmpfiles f-sc-1.data" +cat <<\EOF > f-sc-1.data +# Valid: no argument, ( | . *) +"abc~~def" +# Valid: one argument, (* | . *) +"abc~Sdef" +# Valid: 11 arguments, (* * * * * * * * * * * | . *) +"abc~10@*~Sdef" +# Invalid: unterminated +"abc~~def~" +# Invalid: unterminated +"abc~~def~1" +# Invalid: unterminated +"abc~~def~:" +# Invalid: unterminated +"abc~~def~@" +# Valid: colon +"abc~:Sdef" +# Valid: atsign +"abc~@Sdef" +# Valid: colon and atsign +"abc~:@Sdef" +# Valid: atsign and colon +"abc~@:Sdef" +# Valid: params before atsign and colon +"abc~3,-4,,'*@:Sdef" +# Invalid: params after atsign and colon +"abc~@:3,-4Sdef" +# Invalid: params after atsign and colon +"abc~@:-4Sdef" +# Invalid: params after atsign and colon +"abc~@:,-4Sdef" +# Valid: V and # params, (i() * | . *) +"abc~#,vSdef" +# Invalid: wrong type params +"abc~,'*Sdef" +# Valid: FORMAT-ASCII, (i() i() i() c() * | . *) +"abc~v,v,v,vA" +# Invalid: too many params +"abc~v,v,v,v,5A" +# Valid: FORMAT-S-EXPRESSION, (i() i() i() c() * | . *) +"abc~v,v,v,vS" +# Invalid: too many params +"abc~v,v,v,v,5S" +# Valid: FORMAT-WRITE, (* | . *) +"abc~W" +# Invalid: too many params +"abc~3W" +# Valid: FORMAT-DECIMAL, (i() c() c() i() i | . *) +"abc~v,v,v,vD" +# Invalid: too many params +"abc~v,v,v,v,5D" +# Valid: FORMAT-BINARY, (i() c() c() i() i | . *) +"abc~v,v,v,vB" +# Invalid: too many params +"abc~v,v,v,v,5B" +# Valid: FORMAT-OCTAL, (i() c() c() i() i | . *) +"abc~v,v,v,vO" +# Invalid: too many params +"abc~v,v,v,v,5O" +# Valid: FORMAT-HEXADECIMAL, (i() c() c() i() i | . *) +"abc~v,v,v,vX" +# Invalid: too many params +"abc~v,v,v,v,5X" +# Valid: FORMAT-RADIX, (i() i() c() c() i() i | . *) +"abc~v,v,v,v,vR" +# Invalid: too many params +"abc~v,v,v,v,v,5R" +# Valid: FORMAT-PLURAL, (* | . *) +"abc~P" +# Valid: FORMAT-PLURAL, (i | . *) +"abc~R egg~:P" +# Invalid: too many params +"abc~2P" +# Valid: FORMAT-CHARACTER, (c | . *) +"abc~C" +# Invalid: too many params +"abc~4C" +# Valid: FORMAT-FIXED-FLOAT, (i() i() i() c() c() r | . *) +"abc~v,v,v,v,vF" +# Invalid: too many params +"abc~v,v,v,v,v,5F" +# Valid: FORMAT-EXPONENTIAL-FLOAT, (i() i() i() i() c() c() c() r | . *) +"abc~v,v,v,v,v,v,vE" +# Invalid: too many params +"abc~v,v,v,v,v,v,v,5E" +# Valid: FORMAT-GENERAL-FLOAT, (i() i() i() i() c() c() c() r | . *) +"abc~v,v,v,v,v,v,vG" +# Invalid: too many params +"abc~v,v,v,v,v,v,v,5G" +# Valid: FORMAT-DOLLARS-FLOAT, (i() i() i() c() r | . *) +"abc~v,v,v,v$" +# Invalid: too many params +"abc~v,v,v,v,5$" +# Valid: FORMAT-TERPRI, (i() | . *) +"abc~v%" +# Invalid: too many params +"abc~v,5%" +# Valid: FORMAT-FRESH-LINE, (i() | . *) +"abc~v&" +# Invalid: too many params +"abc~v,5&" +# Valid: FORMAT-PAGE, (i() | . *) +"abc~v|" +# Invalid: too many params +"abc~v,5|" +# Valid: FORMAT-TILDE, (i() | . *) +"abc~v~" +# Invalid: too many params +"abc~v,5~" +# Valid: underscore, ( | . *) +"abc~_" +# Invalid: too many params +"abc~5_" +# Valid: FORMAT-TABULATE, (i() i() | . *) +"abc~v,vT" +# Invalid: too many params +"abc~v,v,5T" +# Valid: FORMAT-GOTO absolute, (* r c | . *) +"abc~S~F~S~2@*~C" +# Invalid: type incompatibility +"abc~S~F~S~1@*~C" +# Valid: FORMAT-GOTO backward, (* c r | . *) +"abc~S~S~F~2:*~C" +# Invalid: type incompatibility +"abc~S~S~F~1:*~C" +# Invalid: too many params +"abc~v,4*" +# Valid: FORMAT-GOTO with large number +"abc~S~F~S~1000000@*~C" +# Valid: FORMAT-INDIRECTION, (~ ( | . *) | . *) +"abc~?" +# Valid: FORMAT-INDIRECTION, (~ | . *) +"abc~@?" +# Invalid: too many params +"abc~4?" +# Valid: FORMAT-CALL-USER-FUNCTION, (* | . *) +"abc~/FOOBAR/" +# Invalid: too many params +"abc~4/FOOBAR/" +# Invalid: unterminated +"abc~/FOOB" +# Invalid: nesting mismatch +"abc~(~/FOOB~)/" +# Valid: FORMAT-CASE-CONVERSION, (* | . *) +"abc~(~S~)" +# Invalid: too many params +"abc~4(~S~)" +# Invalid: too many params +"abc~(~S~4)" +# Invalid: unterminated +"abc~(~S" +# Invalid: separator +"abc~(~S~;~S~)" +# Valid: FORMAT-CONDITIONAL, (i() c | . *) +"abc~@[~D~]~C" +# Valid: FORMAT-CONDITIONAL, (i() | . *) +"abc~@[~D~D~]~C" +# Invalid: separator +"abc~@[~D~;~D~]~C" +# Valid: FORMAT-CONDITIONAL, (* i c | . *) +"abc~:[~X~;~D~]~C" +# Invalid: missing separator +"abc~:[~D~]~C" +# Invalid: too many separators +"abc~:[~X~;~D~;~E~]~C" +# Valid: FORMAT-CONDITIONAL, (* | . *) +"abc~[~D~;~X~]~C" +# Valid: FORMAT-CONDITIONAL, (* i c | . *) +"abc~[~D~;~X~:;~R~]~C" +# Invalid: default clause not last +"abc~[~D~;~X~:;~R~;~R~]~C" +# Invalid: too many params +"abc~4@[~D~]" +# Invalid: too many params +"abc~@[~D~4]" +# Invalid: too many params +"abc~4:[~D~;~X~]" +# Invalid: too many params +"abc~:[~D~4;~X~]" +# Invalid: too many params +"abc~:[~D~;~X~4]" +# Valid: FORMAT-CONDITIONAL, one param, without colon or atsign +"abc~4[~D~;~X~]" +# Invalid: too many params +"abc~4,4[~D~;~X~]" +# Invalid: too many params +"abc~[~D~4;~X~]" +# Invalid: too many params +"abc~[~D~;~X~4]" +# Valid: FORMAT-ITERATION, (( | . *) | . *) +"abc~{~~~}" +# Valid: FORMAT-ITERATION, (( | . ( | . *)) | . *) +"abc~:{~~~}" +# Valid: FORMAT-ITERATION, ( | . *) +"abc~@{~~~}" +# Valid: FORMAT-ITERATION, ( | . ( | . *)) +"abc~:@{~~~}" +# Valid: FORMAT-ITERATION with indirection, (~ ( | . *) | . *) +"abc~{~}" +# Valid: FORMAT-ITERATION with indirection, (~ ( | . ( | . *)) | . *) +"abc~:{~}" +# Valid: FORMAT-ITERATION with indirection, (~ | . *) +"abc~@{~}" +# Valid: FORMAT-ITERATION with indirection, (~ | . ( | . *)) +"abc~:@{~}" +# Valid: FORMAT-ITERATION with loop, (( | . i c) | . *) +"abc~{~D ~C~}" +# Valid: FORMAT-ITERATION with loop, (( | . (i c | . *)) | . *) +"abc~:{~D ~C~}" +# Valid: FORMAT-ITERATION with loop, ( | . i c) +"abc~@{~D ~C~}" +# Valid: FORMAT-ITERATION with loop, ( | . (i c | . *)) +"abc~:@{~D ~C~}" +# Valid: FORMAT-ITERATION with variable-advance loop, (( | . *) | . *) +"abc~{~[~D~]~}" +# Valid: FORMAT-ITERATION with variable-advance loop, (( | . (* | . *)) | . *) +"abc~:{~[~D~]~}" +# Valid: FORMAT-ITERATION with variable-advance loop, ( | . *) +"abc~@{~[~D~]~}" +# Valid: FORMAT-ITERATION with variable-advance loop, ( | . (* | . *)) +"abc~:@{~[~D~]~}" +# Invalid: separator +"abc~{~D~;~C~}" +# Valid: FORMAT-JUSTIFICATION, (i() i() i() c() i | . *) +"abc~v,v,v,v<~D~>" +# Invalid: too many params +"abc~v,v,v,v,4<~D~>" +# Valid: separators +"abc~<~D~;~X~;def~>" +# Invalid: wrongly nested +"abc~<~(~>~)" +# Invalid: wrongly nested +"abc~{~(~}~)" +# Invalid: wrongly nested +"abc~{~<~}~>" +# Valid: FORMAT-CALL, (f * | . *) +"abc~!" +# Valid: any number of arguments +"abc~v,v,v,v,v!" +# Invalid: type incompatibility between integer and list +"abc~D~:*~{~D~}" +# Invalid: type incompatibility between real and list +"abc~{~S~}~:*~F" +# Valid: list must be empty +"abc~{~C~}~:*~{~D~}" +EOF + +: ${XGETTEXT=xgettext} +n=0 +while read comment; do + read string + n=`expr $n + 1` + tmpfiles="$tmpfiles f-sc-1-$n.in f-sc-1-$n.po" + cat < f-sc-1-$n.in +(gettext ${string}) +EOF + ${XGETTEXT} -L Scheme -o f-sc-1-$n.po f-sc-1-$n.in || exit 1 + test -f f-sc-1-$n.po || exit 1 + fail= + if echo "$comment" | grep 'Valid:' > /dev/null; then + if grep scheme-format f-sc-1-$n.po > /dev/null; then + : + else + fail=yes + fi + else + if grep scheme-format f-sc-1-$n.po > /dev/null; then + fail=yes + else + : + fi + fi + if test -n "$fail"; then + echo "Format string recognition error:" 1>&2 + cat f-sc-1-$n.in 1>&2 + echo "Got:" 1>&2 + cat f-sc-1-$n.po 1>&2 + exit 1 + fi + rm -f f-sc-1-$n.in f-sc-1-$n.po +done < f-sc-1.data + +rm -fr $tmpfiles + +exit 0 diff --git a/gettext-tools/tests/format-scheme-2 b/gettext-tools/tests/format-scheme-2 new file mode 100755 index 000000000..67d6cd07e --- /dev/null +++ b/gettext-tools/tests/format-scheme-2 @@ -0,0 +1,208 @@ +#! /bin/sh + +# Test checking of Lisp format strings. + +tmpfiles="" +trap 'rm -fr $tmpfiles' 1 2 3 15 + +tmpfiles="$tmpfiles f-sc-2.data" +cat <<\EOF > f-sc-2.data +# Valid: ~~ doesn't count +msgid "abc~~def" +msgstr "xyz" +# Invalid: invalid msgstr +msgid "abc~~def" +msgstr "xyz~" +# Valid: same argument +msgid "abc~Ddef" +msgstr "xyz~D" +# Valid: same arguments +msgid "abc~1000000@*~Ddef" +msgstr "~1000000@*xyz~D" +# Valid: permutation +msgid "abc~D~C~Fdef" +msgstr "xyz~2@*~F~2:*~C~2:*~D" +# Invalid: too few arguments +msgid "abc~1@*~Sdef~0@*~S" +msgstr "xyz~S" +# Invalid: too many arguments +msgid "abc~Ddef" +msgstr "xyz~Duvw~C" +# Invalid: missing non-final argument +msgid "abc~1@*~Sdef~0@*~F" +msgstr "xyz~1@*~S" +# Invalid: added non-final argument +msgid "abc~1@*~Ddef" +msgstr "xyz~F~D" +# Valid: formatting variations +msgid "abc~Sdef" +msgstr "xyz~:S" +# Valid: formatting variations +msgid "abc~4Sdef" +msgstr "xyz~7S" +# Valid: type compatibility +msgid "abc~Sdef" +msgstr "xyz~W" +# Valid: type compatibility +msgid "abc~Ddef" +msgstr "xyz~B" +# Valid: type compatibility +msgid "abc~Ddef" +msgstr "xyz~O" +# Valid: type compatibility +msgid "abc~Ddef" +msgstr "xyz~X" +# Valid: type compatibility +msgid "abc~Ddef" +msgstr "xyz~R" +# Valid: optional plural +msgid "~D egg~:P" +msgstr "~D Eier" +# Valid: type compatibility +msgid "abc~Fdef" +msgstr "xyz~E" +# Valid: type compatibility +msgid "abc~Fdef" +msgstr "xyz~G" +# Valid: type compatibility +msgid "abc~Fdef" +msgstr "xyz~$" +# Invalid: type incompatibility +msgid "abc~Fdef" +msgstr "xyz~D" +# Invalid: type incompatibility +msgid "abc~Ddef" +msgstr "xyz~C" +# Invalid: type incompatibility +msgid "abc~Fdef" +msgstr "xyz~C" +# Invalid: type incompatibility +msgid "abc~Sdef" +msgstr "xyz~D" +# Invalid: type incompatibility +msgid "abc~Sdef" +msgstr "xyz~F" +# Invalid: type incompatibility +msgid "abc~Sdef" +msgstr "xyz~C" +# Valid: extra formatting +msgid "abc~Ddef~S" +msgstr "xyz~D~_def~%~S" +# Valid: FORMAT-GOTO doesn't consume an argument by itself +msgid "abc~5@*~Ddef~C" +msgstr "xyz~6@*~C~2@*uvw~5@*~R" +# Invalid: @ matters +msgid "abc~?" +msgstr "xyz~@?" +# Valid: case conversion is optional +msgid "abc~(~S~)" +msgstr "xyz~S" +# Valid: case conversion is optional +msgid "abc~(~D~^ ~D~)" +msgstr "xyz~D~^ ~D" +# Invalid: ~^ matters +msgid "abc~(~D~^ ~D~)" +msgstr "xyz~(~D ~D~)" +# Valid: case conversion is optional, and it doesn't catch ~^ +msgid "abc~(~D~^ ~D~)def~C" +msgstr "xyz~D~^ ~Duvw~C" +# Valid: synonymous conditionals +msgid "abc~@[~D~]def~C" +msgstr "xyz~:[~;~:*~D~]~C" +# Valid: synonymous conditionals +msgid "abc~Ddef" +msgstr "abc~[null~;eins~:;~:*~D~]def" +# Valid: conditionals are optional and don't catch ~^ +msgid "abc~:[~;~]~^~D~C" +msgstr "xyz~:[uvw~^~R~;~:*~S~^~D~]~C" +# Invalid: ~:[ requires an argument, ~1@* doesn't +msgid "abc~1@*~^~D~C" +msgstr "xyz~:[uvw~^~R~;~:*~S~^~D~]~C" +# Invalid: ~{~} is special +msgid "abc~{ ~}" +msgstr "xyz~{~}" +# Invalid: @ matters +msgid "abc~{~S~}" +msgstr "xyz~@{~S~}" +# Invalid: @ matters +msgid "abc~:{~S~}" +msgstr "xyz~@:{~S~}" +# Invalid: : matters +msgid "abc~{~S~}" +msgstr "xyz~:{~S~}" +# Invalid: : matters +msgid "abc~@{~S~}" +msgstr "xyz~@:{~S~}" +# Invalid: @: matters +msgid "abc~{~S~}" +msgstr "xyz~@:{~S~}" +# Valid: permutation inside iteration +msgid "abc~{~D ~C~}" +msgstr "xyz~{~1@*~C~2:*~D~1*~}" +# Invalid: permutation inside iteration, but wrong position at iteration end +msgid "abc~{~D ~C~}" +msgstr "xyz~{~1@*~C~2:*~D~}" +# Invalid: ~^ inside iteration matters +msgid "abc~{~D ~^~C~}" +msgstr "xyz~{~D ~C~}" +# Invalid: ~^ inside iteration depends on position +msgid "abc~{~D ~^~C~}" +msgstr "xyz~{~1@*~C~^~2:*~D~1*~}" +# Invalid: ~^ inside iteration depends on position +msgid "abc~{~D ~^~C~}" +msgstr "xyz~{~1@*~C~2:*~^~D~1*~}" +# Invalid: ~^ inside iteration depends on position +msgid "abc~{~D ~^~C~}" +msgstr "xyz~{~1@*~C~2:*~D~^~1*~}" +# Invalid: ~^ inside iteration depends on position +msgid "abc~{~D ~^~C~}" +msgstr "xyz~{~1@*~C~2:*~D~1*~^~}" +# Valid: justification is optional +msgid "abc~<~D~;~C~>" +msgstr "xyz~D~C" +# Valid: justification with different segmentation +msgid "abc~<~D ~D~;~C~;~S~S~>" +msgstr "xyz~<~D~;~D~C~S~;~S~>" +# Invalid: justification catches ~^ +msgid "abc~<~D~;~^~D~>~C" +msgstr "abc~D~^~D~C" +EOF + +: ${MSGFMT=msgfmt} +n=0 +while read comment; do + read msgid_line + read msgstr_line + n=`expr $n + 1` + tmpfiles="$tmpfiles f-sc-2-$n.po f-sc-2-$n.mo" + cat < f-sc-2-$n.po +#, scheme-format +${msgid_line} +${msgstr_line} +EOF + fail= + if echo "$comment" | grep 'Valid:' > /dev/null; then + if ${MSGFMT} --check-format -o f-sc-2-$n.mo f-sc-2-$n.po; then + : + else + fail=yes + fi + else + ${MSGFMT} --check-format -o f-sc-2-$n.mo f-sc-2-$n.po 2> /dev/null + if test $? = 1; then + : + else + fail=yes + fi + fi + if test -n "$fail"; then + echo "Format string checking error:" 1>&2 + cat f-sc-2-$n.po 1>&2 + exit 1 + fi + rm -f f-sc-2-$n.po f-sc-2-$n.mo +done < f-sc-2.data + +rm -fr $tmpfiles + +exit 0