tagged release 0.6.4
[parrot.git] / languages / jako / t / examples.t
bloba587b13bac77c1bf4c3c60c844f30593db4f49d5
1 #! perl
2 # Copyright (C) 2005-2007, The Perl Foundation.
3 # $Id$
5 use strict;
6 use warnings;
7 use lib qw( . lib ../lib ../../lib );
8 use Test::More;
9 use Parrot::Test tests => 15;
10 use Parrot::Config;
12 =head1 NAME
14 jako/t/examples.t - Test examples in F<jako/examples>
16 =head1 SYNOPSIS
18         % prove languages/jako/t/examples.t
20 =head1 DESCRIPTION
22 Test the examples in F<jako/examples>.
24 =head1 SEE ALSO
26 F<t/examples/pir.t>
28 =head1 AUTHOR
30 Bernhard Schmalhofer - <Bernhard.Schmalhofer@gmx.de>
32 =cut
34 # Set up expected output for examples
35 my %expected = (
36     'board.pir' => << 'END_EXPECTED',
37   +---+---+---+---+---+---+---+---+
38 8 |   | * |   | * |   | * |   | * |
39   +---+---+---+---+---+---+---+---+
40 7 | * |   | * |   | * |   | * |   |
41   +---+---+---+---+---+---+---+---+
42 6 |   | * |   | * |   | * |   | * |
43   +---+---+---+---+---+---+---+---+
44 5 | * |   | * |   | * |   | * |   |
45   +---+---+---+---+---+---+---+---+
46 4 |   | * |   | * |   | * |   | * |
47   +---+---+---+---+---+---+---+---+
48 3 | * |   | * |   | * |   | * |   |
49   +---+---+---+---+---+---+---+---+
50 2 |   | * |   | * |   | * |   | * |
51   +---+---+---+---+---+---+---+---+
52 1 | * |   | * |   | * |   | * |   |
53   +---+---+---+---+---+---+---+---+
54     A   B   C   D   E   F   G   H  
55 END_EXPECTED
57     'euclid.pir' => << 'END_EXPECTED',
58 Algorithm E (Euclid's algorithm)
59   Calculating gcd(96, 64) = ...
60   ... = 32
61 END_EXPECTED
63     'fact.pir' => << 'END_EXPECTED',
64 Algorithm F1 (The factorial function)
65     Calculating fact(15) = ...
66     ... = 2004189184
67 END_EXPECTED
69     'fib.pir' => << 'END_EXPECTED',
70 Algorithm F2 (Fibonacci's function)
71   Calculating fib(24) = ...
72   ... = 46368
73 END_EXPECTED
75     'hello.pir' => << 'END_EXPECTED',
76 Hello, world!
77 END_EXPECTED
79     'leibniz.pir' => << 'END_EXPECTED',
80 PI is (very) approximately: 3.14159
81 END_EXPECTED
83     'mandelbrot.pir' => << 'END_EXPECTED',
84 ................::::::::::::::::::::::::::::::::::::::::::::...............
85 ...........::::::::::::::::::::::::::::::::::::::::::::::::::::::..........
86 ........::::::::::::::::::::::::::::::::::,,,,,,,:::::::::::::::::::.......
87 .....:::::::::::::::::::::::::::::,,,,,,,,,,,,,,,,,,,,,,:::::::::::::::....
88 ...::::::::::::::::::::::::::,,,,,,,,,,,,;;;!:H!!;;;,,,,,,,,:::::::::::::..
89 :::::::::::::::::::::::::,,,,,,,,,,,,,;;;;!!/>&*|& !;;;,,,,,,,:::::::::::::
90 ::::::::::::::::::::::,,,,,,,,,,,,,;;;;;!!//)|.*#|>/!;;;;;,,,,,,:::::::::::
91 ::::::::::::::::::,,,,,,,,,,,,;;;;;;!!!!//>|:    !:|//!!;;;;;,,,,,:::::::::
92 :::::::::::::::,,,,,,,,,,;;;;;;;!!/>>I>>)||I#     H&))>////*!;;,,,,::::::::
93 ::::::::::,,,,,,,,,,;;;;;;;;;!!!!/>H:  #|              IH&*I#/;;,,,,:::::::
94 ::::::,,,,,,,,,;;;;;!!!!!!!!!!//>|.H:                     #I>!!;;,,,,::::::
95 :::,,,,,,,,,;;;;!/||>///>>///>>)|H                         %|&/;;,,,,,:::::
96 :,,,,,,,,;;;;;!!//)& :;I*,H#&||&/                           *)/!;;,,,,,::::
97 ,,,,,,;;;;;!!!//>)IH:,        ##                            #&!!;;,,,,,::::
98 ,;;;;!!!!!///>)H%.**           *                            )/!;;;,,,,,::::
99                                                           &)/!!;;;,,,,,::::
100 ,;;;;!!!!!///>)H%.**           *                            )/!;;;,,,,,::::
101 ,,,,,,;;;;;!!!//>)IH:,        ##                            #&!!;;,,,,,::::
102 :,,,,,,,,;;;;;!!//)& :;I*,H#&||&/                           *)/!;;,,,,,::::
103 :::,,,,,,,,,;;;;!/||>///>>///>>)|H                         %|&/;;,,,,,:::::
104 ::::::,,,,,,,,,;;;;;!!!!!!!!!!//>|.H:                     #I>!!;;,,,,::::::
105 ::::::::::,,,,,,,,,,;;;;;;;;;!!!!/>H:  #|              IH&*I#/;;,,,,:::::::
106 :::::::::::::::,,,,,,,,,,;;;;;;;!!/>>I>>)||I#     H&))>////*!;;,,,,::::::::
107 ::::::::::::::::::,,,,,,,,,,,,;;;;;;!!!!//>|:    !:|//!!;;;;;,,,,,:::::::::
108 ::::::::::::::::::::::,,,,,,,,,,,,,;;;;;!!//)|.*#|>/!;;;;;,,,,,,:::::::::::
109 :::::::::::::::::::::::::,,,,,,,,,,,,,;;;;!!/>&*|& !;;;,,,,,,,:::::::::::::
110 ...::::::::::::::::::::::::::,,,,,,,,,,,,;;;!:H!!;;;,,,,,,,,:::::::::::::..
111 .....:::::::::::::::::::::::::::::,,,,,,,,,,,,,,,,,,,,,,:::::::::::::::....
112 ........::::::::::::::::::::::::::::::::::,,,,,,,:::::::::::::::::::.......
113 ...........::::::::::::::::::::::::::::::::::::::::::::::::::::::..........
114 END_EXPECTED
116     'primes.pir' => << 'END_EXPECTED',
117 Algorithm P (Naiive primality test)
118   Printing primes up to 100...
119 2  3  5  7  11  13  17  19  23  29  31  37  41  43  47  53  59  61  67  71  73  79  83  89  97  
120 END_EXPECTED
122     'queens.pir' => << 'END_EXPECTED',
123 Making new board with 8 ranks and 8 files...
124 Board length is 64.
125   +---+---+---+---+---+---+---+---+
126 8 |   | * | Q | * |   | * |   | * |
127   +---+---+---+---+---+---+---+---+
128 7 | * |   | * |   | * | Q | * |   |
129   +---+---+---+---+---+---+---+---+
130 6 |   | * |   | Q |   | * |   | * |
131   +---+---+---+---+---+---+---+---+
132 5 | * | Q | * |   | * |   | * |   |
133   +---+---+---+---+---+---+---+---+
134 4 |   | * |   | * |   | * |   | Q |
135   +---+---+---+---+---+---+---+---+
136 3 | * |   | * |   | Q |   | * |   |
137   +---+---+---+---+---+---+---+---+
138 2 |   | * |   | * |   | * | Q | * |
139   +---+---+---+---+---+---+---+---+
140 1 | Q |   | * |   | * |   | * |   |
141   +---+---+---+---+---+---+---+---+
142     A   B   C   D   E   F   G   H  
143 END_EXPECTED
145     'sub.pir' => << 'END_EXPECTED',
146 x = 42; y = 137
147 x = 1234; y = 137
148 END_EXPECTED
152 while ( my ( $example, $expected ) = each %expected ) {
153     example_output_is( "jako/examples/$example", $expected );
156 TODO:
158     local $TODO = 'some examples not testable yet';
160     fail('bench.pir');
161     fail('life.pir');
162     fail('mandelzoom.pir');
163     fail('mops.pir');
164     fail('nci.pir');
167 # Local Variables:
168 #   mode: cperl
169 #   cperl-indent-level: 4
170 #   fill-column: 100
171 # End:
172 # vim: expandtab shiftwidth=4: