2 * States definitions file for States tests.
3 * Copyright (c) 1997 Markku Rossi.
4 * Author: Markku Rossi <mtr@iki.fi>
8 * This file is part of GNU Enscript.
10 * Enscript is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
15 * Enscript is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with Enscript. If not, see <http://www.gnu.org/licenses/>.
38 /Test startrules\./ test_startrules;
43 /\.st$/ test_namerules;
74 print ("test_startrules");
82 print ("test_namerules");
87 state test_optionstate
90 print ("test_optionstate");
95 state test_first_match
107 state test_case_insensitive_regexps
184 state test_primconcat
187 if (strcmp (concat ("a", "b", "c"), "abc") != 0)
196 if (float (/f/) != 0.0)
198 if (float (list (1, 2, 3)) != 3.0)
200 if (float ("1") != 1.0)
202 if (float ("1.34") != 1.34)
204 if (float ("") != 0.0)
206 if (float (1) != 1.0)
208 if (float (1.1) != 1.1)
214 state test_primgetenv
217 if (strcmp (getenv ("STATES_DATA"), "ok") != 0)
228 if (int (list (1, 2, 3, 4)) != 4)
232 if (int ("1.5") != 1)
244 state test_primlength
247 if (length ("ab") != 2)
249 if (length (list (1, 2, "3", /4/)) != 4)
258 lst = list (1, "2", /3/, 4);
270 print ("ok", 1, /2/);
275 state test_primregexp
279 if (!regmatch ("abcd", re))
285 state test_primregexp_syntax
288 regexp_syntax ('-', 'w');
289 if (regmatch ("foo-bar", /\bbar\b/))
295 state test_primregmatch
298 if (!regmatch ("abcde foo bar", /[a-z]+ ([a-z]+)/))
300 if (strcmp ($0, "abcde foo") != 0)
302 if (strcmp ($1, "foo") != 0)
308 state test_primregsub
311 if (strcmp (regsub ("a.b.c.d", /\./, "_"), "a_b.c.d") != 0)
317 state test_primregsuball
320 if (strcmp (regsuball ("a.b.c.d", /\./, "_"), "a_b_c_d") != 0)
326 state test_primsprintf
329 str = sprintf ("%d: foo %s %.2f", 1, "bar", 1.0);
330 if (strcmp (str, "1: foo bar 1.00") != 0)
336 state test_primstrcmp
339 if (strcmp ("a", "b") != -1)
341 if (strcmp ("aa", "a") != 1)
343 if (strcmp ("a", "a") != 0)
349 state test_primstring
352 str = concat (string (1), string ("a"));
353 if (strcmp (str, "1a") != 0)
359 state test_primstrncmp
362 if (strncmp ("a", "ab", 1) != 0)
364 if (strncmp ("aaa", "a", 2) != 1)
370 state test_primsubstring
373 if (strcmp (substring ("abcdef", 1, 3), "bc") != 0)