Added a test for the auto-joiner.
[artemus.git] / art5
blobfddda1c15cec1ff8460213f8039b2d8587958402
1 #!/usr/bin/perl
3 use Artemus5;
5 my $a = Artemus5->new();
7 #my $src = join('', <>);
9 #print $a->process($src);
11 # <a href = http://host?t=<{$0}>;offset=0><{or $1 "Main index"}></a>
13 my $url = [ '?',
14 [ '"', '<a href = http://host/?t=' ],
15 [ '$', 0 ],
16 [ '"', ';offset='],
17 [ 'or',
18 [ '$', 2 ],
19 [ '"', 0 ],
21 [ '"', '>'],
22 [ 'or',
23 [ '$', 1 ],
24 [ '"', 'Main index' ],
26 [ '"', '</a>' ]
29 $a->{op}->{url} = $url;
31 # navigator
32 # <span class = 'prev'><{
33 # if $2
34 # {?
35 # "<a href = "
36 # {url "INDEX" "topic" $0 "offset" {sub $2 $1}}
37 # ">&lt;&lt;</a>"
38 # }
39 #}></span>
41 # <html>\n<{url 'LOGIN' 'Login page'}>\n<{url 'INDEX'}></html>
43 my $p = [ '?',
44 [ '"', "<html>\n" ],
45 [ 'url', [ '"', 'LOGIN'], ['"', 'Login page'], ['"', 10 ]],
46 [ '"', "\n" ],
47 [ 'url', [ '"', 'INDEX'] ],
48 [ '"', "\n</html>" ]
51 print $a->exec($p), "\n";
53 my $c;
54 $c = $a->compile("Leading <{%arch}> Trailing");
55 print $a->exec($c), "\n";
56 $c = $a->compile("Leading <{? 'Arch: ' %arch}> Trailing");
57 print $a->exec($c), "\n";
58 $c = $a->compile("Leading <{mul {add 10 20} 1000}> Trailing");
59 print $a->exec($c), "\n";
60 $c = $a->compile("Leading <{? {= 'TEST' 'here'} { TEST }}> Trailing");
61 print $a->exec($c), "\n";
62 $c = $a->compile("Leading <{if {eq 1 2} 'Equal' 'Different'}> Trailing");
63 print $a->exec($c), "\n";
64 $c = $a->compile("Leading <{if {eq 1 1} 'Equal' 'Different'}> Trailing");
65 print $a->exec($c), "\n";
66 $c = $a->compile("Leading <{if {eq 1 2} {'Equal'} {'Different'}}> Trailing");
67 print $a->exec($c), "\n";
68 $c = $a->compile("Leading <{if {eq 1 1} {'Equal'} {'Different'}}> Trailing");
69 print $a->exec($c), "\n";
70 $c = $a->compile("Leading <{url 'LOGIN' 'Login page'}> Trailing");
71 print $a->exec($c), "\n";
72 $c = $a->compile("Leading <{random 1 2 3 4 5 6}> Trailing");
73 print $a->exec($c), "\n";
74 $c = $a->compile("Leading <{env}> Trailing");
75 print $a->exec($c), "\n";
76 $c = $a->compile("Leading <{foreach env}> Trailing");
77 print $a->exec($c), "\n";
78 $c = $a->compile("Leading <{foreach env \$0}> Trailing");
79 print $a->exec($c), "\n";
80 $c = $a->compile("Leading <{foreach env \$0 ', '}> Trailing");
81 print $a->exec($c), "\n";
82 $c = $a->compile("Leading <{foreach env {? \$0 '=' {env \$0}} ', '}> Trailing");
83 print $a->exec($c), "\n";
84 $c = $a->compile("Leading <{1 2 3}> Trailing");
85 print $a->exec($c), "\n";
87 exit 0;