@@ -11,16 +11,15 @@ my $read_out_and_err := nqp::const::PIPE_INHERIT_IN + nqp::const::PIPE_CAPTURE_O
11
11
my $ in := nqp ::null();
12
12
my $ out := nqp ::syncpipe();
13
13
my $ err := nqp ::null();
14
- nqp ::setinputlinesep($ out , " \n " );
15
- nqp ::setencoding($ out , ' utf8' );
14
+ my $ out-wrap := NQPFileHandle. new . wrap ($ out );
16
15
nqp :: shell (' echo aardvarks' , nqp ::cwd(), nqp ::getenvhash(), $ in , $ out , $ err , $ read_out );
17
16
18
- ok ( ! nqp ::eoffh( $ out ) , ' nqp::eoffh on a pipe while it still has data' );
17
+ ok ( ! $ out-wrap . eof , ' eof on a pipe while it still has data' );
19
18
20
- my $ pstr := nqp ::readallfh( $ out ) ;
21
- ok ( $ pstr ~~ / 'aardvarks' /, ' nqp::readallfh with a pipe' );
19
+ my $ pstr := $ out-wrap . slurp ;
20
+ ok ( $ pstr ~~ / 'aardvarks' /, ' nqp::slurp with a pipe' );
22
21
23
- ok ( nqp ::eoffh( $ out ) , ' nqp::eoffh on a pipe we have read everything out of' );
22
+ ok ( $ out-wrap . eof , ' eof on a pipe we have read everything out of' );
24
23
25
24
# What should the return value of nqp::close be? MoarVM and JVM always return 1.
26
25
nqp ::closefh($ out ); ok ( 1 , ' nqp::closefh with a pipe' );
@@ -31,15 +30,13 @@ my $read_out_and_err := nqp::const::PIPE_INHERIT_IN + nqp::const::PIPE_CAPTURE_O
31
30
my $ in := nqp ::null();
32
31
my $ out := nqp ::syncpipe();
33
32
my $ err := nqp ::syncpipe();
34
- nqp ::setinputlinesep($ out , " \n " );
35
- nqp ::setinputlinesep($ err , " \n " );
36
- nqp ::setencoding($ out , ' utf8' );
37
- nqp ::setencoding($ err , ' utf8' );
33
+ my $ out-wrap := NQPFileHandle. new . wrap ($ out );
34
+ my $ err-wrap := NQPFileHandle. new . wrap ($ err );
38
35
nqp :: shell (' doesnotexist' , nqp ::cwd(), nqp ::getenvhash(), $ in , $ out , $ err , $ read_out_and_err );
39
36
40
- my $ str_out := nqp ::readallfh( $ out ) ;
41
- my $ str_err := nqp ::readallfh( $ err ) ;
42
- is ( $ str_out , ' ' && $ str_err ~~ / 'doesnotexist' /, ' nqp::readallfh with a pipe nonexistent command' );
37
+ my $ str_out := $ out-wrap . slurp ;
38
+ my $ str_err := $ err-wrap . slurp ;
39
+ is ( $ str_out , ' ' && $ str_err ~~ / 'doesnotexist' /, ' nqp::slurp with a pipe nonexistent command' );
43
40
44
41
nqp ::closefh($ out ); ok ( 1 , ' nqp::closefh with a pipe nonexistent command' );
45
42
nqp ::closefh($ err ); ok ( 1 , ' nqp::closefh with a pipe nonexistent command' );
@@ -50,12 +47,11 @@ my $read_out_and_err := nqp::const::PIPE_INHERIT_IN + nqp::const::PIPE_CAPTURE_O
50
47
my $ in := nqp ::null();
51
48
my $ out := nqp ::syncpipe();
52
49
my $ err := nqp ::null();
53
- nqp ::setinputlinesep($ out , " \n " );
54
- nqp ::setencoding($ out , ' utf8' );
50
+ my $ out-wrap := NQPFileHandle. new . wrap ($ out );
55
51
nqp :: shell (' echo aardvarks' , nqp ::cwd(), nqp ::getenvhash(), $ in , $ out , $ err , $ read_out );
56
52
57
- my $ str := nqp ::readallfh( $ out ) ;
58
- ok ( $ str ~~ / 'aardvarks' /, ' nqp::readallfh with a pipe' );
53
+ my $ str := $ out-wrap . slurp ;
54
+ ok ( $ str ~~ / 'aardvarks' /, ' nqp::slurp with a pipe' );
59
55
60
56
ok ( nqp ::closefh_i($ out ) == 0 , ' nqp::closefh_i with a pipe' );
61
57
ok ( nqp ::closefh_i($ out ) == 0 , ' nqp::closefh_i with a pipe already closed' );
@@ -65,15 +61,13 @@ my $read_out_and_err := nqp::const::PIPE_INHERIT_IN + nqp::const::PIPE_CAPTURE_O
65
61
my $ in := nqp ::null();
66
62
my $ out := nqp ::syncpipe();
67
63
my $ err := nqp ::syncpipe();
68
- nqp ::setinputlinesep($ out , " \n " );
69
- nqp ::setinputlinesep($ err , " \n " );
70
- nqp ::setencoding($ out , ' utf8' );
71
- nqp ::setencoding($ err , ' utf8' );
64
+ my $ out-wrap := NQPFileHandle. new . wrap ($ out );
65
+ my $ err-wrap := NQPFileHandle. new . wrap ($ err );
72
66
nqp :: shell (' doesnotexist' , nqp ::cwd(), nqp ::getenvhash(), $ in , $ out , $ err , $ read_out_and_err );
73
67
74
- my $ str_out := nqp ::readallfh( $ out ) ;
75
- my $ str_err := nqp ::readallfh( $ err ) ;
76
- is ( $ str_out , ' ' && $ str_err ~~ / 'doesnotexist' /, ' nqp::readallfh with a pipe nonexistent command' );
68
+ my $ str_out := $ out-wrap . slurp ;
69
+ my $ str_err := $ err-wrap . slurp ;
70
+ is ( $ str_out , ' ' && $ str_err ~~ / 'doesnotexist' /, ' nqp::slurp with a pipe nonexistent command' );
77
71
78
72
ok ( nqp ::closefh_i($ out ) != 0 , ' nqp::closefh_i with a pipe nonexistent command' );
79
73
}
0 commit comments