Home | History | Annotate | Line # | Download | only in tests
      1 #!/bin/sh
      2 #
      3 # More tests for java support
      4 #
      5 
      6 tmpfiles=""
      7 trap 'rm -fr $tmpfiles' 1 2 3 15
      8 
      9 tmpfiles="$tmpfiles xg-j-2.java"
     10 cat <<\EOF > xg-j-2.java
     11 class TestCase {
     12   public static void main (String[] args) {
     13     // Test recognition of \u escapes: Bse Bbchen
     14     gettext ("B\u00f6se B\u00fcbchen");
     15     // Test recognition of \u escapes with different number of u
     16     gettext ("Japanese: \uu65e5\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu672c\u8A9e");
     17     // Test recognition of \u escapes when they form UTF-16 surrogates
     18     // Here: U+1D49E MATHEMATICAL SCRIPT CAPITAL C
     19     gettext ("script \ud835\udc9e = ...");
     20     // Test invalid surrogates.
     21     gettext ("invalid surrogate \ud835 first half");
     22     gettext ("invalid surrogate \udc9e second half");
     23     // Don't let the line numbers be confused by \u newlines.
     24     \u000a \u000d \u000d\u000a
     25     gettext ("embedded\nnewline");
     26     // Spaces from end of comment are removed.    \u000agettext("dummy");
     27     // Various ways to write a backslash are equivalent.
     28     gettext ("\u005c\u005c");
     29     gettext ("\u005c\");
     30     gettext ("\\u005c");
     31     gettext ("\\");
     32     gettext ("\134");
     33     // Escape sequences in strings.
     34     gettext ("t -> \t, b -> \b, n -> \n, dquote -> \", squote -> \' ...");
     35     // Octal escapes have 2 or 3 digits, depending on the initial digit.
     36     gettext ("bel: \7\nnewline: \12backslash: \134\ndquote-zero: \420\n");
     37     // Hex escapes are not recognized
     38     gettext ("no bel: \x07\n");
     39     gettext // Recognized despite comments
     40        ( /* Even across multiline
     41 comment! */ "this is a single " /* now comes the concatenation! */ + // after +
     42          "long line");
     43     // Character literals are not extracted.
     44     gettext ('x');
     45     // Invalid concatenations are not concatenated.
     46     gettext ("fooba"+'r');
     47     // Verify that the static function name has priority.
     48     GettextResource.gettext("NOT extracted", "this one is extracted");
     49     // Verify that a comma inside braces is hidden.
     50     GettextResource.gettext(
     51         new Object() {
     52           public int foo () {
     53             return 5, 8;
     54           }
     55         },
     56         "this is the second argument");
     57   }
     58 }
     59 EOF
     60 
     61 tmpfiles="$tmpfiles xg-j-2.tmp xg-j-2.pot"
     62 : ${XGETTEXT=xgettext}
     63 ${XGETTEXT} --from-code=ISO-8859-1 -c -o xg-j-2.tmp xg-j-2.java 2>/dev/null
     64 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
     65 grep -v 'POT-Creation-Date' < xg-j-2.tmp > xg-j-2.pot
     66 
     67 tmpfiles="$tmpfiles xg-j-2.ok"
     68 cat <<\EOF > xg-j-2.ok
     69 # SOME DESCRIPTIVE TITLE.
     70 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
     71 # This file is distributed under the same license as the PACKAGE package.
     72 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
     73 #
     74 #, fuzzy
     75 msgid ""
     76 msgstr ""
     77 "Project-Id-Version: PACKAGE VERSION\n"
     78 "Report-Msgid-Bugs-To: \n"
     79 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
     80 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     81 "Language-Team: LANGUAGE <LL (at] li.org>\n"
     82 "MIME-Version: 1.0\n"
     83 "Content-Type: text/plain; charset=UTF-8\n"
     84 "Content-Transfer-Encoding: 8bit\n"
     85 
     86 #. Test recognition of \u escapes: Bse Bbchen
     87 #: xg-j-2.java:4
     88 msgid "Bse Bbchen"
     89 msgstr ""
     90 
     91 #. Test recognition of \u escapes with different number of u
     92 #: xg-j-2.java:6
     93 msgid "Japanese: "
     94 msgstr ""
     95 
     96 #. Test recognition of \u escapes when they form UTF-16 surrogates
     97 #. Here: U+1D49E MATHEMATICAL SCRIPT CAPITAL C
     98 #: xg-j-2.java:9
     99 msgid "script  = ..."
    100 msgstr ""
    101 
    102 #. Test invalid surrogates.
    103 #: xg-j-2.java:11
    104 msgid "invalid surrogate  first half"
    105 msgstr ""
    106 
    107 #: xg-j-2.java:12
    108 msgid "invalid surrogate  second half"
    109 msgstr ""
    110 
    111 #. Don't let the line numbers be confused by \u newlines.
    112 #: xg-j-2.java:15
    113 msgid ""
    114 "embedded\n"
    115 "newline"
    116 msgstr ""
    117 
    118 #. Spaces from end of comment are removed.
    119 #: xg-j-2.java:16
    120 msgid "dummy"
    121 msgstr ""
    122 
    123 #. Various ways to write a backslash are equivalent.
    124 #: xg-j-2.java:18 xg-j-2.java:19 xg-j-2.java:20 xg-j-2.java:21 xg-j-2.java:22
    125 msgid "\\"
    126 msgstr ""
    127 
    128 #. Escape sequences in strings.
    129 #: xg-j-2.java:24
    130 msgid ""
    131 "t -> \t, b -> \b, n -> \n"
    132 ", dquote -> \", squote -> ' ..."
    133 msgstr ""
    134 
    135 #. Octal escapes have 2 or 3 digits, depending on the initial digit.
    136 #: xg-j-2.java:26
    137 msgid ""
    138 "bel: \a\n"
    139 "newline: \n"
    140 "backslash: \\\n"
    141 "dquote-zero: \"0\n"
    142 msgstr ""
    143 
    144 #. Hex escapes are not recognized
    145 #: xg-j-2.java:28
    146 msgid "no bel: \\x07\n"
    147 msgstr ""
    148 
    149 #. Recognized despite comments
    150 #. Even across multiline
    151 #. comment!
    152 #: xg-j-2.java:31
    153 msgid "this is a single long line"
    154 msgstr ""
    155 
    156 #. Invalid concatenations are not concatenated.
    157 #: xg-j-2.java:36
    158 msgid "fooba"
    159 msgstr ""
    160 
    161 #. Verify that the static function name has priority.
    162 #: xg-j-2.java:38
    163 msgid "this one is extracted"
    164 msgstr ""
    165 
    166 #: xg-j-2.java:46
    167 msgid "this is the second argument"
    168 msgstr ""
    169 EOF
    170 
    171 : ${DIFF=diff}
    172 ${DIFF} xg-j-2.ok xg-j-2.pot
    173 result=$?
    174 
    175 rm -fr $tmpfiles
    176 
    177 exit $result
    178