-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·143 lines (104 loc) · 3.19 KB
/
test.sh
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
137
138
#!/bin/bash
mkdir -p tests
sicstus -l make_selfann.pl --goal "go,halt." &> /dev/null
## append test
testLix() {
rm tests/$File*
echo $Ans > tests/$File.ans
sicstus -l lix_main.pl --goal "Call = $Call,lix(Call, R1), portray_clause(':-'(Call,R1)),halt." 2> /dev/null > tests/$File
sicstus -l tests/$File --goal "findall($CallOut,$Call,Bag), print(Bag),nl,halt." 2> /dev/null > tests/$File.out
if ( ! diff -q tests/$File.ans tests/$File.out )
then
echo "######Failed on test Case $Call"
else
echo "OK"
fi
}
testLixGX() {
LCall=lix\($Call,Res\)
rm tests/$File*
echo $Ans > tests/$File.ans
sicstus -l lix_main.pl --goal "Call = $LCall,lix(Call, R1), portray_clause(':-'(Call,R1)),halt." 2> /dev/null > tests/$File
sicstus -l tests/$File --goal "$LCall, portray_clause(':-'($Call,Res)),halt." 2> /dev/null > tests/$File.spec
sicstus -l tests/$File.spec --goal "findall($CallOut,$Call,Bag),print(Bag),nl,halt." 2> /dev/null > tests/$File.out
if ( ! diff -q tests/$File.ans tests/$File.out )
then
echo "######Failed on test Case $Call"
else
echo "OK"
fi
}
testLixCogen() {
LCall=lix\($Call,Res\)
CogCall=lix\($LCall,Res1\)
rm tests/$File*
echo $Ans > tests/$File.ans
#sicstus -l lix_main.pl --goal "Call = $CogCall,lix(Call, R1), portray_clause(':-'(Call,R1)),halt." 2> /dev/null > tests/$File.cog
#sicstus -l tests/$File.cog --goal "Call = $LCall,lix(Call, R1), portray_clause(':-'(Call,R1)),halt." 2> /dev/null > tests/$File.gx
sicstus -l tests/$LixCogen --goal "cogen($Call,R,R1), portray_clause(':-'(gx($Call,R),R1)),halt." 2> /dev/null > tests/$File.gx
sicstus -l tests/$File.gx --goal "gx($Call,R1), portray_clause(':-'($Call,R1)),halt." 2> /dev/null > tests/$File.spec
#sicstus -l tests/$File.gx --goal "$LCall, portray_clause(':-'($Call,Res)),halt." 2> /dev/null > tests/$File.spec
sicstus -l tests/$File.spec --goal "findall($CallOut,$Call,Bag),print(Bag),nl,halt." 2> /dev/null > tests/$File.out
if ( ! diff -q tests/$File.ans tests/$File.out )
then
echo "Failed"
echo "Error on test case $Call"
else
echo "OK"
fi
}
makeLixCogen() {
sicstus -l lix_main.pl --goal "lix(lix(lix(A,R1),R2),R3), portray_clause(':-'(cogen(A,R1,R2),R3)),halt." 2> /dev/null > tests/$LixCogen
}
Indent=" "
echo "Testing Lix mode-->"
# Append Test
echo -n "$Indent app/3..."
File=app.pl
Call=app\([a,b,c,d],[b],C\)
CallOut=C
Ans=[[a,b,c,d,b]]
testLix
# Append Test
echo -n "$Indent fib/2..."
File=fib.pl
Call=fib\(6,X\)
CallOut=X
Ans=[13]
testLix
echo "Testing GX mode-->"
echo -n "$Indent app/3..."
#app_gx
File=appgx.pl
Call=app\([a,b,c,d],[b],C\)
CallOut=C
Ans=[[a,b,c,d,b]]
testLixGX
echo -n "$Indent fib/2..."
#app_gx
File=benchgx.pl
Call=fib\(5,X\)
CallOut=X
Ans=[8]
testLixGX
echo "Testing Cogen mode->"
LixCogen='lix-cogen.pl'
makeLixCogen
echo -n "$Indent app/3..."
File=appcog.pl
Call=app\([a,b,c,d],[b],C\)
CallOut=C
Ans=[[a,b,c,d,b]]
testLixCogen
echo -n "$Indent test/1..."
File=testcog.pl
Call=test\(A\)
CallOut=A
Ans=[a,b]
testLixCogen
echo -n "$Indent fib/2..."
File=fibcog.pl
Call=fib\(5,X\)
CallOut=X
Ans=[8]
testLixCogen