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 use Language::Befunge::Ops;
16 use Language::Befunge::Interpreter;
17 use Language::Befunge::IP;
18 use Language::Befunge::Ops;
19 use Language::Befunge::Vector;
20 use Test::More tests => 4;
25 $lbi = Language::Befunge::Interpreter->new;
26 $ip = Language::Befunge::IP->new;
27 $lbi->set_curip( $ip );
29 $v = Language::Befunge::Vector->new(2,1,0);
31 $ip->spush( 12, 24, 46 );
32 Language::Befunge::Ops::decis_cmp( $lbi );
33 is( $ip->get_delta, '(0,-1)',
34 'decis_cmp turns left if popped values are sorted' );
35 is( $ip->spop, 12, 'decis_cmp pops only two values' );
37 $v = Language::Befunge::Vector->new(2,1,0);
39 $ip->spush( 12, 24, 13 );
40 Language::Befunge::Ops::decis_cmp( $lbi );
41 is( $ip->get_delta, '(0,1)',
42 'decis_cmp turns right if popped values are not sorted' );
44 $v = Language::Befunge::Vector->new(2,1,0);
46 $ip->spush( 12, 24, 24 );
47 Language::Befunge::Ops::decis_cmp( $lbi );
48 is( $ip->get_delta, '(1,0)',
49 'decis_cmp continues forward if popped values are equal' );