2 # Copyright (C) 2005-2007, The Perl Foundation.
7 use lib qw( . lib ../lib ../../lib );
9 use Parrot::Test tests => 15;
14 jako/t/examples.t - Test examples in F<jako/examples>
18 % prove languages/jako/t/examples.t
22 Test the examples in F<jako/examples>.
30 Bernhard Schmalhofer - <Bernhard.Schmalhofer@gmx.de>
34 # Set up expected output for examples
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 +---+---+---+---+---+---+---+---+
57 'euclid.pir' => << 'END_EXPECTED',
58 Algorithm E (Euclid's algorithm)
59 Calculating gcd(96, 64) = ...
63 'fact.pir' => << 'END_EXPECTED',
64 Algorithm F1 (The factorial function)
65 Calculating fact(15) = ...
69 'fib.pir' => << 'END_EXPECTED',
70 Algorithm F2 (Fibonacci's function)
71 Calculating fib(24) = ...
75 'hello.pir' => << 'END_EXPECTED',
79 'leibniz.pir' => << 'END_EXPECTED',
80 PI is (very) approximately: 3.14159
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%.** * )/!;;;,,,,,::::
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 ...........::::::::::::::::::::::::::::::::::::::::::::::::::::::..........
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
122 'queens.pir' => << 'END_EXPECTED',
123 Making new board with 8 ranks and 8 files...
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 +---+---+---+---+---+---+---+---+
145 'sub.pir' => << 'END_EXPECTED',
152 while ( my ( $example, $expected ) = each %expected ) {
153 example_output_is( "jako/examples/$example", $expected );
158 local $TODO = 'some examples not testable yet';
162 fail('mandelzoom.pir');
169 # cperl-indent-level: 4
172 # vim: expandtab shiftwidth=4: