Skip to content

Commit

Permalink
Implement getc funcion in IO, add getc.t to spectest.data
Browse files Browse the repository at this point in the history
  • Loading branch information
nunorc committed Apr 8, 2010
1 parent 6b54693 commit 8681735
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/IO.pm
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ class IO {
self.print(@items, "\n");
}

multi method getc() {
my $c = $!PIO.read(1);
fail if $c eq '';
$c;
}

multi method slurp() {
$!PIO.readall();
}
Expand Down Expand Up @@ -83,6 +89,8 @@ multi sub prompt($msg) {

multi sub say(Mu *@items) { $*OUT.say(@items); }

sub getc($handle) { $handle.getc(); }

sub open($filename, :$r, :$w, :$a) {
my $mode = $w ?? 'w' !! ($a ?? 'wa' !! 'r');
my $PIO = pir::open__PSS($filename, $mode);
Expand Down
1 change: 1 addition & 0 deletions t/spectest.data
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ S16-filehandles/open.t
# S16-io/bare-say.t
S16-io/basic-open.t
S16-io/say.t
S16-io/getc.t
# S16-unfiled/rebindstdhandles.t
S16-unfiled/slurp.t
# S28-named-variables/cwd.t
Expand Down

0 comments on commit 8681735

Please sign in to comment.