3 # This file is part of Language::Befunge.
4 # Copyright (c) 2001-2007 Jerome Quelin, all rights reserved.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the same terms as Perl itself.
11 #---------------------------------#
13 #---------------------------------#
16 use Language::Befunge;
18 use POSIX qw! tmpnam !;
26 my $bef = Language::Befunge->new;
29 # In order to see what happens...
32 open OUT, ">$file" or die $!;
38 open OUT, "<$file" or die $!;
51 skip 'will barf on windows...', 1 if $^O eq 'MSWin32';
54 $bef->store_code( '< q . = "a_file_unlikely_to_exist"0' );
56 local $SIG{__WARN__} = sub {};
62 sel; # normal system-ing.
63 $bef->store_code( <<'END_OF_CODE' );
64 < q . = "perl t/exit3.pl"0
69 BEGIN { $tests += 2 };
71 # System info retrieval.
73 $bef->store_code( <<'END_OF_CODE' );
79 BEGIN { $tests += 1 };
81 sel; # 2. size of funge integers in bytes.
82 $bef->store_code( <<'END_OF_CODE' );
88 BEGIN { $tests += 1 };
91 $bef->store_code( <<'END_OF_CODE' );
96 is( $out, "JQBF980 " );
97 BEGIN { $tests += 1 };
99 sel; # 4. version of interpreter.
100 $bef->store_code( <<'END_OF_CODE' );
105 my $ver = $Language::Befunge::VERSION;
108 BEGIN { $tests += 1 };
111 $bef->store_code( <<'END_OF_CODE' );
117 BEGIN { $tests += 1 };
119 sel; # 6. path separator.
120 $bef->store_code( <<'END_OF_CODE' );
125 is( $out, $Config{path_sep} );
126 BEGIN { $tests += 1 };
128 sel; # 7. size of funge (2D).
129 $bef->store_code( <<'END_OF_CODE' );
135 BEGIN { $tests += 1 };
138 $bef->store_code( <<'END_OF_CODE' );
143 like( $out, qr/^\d+ $/ );
144 BEGIN { $tests += 1 };
146 sel; # 9. NetFunge (unimplemented).
147 $bef->store_code( <<'END_OF_CODE' );
153 BEGIN { $tests += 1 };
155 sel; # 10. pos of IP.
156 $bef->store_code( <<'END_OF_CODE' );
163 BEGIN { $tests += 1 };
165 sel; # 11. delta of IP.
166 $bef->store_code( <<'END_OF_CODE' );
176 BEGIN { $tests += 1 };
178 sel; # 12. Storage offset.
179 $bef->store_code( <<'END_OF_CODE' );
185 BEGIN { $tests += 1 };
187 sel; # 13. top-left corner of Lahey space.
188 $bef->store_code( <<'END_OF_CODE' );
193 is( $out, "-4 -3 " );
194 BEGIN { $tests += 1 };
196 sel; # 14. bottom-right corner of Lahey space.
197 $bef->store_code( <<'END_OF_CODE' );
198 6 ff+8p 6 03-04-p ey..q
202 is( $out, "13 34 " );
203 BEGIN { $tests += 1 };
206 my ($s,$m,$h,$dd,$mm,$yy)=localtime;
207 my $date = $yy*256*256+$mm*256+$dd;
208 my $time = $h*256*256+$m*256+$s;
209 $bef->store_code( <<'END_OF_CODE' );
214 chop($out); # remove trailing space.
215 is( $out >= $date, 1); # There is a tiny little chance
216 is( $out <= $date+1, 1); # that the date has changed.
217 BEGIN { $tests += 2 };
220 $bef->store_code( <<'END_OF_CODE' );
225 chop($out); # remove trailing space.
226 is( $out >= $time, 1); # The two tests should not take
227 is( $out <= $time+15, 1); # more than 15 seconds.
228 BEGIN { $tests += 2 };
230 sel; # 17. Size of stack stack.
231 $bef->store_code( <<'END_OF_CODE' );
232 0{0{0{0{ 89+y. 0}0} 89+y.q
237 BEGIN { $tests += 1 };
239 sel; # 18. Size of each stack.
240 $bef->store_code( <<'END_OF_CODE' );
241 123 0{ 12 0{ 987654 99+y...q
245 is( $out, "6 4 5 " );
246 BEGIN { $tests += 1 };
249 $bef->store_code( <<'END_OF_CODE' );
250 a9+y > :#, _ $a, :#v _q
253 $bef->run_code( "foo", 7, "bar" );
255 is( $out, "STDIN\nfoo\n7\nbar\n" );
256 BEGIN { $tests += 1 };
262 $bef->store_code( <<'END_OF_CODE' );
265 > 2a*y : | ;new pair; : <
270 is( $out, "LANG=C\nLC_ALL=C\n" );
271 BEGIN { $tests += 1 };
274 $bef->store_code( <<'END_OF_CODE' );
279 is( $out, "15 4 JQBF98" );
280 BEGIN { $tests += 1 };
282 sel; # pick in stack.
283 $bef->store_code( <<'END_OF_CODE' );
289 BEGIN { $tests += 1 };
291 BEGIN { plan tests => $tests };