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 aliased 'Language::Befunge::Vector' => 'LBV';
19 use POSIX qw! tmpnam !;
26 my $tref = Language::Befunge->new( {syntax=>'trefunge98'} );
29 # In order to see what happens...
32 open OUT, ">$file" or die $!;
38 open OUT, "<$file" or die $!;
51 $tref = Language::Befunge->new( {file=>'t/_resources/q.bf', syntax=>'trefunge98'} );
54 is( $out, '', 'constructor worked' );
55 BEGIN { $tests += 1 };
58 $tref = Language::Befunge->new({
59 syntax => 'trefunge98',
60 storage => 'Language::Befunge::Storage::Generic::Vec' });
61 is(ref($tref->get_storage), 'Language::Befunge::Storage::Generic::Vec', 'storage specified');
62 $tref = Language::Befunge->new({
63 syntax => 'trefunge98',
64 wrapping => 'Language::Befunge::Wrapping::LaheySpace' });
65 is(ref($tref->get_wrapping), 'Language::Befunge::Wrapping::LaheySpace', 'wrapping specified');
66 $tref = Language::Befunge->new({
67 syntax => 'trefunge98',
68 ops => 'Language::Befunge::Ops::GenericFunge98' });
69 ok(exists($$tref{ops}{m}), 'ops specified');
70 $tref = Language::Befunge->new({
71 syntax => 'trefunge98',
73 is($$tref{dimensions}, 4, 'dims specified');
74 BEGIN { $tests += 4 };
77 $tref = Language::Befunge->new( {syntax=>'trefunge98'} );
79 $tref->read_file( "t/_resources/q.bf" );
82 is( $out, "", 'read_file' );
83 BEGIN { $tests += 1 };
87 $tref->store_code( <<'END_OF_CODE' );
92 is( $out, '', 'store_code' );
93 BEGIN { $tests += 1 };
95 # Interpreter must treat non-characters as if they were an 'r' instruction.
97 $tref->store_code( <<'END_OF_CODE' );
102 is( $out, "1 2 ", 'treats non-characters like "r"' );
103 BEGIN { $tests += 1 };
105 # Interpreter must treat non-commands as if they were an 'r' instruction.
107 $tref->store_code( <<'END_OF_CODE' );
112 is( $out, "1 2 ", 'treats non-commands like "r"' );
113 BEGIN { $tests += 1 };
115 # Interpreter reads trefunge code properly, and operates in 3 dimensions, and
116 # knows that vectors are 3 integers.
118 my $code = <<"END_OF_CODE";
124 $tref->store_code( $code );
127 is( $out, "3 4 ", 'full operation' );
128 BEGIN { $tests += 1 };
130 # rectangle() returns the original box again
132 is($tref->get_storage->rectangle(LBV->new(0,0,0), LBV->new(9,2,2)), $code, 'rectangle works');
133 BEGIN { $tests += 1 };
135 BEGIN { plan tests => $tests };