Blame unit-tests/das-testsuite/das-test.0/test.7.exp

Packit a4aae4
# expect/tcl code to test the das parser and scanner
Packit a4aae4
# jhrg
Packit a4aae4
#
Packit a4aae4
# $Log: test.7.exp,v $
Packit a4aae4
# Revision 1.10  2003/12/11 01:08:38  jimg
Packit a4aae4
# More fixes after resolving conflicts. This code still fails some tests.
Packit a4aae4
#
Packit a4aae4
# Revision 1.9.10.1  2003/10/03 16:26:30  jimg
Packit a4aae4
# Fixed tests; I changed the text of das-test just a little and so these
Packit a4aae4
# had to be updated. I wanted to be sure that the error message was from
Packit a4aae4
# an exception and not just a write to stderr.
Packit a4aae4
#
Packit a4aae4
# Revision 1.9  2000/09/22 02:52:59  jimg
Packit a4aae4
# Fixes to the tests to recognize some of the new error messages. Also,
Packit a4aae4
# the test drivers were modified to catch the exceptions now thrown by
Packit a4aae4
# some of the parsers.
Packit a4aae4
#
Packit a4aae4
# Revision 1.8  2000/06/16 18:15:01  jimg
Packit a4aae4
# Merged with 3.1.7
Packit a4aae4
#
Packit a4aae4
# Revision 1.7.10.1  2000/06/15 02:24:57  jimg
Packit a4aae4
# Fixed the tests: problems with PATH, etc. broke the tests on my new machine
Packit a4aae4
#
Packit a4aae4
# Revision 1.7  1999/03/24 23:42:23  jimg
Packit a4aae4
# Added or updated for the new simple types (Int16, UInt16 and Float32)
Packit a4aae4
#
Packit a4aae4
# Revision 1.6  1997/05/13 23:29:30  jimg
Packit a4aae4
# *** empty log message ***
Packit a4aae4
#
Packit a4aae4
# Revision 1.5  1997/03/27 18:20:02  jimg
Packit a4aae4
# Update for version 2.13
Packit a4aae4
#
Packit a4aae4
# Revision 1.4  1996/11/13 19:23:47  jimg
Packit a4aae4
# *** empty log message ***
Packit a4aae4
#
Packit a4aae4
# Revision 1.3  1996/08/12 22:22:21  jimg
Packit a4aae4
# Changed for the new error message text from the parser.
Packit a4aae4
#
Packit a4aae4
# Revision 1.2  1996/05/14 15:40:54  jimg
Packit a4aae4
# These changes have already been checked in once before. However, I
Packit a4aae4
# corrupted the source repository and restored it from a 5/9/96 backup
Packit a4aae4
# tape. The previous version's log entry should cover the changes.
Packit a4aae4
#
Packit a4aae4
# Revision 1.1  1995/02/16  15:34:53  jimg
Packit a4aae4
# Added these tests. See comments in files in parent directory.
Packit a4aae4
#
Packit a4aae4
Packit a4aae4
global comp_output		# contains output from das-test_start
Packit a4aae4
global verbose			# this and srcdir are set by runtest.exp
Packit a4aae4
global srcdir
Packit a4aae4
Packit a4aae4
# The variable `test_name' is the name of the das input file for this test.
Packit a4aae4
Packit a4aae4
set test_name test.7
Packit a4aae4
Packit a4aae4
# The variable `test_out' is a string that contains the text that should be
Packit a4aae4
# stored in comp_output by das-test_start. The two strings should match
Packit a4aae4
# exactly.
Packit a4aae4
Packit a4aae4
set test_out "Caught Error object:
Packit a4aae4
Error parsing the text on line 10 at or near: my_test
Packit a4aae4
Expected an attribute type (Byte, Int16, UInt16, Int32, UInt32, Float32,
Packit a4aae4
Float64, String or Url) followed by a name and value."
Packit a4aae4
Packit a4aae4
das-test_start p $srcdir/$test_name
Packit a4aae4
Packit a4aae4
set comp_output [string trim $comp_output]
Packit a4aae4
Packit a4aae4
if ![string compare $test_out $comp_output] { # check comp_output
Packit a4aae4
    pass "$test_name"
Packit a4aae4
} else {
Packit a4aae4
    set tlen [string length $test_out]
Packit a4aae4
    set clen [string length $comp_output]
Packit a4aae4
Packit a4aae4
    set len $tlen;			# used by for loop below
Packit a4aae4
Packit a4aae4
    if {$clen < $tlen} {
Packit a4aae4
	set len $clen;			# set if needed
Packit a4aae4
Packit a4aae4
	set size [expr $tlen - $clen]
Packit a4aae4
	send_user "comp_output is smaller (by $size chars) than expected!\n"
Packit a4aae4
	send_user "Here's the excess: '"
Packit a4aae4
	send_user [string range $test_out [expr $clen -1] end]
Packit a4aae4
 	send_user "'\n"
Packit a4aae4
    } elseif {$tlen < $clen} {
Packit a4aae4
	set size [expr $clen - $tlen]
Packit a4aae4
	send_user "comp_output is larger (by $size chars) than expected!\n"
Packit a4aae4
	send_user "Here's the excess: '"
Packit a4aae4
	send_user [string range $comp_output [expr $tlen -1] end]
Packit a4aae4
	send_user "'\n"
Packit a4aae4
    }
Packit a4aae4
Packit a4aae4
    # $len is set to the smallest of $tlen or $clen to avoid running off the
Packit a4aae4
    # end either of the strings.
Packit a4aae4
    for {set i 0} {$i < $len} {incr i} {
Packit a4aae4
	set c [string index $comp_output $i]
Packit a4aae4
	set t [string index $test_out $i]
Packit a4aae4
	if {$t != $c} {
Packit a4aae4
	    send_user "comp_output ($c) and test_out ($t) differ at $i.\n"
Packit a4aae4
	}
Packit a4aae4
    }
Packit a4aae4
    
Packit a4aae4
    fail "$test_name"
Packit a4aae4
}
Packit a4aae4
Packit a4aae4