Howdy all,

While writing some new Pugs examples I came across another file reading bug having to do with laziness. When a list is slurped from a filehandle, then the file closed before the list is accessed, the list seems to be empty. I believe this is because of how lazily Pugs creates/evaluates the array. Here is the test I wrote (it is in t/builtins/io/io.t):

my $in7 = open($filename);
isa_ok($in7, 'Handle');
my @lines7 = readline($in7);
ok($in7.close, 'file closed okay'); # << this is where the trouble begins.


is([EMAIL PROTECTED], 4, 'we got four lines from the file (lazily)');
is(@lines7[0], "Hello World\n", 'readline($in) worked in list context');
is(@lines7[1], "Foo Bar Baz\n", 'readline($in) worked in list context');
is(@lines7[2], "The End\n", 'readline($in) worked in list context');
is(@lines7[3], "... Its not over yet!\n", 'readline($in) worked in list context');


- Steve



Reply via email to