comparison interps/clc-intercal/CLC-INTERCAL-ICALC-1.-94.-2/t/04intercalc-sick.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 sick 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 ['.3 <- #666', 'OK'],
17 ['#666 <- #2', 'OK'],
18 ['#666', 'II'],
19 ['#2 <- .3', 'OK'],
20 ['.3', 'DCLXVI'],
21 ['#2', 'DCLXVI'],
22 # note that from now on #2 and #666 have been swapped
23 ['.&1', 'I'],
24 ['.V-1', 'xxxiiDCCLXX'],
25 ['.¥1', 'xxxiiDCCLXX'],
26 [':1 <- #V666', 'OK'],
27 [':1', 'III'],
28 [':V1', '\M\M\C\X\L\V\I\IcdlxxxiiiDCLI'],
29 [':&1', 'I'],
30 [':V-1', '\M\M\C\X\L\V\I\IcdlxxxiiiDCL'],
31 [':¥1', '\M\M\C\X\L\V\I\IcdlxxxiiiDCL'],
32 ['.2 <- #1', 'OK'],
33 ['.1C/.2', 'XI'],
34 ['.1¢.2', 'XI'],
35 [':1~.1', 'III'],
36 [':1~.2', 'I'],
37 # XXX more tests are necessary
38 );
39
40 my @full_tests = (
41 ['DO .1 <- #V666', 'OK'],
42 ['DO .666 <- .V1', 'OK'],
43 ['.1', 'III'],
44 ['.666', 'xxxiiDCCLXXI'],
45 ['PLEASE IGNORE .666', 'OK'],
46 ['DO .666 <- #2', 'OK'],
47 ['.666', 'xxxiiDCCLXXI'],
48 ['PLEASE REMEMBER .666', 'OK'],
49 ['DO .666 <- #2', 'OK'],
50 ['.666', 'DCLXVI'],
51 ['#-666', 'II'],
52 ['.-666', 'II'],
53 ['DO ABSTAIN FROM CALCULATING', 'OK'],
54 ['DO .666 <- .V1', 'OK'],
55 ['.666', 'DCLXVI'],
56 ['DO REINSTATE CALCULATING', 'OK'],
57 ['DO ABSTAIN FROM (1)', 'OK'],
58 ['DO .666 <- .V1', 'OK'],
59 ['(1) DO .666 <- #1', 'OK'],
60 ['.666', 'xxxiiDCCLXXI'],
61 ['DO REINSTATE (1)', 'OK'],
62 ['(1) DO .666 <- #1', 'OK'],
63 ['.666', 'I'],
64 # XXX more tests are necessary
65 );
66
67 my $maxtest = 1 + @expr_tests + @full_tests;
68 print "1..$maxtest\n";
69
70 my ($pid, $read, $write) = run_calculator('expr', 'sick');
71
72 my $testnum = 1;
73 for my $test (@expr_tests) {
74 my ($cmd, $res) = @$test;
75 print $read "$cmd\n";
76 my $line = <$write>;
77 defined $line or die "Calculator: end of input\n";
78 chomp $line;
79 while ($line =~ /loading compiler/i) {
80 $line = <$write>;
81 defined $line or die "Calculator: end of input\n";
82 chomp $line;
83 }
84 $line =~ s/^\s+//;
85 my ($gr, $gc) = split(/\s+/, $line, 2);
86 my $not = 'not ';
87 if ($gr ne $res) {
88 print STDERR "FAIL $testnum res ($gr ne $res)\n";
89 } else {
90 $not = '';
91 }
92 print "${not}ok ", $testnum++, "\n";
93 }
94
95 print $read "`mfull\n";
96 my $line = <$write>;
97 print $line =~ /mode changed/i ? '' : 'not ', "ok ", $testnum++, "\n";
98
99 for my $test (@full_tests) {
100 my ($cmd, $res) = @$test;
101 print $read "$cmd\n";
102 my $line = <$write>;
103 defined $line or die "Calculator: end of input\n";
104 chomp $line;
105 while ($line =~ /loading compiler/i) {
106 $line = <$write>;
107 defined $line or die "Calculator: end of input\n";
108 chomp $line;
109 }
110 $line =~ s/^\s+//;
111 my ($gr, $gc) = split(/\s+/, $line, 2);
112 my $not = 'not ';
113 if ($gr ne $res) {
114 print STDERR "FAIL $testnum res ($gr ne $res)\n";
115 } else {
116 $not = '';
117 }
118 print "${not}ok ", $testnum++, "\n";
119 }
120