1
# this program creates a multiplication table, then reads pairs of numbers
2
# from its standard input (until it receives a zero) and output the product of
3
# each pair. The loops make use of computed COME FROM in some interesting way.
5
use Language::INTERCAL;
6
use Language::INTERCAL::Runtime::Library;
10
print "1..", 6 * (2 + @range), "\n";
12
my %range = map { ($_, 1 + int(rand 65535)) } @range;
13
my @data = map { (1 + ($_ % 10), 1 + int($_ / 10), $range{$_}) } @range;
16
for (my $i = 0; $i < 10000; $i++) {
17
my $a = rand(scalar @range);
18
my $b = rand(scalar @range);
19
@range[$a, $b] = @range[$b, $a];
21
push @data, map { (1 + ($_ % 10), 1 + int($_ / 10)) } @range;
23
@range = map { $range{$_} } @range;
29
@@@@��@^�@L`@{��@��@{��
30
@@@@������@����@����@M�]
32
@@@@��@K�@L`@K��@�@{�����
33
@@@@��@K�@L`@K��@�@{��
37
M�]@������@��@���@�����
38
@@@@������@����@����@z�
41
M�]@��@^�@���@K�@K�@L`@z�
42
@@@@������@����@����@M�]
43
@@@@������@����@����@M�]
45
@@@@��@K�@L`@K��@�@{�����
46
@@@@��@K�@L`@K��@�@{��
52
M�]@������@��@���@�����
53
@@@@������@����@����@z�
56
@@@@��@z�@L`@^�@���@K�@K�
58
@@@@������@����@����@M�]
62
fiddle Language::INTERCAL 'bug=0', 'ubug=0';
67
compile Language::INTERCAL 'prog', $prog;
70
eval { prog(\&stdin, \@stdout) };
72
print $@ ? "not " : "", "ok ", $testnum++, "\n";
73
print @stdout == @range ? "" : "not ", "ok ", $testnum++, "\n";
75
while (@stdout && @stdin) {
76
my $out = shift @stdout;
77
my $in = shift @stdin;
78
print $out eq roman($in, 0) . "\n" ? '' : 'not ', "ok ", $testnum++, "\n";
82
print "not ok ", $testnum++, "\n";
85
compile Language::INTERCAL 'prog_o', $prog, 'opt';
88
eval { prog_o(\&stdin, \@stdout) };
90
print $@ ? "not " : "", "ok ", $testnum++, "\n";
91
print @stdout == @range ? "" : "not ", "ok ", $testnum++, "\n";
93
while (@stdout && @stdin) {
94
my $out = shift @stdout;
95
my $in = shift @stdin;
96
print $out eq roman($in, 0) . "\n" ? '' : 'not ', "ok ", $testnum++, "\n";
100
print "not ok ", $testnum++, "\n";
103
compile Language::INTERCAL 'prog_q', $prog, 'quantum';
106
eval { prog_q(\&stdin, \@stdout) };
108
print $@ ? "not " : "", "ok ", $testnum++, "\n";
109
print @stdout == @range ? "" : "not ", "ok ", $testnum++, "\n";
111
while (@stdout && @stdin) {
112
my $out = shift @stdout;
113
my $in = shift @stdin;
114
print $out eq roman($in, 0) . "\n" ? '' : 'not ', "ok ", $testnum++, "\n";
118
print "not ok ", $testnum++, "\n";
121
compile Language::INTERCAL 'prog_p', $prog, 'post';
124
eval { prog_p(\&stdin, \@stdout) };
126
print $@ ? "not " : "", "ok ", $testnum++, "\n";
127
print @stdout == @range ? "" : "not ", "ok ", $testnum++, "\n";
129
while (@stdout && @stdin) {
130
my $out = shift @stdout;
131
my $in = shift @stdin;
132
print $out eq roman($in, 0) . "\n" ? '' : 'not ', "ok ", $testnum++, "\n";
136
print "not ok ", $testnum++, "\n";
139
compile Language::INTERCAL 'prog_qp', $prog, 'quantum', 'post';
142
eval { prog_qp(\&stdin, \@stdout) };
144
print $@ ? "not " : "", "ok ", $testnum++, "\n";
145
print @stdout == @range ? "" : "not ", "ok ", $testnum++, "\n";
147
while (@stdout && @stdin) {
148
my $out = shift @stdout;
149
my $in = shift @stdin;
150
print $out eq roman($in, 0) . "\n" ? '' : 'not ', "ok ", $testnum++, "\n";
154
print "not ok ", $testnum++, "\n";
157
compile Language::INTERCAL 'prog_d', $prog, 'dbhook';
160
_run_db(prog_d(\&stdin, \@stdout));
162
print $@ ? "not " : "", "ok ", $testnum++, "\n";
163
print @stdout == @range ? "" : "not ", "ok ", $testnum++, "\n";
165
while (@stdout && @stdin) {
166
my $out = shift @stdout;
167
my $in = shift @stdin;
168
print $out eq roman($in, 0) . "\n" ? '' : 'not ', "ok ", $testnum++, "\n";
172
print "not ok ", $testnum++, "\n";
176
join('@', map { ['����',
185
'����' ]->[$_] } split(/ *?/, shift @stdin));