summaryrefslogtreecommitdiffstats
path: root/tests/parseExpr.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/parseExpr.test')
-rw-r--r--tests/parseExpr.test116
1 files changed, 47 insertions, 69 deletions
diff --git a/tests/parseExpr.test b/tests/parseExpr.test
index fd32df9..c3b0d71 100644
--- a/tests/parseExpr.test
+++ b/tests/parseExpr.test
@@ -2,19 +2,14 @@
# file tclCompExpr.c. Sourcing this file into Tcl runs the tests and
# generates output for errors. No output means no errors were found.
#
-# Copyright © 1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 Scriptics Corporation.
+# Copyright (c) 1997 Sun Microsystems, Inc.
+# Copyright (c) 1998-1999 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-if {"::tcltest" ni [namespace children]} {
- package require tcltest 2.5
- namespace import -force ::tcltest::*
-}
-
-::tcltest::loadTestedCommands
-catch [list package require -exact tcl::test [info patchlevel]]
+package require tcltest 2
+namespace import ::tcltest::*
# Note that the Tcl expression parser (tclCompExpr.c) does not check
# the semantic validity of the expressions it parses. It does not check,
@@ -22,7 +17,6 @@ catch [list package require -exact tcl::test [info patchlevel]]
# of "<<" are integers.
testConstraint testexprparser [llength [info commands testexprparser]]
-testConstraint testbytestring [llength [info commands testbytestring]]
# Big test for correct ordering of data in [expr]
@@ -32,9 +26,9 @@ proc testIEEE {} {
switch -exact -- $c {
{0 0 0 0 0 0 -16 -65 0 0 0 0 0 0 -16 63} {
# little endian
- binary scan \x00\x00\x00\x00\x00\x00\xF0\xFF d \
+ binary scan \x00\x00\x00\x00\x00\x00\xf0\xff d \
ieeeValues(-Infinity)
- binary scan \x00\x00\x00\x00\x00\x00\xF0\xBF d \
+ binary scan \x00\x00\x00\x00\x00\x00\xf0\xbf d \
ieeeValues(-Normal)
binary scan \x00\x00\x00\x00\x00\x00\x08\x80 d \
ieeeValues(-Subnormal)
@@ -44,19 +38,19 @@ proc testIEEE {} {
ieeeValues(+0)
binary scan \x00\x00\x00\x00\x00\x00\x08\x00 d \
ieeeValues(+Subnormal)
- binary scan \x00\x00\x00\x00\x00\x00\xF0\x3F d \
+ binary scan \x00\x00\x00\x00\x00\x00\xf0\x3f d \
ieeeValues(+Normal)
- binary scan \x00\x00\x00\x00\x00\x00\xF0\x7F d \
+ binary scan \x00\x00\x00\x00\x00\x00\xf0\x7f d \
ieeeValues(+Infinity)
- binary scan \x00\x00\x00\x00\x00\x00\xF8\x7F d \
+ binary scan \x00\x00\x00\x00\x00\x00\xf8\x7f d \
ieeeValues(NaN)
set ieeeValues(littleEndian) 1
return 1
}
{-65 -16 0 0 0 0 0 0 63 -16 0 0 0 0 0 0} {
- binary scan \xFF\xF0\x00\x00\x00\x00\x00\x00 d \
+ binary scan \xff\xf0\x00\x00\x00\x00\x00\x00 d \
ieeeValues(-Infinity)
- binary scan \xBF\xF0\x00\x00\x00\x00\x00\x00 d \
+ binary scan \xbf\xf0\x00\x00\x00\x00\x00\x00 d \
ieeeValues(-Normal)
binary scan \x80\x08\x00\x00\x00\x00\x00\x00 d \
ieeeValues(-Subnormal)
@@ -66,11 +60,11 @@ proc testIEEE {} {
ieeeValues(+0)
binary scan \x00\x08\x00\x00\x00\x00\x00\x00 d \
ieeeValues(+Subnormal)
- binary scan \x3F\xF0\x00\x00\x00\x00\x00\x00 d \
+ binary scan \x3f\xf0\x00\x00\x00\x00\x00\x00 d \
ieeeValues(+Normal)
- binary scan \x7F\xF0\x00\x00\x00\x00\x00\x00 d \
+ binary scan \x7f\xf0\x00\x00\x00\x00\x00\x00 d \
ieeeValues(+Infinity)
- binary scan \x7F\xF8\x00\x00\x00\x00\x00\x00 d \
+ binary scan \x7f\xf8\x00\x00\x00\x00\x00\x00 d \
ieeeValues(NaN)
set ieeeValues(littleEndian) 0
return 1
@@ -84,8 +78,8 @@ testConstraint ieeeFloatingPoint [testIEEE]
######################################################################
-test parseExpr-1.1 {Tcl_ParseExpr procedure, computing string length} {testexprparser testbytestring} {
- testexprparser [testbytestring "1+2\x00 +3"] -1
+test parseExpr-1.1 {Tcl_ParseExpr procedure, computing string length} testexprparser {
+ testexprparser [bytestring "1+2\0 +3"] -1
} {- {} 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 {}}
test parseExpr-1.2 {Tcl_ParseExpr procedure, computing string length} testexprparser {
testexprparser "1 + 2" -1
@@ -770,11 +764,11 @@ test parseExpr-21.8 {error messages} -body {
expr {0o8x}
} -returnCodes error -match glob -result {*invalid octal number*}
test parseExpr-21.9 {error messages} -body {
- expr {"}
+ expr {"}
} -returnCodes error -result {missing "
in expression """}
test parseExpr-21.10 {error messages} -body {
- expr \{
+ expr \{
} -returnCodes error -result "missing close-brace
in expression \"\{\""
test parseExpr-21.11 {error messages} -body {
@@ -882,17 +876,17 @@ test parseExpr-21.36 {error messages} -body {
} -returnCodes error -result {invalid character "@"
in expression "...fghijklmnopqrstuvwxyz"@"abcdefghijklmnopqrstu..."}
test parseExpr-21.37 {error messages} -body {
- expr [format {"%s" @ 0} [string repeat \xA7 25]]
+ expr [format {"%s" @ 0} [string repeat \u00a7 25]]
} -returnCodes error -result [format {invalid character "@"
-in expression "...%s" @ 0"} [string repeat \xA7 10]]
+in expression "...%s" @ 0"} [string repeat \u00a7 10]]
test parseExpr-21.38 {error messages} -body {
- expr [format {0 @ "%s"} [string repeat \xA7 25]]
+ expr [format {0 @ "%s"} [string repeat \u00a7 25]]
} -returnCodes error -result [format {invalid character "@"
-in expression "0 @ "%s..."} [string repeat \xA7 10]]
+in expression "0 @ "%s..."} [string repeat \u00a7 10]]
test parseExpr-21.39 {error messages} -body {
- expr [format {"%s" @ "%s"} [string repeat \xA7 25] [string repeat \xA7 25]]
+ expr [format {"%s" @ "%s"} [string repeat \u00a7 25] [string repeat \u00a7 25]]
} -returnCodes error -result [format {invalid character "@"
-in expression "...%s" @ "%s..."} [string repeat \xA7 10] [string repeat \xA7 10]]
+in expression "...%s" @ "%s..."} [string repeat \u00a7 10] [string repeat \u00a7 10]]
test parseExpr-21.40 {error messages} -body {
catch {expr {"abcdefghijklmnopqrstuvwxyz"@0}} m o
dict get $o -errorinfo
@@ -902,13 +896,13 @@ in expression "...fghijklmnopqrstuvwxyz"@0"
invoked from within
"expr {"abcdefghijklmnopqrstuvwxyz"@0}"}
test parseExpr-21.41 {error messages} -body {
- catch {expr [format {"%s" @ 0} [string repeat \xA7 25]]} m o
+ catch {expr [format {"%s" @ 0} [string repeat \u00a7 25]]} m o
dict get $o -errorinfo
} -result [format {invalid character "@"
in expression "...%s" @ 0"
(parsing expression ""%s...")
invoked from within
-"expr [format {"%%s" @ 0} [string repeat \xA7 25]]"} [string repeat \xA7 10] [string repeat \xA7 10]]
+"expr [format {"%%s" @ 0} [string repeat \u00a7 25]]"} [string repeat \u00a7 10] [string repeat \u00a7 10]]
test parseExpr-21.42 {error message} -body {
expr {123456789012345678901234567890*"abcdefghijklmnopqrstuvwxyz}
} -returnCodes error -result {missing "
@@ -1023,66 +1017,50 @@ test parseExpr-22.7 {Bug 3401704} -constraints testexprparser -body {
testexprparser nan_() -1
} -result {- {} 0 subexpr nan_() 1 operator nan_ 0 {}}
test parseExpr-22.8 {Bug 3401704} -constraints testexprparser -body {
- catch {testexprparser nan!() -1} m o
- dict get $o -errorcode
-} -result {TCL PARSE EXPR MISSING}
+ testexprparser nan!() -1
+} -returnCodes error -match glob -result *
test parseExpr-22.9 {Bug 3401704} -constraints testexprparser -body {
testexprparser 1e3_() -1
} -result {- {} 0 subexpr 1e3_() 1 operator 1e3_ 0 {}}
test parseExpr-22.10 {Bug 3401704} -constraints testexprparser -body {
- catch {testexprparser 1.3_() -1} m o
- dict get $o -errorcode
-} -result {TCL PARSE EXPR BADCHAR}
+ testexprparser 1.3_() -1
+} -returnCodes error -match glob -result *
test parseExpr-22.11 {Bug 3401704} -constraints testexprparser -body {
- catch {testexprparser 1e-3`() -1} m o
- dict get $o -errorcode
-} -result {TCL PARSE EXPR BADCHAR}
+ testexprparser 1e-3_() -1
+} -returnCodes error -match glob -result *
test parseExpr-22.12 {Bug 3401704} -constraints testexprparser -body {
- catch {testexprparser naneq() -1} m o
- dict get $o -errorcode
-} -result {TCL PARSE EXPR EMPTY}
+ testexprparser naneq() -1
+} -returnCodes error -match glob -result *
test parseExpr-22.13 {Bug 3401704} -constraints testexprparser -body {
testexprparser naner() -1
} -result {- {} 0 subexpr naner() 1 operator naner 0 {}}
test parseExpr-22.14 {Bug 3401704} -constraints testexprparser -body {
- testexprparser 07 -1
-} -result {- {} 0 subexpr 07 1 text 07 0 {}}
+ testexprparser 08 -1
+} -returnCodes error -match glob -result {*invalid octal number*}
test parseExpr-22.15 {Bug 3401704} -constraints testexprparser -body {
- catch {testexprparser 0o8 -1} m o
- dict get $o -errorcode
-} -result {TCL PARSE EXPR BADNUMBER OCTAL}
+ testexprparser 0o8 -1
+} -returnCodes error -match glob -result {*invalid octal number*}
test parseExpr-22.16 {Bug 3401704} -constraints testexprparser -body {
- catch {testexprparser 0o08 -1} m o
- dict get $o -errorcode
-} -result {TCL PARSE EXPR BADNUMBER OCTAL}
+ testexprparser 0o08 -1
+} -returnCodes error -match glob -result {*invalid octal number*}
test parseExpr-22.17 {Bug 3401704} -constraints testexprparser -body {
- catch {testexprparser 0b2 -1} m o
- dict get $o -errorcode
-} -result {TCL PARSE EXPR BADNUMBER BINARY}
+ testexprparser 0b2 -1
+} -returnCodes error -match glob -result {*invalid binary number*}
test parseExpr-22.18 {Bug 3401704} -constraints testexprparser -body {
- catch {testexprparser 0b02 -1} m o
- dict get $o -errorcode
-} -result {TCL PARSE EXPR BADNUMBER BINARY}
+ testexprparser 0b02 -1
+} -returnCodes error -match glob -result {*invalid binary number*}
test parseExpr-22.19 {Bug d2ffcca163} -constraints testexprparser -body {
- testexprparser г -1
+ testexprparser \u0433 -1
} -returnCodes error -match glob -result {*invalid character*}
test parseExpr-22.20 {Bug d2ffcca163} -constraints testexprparser -body {
- testexprparser п -1
+ testexprparser \u043f -1
} -returnCodes error -match glob -result {*invalid character*}
test parseExpr-22.21 {Bug d2ffcca163} -constraints testexprparser -body {
- testexprparser inг(0) -1
+ testexprparser in\u0433(0) -1
} -returnCodes error -match glob -result {missing operand*}
-test parseExpr-23.1 {TIP 582: comments} -constraints testexprparser -body {
- testexprparser "7 # * 8 " -1
-} -result {- {} 0 subexpr 7 1 text 7 0 {}}
-test parseExpr-23.2 {TIP 582: comments} -constraints testexprparser -body {
- testexprparser "7 #\n* 8 " -1
-} -result {- {} 0 subexpr {7 #
-*} 5 operator # 0 subexpr 7 1 text 7 0 subexpr * 1 text * 0 {}}
-
# cleanup
cleanupTests
return