Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
First tests for file ops, plus fixes on JVM.
- Loading branch information
Showing
7 changed files
with
88 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,11 @@ | ||
| package org.perl6.nqp.io; | ||
|
|
||
| import java.nio.ByteBuffer; | ||
|
|
||
| import org.perl6.nqp.runtime.ThreadContext; | ||
|
|
||
| public interface IIOSyncWritable { | ||
| public void print(ThreadContext tc, String s); | ||
| public void say(ThreadContext tc, String s); | ||
| public void write(ThreadContext tc, ByteBuffer bb); | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| #! nqp | ||
|
|
||
| # Test nqp::op file operations. | ||
|
|
||
| plan(20); | ||
|
|
||
| ok( nqp::stat('CREDITS', nqp::const::STAT_EXISTS) == 1, 'nqp::stat exists'); | ||
| ok( nqp::stat('AARDVARKS', nqp::const::STAT_EXISTS) == 0, 'nqp::stat not exists'); | ||
|
|
||
| ok( nqp::stat('t', nqp::const::STAT_ISDIR) == 1, 'nqp::stat is directory'); | ||
| ok( nqp::stat('CREDITS', nqp::const::STAT_ISDIR) == 0, 'nqp::stat not directory'); | ||
|
|
||
| ok( nqp::stat('CREDITS', nqp::const::STAT_ISREG) == 1, 'nqp::stat is regular file'); | ||
| ok( nqp::stat('t', nqp::const::STAT_ISREG) == 0, 'nqp::stat not regular file'); | ||
|
|
||
| my $credits := nqp::open('CREDITS', 'r'); | ||
| ok( $credits, 'nqp::open for read'); | ||
| ok( nqp::tellfh($credits) == 0, 'nqp::tellfh start of file'); | ||
| my $line := nqp::readlinefh($credits); | ||
| ok( nqp::chars($line) == nqp::chars($line), 'nqp::readlinefh line to read'); | ||
| ok( nqp::tellfh($credits) == 5, 'nqp::tellfh line two'); | ||
| my $rest := nqp::readallfh($credits); | ||
| ok( nqp::chars($rest) > 100, 'nqp::readallfh lines to read'); | ||
| ok( nqp::tellfh($credits) == nqp::chars($line) + nqp::chars($rest), 'nqp::tellfh end of file'); | ||
| ok( nqp::chars(nqp::readlinefh($credits)) == 0, 'nqp::readlinefh end of file'); | ||
| ok( nqp::chars(nqp::readlinefh($credits)) == 0, 'nqp::readlinefh end of file repeat'); | ||
| ok( nqp::chars(nqp::readallfh($credits)) == 0, 'nqp::readallfh end of file'); | ||
| ok( nqp::chars(nqp::readlinefh($credits)) == 0, 'nqp::readlinefh end of file repeat'); | ||
| ok( nqp::defined(nqp::closefh($credits)), 'nqp::closefh'); | ||
|
|
||
| ok( nqp::defined(nqp::getstdin()), 'nqp::getstdin'); | ||
| ok( nqp::defined(nqp::getstdout()), 'nqp::getstdout'); | ||
| ok( nqp::defined(nqp::getstderr()), 'nqp::getstderr'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters