r5019@merlin: jquelin | 2007-05-24 17:31:25 +0200
[inline-befunge.git] / t / 02subs.t
blob648ff60b709413ad75801cb8e2c0f4cbf9cd085d
1 #!perl
3 # This file is part of Inline::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 terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or (at
9 # your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #-------------------------------------#
24 #          Subroutine calls.          #
25 #-------------------------------------#
27 use strict;
28 use Inline "Befunge";
29 use Test;
31 # Vars.
32 my $tests;
33 BEGIN { $tests = 0 };
35 # Test various subs.
36 ok( return4(), 4 );
37 ok( bf_cmp(2,4), -1 );
38 ok( bf_cmp(2,2), 0 );
39 ok( bf_cmp(2,1), 1 );
40 BEGIN { $tests += 4 };
42 # String mode.
43 use Inline BEF => <<'END_OF_CODE';
44 019p >    :             #v _ v ;:bf_reverse;
45 @    ^ p91 +1 g91 p8 g91 <   $
46 |       ` g91 g92  <    p920 <
47 > 29g 8g 29g 1+29p ^
48 END_OF_CODE
49 ok( join "", map {chr} bf_reverse( "foobar" ) eq "raboof" );
50 BEGIN { $tests += 1 };
53 BEGIN { plan tests => $tests };
55 __END__
56 __Befunge__
57 ;:return4;4q
58    ;
59    :
60    b
61    f
62    _
63    c
64    m
65    p
66    ;
67    v
68 q1 w 01-
69    0
70    q