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 * This program 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 2, or (at your option)
15 * This program 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 this program; see the file COPYING. If not, write to
22 * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301, USA.
40 /Test startrules\./ test_startrules;
45 /\.st$/ test_namerules;
76 print ("test_startrules");
84 print ("test_namerules");
89 state test_optionstate
92 print ("test_optionstate");
97 state test_first_match
109 state test_case_insensitive_regexps
186 state test_primconcat
189 if (strcmp (concat ("a", "b", "c"), "abc") != 0)
198 if (float (/f/) != 0.0)
200 if (float (list (1, 2, 3)) != 3.0)
202 if (float ("1") != 1.0)
204 if (float ("1.34") != 1.34)
206 if (float ("") != 0.0)
208 if (float (1) != 1.0)
210 if (float (1.1) != 1.1)
216 state test_primgetenv
219 if (strcmp (getenv ("STATES_DATA"), "ok") != 0)
230 if (int (list (1, 2, 3, 4)) != 4)
234 if (int ("1.5") != 1)
246 state test_primlength
249 if (length ("ab") != 2)
251 if (length (list (1, 2, "3", /4/)) != 4)
260 lst = list (1, "2", /3/, 4);
272 print ("ok", 1, /2/);
277 state test_primregexp
281 if (!regmatch ("abcd", re))
287 state test_primregexp_syntax
290 regexp_syntax ('-', 'w');
291 if (regmatch ("foo-bar", /\bbar\b/))
297 state test_primregmatch
300 if (!regmatch ("abcde foo bar", /[a-z]+ ([a-z]+)/))
302 if (strcmp ($0, "abcde foo") != 0)
304 if (strcmp ($1, "foo") != 0)
310 state test_primregsub
313 if (strcmp (regsub ("a.b.c.d", /\./, "_"), "a_b.c.d") != 0)
319 state test_primregsuball
322 if (strcmp (regsuball ("a.b.c.d", /\./, "_"), "a_b_c_d") != 0)
328 state test_primsprintf
331 str = sprintf ("%d: foo %s %.2f", 1, "bar", 1.0);
332 if (strcmp (str, "1: foo bar 1.00") != 0)
338 state test_primstrcmp
341 if (strcmp ("a", "b") != -1)
343 if (strcmp ("aa", "a") != 1)
345 if (strcmp ("a", "a") != 0)
351 state test_primstring
354 str = concat (string (1), string ("a"));
355 if (strcmp (str, "1a") != 0)
361 state test_primstrncmp
364 if (strncmp ("a", "ab", 1) != 0)
366 if (strncmp ("aaa", "a", 2) != 1)
372 state test_primsubstring
375 if (strcmp (substring ("abcdef", 1, 3), "bc") != 0)