Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IO.get should always return a Str (or Buf) #969

Closed
p6rt opened this issue May 3, 2009 · 6 comments
Closed

IO.get should always return a Str (or Buf) #969

p6rt opened this issue May 3, 2009 · 6 comments

Comments

@p6rt
Copy link

p6rt commented May 3, 2009

Migrated from rt.perl.org#65348 (status was 'resolved')

Searchable as RT65348$

@p6rt
Copy link
Author

p6rt commented May 3, 2009

From @moritz

Currently IO.get still does the old magic that prefix​:<=> needed, which
means that it returns a list of all lines in list context.

That must go away, and always return a Str.

For example $*IN.get.int should work, but does not currently​:
Could not locate a method 'int' to invoke on class 'IOIterator'

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Aug 25, 2009

From @jnthn

On Sun May 03 14​:40​:32 2009, moritz wrote​:

Currently IO.get still does the old magic that prefix​:<=> needed, which
means that it returns a list of all lines in list context.

That must go away, and always return a Str.

For example $*IN.get.int should work, but does not currently​:
Could not locate a method 'int' to invoke on class 'IOIterator'

It seems that this now works as it should.

my $fh = open("README", :r); say $fh.get.int
0
say $*IN.get.int
42.5
42

Assigning to moritz++ for spectests.

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented Aug 25, 2009

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Oct 11, 2009

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S16-filehandles/io.t

commit 6d8fde79ae58c5a4e247771409d83fff3435d072
Author​: kyle <kyle@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Sun Oct 11 04​:09​:37 2009 +0000

  [t/spec] Test for RT #​65348
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;28748 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S16-filehandles/io.t b/t/spec/S16-filehandles/io.t
index 427b4e8..a42ec12 100644
--- a/t/spec/S16-filehandles/io.t
+++ b/t/spec/S16-filehandles/io.t
@@ -13,7 +13,7 @@ I/O tests
 
 =end pod
 
-plan 62;
+plan *;
 
 #?pugs emit if $*OS eq "browser" {
 #?pugs emit   skip_rest "Programs running in browsers don't have access to regular IO.";
@@ -164,8 +164,28 @@ ok($fh9.close, 'file closed okay (9)');
     #ok($fh10.close, 'file closed okay (10)');
 }
 
+# RT #65348
+{
+    my $rt65348_out = open($filename, :w);
+    isa_ok $rt65348_out, IO;
+    $rt65348_out.say( 'RT #65348' );
+    $rt65348_out.say( '13.37' );
+    $rt65348_out.say( '42.17' );
+    ok $rt65348_out.close, 'close worked (rt65348 out)';
+
+    my $rt65348_in = open( $filename );
+    isa_ok $rt65348_in, IO;
+    my @list_context = ($rt65348_in.get);
+    is +@list_context, 1, '.get in list context reads only one line';
+    ok $rt65348_in.get.Int ~~ Int, '.get.Int gets int';
+    is $rt65348_in.get.Int, 42, '.get.Int gets the right int';
+    ok $rt65348_in.close, 'close worked (rt65348 in)';
+}
+
 #?pugs todo 'buggy on Win32'
 ok(unlink($filename), 'file has been removed');
 ok $filename !~~ :e, '... and the tempfile is gone, really';
 
+done_testing;
+
 # vim: ft=perl6

@p6rt
Copy link
Author

p6rt commented Oct 11, 2009

From @kyleha

Tests for this are written and passing, so I'm marking this resolved.

@p6rt
Copy link
Author

p6rt commented Oct 11, 2009

@kyleha - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Oct 11, 2009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant