/
say.t
136 lines (116 loc) · 2.24 KB
/
say.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!perl
# Copyright (C) 2001-2012, Parrot Foundation.
use strict;
use warnings;
use lib qw( . lib ../lib ../../lib );
use Test::More;
use Parrot::Test tests => 9;
=head1 NAME
t/op/say.t - Testing the say pseudo-opcode
=head1 SYNOPSIS
% prove t/op/say.t
=head1 DESCRIPTION
Tests various PMCs and registers with say.
=cut
pir_output_is( <<'CODE', <<'OUTPUT', 'say with a literal string' );
.sub main :main
say "string literal"
.end
CODE
string literal
OUTPUT
pir_output_is( <<'CODE', <<'OUTPUT', 'say with a literal integer' );
.sub main :main
say 42
.end
CODE
42
OUTPUT
pir_output_is( <<'CODE', <<'OUTPUT', 'say with a literal number' );
.sub main :main
say 3.14
.end
CODE
3.14
OUTPUT
pir_output_is( <<'CODE', <<'OUTPUT', 'say with a temporary string register' );
.sub main :main
$S5 = "string register"
say $S5
.end
CODE
string register
OUTPUT
pir_output_is( <<'CODE', <<'OUTPUT', 'say with a temporary integer register' );
.sub main :main
$I4 = 10
say $I4
.end
CODE
10
OUTPUT
pir_output_is( <<'CODE', <<'OUTPUT', 'say with a temporary number register' );
.sub main :main
$N2 = 1.414
say $N2
.end
CODE
1.414
OUTPUT
pir_output_is( <<'CODE', <<'OUTPUT', 'say and print with a number register' );
.sub main :main
$N0 = 3.14159
say $N0
print $N0
print "\n"
.end
CODE
3.14159
3.14159
OUTPUT
pir_error_output_like( <<'CODE', <<'OUTPUT', 'say with PMCNULL argument' );
.sub main :main
null $P0
say $P0
.end
CODE
/Null PMC in say/
OUTPUT
# [GH #893] 80% of threaded say should print the \n immediately after the string.
my ($good, $fail) = (0,0);
for (0..9) {
my $result = Parrot::Test::_pir_stdin_output_slurp('',<<'CODE');
.sub main :main
$P0 = get_global 'task'
$P1 = new 'Task', $P0
schedule $P1
$P2 = new 'Task', $P0
schedule $P2
$P3 = new 'Task', $P0
schedule $P3
$P4 = new 'Task', $P0
schedule $P4
wait $P1
wait $P2
wait $P3
wait $P4
sleep 0.1
.end
.sub task
say "line"
.end
CODE
if ($result =~ /lineline/) {
$fail++;
}
else {
$good++;
}
}
ok($good >= 8, "threads: better atomic say. $good/10");
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4: