Home | History | Annotate | Line # | Download | only in tests
      1 #!/bin/sh
      2 
      3 # More tests for C# support: string syntax
      4 
      5 tmpfiles=""
      6 trap 'rm -fr $tmpfiles' 1 2 3 15
      7 
      8 tmpfiles="$tmpfiles xg-cs-3.cs"
      9 tr '%' '\015' <<\EOF > xg-cs-3.cs
     10 class TestCase {
     11   public static void Main (String[] args) {
     12     // Test recognition of \u escapes.
     13     GetString ("B\u00f6se B\u00fcbchen");
     14     // \u escapes with more than one u are invalid.
     15     GetString ("Japanese: \uu65e5\uuu672c\u8A9e");
     16     GetString ("embedded\nnewline");
     17     // Spaces from end of comment are removed.    %GetString("dummy");
     18     // Two backslashes (unlike in Java, where this is just one backslash).
     19     GetString ("\u005c\u005c");
     20     // A 6-character string (unlike in Java, where this is just one backslash).
     21     GetString ("\\u005c");
     22     // A single backslash.
     23     GetString ("\\");
     24     // There is only one \u recognition pass.
     25     GetString ("\u005cu005c");
     26     // Octal escape sequences are not recognized, except for \0.
     27     GetString ("\134");
     28     // Escape sequences in strings.
     29     GetString ("t -> \t, b -> \b, n -> \n, dquote -> \", squote -> \' ...");
     30     // Hex escapes are recognized.
     31     GetString ("bel: \x07\n");
     32     GetString // Recognized despite comments
     33        ( /* Even across multiline
     34 comment! */ "this is a single " /* now comes the concatenation! */ + // after +
     35          "long line");
     36     // Verbatim string literals are extracted.
     37     GetString (@"verbatim 1");
     38     // In verbatim string literals, no escape sequences are recognized.
     39     GetString (@"verbatim 2 \u005c \\ \t \b \n \'");
     40     // In verbatim string literals, only doubled delimiters are recognized.
     41     GetString (@"verbatim 3 ""test");
     42     // Normal and verbatim string literals can be concatenated.
     43     GetString ("left - \"quot" + @"ation"" - right");
     44     // Character literals are not extracted.
     45     GetString ('x');
     46     // Invalid concatenations are not concatenated.
     47     GetString ("fooba"+'r');
     48     // Verify that a comma inside braces is hidden.
     49     MyGetString (new Object[] { "don't", "fool", "me" }, "this is the second argument");
     50   }
     51 }
     52 EOF
     53 
     54 tmpfiles="$tmpfiles xg-cs-3.po"
     55 : ${XGETTEXT=xgettext}
     56 # delete POT-Creation-Date: line because the date depends on local time.
     57 ${XGETTEXT} --output - --add-location -c -kMyGetString:2 xg-cs-3.cs 2>/dev/null \
     58   | sed '/\"POT-Creation-Date:.*/d' > xg-cs-3.po
     59 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
     60 
     61 tmpfiles="$tmpfiles xg-cs-3.ok"
     62 cat <<\EOF > xg-cs-3.ok
     63 # SOME DESCRIPTIVE TITLE.
     64 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
     65 # This file is distributed under the same license as the PACKAGE package.
     66 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
     67 #
     68 #, fuzzy
     69 msgid ""
     70 msgstr ""
     71 "Project-Id-Version: PACKAGE VERSION\n"
     72 "Report-Msgid-Bugs-To: \n"
     73 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
     74 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     75 "Language-Team: LANGUAGE <LL (at] li.org>\n"
     76 "MIME-Version: 1.0\n"
     77 "Content-Type: text/plain; charset=UTF-8\n"
     78 "Content-Transfer-Encoding: 8bit\n"
     79 
     80 #. Test recognition of \u escapes.
     81 #: xg-cs-3.cs:4
     82 msgid "Bse Bbchen"
     83 msgstr ""
     84 
     85 #. \u escapes with more than one u are invalid.
     86 #: xg-cs-3.cs:6
     87 msgid "Japanese: \\uu65e5\\uuu672c"
     88 msgstr ""
     89 
     90 #: xg-cs-3.cs:7
     91 msgid ""
     92 "embedded\n"
     93 "newline"
     94 msgstr ""
     95 
     96 #. Spaces from end of comment are removed.
     97 #: xg-cs-3.cs:8
     98 msgid "dummy"
     99 msgstr ""
    100 
    101 #. Two backslashes (unlike in Java, where this is just one backslash).
    102 #: xg-cs-3.cs:10
    103 msgid "\\\\"
    104 msgstr ""
    105 
    106 #. A 6-character string (unlike in Java, where this is just one backslash).
    107 #. There is only one \u recognition pass.
    108 #: xg-cs-3.cs:12 xg-cs-3.cs:16
    109 msgid "\\u005c"
    110 msgstr ""
    111 
    112 #. A single backslash.
    113 #: xg-cs-3.cs:14
    114 msgid "\\"
    115 msgstr ""
    116 
    117 #. Octal escape sequences are not recognized, except for \0.
    118 #: xg-cs-3.cs:18
    119 msgid "\\134"
    120 msgstr ""
    121 
    122 #. Escape sequences in strings.
    123 #: xg-cs-3.cs:20
    124 msgid ""
    125 "t -> \t, b -> \b, n -> \n"
    126 ", dquote -> \", squote -> ' ..."
    127 msgstr ""
    128 
    129 #. Hex escapes are recognized.
    130 #: xg-cs-3.cs:22
    131 msgid "bel: \a\n"
    132 msgstr ""
    133 
    134 #. Recognized despite comments
    135 #. Even across multiline
    136 #. comment!
    137 #: xg-cs-3.cs:25
    138 msgid "this is a single long line"
    139 msgstr ""
    140 
    141 #. Verbatim string literals are extracted.
    142 #: xg-cs-3.cs:28
    143 msgid "verbatim 1"
    144 msgstr ""
    145 
    146 #. In verbatim string literals, no escape sequences are recognized.
    147 #: xg-cs-3.cs:30
    148 msgid "verbatim 2 \\u005c \\\\ \\t \\b \\n \\'"
    149 msgstr ""
    150 
    151 #. In verbatim string literals, only doubled delimiters are recognized.
    152 #: xg-cs-3.cs:32
    153 msgid "verbatim 3 \"test"
    154 msgstr ""
    155 
    156 #. Normal and verbatim string literals can be concatenated.
    157 #: xg-cs-3.cs:34
    158 msgid "left - \"quotation\" - right"
    159 msgstr ""
    160 
    161 #. Invalid concatenations are not concatenated.
    162 #: xg-cs-3.cs:38
    163 msgid "fooba"
    164 msgstr ""
    165 
    166 #. Verify that a comma inside braces is hidden.
    167 #: xg-cs-3.cs:40
    168 msgid "this is the second argument"
    169 msgstr ""
    170 EOF
    171 
    172 : ${DIFF=diff}
    173 ${DIFF} xg-cs-3.ok xg-cs-3.po
    174 result=$?
    175 
    176 rm -fr $tmpfiles
    177 
    178 exit $result
    179