10 $art5->{op
}->{ary1
} = sub { [ 'a', 'b', 'c' ]; };
11 $art5->{op
}->{ary2
} = sub { [ [1, 'a'], [2, 'b'], [3, 'b'], [4, 'c'] ]; };
12 $art5->{op
}->{link} = sub { "<a href = '" . $art5->exec(shift) . "'>" . $art5->exec(shift) . "</a>"; };
18 my $result = $art5->process($code);
20 if ($result eq $expected) {
21 print "OK test: ", $code, "\n";
25 print "ERROR test: ", $code, "\n";
26 print "\tExpected: '", $expected, "' ",
27 "Got: '", $result, "'\n";
36 try
('1<{#this is a comment}>2', '12');
37 try
('1<{#this is a comment "hello"}>2', '12');
38 try
("1<{#this is a comment\n'hello'}>2", '1hello2');
39 try
('1<{"hello"}>2', '1hello2');
40 try
("1<{'hello'}>2", '1hello2');
41 try
('1<{"hello\n"}>2', "1hello\n2");
42 try
('1<{%arch}>2', '1Unix2');
43 try
('1<{3 4}>2', '1342');
44 try
('1<{? 3 4}>2', '1342');
45 try
('1<{3 4 5 6}>2', '134562');
46 try
('1<{? 3 4 5 6}>2', '134562');
47 try
('1<{add 3 4}>2', '172');
48 try
('1<{foreach ary1}>2', '1abc2');
49 try
('1<{foreach ary1 $0}>2', '1abc2');
50 try
('1<{foreach ary1 {? "<" $0 ">"}>2', '1<a><b><c>2');
51 try
('1<{foreach ary1 $0 ", "}>2', '1a, b, c2');
52 try
('1<{foreach ary2}>2', '112342');
53 try
('1<{foreach ary2 $0}>2', '112342');
54 try
('1<{foreach ary2 $1}>2', '1abbc2');
55 try
('1<{foreach ary2 $0 ", "}>2', '11, 2, 3, 42');
56 try
('1<{foreach ary2 $1 ", "}>2', '1a, b, b, c2');
57 try
('1<{foreach ary2 $0 ", " {? "[" $1 "]"}}>2', '1[a]1, [b]2, 3, [c]42');
58 try
('1<{if {eq 1 2} "equal"}>2', '12');
59 try
('1<{if {eq 1 1} "equal"}>2', '1equal2');
60 try
('1<{if {eq 1 2} "equal" "different"}>2', '1different2');
61 try
('1<{if {eq 1 1} "equal" "different"}>2', '1equal2');
62 try
('1<{if {eq 1 2} {"equal"}}>2', '12');
63 try
('1<{if {eq 1 1} {"equal"}}>2', '1equal2');
64 try
('1<{if {eq 1 2} {"equal"} {"different"}}>2', '1different2');
65 try
('1<{if {eq 1 1} {"equal"} "different"}}>2', '1equal2');
66 try
('1<{link}>2', "1<a href = ''></a>2");
67 try
('1<{link "http://url"}>2', "1<a href = 'http://url'></a>2");
68 try
('1<{link "http://url" "label"}>2', "1<a href = 'http://url'>label</a>2");
69 try
('1<{= "RESULT" 1000}>2<{RESULT}>3', '1210003');
71 print "\nTest result: ", $tests_ok, '/', $tests, ' (', ($tests_ok / $tests) * 100, "%)\n";