| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | # | 
| 2 |  |  |  |  |  |  | # This file is part of Language-Befunge | 
| 3 |  |  |  |  |  |  | # | 
| 4 |  |  |  |  |  |  | # This software is copyright (c) 2003 by Jerome Quelin. | 
| 5 |  |  |  |  |  |  | # | 
| 6 |  |  |  |  |  |  | # This is free software; you can redistribute it and/or modify it under | 
| 7 |  |  |  |  |  |  | # the same terms as the Perl 5 programming language system itself. | 
| 8 |  |  |  |  |  |  | # | 
| 9 | 2 |  |  | 2 |  | 7 | use strict; | 
|  | 2 |  |  |  |  | 1 |  | 
|  | 2 |  |  |  |  | 48 |  | 
| 10 | 2 |  |  | 2 |  | 5 | use warnings; | 
|  | 2 |  |  |  |  | 2 |  | 
|  | 2 |  |  |  |  | 67 |  | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | package Language::Befunge::lib::TEST; | 
| 13 |  |  |  |  |  |  | # ABSTRACT: extension to run tests | 
| 14 |  |  |  |  |  |  | $Language::Befunge::lib::TEST::VERSION = '5.000'; | 
| 15 | 2 |  |  | 2 |  | 1123 | use Test::Builder; | 
|  | 2 |  |  |  |  | 14424 |  | 
|  | 2 |  |  |  |  | 14 |  | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | my $Tester = Test::Builder->new(); | 
| 18 |  |  |  |  |  |  |  | 
| 19 | 6 |  |  | 6 | 1 | 12 | sub new { return bless {}, shift; } | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | # P = plan() | 
| 22 |  |  |  |  |  |  | # num - | 
| 23 |  |  |  |  |  |  | sub P { | 
| 24 | 2 |  |  | 2 | 1 | 2 | my ( $self, $interp ) = @_; | 
| 25 | 2 |  |  |  |  | 6 | my $tests = $interp->get_curip()->spop(); | 
| 26 | 2 | 100 |  |  |  | 7 | $Tester->plan( $tests ? ( tests => $tests ) : 'no_plan' ); | 
| 27 |  |  |  |  |  |  | } | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | # O = ok() | 
| 30 |  |  |  |  |  |  | # 0gnirts bool - | 
| 31 |  |  |  |  |  |  | sub O { | 
| 32 | 2 |  |  | 2 | 1 | 4 | my ( $self, $interp ) = @_; | 
| 33 | 2 |  |  |  |  | 7 | my $ip = $interp->get_curip(); | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | # pop the args and output the test result | 
| 36 | 2 |  |  |  |  | 4 | my $ok  = $ip->spop(); | 
| 37 | 2 |  |  |  |  | 32 | my $msg = $ip->spop_gnirts(); | 
| 38 | 2 |  |  |  |  | 6 | $Tester->ok( $ok, $msg ); | 
| 39 |  |  |  |  |  |  | } | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | # I = is() | 
| 42 |  |  |  |  |  |  | # 0gnirts expected got - | 
| 43 |  |  |  |  |  |  | sub I { | 
| 44 | 2 |  |  | 2 | 1 | 3 | my ( $self, $interp ) = @_; | 
| 45 | 2 |  |  |  |  | 4 | my $ip = $interp->get_curip(); | 
| 46 |  |  |  |  |  |  |  | 
| 47 | 2 |  |  |  |  | 5 | my ( $got, $expected ) = ( $ip->spop(), $ip->spop() ); | 
| 48 | 2 |  |  |  |  | 4 | my $msg = $ip->spop_gnirts(); | 
| 49 | 2 |  |  |  |  | 7 | $Tester->is_eq( $got, $expected, $msg ); | 
| 50 |  |  |  |  |  |  | } | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | 'ok'; | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | __END__ |