1use lib '../lib'; 2use strict; 3use Test::More tests => 9; 4 5my $TJSIM = "../../tjsim"; 6my $PATH = "-p lists/"; 7my $MODULE = "lists"; 8my $code; 9my $ans; 10 11############################################ 12############################################ 13$code = <<'CODE'; 14append (2::nil) (3::nil) L. 15CODE 16$ans = <<'ANS'; 17 18The answer substitution: 19L = 2 :: 3 :: nil 20 21ANS 22same_answers( `$TJSIM -b $PATH --solve "$code" $MODULE\n`, $ans,"append"); 23############################################ 24############################################ 25$code = <<'CODE'; 26append L1 L2 (1::2::3::4::5::nil). 27CODE 28$ans = <<'ANS'; 29 30The answer substitution: 31L2 = 1 :: 2 :: 3 :: 4 :: 5 :: nil 32L1 = nil 33 34 35The answer substitution: 36L2 = 2 :: 3 :: 4 :: 5 :: nil 37L1 = 1 :: nil 38 39 40The answer substitution: 41L2 = 3 :: 4 :: 5 :: nil 42L1 = 1 :: 2 :: nil 43 44 45The answer substitution: 46L2 = 4 :: 5 :: nil 47L1 = 1 :: 2 :: 3 :: nil 48 49 50The answer substitution: 51L2 = 5 :: nil 52L1 = 1 :: 2 :: 3 :: 4 :: nil 53 54 55The answer substitution: 56L2 = nil 57L1 = 1 :: 2 :: 3 :: 4 :: 5 :: nil 58 59ANS 60same_answers( `$TJSIM -b $PATH --solve "$code" $MODULE\n`, $ans,"append"); 61 62############################################ 63############################################ 64$code = <<'CODE'; 65pi (X \ (append (X::nil) (2::X::nil) (F X))). 66CODE 67$ans = <<'ANS'; 68 69The answer substitution: 70F = W1\ W1 :: 2 :: W1 :: nil 71 72ANS 73same_answers( `$TJSIM -b $PATH --solve "$code" $MODULE\n`, $ans,"pi append"); 74 75############################################ 76############################################ 77$code = <<'CODE'; 78append (F 2) (3::nil) (2::2::3::nil). 79CODE 80$ans = <<'ANS'; 81 82The answer substitution: 83F = F 84 85The remaining disagreement pairs list: 86<F 2, 2 :: 2 :: nil> 87 88ANS 89same_answers( `$TJSIM -b $PATH --solve "$code" $MODULE\n`, $ans,"append"); 90 91############################################ 92############################################ 93$code = <<'CODE'; 94append (F X) nil (2::3::2::5::nil). 95CODE 96$ans = <<'ANS'; 97 98The answer substitution: 99X = X 100F = F 101 102The remaining disagreement pairs list: 103<F X, 2 :: 3 :: 2 :: 5 :: nil> 104 105ANS 106same_answers( `$TJSIM -b $PATH --solve "$code" $MODULE\n`, $ans,"append"); 107 108############################################ 109############################################ 110$code = <<'CODE'; 111sigma X \ (append [2] [3,3] (F X)). 112CODE 113$ans = <<'ANS'; 114 115The answer substitution: 116F = F 117 118The remaining disagreement pairs list: 119<F _T1, 2 :: 3 :: 3 :: nil> 120 121ANS 122same_answers( `$TJSIM -b $PATH --solve "$code" $MODULE\n`, $ans,"append"); 123 124############################################ 125############################################ 126 127$code = <<'CODE'; 128memb 1 (2::2::nil). 129CODE 130$ans = <<'ANS'; 131ANS 132same_answers( `$TJSIM -b $PATH --solve "$code" $MODULE\n`, $ans,"memb"); 133 134############################################ 135############################################ 136 137$code = <<'CODE'; 138memb 1 (2::1::nil). 139CODE 140$ans = <<'ANS'; 141ANS 142same_answers( `$TJSIM -b $PATH --solve "$code" $MODULE\n`, $ans,"memb"); 143 144############################################ 145############################################ 146 147$code = <<'CODE'; 148memb X (2::1::nil). 149CODE 150$ans = <<'ANS'; 151 152The answer substitution: 153X = 2 154 155The answer substitution: 156X = 1 157 158ANS 159same_answers( `$TJSIM -b $PATH --solve "$code" $MODULE\n`, $ans,"memb"); 160############################################ 161############################################ 162