diff options
Diffstat (limited to 'expect/tests/expect.test')
-rw-r--r-- | expect/tests/expect.test | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/expect/tests/expect.test b/expect/tests/expect.test new file mode 100644 index 00000000000..73bfdb2fdaa --- /dev/null +++ b/expect/tests/expect.test @@ -0,0 +1,96 @@ +# Commands covered: cat (UNIX), expect +# +# This file contains a collection of tests for one or more of the Tcl +# built-in commands. Sourcing this file into Tcl runs the tests and +# generates output for errors. No output means no errors were found. + +if {[string compare test [info procs test]] == 1} then {source defs} + +catch {unset x} + +log_user 0 + +exp_spawn cat -u +exp_stty -echo < $spawn_out(slave,name) + +test expect-1.1 {exact pattern} { + expect "*" + exp_send "a\r" + + set timeout 10 + set x 0 + expect -ex a {set x 1} + set x +} {1} + +test expect-1.2 {exact pattern buffering} { + expect "*" + exp_send "hiahi\r" + + set timeout 10 + set x 0 + expect -ex hi + expect -ex hi {set x 1} + set x +} {1} + +# if only this test fails, then configure has guessed incorrectly and +# stty accesses the control terminal from stdout. The quick fix is +# to edit expect_cf.h and define STTY_READS_STDOUT to 1. (It should +# be commented out.) If you figure out a way to fix the configure test, +# let me know. Else, let me know a way to test for your particular +# machine and os version so it can be hardwired. +test expect-1.3 {exact pattern failure} { + expect "*" + exp_send "hiahi\r" + + set timeout 10 + set x 0 + expect -ex hi {set x 1} + expect -ex hi {set x 2} + expect -ex hi {set x 3} + set x +} {2} + +test expect-1.4 {glob pattern} { + expect "*" + exp_send "a\r" + + set timeout 10 + set x 0 + expect "a" {set x 1} + set x +} {1} + +test expect-1.5 {glob pattern buffering} { + expect "*" + exp_send "a\r" + + set timeout 10 + set x 0 + expect "*" {set x 1} + set x +} {1} + +test expect-1.6 {glob buffer} { + expect "*" + exp_send "philosophic\r" + + set timeout 10 + set x 0 + expect "hi" + set x [string match *phi $expect_out(buffer)] +} {1} + +test expect-1.7 {glob string} { + expect "*" + exp_send "philosophic\r" + + set timeout 10 + set x 0 + expect "hi" + set expect_out(0,string) +} {hi} + +close +wait |