Mercurial > repo
comparison interps/clc-intercal/CLC-INTERCAL-ICALC-1.-94.-2/t/02intercalc-1972.t @ 996:859f9b4339e6
<Gregor> tar xf egobot.tar.xz
author | HackBot |
---|---|
date | Sun, 09 Dec 2012 19:30:08 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
995:6883f5911eb7 | 996:859f9b4339e6 |
---|---|
1 # test the calculator in 1972 mode | |
2 | |
3 # Copyright (c) 2006-2008 Claudio Calvelli, all rights reserved. | |
4 | |
5 # CLC-INTERCAL is copyrighted software. However, permission to use, modify, | |
6 # and distribute it is granted provided that the conditions set out in the | |
7 # licence agreement are met. See files README and COPYING in the distribution. | |
8 | |
9 require 't/run-calculator'; | |
10 | |
11 my @expr_tests = ( | |
12 ['#1', 'I'], | |
13 ['.1 <- #V2', 'OK'], | |
14 ['.1', 'III'], | |
15 ['.V1', 'xxxiiDCCLXXI'], | |
16 ['.&1', 'I'], | |
17 ['.V-1', 'xxxiiDCCLXX'], | |
18 ['.¥1', 'xxxiiDCCLXX'], | |
19 [':1 <- #V2', 'OK'], | |
20 [':1', 'III'], | |
21 [':V1', '\M\M\C\X\L\V\I\IcdlxxxiiiDCLI'], | |
22 [':&1', 'I'], | |
23 [':V-1', '\M\M\C\X\L\V\I\IcdlxxxiiiDCL'], | |
24 [':¥1', '\M\M\C\X\L\V\I\IcdlxxxiiiDCL'], | |
25 ['.2 <- #1', 'OK'], | |
26 ['.1C/.2', 'XI'], | |
27 ['.1¢.2', 'XI'], | |
28 [':1~.1', 'III'], | |
29 [':1~.2', 'I'], | |
30 # XXX more tests are necessary | |
31 ); | |
32 | |
33 my @full_tests = ( | |
34 ['DO .1 <- #V2', 'OK'], | |
35 ['DO .2 <- .V1', 'OK'], | |
36 ['.1', 'III'], | |
37 ['.2', 'xxxiiDCCLXXI'], | |
38 ['PLEASE IGNORE .2', 'OK'], | |
39 ['DO .2 <- #666', 'OK'], | |
40 ['.2', 'xxxiiDCCLXXI'], | |
41 ['PLEASE REMEMBER .2', 'OK'], | |
42 ['DO .2 <- #666', 'OK'], | |
43 ['.2', 'DCLXVI'], | |
44 ['DO ABSTAIN FROM CALCULATING', 'OK'], | |
45 ['DO .2 <- .V1', 'OK'], | |
46 ['.2', 'DCLXVI'], | |
47 ['DO REINSTATE CALCULATING', 'OK'], | |
48 ['DO ABSTAIN FROM (1)', 'OK'], | |
49 ['DO .2 <- .V1', 'OK'], | |
50 ['(1) DO .2 <- #1', 'OK'], | |
51 ['.2', 'xxxiiDCCLXXI'], | |
52 ['DO REINSTATE (1)', 'OK'], | |
53 ['(1) DO .2 <- #1', 'OK'], | |
54 ['.2', 'I'], | |
55 # XXX more tests are necessary | |
56 ); | |
57 | |
58 my $maxtest = 1 + @expr_tests + @full_tests; | |
59 print "1..$maxtest\n"; | |
60 | |
61 my ($pid, $read, $write) = run_calculator('expr', '1972'); | |
62 | |
63 my $testnum = 1; | |
64 for my $test (@expr_tests) { | |
65 my ($cmd, $res) = @$test; | |
66 print $read "$cmd\n"; | |
67 my $line = <$write>; | |
68 defined $line or die "Calculator: end of input\n"; | |
69 chomp $line; | |
70 while ($line =~ /loading compiler/i) { | |
71 $line = <$write>; | |
72 defined $line or die "Calculator: end of input\n"; | |
73 chomp $line; | |
74 } | |
75 $line =~ s/^\s+//; | |
76 my ($gr, $gc) = split(/\s+/, $line, 2); | |
77 my $not = 'not '; | |
78 if ($gr ne $res) { | |
79 print STDERR "FAIL $testnum res ($gr ne $res)\n"; | |
80 } else { | |
81 $not = ''; | |
82 } | |
83 print "${not}ok ", $testnum++, "\n"; | |
84 } | |
85 | |
86 print $read "`mfull\n"; | |
87 my $line = <$write>; | |
88 print $line =~ /mode changed/i ? '' : 'not ', "ok ", $testnum++, "\n"; | |
89 | |
90 for my $test (@full_tests) { | |
91 my ($cmd, $res) = @$test; | |
92 print $read "$cmd\n"; | |
93 my $line = <$write>; | |
94 defined $line or die "Calculator: end of input\n"; | |
95 chomp $line; | |
96 while ($line =~ /loading compiler/i) { | |
97 $line = <$write>; | |
98 defined $line or die "Calculator: end of input\n"; | |
99 chomp $line; | |
100 } | |
101 $line =~ s/^\s+//; | |
102 my ($gr, $gc) = split(/\s+/, $line, 2); | |
103 my $not = 'not '; | |
104 if ($gr ne $res) { | |
105 print STDERR "FAIL $testnum res ($gr ne $res)\n"; | |
106 } else { | |
107 $not = ''; | |
108 } | |
109 print "${not}ok ", $testnum++, "\n"; | |
110 } | |
111 |