diff options
Diffstat (limited to 'contrib/bluegnu2.0.3/example/calc/testsuite/calc.test/calc.exp')
-rw-r--r-- | contrib/bluegnu2.0.3/example/calc/testsuite/calc.test/calc.exp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/contrib/bluegnu2.0.3/example/calc/testsuite/calc.test/calc.exp b/contrib/bluegnu2.0.3/example/calc/testsuite/calc.test/calc.exp new file mode 100644 index 0000000..73e99e4 --- /dev/null +++ b/contrib/bluegnu2.0.3/example/calc/testsuite/calc.test/calc.exp @@ -0,0 +1,60 @@ +set timeout 3 +# +# expectations that clean up in case of error. Note that `$test' is +# a purely local variable. +# +# The first of these is used to match any bad responses, and resynchronise +# things by finding a prompt. The second is a timeout error, and shouldn't +# ever be triggered. +# +expect_after { + -re "\[^\n\r\]*$prompt$" { + fail "$test (bad match)" + if { $verbose > 0 } { + regexp ".*\r\n(\[^\r\n\]+)(\[\r\n\])+$prompt$" \ + $expect_out(buffer) "" output + send_user "\tUnmatched output: \"$output\"\n" + } + } + timeout { + fail "$test (timeout)" + } +} +# +# Here are the tests +# +set test "version" +send "version\n" +expect { + -re "Version:.*$prompt$" { pass "version" } +} + +set test add1 +send "add 3 4\n" +expect { + -re "7+.*$prompt$" { pass "$test" } +} + +set test add2 +send "add 1 2 3\n" +expect { + -re "Usage: add #1 #2.*$prompt$" { pass "$test" } +} + +set test multiply1 +send "multiply 3 4\n" +expect { + -re "12.*$prompt$" { pass "$test" } +} + +set test multiply2 +send "multiply 2 4\n" +expect { + -re "8.*$prompt$" { pass "$test" } +} + +set test multiply3 +send "multiply 1 2 3\n" +expect { + -re "Usage: multiply #1 #2.*$prompt$" { pass "$test" } +} |