3 # This file is part of Language::Befunge.
4 # Copyright (c) 2001-2009 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.
14 use Language::Befunge;
16 use Test::More tests => 10;
23 $bef = Language::Befunge->new( {file => "t/_resources/q.bf"} );
24 stdout_is { $bef->run_code } '', 'constructor works';
28 stderr_is { $bef->debug( "foo\n" ) } '', 'DEBUG is off by default';
30 stderr_is { $bef->debug( "bar\n" ) } "bar\n", 'debug warns properly when DEBUG is on';
32 stderr_is { $bef->debug( "baz\n" ) } '', 'debug does not warn when DEBUG is off';
36 $bef = Language::Befunge->new;
37 $bef->read_file( 't/_resources/q.bf' );
38 stdout_is { $bef->run_code } '', 'basic reading';
41 # reading a non existent file.
42 eval { $bef->read_file( '/dev/a_file_that_is_not_likely_to_exist' ); };
43 like( $@, qr/line/, 'reading a non-existent file barfs' );
47 $bef->store_code( <<'END_OF_CODE' );
50 stdout_is { $bef->run_code } '', 'basic storing';
53 # interpreter must treat non-characters as if they were an 'r' instruction.
54 $bef->store_code( <<'END_OF_CODE' );
57 stdout_is { $bef->run_code } '1 2 ', 'non-chars treated as "r" instruction';
60 # interpreter must treat non-commands as if they were an 'r' instruction.
61 $bef->store_code( <<'END_OF_CODE' );
64 stdout_is { $bef->run_code } '1 2 ', 'non-commands treated as "r" instruction';
67 # befunge interpreter treats high/low instructions as unknown characters.
68 $bef->store_code( <<"END_OF_CODE" );
71 stdout_is { $bef->run_code } '1 2 ', 'high/low treated as "r" instruction';