-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·68 lines (57 loc) · 1.04 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
#!/usr/bin/expect
set timeout 5
spawn ./calculator/calculator
# only plus
expect {
">" {send "1+2+3+4;\r"}
}
# mutiply, conisder priority
expect {
">" {send "1+2*3+4;\r"}
}
# mutiply, ()
expect {
">" {send "(1+2)*3+4;\r"}
}
# mutiply, conisder priority, first 0
expect {
">" {send "(01+2)*03+4;\r"}
}
# + * /, conisder priority, first 0, ()
expect {
">" {send "1/2+3*5+(012.53+09.8/02)*6;\r"}
}
# + - * /, conisder priority, first 0, (), space, tab
expect {
">" {send "1/2+3*5- (012.53+ 09.8/02)*6;\r"}
}
# one sentence split to two lines.
# + - * /, conisder priority, first 0, (), space, tab
expect {
">" {send "1/2+3*5\r"}
}
expect {
">" {send " - (012.53+ 09.8/02)*6;\r"}
}
# one sentence and a half in one line
expect {
">" {send "1+2+4-6*2; 1+3+5-9*7\r"}
}
expect {
"> 1+3+5-9*7" {send ""}; #The halfline will be print again by the calculator
}
expect {
">" {send " -8;\r"}
}
# blank line
expect {
">" {send "\r"}
}
expect {
">" {send "1+3;\r"};
}
#exit
expect {
">" {send "quit;\r"}
}
expect eof