Modified tests.pl to be really a testing unit.
[artemus.git] / tests / tests.pl
blob01f24819700bf94c89f20e8ebede2ee966c1d3cf
1 #!/usr/bin/perl
3 use Art5;
5 $art5 = Art5->new();
7 $tests = 0;
8 $tests_ok = 0;
10 sub try {
11 my $code = shift;
12 my $expected = shift;
14 my $result = $art5->process($code);
16 if ($result eq $expected) {
17 print "OK test: ", $code, "\n";
18 $tests_ok++;
20 else {
21 print "ERROR test: ", $code, "\n";
22 print "\tExpected: '", $expected, "' ",
23 "Got: '", $result, "'\n";
26 $tests++;
29 try('1<{}>2', '12');
30 try('1<{#}>2', '12');
31 try('1<{#this is a comment}>2', '12');
32 try('1<{#this is a comment "hello"}>2', '12');
33 try('1<{"hello"}>2', '1hello2');
34 try("1<{'hello'}>2", '1hello2');
35 try('1<{"hello\n"}>2', "1hello\n2");
37 print "\nTest result: ", $tests_ok, '/', $tests, ' (', ($tests_ok / $tests) * 100, "%)\n";
39 exit 0;