2 # Copyright (C) 2001-2006, Parrot Foundation.
7 use lib qw( t . lib ../lib ../../lib );
10 use Parrot::Test tests => 20;
14 t/library/streams.t - Stream tests
18 % prove t/library/streams.t
26 my @streams = qw[Combiner Coroutine Filter Lines ParrotIO Replay Sub Writer];
28 for my $a (@streams) {
33 pir_output_is( <<"CODE", <<"OUT", "load and create a Stream;$a" );
36 print "loading '$a'...\\n"
37 load_bytecode 'Stream/$a.pbc'
40 \$P0 = new ['Stream'; '$a']
51 class name: 'Stream;$a'
60 pir_output_is( <<'CODE', <<'OUT', "Stream;Sub" );
65 load_bytecode 'Stream/Sub.pbc'
67 stream = new ['Stream'; 'Sub']
69 # set the stream's source sub #'
70 .const 'Sub' temp = "_hello"
75 # read again to see if read returns null
78 print "error: read returned '"
80 print "' instead of (null)\n"
89 self."write"( "hello" )
90 self."write"( "world!" )
91 self."write"( "parrot" )
92 self."write"( "is cool" )
106 pir_output_is( <<'CODE', <<'OUT', "Stream::read_bytes" );
111 load_bytecode 'Stream/Sub.pbc'
112 load_bytecode 'Stream/Replay.pbc'
114 $P0 = new ['Stream'; 'Sub']
115 # set the stream's source sub #'
116 .const 'Sub' temp = "_hello"
119 stream = new ['Stream'; 'Replay']
122 $S0 = stream."read_bytes"( 3 )
127 stream = clone stream
130 $S0 = stream."read_bytes"( 4 )
135 $S0 = $P0."read_bytes"( 4 )
140 $S0 = stream."read"()
145 print "# _hello ends now:\n"
146 $S0 = stream."read_bytes"( 100 )
159 print "_hello start!\n"
160 self."write"( "hello" )
161 self."write"( "world!" )
162 self."write"( "parrot" )
163 self."write"( "is cool" )
164 print "_hello end!\n"
169 2: [lowo] = 3: [lowo]
181 pir_output_is( <<'CODE', <<'OUT', "Stream::Combiner" );
188 load_bytecode 'Stream/Base.pbc'
189 load_bytecode 'Stream/Combiner.pbc'
190 load_bytecode 'Stream/Sub.pbc'
192 # create the counter stream
193 counter = new ['Stream'; 'Sub']
194 .const 'Sub' ct = "_counter"
197 # create the text stream
198 text = new ['Stream'; 'Sub']
200 .const 'Sub' src = "_text"
203 # create a combiner stream
204 combined = new ['Stream'; 'Combiner']
206 assign combined, counter
207 assign combined, text
209 # specify our own combiner sub
210 .const 'Sub' cb = "_combiner"
211 combined."combiner"( cb )
213 # dump the combined stream
232 stream."write"( str )
239 stream."write"( "hello" )
240 stream."write"( "world!" )
241 stream."write"( "parrot" )
242 stream."write"( "is cool" )
269 pir_output_is( <<'CODE', <<'OUT', "Stream::Coroutine" );
274 load_bytecode 'Stream/Base.pbc'
275 load_bytecode 'Stream/Coroutine.pbc'
277 # create the coroutine stream
278 stream = new ['Stream'; 'Coroutine']
280 # set the stream's source coroutine #'
281 .const 'Sub' temp = "_coro"
283 #stream."source"( temp )
309 # the stream is automatically closed if you return a null string
310 # you can also close it explicitly with
312 # in which case it doesn't matter what you are returning.
335 pir_output_is( <<'CODE', <<'OUT', "Stream::ParrotIO" );
344 name = "t/library/perlhist.txt"
346 load_bytecode 'Stream/ParrotIO.pbc'
347 load_bytecode 'Stream/Lines.pbc'
348 load_bytecode 'Stream/Sub.pbc'
349 load_bytecode 'Stream/Combiner.pbc'
351 # create a file stream
352 file = new ['Stream'; 'ParrotIO']
353 file."open"( name, 'r' )
355 # process it one line per read
356 lines = new ['Stream'; 'Lines']
360 counter = new ['Stream'; 'Sub']
361 .const 'Sub' temp = "_counter"
364 # combine the counter and the file's lines #'
365 combiner = new ['Stream'; 'Combiner']
366 assign combiner, counter
367 assign combiner, lines
386 array = new 'ResizablePMCArray'
391 sprintf str, "%5d ", array
392 stream."write"( str )
397 read:[ 2 This file is used as a source for ParrotIO streams in t/library/streams.t]
399 read:[ 4 Larry 0 Classified. Don't ask.]
400 read:[ 5 Larry 1.000 1987-Dec-18]
401 read:[ 6 1.001..10 1988-Jan-30]
402 read:[ 7 1.011..14 1988-Feb-02]
403 read:[ 8 Schwern 1.0.15 2002-Dec-18 Modernization]
404 read:[ 9 Richard 1.0.16 2003-Dec-18]
405 read:[ 10 Larry 2.000 1988-Jun-05]
406 read:[ 11 2.001 1988-Jun-28]
407 read:[ 12 Larry 3.000 1989-Oct-18]
408 read:[ 13 3.001 1989-Oct-26]
409 read:[ 14 3.002..4 1989-Nov-11]
410 read:[ 15 3.005 1989-Nov-18]
411 read:[ 16 3.006..8 1989-Dec-22]
412 read:[ 17 3.009..13 1990-Mar-02]
413 read:[ 18 3.014 1990-Mar-13]
414 read:[ 19 3.015 1990-Mar-14]
415 read:[ 20 3.016..18 1990-Mar-28]
416 read:[ 21 3.019..27 1990-Aug-10 User subs.]
417 read:[ 22 3.028 1990-Aug-14]
418 read:[ 23 3.029..36 1990-Oct-17]
419 read:[ 24 3.037 1990-Oct-20]
420 read:[ 25 3.040 1990-Nov-10]
421 read:[ 26 3.041 1990-Nov-13]
422 read:[ 27 3.042..43 1991-Jan-??]
423 read:[ 28 3.044 1991-Jan-12]
424 read:[ 29 Larry 4.000 1991-Mar-21]
425 read:[ 30 4.001..3 1991-Apr-12]
426 read:[ 31 4.004..9 1991-Jun-07]
427 read:[ 32 4.010 1991-Jun-10]
428 read:[ 33 4.011..18 1991-Nov-05]
429 read:[ 34 4.019 1991-Nov-11 Stable.]
430 read:[ 35 4.020..33 1992-Jun-08]
431 read:[ 36 4.034 1992-Jun-11]
432 read:[ 37 4.035 1992-Jun-23]
433 read:[ 38 Larry 4.036 1993-Feb-05 Very stable.]
434 read:[ 39 5.000alpha1 1993-Jul-31]
435 read:[ 40 5.000alpha2 1993-Aug-16]
436 read:[ 41 5.000alpha3 1993-Oct-10]
437 read:[ 42 5.000alpha4 1993-???-??]
438 read:[ 43 5.000alpha5 1993-???-??]
439 read:[ 44 5.000alpha6 1994-Mar-18]
440 read:[ 45 5.000alpha7 1994-Mar-25]
441 read:[ 46 Andy 5.000alpha8 1994-Apr-04]
442 read:[ 47 Larry 5.000alpha9 1994-May-05 ext appears.]
443 read:[ 48 5.000alpha10 1994-Jun-11]
444 read:[ 49 5.000alpha11 1994-Jul-01]
445 read:[ 50 Andy 5.000a11a 1994-Jul-07 To fit 14.]
446 read:[ 51 5.000a11b 1994-Jul-14]
447 read:[ 52 5.000a11c 1994-Jul-19]
448 read:[ 53 5.000a11d 1994-Jul-22]
449 read:[ 54 Larry 5.000alpha12 1994-Aug-04]
450 read:[ 55 Andy 5.000a12a 1994-Aug-08]
451 read:[ 56 5.000a12b 1994-Aug-15]
452 read:[ 57 5.000a12c 1994-Aug-22]
453 read:[ 58 5.000a12d 1994-Aug-22]
454 read:[ 59 5.000a12e 1994-Aug-22]
455 read:[ 60 5.000a12f 1994-Aug-24]
456 read:[ 61 5.000a12g 1994-Aug-24]
457 read:[ 62 5.000a12h 1994-Aug-24]
458 read:[ 63 Larry 5.000beta1 1994-Aug-30]
459 read:[ 64 Andy 5.000b1a 1994-Sep-06]
460 read:[ 65 Larry 5.000beta2 1994-Sep-14 Core slushified.]
461 read:[ 66 Andy 5.000b2a 1994-Sep-14]
462 read:[ 67 5.000b2b 1994-Sep-17]
463 read:[ 68 5.000b2c 1994-Sep-17]
464 read:[ 69 Larry 5.000beta3 1994-Sep-??]
465 read:[ 70 Andy 5.000b3a 1994-Sep-18]
466 read:[ 71 5.000b3b 1994-Sep-22]
467 read:[ 72 5.000b3c 1994-Sep-23]
468 read:[ 73 5.000b3d 1994-Sep-27]
469 read:[ 74 5.000b3e 1994-Sep-28]
470 read:[ 75 5.000b3f 1994-Sep-30]
471 read:[ 76 5.000b3g 1994-Oct-04]
472 read:[ 77 Andy 5.000b3h 1994-Oct-07]
473 read:[ 78 Larry? 5.000gamma 1994-Oct-13?]
474 read:[ 79 Larry 5.000 1994-Oct-17]
475 read:[ 80 Andy 5.000a 1994-Dec-19]
476 read:[ 81 5.000b 1995-Jan-18]
477 read:[ 82 5.000c 1995-Jan-18]
478 read:[ 83 5.000d 1995-Jan-18]
479 read:[ 84 5.000e 1995-Jan-18]
480 read:[ 85 5.000f 1995-Jan-18]
481 read:[ 86 5.000g 1995-Jan-18]
482 read:[ 87 5.000h 1995-Jan-18]
483 read:[ 88 5.000i 1995-Jan-26]
484 read:[ 89 5.000j 1995-Feb-07]
485 read:[ 90 5.000k 1995-Feb-11]
486 read:[ 91 5.000l 1995-Feb-21]
487 read:[ 92 5.000m 1995-Feb-28]
488 read:[ 93 5.000n 1995-Mar-07]
489 read:[ 94 5.000o 1995-Mar-13?]
490 read:[ 95 Larry 5.001 1995-Mar-13]
491 read:[ 96 Andy 5.001a 1995-Mar-15]
492 read:[ 97 5.001b 1995-Mar-31]
493 read:[ 98 5.001c 1995-Apr-07]
494 read:[ 99 5.001d 1995-Apr-14]
495 read:[ 100 5.001e 1995-Apr-18 Stable.]
496 read:[ 101 5.001f 1995-May-31]
497 read:[ 102 5.001g 1995-May-25]
498 read:[ 103 5.001h 1995-May-25]
499 read:[ 104 5.001i 1995-May-30]
500 read:[ 105 5.001j 1995-Jun-05]
501 read:[ 106 5.001k 1995-Jun-06]
502 read:[ 107 5.001l 1995-Jun-06 Stable.]
503 read:[ 108 5.001m 1995-Jul-02 Very stable.]
504 read:[ 109 5.001n 1995-Oct-31 Very unstable.]
505 read:[ 110 5.002beta1 1995-Nov-21]
506 read:[ 111 5.002b1a 1995-Dec-04]
507 read:[ 112 5.002b1b 1995-Dec-04]
508 read:[ 113 5.002b1c 1995-Dec-04]
509 read:[ 114 5.002b1d 1995-Dec-04]
510 read:[ 115 5.002b1e 1995-Dec-08]
511 read:[ 116 5.002b1f 1995-Dec-08]
512 read:[ 117 Tom 5.002b1g 1995-Dec-21 Doc release.]
513 read:[ 118 Andy 5.002b1h 1996-Jan-05]
514 read:[ 119 5.002b2 1996-Jan-14]
515 read:[ 120 Larry 5.002b3 1996-Feb-02]
516 read:[ 121 Andy 5.002gamma 1996-Feb-11]
517 read:[ 122 Larry 5.002delta 1996-Feb-27]
518 read:[ 123 Larry 5.002 1996-Feb-29 Prototypes.]
519 read:[ 124 Charles 5.002_01 1996-Mar-25]
520 read:[ 125 5.003 1996-Jun-25 Security release.]
521 read:[ 126 5.003_01 1996-Jul-31]
522 read:[ 127 Nick 5.003_02 1996-Aug-10]
523 read:[ 128 Andy 5.003_03 1996-Aug-28]
524 read:[ 129 5.003_04 1996-Sep-02]
525 read:[ 130 5.003_05 1996-Sep-12]
526 read:[ 131 5.003_06 1996-Oct-07]
527 read:[ 132 5.003_07 1996-Oct-10]
528 read:[ 133 Chip 5.003_08 1996-Nov-19]
529 read:[ 134 5.003_09 1996-Nov-26]
530 read:[ 135 5.003_10 1996-Nov-29]
531 read:[ 136 5.003_11 1996-Dec-06]
532 read:[ 137 5.003_12 1996-Dec-19]
533 read:[ 138 5.003_13 1996-Dec-20]
534 read:[ 139 5.003_14 1996-Dec-23]
535 read:[ 140 5.003_15 1996-Dec-23]
536 read:[ 141 5.003_16 1996-Dec-24]
537 read:[ 142 5.003_17 1996-Dec-27]
538 read:[ 143 5.003_18 1996-Dec-31]
539 read:[ 144 5.003_19 1997-Jan-04]
540 read:[ 145 5.003_20 1997-Jan-07]
541 read:[ 146 5.003_21 1997-Jan-15]
542 read:[ 147 5.003_22 1997-Jan-16]
543 read:[ 148 5.003_23 1997-Jan-25]
544 read:[ 149 5.003_24 1997-Jan-29]
545 read:[ 150 5.003_25 1997-Feb-04]
546 read:[ 151 5.003_26 1997-Feb-10]
547 read:[ 152 5.003_27 1997-Feb-18]
548 read:[ 153 5.003_28 1997-Feb-21]
549 read:[ 154 5.003_90 1997-Feb-25 Ramping up to the 5.004 release.]
550 read:[ 155 5.003_91 1997-Mar-01]
551 read:[ 156 5.003_92 1997-Mar-06]
552 read:[ 157 5.003_93 1997-Mar-10]
553 read:[ 158 5.003_94 1997-Mar-22]
554 read:[ 159 5.003_95 1997-Mar-25]
555 read:[ 160 5.003_96 1997-Apr-01]
556 read:[ 161 5.003_97 1997-Apr-03 Fairly widely used.]
557 read:[ 162 5.003_97a 1997-Apr-05]
558 read:[ 163 5.003_97b 1997-Apr-08]
559 read:[ 164 5.003_97c 1997-Apr-10]
560 read:[ 165 5.003_97d 1997-Apr-13]
561 read:[ 166 5.003_97e 1997-Apr-15]
562 read:[ 167 5.003_97f 1997-Apr-17]
563 read:[ 168 5.003_97g 1997-Apr-18]
564 read:[ 169 5.003_97h 1997-Apr-24]
565 read:[ 170 5.003_97i 1997-Apr-25]
566 read:[ 171 5.003_97j 1997-Apr-28]
567 read:[ 172 5.003_98 1997-Apr-30]
568 read:[ 173 5.003_99 1997-May-01]
569 read:[ 174 5.003_99a 1997-May-09]
570 read:[ 175 p54rc1 1997-May-12 Release Candidates.]
571 read:[ 176 p54rc2 1997-May-14]
572 read:[ 177 Chip 5.004 1997-May-15 A major maintenance release.]
573 read:[ 178 Tim 5.004_01-t1 1997-???-?? The 5.004 maintenance track.]
574 read:[ 179 5.004_01-t2 1997-Jun-11 aka perl5.004m1t2]
575 read:[ 180 5.004_01 1997-Jun-13]
576 read:[ 181 5.004_01_01 1997-Jul-29 aka perl5.004m2t1]
577 read:[ 182 5.004_01_02 1997-Aug-01 aka perl5.004m2t2]
578 read:[ 183 5.004_01_03 1997-Aug-05 aka perl5.004m2t3]
579 read:[ 184 5.004_02 1997-Aug-07]
580 read:[ 185 5.004_02_01 1997-Aug-12 aka perl5.004m3t1]
581 read:[ 186 5.004_03-t2 1997-Aug-13 aka perl5.004m3t2]
582 read:[ 187 5.004_03 1997-Sep-05]
583 read:[ 188 5.004_04-t1 1997-Sep-19 aka perl5.004m4t1]
584 read:[ 189 5.004_04-t2 1997-Sep-23 aka perl5.004m4t2]
585 read:[ 190 5.004_04-t3 1997-Oct-10 aka perl5.004m4t3]
586 read:[ 191 5.004_04-t4 1997-Oct-14 aka perl5.004m4t4]
587 read:[ 192 5.004_04 1997-Oct-15]
588 read:[ 193 5.004_04-m1 1998-Mar-04 (5.004m5t1) Maint. trials for 5.004_05.]
589 read:[ 194 5.004_04-m2 1998-May-01]
590 read:[ 195 5.004_04-m3 1998-May-15]
591 read:[ 196 5.004_04-m4 1998-May-19]
592 read:[ 197 5.004_05-MT5 1998-Jul-21]
593 read:[ 198 5.004_05-MT6 1998-Oct-09]
594 read:[ 199 5.004_05-MT7 1998-Nov-22]
595 read:[ 200 5.004_05-MT8 1998-Dec-03]
596 read:[ 201 Chip 5.004_05-MT9 1999-Apr-26]
597 read:[ 202 5.004_05 1999-Apr-29]
598 read:[ 203 Malcolm 5.004_50 1997-Sep-09 The 5.005 development track.]
599 read:[ 204 5.004_51 1997-Oct-02]
600 read:[ 205 5.004_52 1997-Oct-15]
601 read:[ 206 5.004_53 1997-Oct-16]
602 read:[ 207 5.004_54 1997-Nov-14]
603 read:[ 208 5.004_55 1997-Nov-25]
604 read:[ 209 5.004_56 1997-Dec-18]
605 read:[ 210 5.004_57 1998-Feb-03]
606 read:[ 211 5.004_58 1998-Feb-06]
607 read:[ 212 5.004_59 1998-Feb-13]
608 read:[ 213 5.004_60 1998-Feb-20]
609 read:[ 214 5.004_61 1998-Feb-27]
610 read:[ 215 5.004_62 1998-Mar-06]
611 read:[ 216 5.004_63 1998-Mar-17]
612 read:[ 217 5.004_64 1998-Apr-03]
613 read:[ 218 5.004_65 1998-May-15]
614 read:[ 219 5.004_66 1998-May-29]
615 read:[ 220 Sarathy 5.004_67 1998-Jun-15]
616 read:[ 221 5.004_68 1998-Jun-23]
617 read:[ 222 5.004_69 1998-Jun-29]
618 read:[ 223 5.004_70 1998-Jul-06]
619 read:[ 224 5.004_71 1998-Jul-09]
620 read:[ 225 5.004_72 1998-Jul-12]
621 read:[ 226 5.004_73 1998-Jul-13]
622 read:[ 227 5.004_74 1998-Jul-14 5.005 beta candidate.]
623 read:[ 228 5.004_75 1998-Jul-15 5.005 beta1.]
624 read:[ 229 5.004_76 1998-Jul-21 5.005 beta2.]
625 read:[ 230 5.005 1998-Jul-22 Oneperl.]
626 read:[ 231 Sarathy 5.005_01 1998-Jul-27 The 5.005 maintenance track.]
627 read:[ 232 5.005_02-T1 1998-Aug-02]
628 read:[ 233 5.005_02-T2 1998-Aug-05]
629 read:[ 234 5.005_02 1998-Aug-08]
630 read:[ 235 Graham 5.005_03-MT1 1998-Nov-30]
631 read:[ 236 5.005_03-MT2 1999-Jan-04]
632 read:[ 237 5.005_03-MT3 1999-Jan-17]
633 read:[ 238 5.005_03-MT4 1999-Jan-26]
634 read:[ 239 5.005_03-MT5 1999-Jan-28]
635 read:[ 240 5.005_03-MT6 1999-Mar-05]
636 read:[ 241 5.005_03 1999-Mar-28]
637 read:[ 242 Sarathy 5.005_50 1998-Jul-26 The 5.6 development track.]
638 read:[ 243 5.005_51 1998-Aug-10]
639 read:[ 244 5.005_52 1998-Sep-25]
640 read:[ 245 5.005_53 1998-Oct-31]
641 read:[ 246 5.005_54 1998-Nov-30]
642 read:[ 247 5.005_55 1999-Feb-16]
643 read:[ 248 5.005_56 1999-Mar-01]
644 read:[ 249 5.005_57 1999-May-25]
645 read:[ 250 5.005_58 1999-Jul-27]
646 read:[ 251 5.005_59 1999-Aug-02]
647 read:[ 252 5.005_60 1999-Aug-02]
648 read:[ 253 5.005_61 1999-Aug-20]
649 read:[ 254 5.005_62 1999-Oct-15]
650 read:[ 255 5.005_63 1999-Dec-09]
651 read:[ 256 5.5.640 2000-Feb-02]
652 read:[ 257 5.5.650 2000-Feb-08 beta1]
653 read:[ 258 5.5.660 2000-Feb-22 beta2]
654 read:[ 259 5.5.670 2000-Feb-29 beta3]
655 read:[ 260 5.6.0-RC1 2000-Mar-09 Release candidate 1.]
656 read:[ 261 5.6.0-RC2 2000-Mar-14 Release candidate 2.]
657 read:[ 262 5.6.0-RC3 2000-Mar-21 Release candidate 3.]
658 read:[ 263 5.6.0 2000-Mar-22]
659 read:[ 264 Sarathy 5.6.1-TRIAL1 2000-Dec-18 The 5.6 maintenance track.]
660 read:[ 265 5.6.1-TRIAL2 2001-Jan-31]
661 read:[ 266 5.6.1-TRIAL3 2001-Mar-19]
662 read:[ 267 5.6.1-foolish 2001-Apr-01 The \"fools-gold\" release.]
663 read:[ 268 5.6.1 2001-Apr-08]
664 read:[ 269 Rafael 5.6.2-RC1 2003-Nov-08]
665 read:[ 270 5.6.2 2003-Nov-15 Fix new build issues]
666 read:[ 271 Jarkko 5.7.0 2000-Sep-02 The 5.7 track: Development.]
667 read:[ 272 5.7.1 2001-Apr-09]
668 read:[ 273 5.7.2 2001-Jul-13 Virtual release candidate 0.]
669 read:[ 274 5.7.3 2002-Mar-05]
670 read:[ 275 5.8.0-RC1 2002-Jun-01]
671 read:[ 276 5.8.0-RC2 2002-Jun-21]
672 read:[ 277 5.8.0-RC3 2002-Jul-13]
673 read:[ 278 5.8.0 2002-Jul-18]
674 read:[ 279 5.8.1-RC1 2003-Jul-10]
675 read:[ 280 5.8.1-RC2 2003-Jul-11]
676 read:[ 281 5.8.1-RC3 2003-Jul-30]
677 read:[ 282 5.8.1-RC4 2003-Aug-01]
678 read:[ 283 5.8.1-RC5 2003-Sep-22]
679 read:[ 284 5.8.1 2003-Sep-25]
680 read:[ 285 Nicholas 5.8.2-RC1 2003-Oct-27]
681 read:[ 286 5.8.2-RC2 2003-Nov-03]
682 read:[ 287 5.8.2 2003-Nov-05]
683 read:[ 288 5.8.3-RC1 2004-Jan-07]
684 read:[ 289 5.8.3 2004-Jan-14]
685 read:[ 290 5.8.4-RC1 2004-Apr-05]
686 read:[ 291 5.8.4-RC2 2004-Apr-15]
687 read:[ 292 5.8.4 2004-Apr-21]
688 read:[ 293 5.8.5-RC1 2004-Jul-06]
689 read:[ 294 5.8.5-RC2 2004-Jul-08]
690 read:[ 295 5.8.5 2004-Jul-19]
692 read:[ 297 Hugo 5.9.0 2003-Oct-27]
693 read:[ 298 Rafael 5.9.1 2004-Mar-16]
701 pir_output_is( <<'CODE', <<'OUT', "Stream::Filter" );
707 load_bytecode 'Stream/Sub.pbc'
708 load_bytecode 'Stream/Filter.pbc'
710 # create the counter stream
711 stream = new ['Stream'; 'Sub']
713 .const 'Sub' temp = "_counter"
716 # create the filter stream
717 filter = new ['Stream'; 'Filter']
719 assign filter, stream
721 .const 'Sub' ft = "_filter"
722 filter."filter"( ft )
743 stream."write"( str )
761 concat str, " * 2 = "
787 pir_output_is( <<'CODE', <<'OUT', "Stream::include" );
792 load_bytecode 'Stream/Sub.pbc'
794 stream = new ['Stream'; 'Sub']
796 .const 'Sub' temp = "_counter"
809 .sub _counter :method
820 # include another stream after '4'
824 temp = new ['Stream'; 'Sub']
826 .const 'Sub' func = "_included"
830 self."include"( temp )
837 .sub _included :method
840 self."write"( "hello" )
842 # create another stream
843 temp = new ['Stream'; 'Sub']
844 .const 'Sub' func = "_counter2"
848 self."include"( temp )
850 self."write"( "world" )
853 .sub _counter2 :method
864 if str != "G" goto LOOP
892 pir_output_is( <<'CODE', <<'OUT', "Stream::Lines" );
898 load_bytecode 'Stream/Sub.pbc'
899 load_bytecode 'Stream/Lines.pbc'
901 # create a text stream
902 stream = new ['Stream'; 'Sub']
904 .const 'Sub' temp = "_text"
907 # create a lines stream
908 lines = new ['Stream'; 'Lines']
923 self."write"( "this\nis a\n" )
924 self."write"( "Stream::Lines\ntest" )
925 self."write"( "case\nhello world" )
939 pir_output_is( <<'CODE', <<'OUT', "Stream::ParrotIO" );
945 load_bytecode 'Stream/ParrotIO.pbc'
947 # create the ParrotIO stream
948 stream = new ['Stream'; 'ParrotIO']
951 stream."open"( "t/library/perlhist.txt", 'r' )
953 # you can specifiy a custom block size with
954 # stream."blockSize"( 10 )
966 read:[\nThis file is used as a source for ParrotIO stream]
967 read:[s in t/library/streams.t\n\n Larry 0 ]
968 read:[ Classified. Don't ask.\n Larry ]
969 read:[1.000 1987-Dec-18\n 1.001.]
970 read:[.10 1988-Jan-30\n 1.011..14 ]
971 read:[ 1988-Feb-02\n Schwern 1.0.15 2002-D]
972 read:[ec-18 Modernization\n Richard 1.0.16 ]
973 read:[ 2003-Dec-18\n Larry 2.000 19]
974 read:[88-Jun-05\n 2.001 1988-Jun-]
975 read:[28\n Larry 3.000 1989-Oct-18\n ]
976 read:[ 3.001 1989-Oct-26\n ]
977 read:[ 3.002..4 1989-Nov-11\n 3]
978 read:[.005 1989-Nov-18\n 3.006..8]
979 read:[ 1989-Dec-22\n 3.009..13 1]
980 read:[990-Mar-02\n 3.014 1990-Mar]
981 read:[-13\n 3.015 1990-Mar-14\n ]
982 read:[ 3.016..18 1990-Mar-28\n ]
983 read:[ 3.019..27 1990-Aug-10 User subs.\n ]
984 read:[ 3.028 1990-Aug-14\n ]
985 read:[ 3.029..36 1990-Oct-17\n ]
986 read:[ 3.037 1990-Oct-20\n 3.040 ]
987 read:[ 1990-Nov-10\n 3.041 ]
988 read:[ 1990-Nov-13\n 3.042..43 1991-J]
989 read:[an-??\n 3.044 1991-Jan-12\n ]
990 read:[ Larry 4.000 1991-Mar-21\n ]
991 read:[ 4.001..3 1991-Apr-12\n ]
992 read:[ 4.004..9 1991-Jun-07\n 4.010]
993 read:[ 1991-Jun-10\n 4.011..18 ]
994 read:[ 1991-Nov-05\n 4.019 1991-]
995 read:[Nov-11 Stable.\n 4.020..33 ]
996 read:[1992-Jun-08\n 4.034 1992-Ju]
997 read:[n-11\n 4.035 1992-Jun-23\n ]
998 read:[ Larry 4.036 1993-Feb-05 Very ]
999 read:[stable.\n 5.000alpha1 1993-Jul-31]
1000 read:[\n 5.000alpha2 1993-Aug-16\n ]
1001 read:[ 5.000alpha3 1993-Oct-10\n ]
1002 read:[ 5.000alpha4 1993-???-??\n 5.0]
1003 read:[00alpha5 1993-???-??\n 5.000alpha]
1004 read:[6 1994-Mar-18\n 5.000alpha7 199]
1005 read:[4-Mar-25\n Andy 5.000alpha8 1994-Apr-0]
1006 read:[4\n Larry 5.000alpha9 1994-May-05 e]
1007 read:[xt appears.\n 5.000alpha10 1994-Ju]
1008 read:[n-11\n 5.000alpha11 1994-Jul-01\n ]
1009 read:[ Andy 5.000a11a 1994-Jul-07 To fi]
1010 read:[t 14.\n 5.000a11b 1994-Jul-14\n ]
1011 read:[ 5.000a11c 1994-Jul-19\n ]
1012 read:[ 5.000a11d 1994-Jul-22\n Larry ]
1013 read:[ 5.000alpha12 1994-Aug-04\n Andy 5.000]
1014 read:[a12a 1994-Aug-08\n 5.000a12b ]
1015 read:[ 1994-Aug-15\n 5.000a12c 1994-]
1016 read:[Aug-22\n 5.000a12d 1994-Aug-22\n]
1017 read:[ 5.000a12e 1994-Aug-22\n ]
1018 read:[ 5.000a12f 1994-Aug-24\n ]
1019 read:[ 5.000a12g 1994-Aug-24\n 5.00]
1020 read:[0a12h 1994-Aug-24\n Larry 5.000beta1 ]
1021 read:[ 1994-Aug-30\n Andy 5.000b1a 1994]
1022 read:[-Sep-06\n Larry 5.000beta2 1994-Sep-14]
1023 read:[ Core slushified.\n Andy 5.000b2a ]
1024 read:[ 1994-Sep-14\n 5.000b2b 1994]
1025 read:[-Sep-17\n 5.000b2c 1994-Sep-17]
1026 read:[\n Larry 5.000beta3 1994-Sep-??\n ]
1027 read:[ Andy 5.000b3a 1994-Sep-18\n ]
1028 read:[ 5.000b3b 1994-Sep-22\n 5.0]
1029 read:[00b3c 1994-Sep-23\n 5.000b3d ]
1030 read:[ 1994-Sep-27\n 5.000b3e 199]
1031 read:[4-Sep-28\n 5.000b3f 1994-Sep-3]
1032 read:[0\n 5.000b3g 1994-Oct-04\n ]
1033 read:[ Andy 5.000b3h 1994-Oct-07\n Larr]
1034 read:[y? 5.000gamma 1994-Oct-13?\n Larry 5.]
1035 read:[000 1994-Oct-17\n Andy 5.000a ]
1036 read:[ 1994-Dec-19\n 5.000b 1]
1037 read:[995-Jan-18\n 5.000c 1995-Jan]
1038 read:[-18\n 5.000d 1995-Jan-18\n ]
1039 read:[ 5.000e 1995-Jan-18\n ]
1040 read:[ 5.000f 1995-Jan-18\n ]
1041 read:[5.000g 1995-Jan-18\n 5.000h ]
1042 read:[ 1995-Jan-18\n 5.000i ]
1043 read:[1995-Jan-26\n 5.000j 1995-Fe]
1044 read:[b-07\n 5.000k 1995-Feb-11\n ]
1045 read:[ 5.000l 1995-Feb-21\n ]
1046 read:[ 5.000m 1995-Feb-28\n ]
1047 read:[ 5.000n 1995-Mar-07\n 5.000o]
1048 read:[ 1995-Mar-13?\n Larry 5.001 ]
1049 read:[ 1995-Mar-13\n Andy 5.001a 1995-]
1050 read:[Mar-15\n 5.001b 1995-Mar-31\n]
1051 read:[ 5.001c 1995-Apr-07\n ]
1052 read:[ 5.001d 1995-Apr-14\n ]
1053 read:[ 5.001e 1995-Apr-18 Stable.\n ]
1054 read:[ 5.001f 1995-May-31\n ]
1055 read:[ 5.001g 1995-May-25\n 5.001h]
1056 read:[ 1995-May-25\n 5.001i ]
1057 read:[ 1995-May-30\n 5.001j 1995-J]
1058 read:[un-05\n 5.001k 1995-Jun-06\n ]
1059 read:[ 5.001l 1995-Jun-06 Stab]
1060 read:[le.\n 5.001m 1995-Jul-02 ]
1061 read:[ Very stable.\n 5.001n 1995-]
1062 read:[Oct-31 Very unstable.\n 5.002be]
1063 read:[ta1 1995-Nov-21\n 5.002b1a ]
1064 read:[1995-Dec-04\n 5.002b1b 1995-De]
1065 read:[c-04\n 5.002b1c 1995-Dec-04\n ]
1066 read:[ 5.002b1d 1995-Dec-04\n ]
1067 read:[ 5.002b1e 1995-Dec-08\n ]
1068 read:[ 5.002b1f 1995-Dec-08\n Tom 5.002b]
1069 read:[1g 1995-Dec-21 Doc release.\n Andy ]
1070 read:[ 5.002b1h 1996-Jan-05\n 5.0]
1071 read:[02b2 1996-Jan-14\n Larry 5.002b3 ]
1072 read:[ 1996-Feb-02\n Andy 5.002gamma 199]
1073 read:[6-Feb-11\n Larry 5.002delta 1996-Feb-2]
1074 read:[7\n Larry 5.002 1996-Feb-29 P]
1075 read:[rototypes.\n Charles 5.002_01 1996-Mar]
1076 read:[-25\n 5.003 1996-Jun-25 ]
1077 read:[ Security release.\n 5.003_01 ]
1078 read:[1996-Jul-31\n Nick 5.003_02 1996-Au]
1079 read:[g-10\n Andy 5.003_03 1996-Aug-28\n ]
1080 read:[ 5.003_04 1996-Sep-02\n ]
1081 read:[ 5.003_05 1996-Sep-12\n ]
1082 read:[ 5.003_06 1996-Oct-07\n 5.003_]
1083 read:[07 1996-Oct-10\n Chip 5.003_08 ]
1084 read:[ 1996-Nov-19\n 5.003_09 1996-N]
1085 read:[ov-26\n 5.003_10 1996-Nov-29\n ]
1086 read:[ 5.003_11 1996-Dec-06\n ]
1087 read:[ 5.003_12 1996-Dec-19\n ]
1088 read:[ 5.003_13 1996-Dec-20\n 5.003]
1089 read:[_14 1996-Dec-23\n 5.003_15 ]
1090 read:[ 1996-Dec-23\n 5.003_16 1996-]
1091 read:[Dec-24\n 5.003_17 1996-Dec-27\n]
1092 read:[ 5.003_18 1996-Dec-31\n ]
1093 read:[ 5.003_19 1997-Jan-04\n ]
1094 read:[ 5.003_20 1997-Jan-07\n 5.00]
1095 read:[3_21 1997-Jan-15\n 5.003_22 ]
1096 read:[ 1997-Jan-16\n 5.003_23 1997]
1097 read:[-Jan-25\n 5.003_24 1997-Jan-29]
1098 read:[\n 5.003_25 1997-Feb-04\n ]
1099 read:[ 5.003_26 1997-Feb-10\n ]
1100 read:[ 5.003_27 1997-Feb-18\n 5.0]
1101 read:[03_28 1997-Feb-21\n 5.003_90 ]
1102 read:[ 1997-Feb-25 Ramping up to the 5.004 releas]
1103 read:[e.\n 5.003_91 1997-Mar-01\n ]
1104 read:[ 5.003_92 1997-Mar-06\n ]
1105 read:[ 5.003_93 1997-Mar-10\n 5]
1106 read:[.003_94 1997-Mar-22\n 5.003_95]
1107 read:[ 1997-Mar-25\n 5.003_96 1]
1108 read:[997-Apr-01\n 5.003_97 1997-Apr]
1109 read:[-03 Fairly widely used.\n 5.003]
1110 read:[_97a 1997-Apr-05\n 5.003_97b ]
1111 read:[ 1997-Apr-08\n 5.003_97c 1997-]
1112 read:[Apr-10\n 5.003_97d 1997-Apr-13\n]
1113 read:[ 5.003_97e 1997-Apr-15\n ]
1114 read:[ 5.003_97f 1997-Apr-17\n ]
1115 read:[ 5.003_97g 1997-Apr-18\n 5.00]
1116 read:[3_97h 1997-Apr-24\n 5.003_97i ]
1117 read:[ 1997-Apr-25\n 5.003_97j 1997]
1118 read:[-Apr-28\n 5.003_98 1997-Apr-30]
1119 read:[\n 5.003_99 1997-May-01\n ]
1120 read:[ 5.003_99a 1997-May-09\n ]
1121 read:[ p54rc1 1997-May-12 Release Candidat]
1122 read:[es.\n p54rc2 1997-May-14\n ]
1123 read:[ Chip 5.004 1997-May-15 A majo]
1124 read:[r maintenance release.\n Tim 5.004_01-t]
1125 read:[1 1997-???-?? The 5.004 maintenance track.\n ]
1126 read:[ 5.004_01-t2 1997-Jun-11 aka ]
1127 read:[perl5.004m1t2\n 5.004_01 1997-]
1128 read:[Jun-13\n 5.004_01_01 1997-Jul-29 ]
1129 read:[ aka perl5.004m2t1\n 5.004_01_02]
1130 read:[ 1997-Aug-01 aka perl5.004m2t2\n ]
1131 read:[ 5.004_01_03 1997-Aug-05 aka perl5.004m2t]
1132 read:[3\n 5.004_02 1997-Aug-07\n ]
1133 read:[ 5.004_02_01 1997-Aug-12 aka perl]
1134 read:[5.004m3t1\n 5.004_03-t2 1997-Aug-]
1135 read:[13 aka perl5.004m3t2\n 5.004_03]
1136 read:[ 1997-Sep-05\n 5.004_04-t1 1]
1137 read:[997-Sep-19 aka perl5.004m4t1\n ]
1138 read:[5.004_04-t2 1997-Sep-23 aka perl5.004m4t2\n ]
1139 read:[ 5.004_04-t3 1997-Oct-10 aka p]
1140 read:[erl5.004m4t3\n 5.004_04-t4 1997-O]
1141 read:[ct-14 aka perl5.004m4t4\n 5.004]
1142 read:[_04 1997-Oct-15\n 5.004_04-m1 ]
1143 read:[ 1998-Mar-04 (5.004m5t1) Maint. trials for 5.]
1144 read:[004_05.\n 5.004_04-m2 1998-May-01]
1145 read:[\n 5.004_04-m3 1998-May-15\n ]
1146 read:[ 5.004_04-m4 1998-May-19\n ]
1147 read:[ 5.004_05-MT5 1998-Jul-21\n 5.0]
1148 read:[04_05-MT6 1998-Oct-09\n 5.004_05-M]
1149 read:[T7 1998-Nov-22\n 5.004_05-MT8 199]
1150 read:[8-Dec-03\n Chip 5.004_05-MT9 1999-Apr-2]
1151 read:[6\n 5.004_05 1999-Apr-29\n ]
1152 read:[ Malcolm 5.004_50 1997-Sep-09 The 5.00]
1153 read:[5 development track.\n 5.004_51 ]
1154 read:[ 1997-Oct-02\n 5.004_52 1997-]
1155 read:[Oct-15\n 5.004_53 1997-Oct-16\n]
1156 read:[ 5.004_54 1997-Nov-14\n ]
1157 read:[ 5.004_55 1997-Nov-25\n ]
1158 read:[ 5.004_56 1997-Dec-18\n 5.00]
1159 read:[4_57 1998-Feb-03\n 5.004_58 ]
1160 read:[ 1998-Feb-06\n 5.004_59 1998]
1161 read:[-Feb-13\n 5.004_60 1998-Feb-20]
1162 read:[\n 5.004_61 1998-Feb-27\n ]
1163 read:[ 5.004_62 1998-Mar-06\n ]
1164 read:[ 5.004_63 1998-Mar-17\n 5.0]
1165 read:[04_64 1998-Apr-03\n 5.004_65 ]
1166 read:[ 1998-May-15\n 5.004_66 199]
1167 read:[8-May-29\n Sarathy 5.004_67 1998-Jun-1]
1168 read:[5\n 5.004_68 1998-Jun-23\n ]
1169 read:[ 5.004_69 1998-Jun-29\n ]
1170 read:[ 5.004_70 1998-Jul-06\n 5.]
1171 read:[004_71 1998-Jul-09\n 5.004_72 ]
1172 read:[ 1998-Jul-12\n 5.004_73 19]
1173 read:[98-Jul-13\n 5.004_74 1998-Jul-]
1174 read:[14 5.005 beta candidate.\n 5.00]
1175 read:[4_75 1998-Jul-15 5.005 beta1.\n ]
1176 read:[ 5.004_76 1998-Jul-21 5.005 beta2.\n ]
1177 read:[ 5.005 1998-Jul-22 Onep]
1178 read:[erl.\n Sarathy 5.005_01 1998-Jul-27 ]
1179 read:[ The 5.005 maintenance track.\n 5.]
1180 read:[005_02-T1 1998-Aug-02\n 5.005_02-]
1181 read:[T2 1998-Aug-05\n 5.005_02 19]
1182 read:[98-Aug-08\n Graham 5.005_03-MT1 1998-Nov-]
1183 read:[30\n 5.005_03-MT2 1999-Jan-04\n ]
1184 read:[ 5.005_03-MT3 1999-Jan-17\n ]
1185 read:[ 5.005_03-MT4 1999-Jan-26\n 5]
1186 read:[.005_03-MT5 1999-Jan-28\n 5.005_03]
1187 read:[-MT6 1999-Mar-05\n 5.005_03 1]
1188 read:[999-Mar-28\n Sarathy 5.005_50 1998-Jul]
1189 read:[-26 The 5.6 development track.\n ]
1190 read:[ 5.005_51 1998-Aug-10\n 5.005]
1191 read:[_52 1998-Sep-25\n 5.005_53 ]
1192 read:[ 1998-Oct-31\n 5.005_54 1998-]
1193 read:[Nov-30\n 5.005_55 1999-Feb-16\n]
1194 read:[ 5.005_56 1999-Mar-01\n ]
1195 read:[ 5.005_57 1999-May-25\n ]
1196 read:[ 5.005_58 1999-Jul-27\n 5.00]
1197 read:[5_59 1999-Aug-02\n 5.005_60 ]
1198 read:[ 1999-Aug-02\n 5.005_61 1999]
1199 read:[-Aug-20\n 5.005_62 1999-Oct-15]
1200 read:[\n 5.005_63 1999-Dec-09\n ]
1201 read:[ 5.5.640 2000-Feb-02\n ]
1202 read:[ 5.5.650 2000-Feb-08 beta1\n ]
1203 read:[ 5.5.660 2000-Feb-22 beta2\n ]
1204 read:[ 5.5.670 2000-Feb-29 beta3\n ]
1205 read:[ 5.6.0-RC1 2000-Mar-09 Release]
1206 read:[ candidate 1.\n 5.6.0-RC2 2000-]
1207 read:[Mar-14 Release candidate 2.\n 5]
1208 read:[.6.0-RC3 2000-Mar-21 Release candidate 3.\n]
1209 read:[ 5.6.0 2000-Mar-22\n ]
1210 read:[ Sarathy 5.6.1-TRIAL1 2000-Dec-18 The 5.6 ma]
1211 read:[intenance track.\n 5.6.1-TRIAL2 20]
1212 read:[01-Jan-31\n 5.6.1-TRIAL3 2001-Mar-]
1213 read:[19\n 5.6.1-foolish 2001-Apr-01 ]
1214 read:[The \"fools-gold\" release.\n 5.6.1 ]
1215 read:[ 2001-Apr-08\n Rafael 5.6.2-RC1 ]
1216 read:[2003-Nov-08\n 5.6.2 2003-No]
1217 read:[v-15 Fix new build issues\n Jarkko 5.7]
1218 read:[.0 2000-Sep-02 The 5.7 track: Developm]
1219 read:[ent.\n 5.7.1 2001-Apr-09\n ]
1220 read:[ 5.7.2 2001-Jul-13 Virtu]
1221 read:[al release candidate 0.\n 5.7.3 ]
1222 read:[ 2002-Mar-05\n 5.8.0-RC1 20]
1223 read:[02-Jun-01\n 5.8.0-RC2 2002-Jun-]
1224 read:[21\n 5.8.0-RC3 2002-Jul-13\n ]
1225 read:[ 5.8.0 2002-Jul-18\n ]
1226 read:[ 5.8.1-RC1 2003-Jul-10\n 5]
1227 read:[.8.1-RC2 2003-Jul-11\n 5.8.1-RC]
1228 read:[3 2003-Jul-30\n 5.8.1-RC4 2]
1229 read:[003-Aug-01\n 5.8.1-RC5 2003-Sep]
1230 read:[-22\n 5.8.1 2003-Sep-25\n ]
1231 read:[ Nicholas 5.8.2-RC1 2003-Oct-27\n ]
1232 read:[ 5.8.2-RC2 2003-Nov-03\n ]
1233 read:[5.8.2 2003-Nov-05\n 5.8.3-R]
1234 read:[C1 2004-Jan-07\n 5.8.3 ]
1235 read:[2004-Jan-14\n 5.8.4-RC1 2004-Ap]
1236 read:[r-05\n 5.8.4-RC2 2004-Apr-15\n ]
1237 read:[ 5.8.4 2004-Apr-21\n ]
1238 read:[ 5.8.5-RC1 2004-Jul-06\n ]
1239 read:[ 5.8.5-RC2 2004-Jul-08\n 5.8.5 ]
1240 read:[ 2004-Jul-19\n\n Hugo 5.9.0 ]
1241 read:[ 2003-Oct-27\n Rafael 5.9.1 2004-]
1253 skip( "broken method invocation", 1 );
1254 pir_output_is( <<'CODE', <<'OUT', "Stream::Replay" );
1259 load_bytecode 'Stream/Writer.pbc'
1260 load_bytecode 'Stream/Replay.pbc'
1262 stream = new ['Stream'; 'Writer']
1263 P0 = global "_reader"
1266 stream."write"( "1" )
1267 stream."write"( "2" )
1268 stream."write"( "A" )
1269 stream."write"( "B" )
1270 stream."write"( "4" )
1271 stream."write"( "5" )
1272 stream."write"( "*" )
1282 .sub _reader :method
1288 stream1 = new ['Stream'; 'Replay']
1289 assign stream1, self
1291 print "reader start\n"
1294 str = stream1."read"()
1296 str = stream1."read"()
1300 stream2 = clone stream1
1301 stream3 = clone stream1
1304 str = stream2."read"()
1306 str = stream2."read"()
1311 str = stream1."read"()
1313 str = stream1."read"()
1316 str = stream1."read"()
1318 str = stream1."read"()
1323 str = stream3."read"()
1325 str = stream3."read"()
1327 str = stream3."read"()
1329 str = stream3."read"()
1332 str = stream3."read"()
1337 print "reader done\n"
1355 pir_output_is( <<'CODE', <<'OUT', "Stream::Sub" );
1360 load_bytecode 'Stream/Base.pbc'
1361 load_bytecode 'Stream/Sub.pbc'
1363 stream = new ['Stream'; 'Sub']
1365 .const 'Sub' temp = "_counter"
1378 .sub _counter :method
1385 # streams are using strings,
1386 # so we have to convert the number into a string
1415 skip( "broken method invocation", 1 );
1416 pir_output_is( <<'CODE', <<'OUT', "Stream::Write" );
1421 load_bytecode 'Stream/Writer.pbc'
1423 stream = new ['Stream'; 'Writer']
1425 # set the stream's source sub
1426 .const 'Sub' temp = "_reader"
1429 print "main start\n"
1430 stream."write"( "hello" )
1431 stream."write"( "world!" )
1432 stream."write"( "parrot" )
1433 stream."write"( "is cool" )
1443 .sub _reader :method
1444 print "reader start\n"
1446 print "reader done\n"
1463 # cperl-indent-level: 4
1466 # vim: expandtab shiftwidth=4: