[t][TT #1122] Convert t/op/numbert.t to PIR, mgrimes++
[parrot.git] / t / pmc / io_iterator.t
blob6544d718ce838aa8bdb93e286c9cdaf338da1c9e
1 #!perl
2 # Copyright (C) 2006-2007, Parrot Foundation.
3 # $Id$
5 use strict;
6 use warnings;
7 use lib qw( . lib ../lib ../../lib );
8 use Test::More;
9 use Parrot::Test tests => 3;
11 =head1 NAME
13 t/pmc/io_iterator.t - test the I/O Iterator PMC described in PDD22
15 =head1 SYNOPSIS
17     % prove t/pmc/io_iterator.t
19 =head1 DESCRIPTION
21 Tests the I/O Iterator PMC described in PDD22.
23 =cut
25 # L<PDD22/I\/O Iterator PMC API/=item new>
26 pir_output_is( <<'CODE', <<'OUT', 'new', todo => 'not yet implemented' );
27 .sub 'test' :main
28     $P99 = 1 # TT #1242 replace with io object
29     $P0 = iter $P99
30     say "ok 1 - $P0 = iter $P1"
31 .end
32 CODE
33 ok 1 - $P0 = iter $P1
34 OUT
36 # L<PDD22/I\/O Iterator PMC API/=item shift>
37 pir_output_is( <<'CODE', <<'OUT', 'shift', todo => 'not yet implemented' );
38 .sub 'test' :main
39     $P99 = 1 # TT #1242 replace with io object
40     $P0 = iter $P99
42     $S0 = shift $P0
44     if $S0 == 'abc' goto ok_1
45     print 'not '
46   ok_1:
47     say 'ok 1 - $S0 = shift $P1 # success'
49     # TT #1206  test more return values, including end of file
50 .end
51 CODE
52 ok 1 - $I0 = shift $P1 # success
53 OUT
55 # L<PDD22/I\/O Iterator PMC API/=item get_bool (vtable)>
56 pir_output_is( <<'CODE', <<'OUT', 'get_bool (vtable)', todo => 'not yet implemented' );
57 .sub 'test' :main
58     $P99 = 1 # TT #1242 replace with io object
59     $P0 = iter $P99
61     # empty i/o object
62     unless $P0 goto ok_1
63     print 'not '
64   ok_1:
65     say 'ok 1 - $P0 # empty i/o object returns false'
67     # TT #1242 setup i/o object with two lines
68     if $P0 got ok_2
69     print 'not '
70   ok_2:
71     say 'ok 2 - $P0 # i/o object with data returns true
73     $S0 = shift $P0
74     $I0 = length $S0
75     unless $I0 goto nok_3
76     if $P0 goto ok_3
78   nok_3:
79     print 'not '
80   ok_3:
81     say 'ok 3 - $P0 # i/o object with more data returns true'
83     $S0 = shift $P0
84     $I0 = length $S0
85     unless $I0 goto nok_4
86     unless $P0 goto ok_4
88   nok_4:
89     print 'not '
90   ok_4:
91     say 'ok 4 - $P0 # i/o object with no more data returns false'
93     if $P0 goto ok_1
94     print 'not '
95 .end
96 CODE
97 ok 1 - $P0 # empty i/o object returns false
98 ok 2 - $P0 # i/o object with data returns true
99 ok 3 - $P0 # i/o object with more data returns true
100 ok 4 - $P0 # i/o object with no more data returns false
103 # Local Variables:
104 #   mode: cperl
105 #   cperl-indent-level: 4
106 #   fill-column: 100
107 # End:
108 # vim: expandtab shiftwidth=4: