r5087@merlin: jquelin | 2007-05-25 17:19:53 +0200
[inline-befunge.git] / t / 10-subs.t
blobe6b473fb01b0b05e8a40bcd4249545b574fd39fb
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 same terms as Perl itself.
12 #-------------------------------------#
13 #          Subroutine calls.          #
14 #-------------------------------------#
16 use strict;
17 use Inline "Befunge";
18 use Test;
20 # Vars.
21 my $tests;
22 BEGIN { $tests = 0 };
24 # Test various subs.
25 ok( return4(), 4 );
26 ok( bf_cmp(2,4), -1 );
27 ok( bf_cmp(2,2), 0 );
28 ok( bf_cmp(2,1), 1 );
29 BEGIN { $tests += 4 };
31 # String mode.
32 use Inline BEF => <<'END_OF_CODE';
33 019p >    :             #v _ v ;:bf_reverse;
34 @    ^ p91 +1 g91 p8 g91 <   $
35 |       ` g91 g92  <    p920 <
36 > 29g 8g 29g 1+29p ^
37 END_OF_CODE
38 ok( join "", map {chr} bf_reverse( "foobar" ) eq "raboof" );
39 BEGIN { $tests += 1 };
42 BEGIN { plan tests => $tests };
44 __END__
45 __Befunge__
46 ;:return4;4q
47    ;
48    :
49    b
50    f
51    _
52    c
53    m
54    p
55    ;
56    v
57 q1 w 01-
58    0
59    q