3 # This file is part of Language::Befunge.
4 # Copyright (c) 2001-2008 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;
17 use POSIX qw! tmpnam !;
24 my $bef = Language::Befunge->new;
27 # In order to see what happens...
30 open OUT, ">$file" or die $!;
36 open OUT, "<$file" or die $!;
49 $bef = Language::Befunge->new( {file => "t/_resources/q.bf"} );
53 BEGIN { $tests += 1 };
58 local $SIG{__WARN__} = sub { $warning = "@_" };
59 $bef = Language::Befunge->new;
62 $bef->debug( "foo\n" );
63 is( $warning, "", "DEBUG is off by default" );
67 $bef->debug( "bar\n" );
68 is( $warning, "bar\n", "debug warns properly when DEBUG is on" );
72 $bef->debug( "baz\n" );
73 is( $warning, "", "debug does not warn when DEBUG is off" );
75 BEGIN { $tests += 3 };
79 $bef = Language::Befunge->new;
81 $bef->read_file( "t/_resources/q.bf" );
85 BEGIN { $tests += 1 };
87 # Reading a non existent file.
88 eval { $bef->read_file( "/dev/a_file_that_is_not_likely_to_exist" ); };
89 like( $@, qr/line/, "reading a non-existent file barfs" );
90 BEGIN { $tests += 1 };
94 $bef->store_code( <<'END_OF_CODE' );
100 BEGIN { $tests += 1 };
102 # Interpreter must treat non-characters as if they were an 'r' instruction.
104 $bef->store_code( <<'END_OF_CODE' );
110 BEGIN { $tests += 1 };
112 # Interpreter must treat non-commands as if they were an 'r' instruction.
114 $bef->store_code( <<'END_OF_CODE' );
120 BEGIN { $tests += 1 };
122 # Befunge Interpreter treats High/Low instructions as unknown characters.
124 $bef->store_code( <<"END_OF_CODE" );
130 BEGIN { $tests += 1 };
132 BEGIN { plan tests => $tests };