aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/expr-base.test39
-rw-r--r--tests/expr-new.test8
-rw-r--r--tests/expr-old.test2
-rw-r--r--tests/jim.test10
-rw-r--r--tests/lsort.test4
-rw-r--r--tests/scan.test4
-rw-r--r--tests/string.test2
7 files changed, 54 insertions, 15 deletions
diff --git a/tests/expr-base.test b/tests/expr-base.test
new file mode 100644
index 0000000..5c9e1da
--- /dev/null
+++ b/tests/expr-base.test
@@ -0,0 +1,39 @@
+source [file dirname [info script]]/testing.tcl
+
+# Test number detection
+set good_testcases {
+ 0 0
+ 1 1
+ 8 8
+ 00 0
+ 07 7
+ 08 8
+ 0x5 5
+ 0x0 0
+ 0x00 0
+ -0x5 -5
+ 0b111 7
+ -0b111 -7
+ -0B101 -5
+ 0o7 7
+}
+
+set i 0
+foreach {str exp} $good_testcases {
+ test expr-base-1.[incr i] "expr conversion" [list expr [list $str]] $exp
+}
+
+set bad_testcases {
+ {0x + 1}
+ x
+ 0xx5
+ 0x-5
+ {0x 5}
+ {0o8 + 1}
+}
+
+set i 0
+foreach str $bad_testcases {
+ test expr-base-2.[incr i] "expr conversion failure" -returnCodes error -body [list expr $str] -match glob -result "*"
+}
+testreport
diff --git a/tests/expr-new.test b/tests/expr-new.test
index 1130eb1..e3c4378 100644
--- a/tests/expr-new.test
+++ b/tests/expr-new.test
@@ -294,7 +294,7 @@ test expr-9.10 {CompileRelationalExpr: error compiling relational arm} {
test expr-10.1 {CompileShiftExpr: just add expr} {expr 4+-2} 2
test expr-10.2 {CompileShiftExpr: just add expr} {expr 0xff-2} 253
test expr-10.3 {CompileShiftExpr: just add expr} {expr -1--2} 1
-test expr-10.4 {CompileShiftExpr: just add expr} {expr 1-0123} -82
+test expr-10.4 {CompileShiftExpr: just add expr} {expr 1-0123} -122
test expr-10.5 {CompileShiftExpr: error in add expr} {
catch {expr x+3} msg
} {1}
@@ -316,7 +316,7 @@ test expr-10.11 {CompileShiftExpr: runtime error} {
test expr-11.1 {CompileAddExpr: just multiply expr} {expr 4*-2} -8
test expr-11.2 {CompileAddExpr: just multiply expr} {expr 0xff%2} 1
test expr-11.3 {CompileAddExpr: just multiply expr} {expr -1/2} -1
-test expr-11.4 {CompileAddExpr: just multiply expr} {expr 7891%0123} 6
+test expr-11.4 {CompileAddExpr: just multiply expr} {expr 7891%0123} 19
test expr-11.5 {CompileAddExpr: error in multiply expr} {
catch {expr x*3} msg
} {1}
@@ -367,7 +367,7 @@ test expr-12.11 {CompileMultiplyExpr: runtime error} {
} {1}
test expr-13.1 {CompileUnaryExpr: unary exprs} {expr -0xff} -255
-test expr-13.2 {CompileUnaryExpr: unary exprs} {expr +000123} 83
+test expr-13.2 {CompileUnaryExpr: unary exprs} {expr +000123} 123
test expr-13.3 {CompileUnaryExpr: unary exprs} {expr +--++36} 36
test expr-13.4 {CompileUnaryExpr: unary exprs} {expr !2} 0
test expr-13.5 {CompileUnaryExpr: unary exprs} {expr +--+-62.0} -62.0
@@ -400,7 +400,7 @@ test expr-13.16 {CompileUnaryExpr: error in primary expr} {
test expr-14.1 {CompilePrimaryExpr: literal primary} {expr 1} 1
test expr-14.2 {CompilePrimaryExpr: literal primary} {expr 123} 123
test expr-14.3 {CompilePrimaryExpr: literal primary} {expr 0xff} 255
-test expr-14.4 {CompilePrimaryExpr: literal primary} {expr 00010} 8
+test expr-14.4 {CompilePrimaryExpr: literal primary} {expr 00010} 10
test expr-14.5 {CompilePrimaryExpr: literal primary} {expr 62.0} 62.0
test expr-14.6 {CompilePrimaryExpr: literal primary} {
expr 3.1400000
diff --git a/tests/expr-old.test b/tests/expr-old.test
index c5deb0e..b1d722d 100644
--- a/tests/expr-old.test
+++ b/tests/expr-old.test
@@ -375,7 +375,7 @@ test expr-old-23.8 {double quotes} {
# Numbers in various bases.
test expr-old-24.1 {numbers in different bases} {expr 0x20} 32
-test expr-old-24.2 {numbers in different bases} {expr 015} 13
+test expr-old-24.2 {numbers in different bases} {expr 015} 15
# Conversions between various data types.
diff --git a/tests/jim.test b/tests/jim.test
index de675f2..e8c125e 100644
--- a/tests/jim.test
+++ b/tests/jim.test
@@ -159,9 +159,9 @@ test set-1.22 {TclCompileSetCmd: doing assignment, large int} {
test set-1.23 {TclCompileSetCmd: doing assignment, formatted int != int} {
set i 25
- set i 000012345 ;# an octal literal == 5349 decimal
+ set i 000012345 ;# a decimal literal == 5349 decimal
list $i [incr i]
-} {000012345 5350}
+} {000012345 12346}
################################################################################
# LIST
@@ -1268,8 +1268,8 @@ test incr-1.22 {TclCompileIncrCmd: increment given, large int} {
} 200005
test incr-1.23 {TclCompileIncrCmd: increment given, formatted int != int} {
set i 25
- incr i 000012345 ;# an octal literal
-} 5374
+ incr i 000012345 ;# a decimal literal
+} 12370
test incr-1.24 {TclCompileIncrCmd: increment given, formatted int != int} {
set i 25
catch {incr i 1a} msg
@@ -1488,7 +1488,7 @@ test incr-2.23 {incr command (not compiled): increment given, formatted int != i
set z incr
set i 25
$z i 000012345 ;# an octal literal
-} 5374
+} 12370
test incr-2.24 {incr command (not compiled): increment given, formatted int != int} {
set z incr
set i 25
diff --git a/tests/lsort.test b/tests/lsort.test
index a01b14f..ad28b6e 100644
--- a/tests/lsort.test
+++ b/tests/lsort.test
@@ -145,7 +145,7 @@ test lsort-3.10 {SortCompare procedure, -integer option} {
} {1 {expected integer but got "q"}}
test lsort-3.11 {SortCompare procedure, -integer option} {
lsort -integer {35 21 0x20 30 023 100 8}
-} {8 023 21 30 0x20 35 100}
+} {8 21 023 30 0x20 35 100}
test lsort-3.15 {SortCompare procedure, -command option} {
proc cmp {a b} {
error "comparison error"
@@ -172,7 +172,7 @@ test lsort-3.18 {SortCompare procedure, -command option} {
} {48 36 35 22 21 18 6}
test lsort-3.19 {SortCompare procedure, -decreasing option} {
lsort -decreasing -integer {35 21 0x20 30 023 100 8}
-} {100 35 0x20 30 21 023 8}
+} {100 35 0x20 30 023 21 8}
test lsort-4.26 {DefaultCompare procedure, signed characters} utf8 {
set l [lsort [list "abc\u80" "abc"]]
diff --git a/tests/scan.test b/tests/scan.test
index 8bfcbe8..2267d22 100644
--- a/tests/scan.test
+++ b/tests/scan.test
@@ -247,11 +247,11 @@ test scan-4.40.2 {Tcl_ScanObjCmd, base-16 integer scanning} {
test scan-4.41 {Tcl_ScanObjCmd, base-unknown integer scanning} {
set x {}
list [scan {10 010 0x10} {%i%i%i} x y z] $x $y $z
-} {3 10 8 16}
+} {3 10 10 16}
test scan-4.42 {Tcl_ScanObjCmd, base-unknown integer scanning} {
set x {}
list [scan {10 010 0X10} {%i%i%i} x y z] $x $y $z
-} {3 10 8 16}
+} {3 10 10 16}
test scan-4.43 {Tcl_ScanObjCmd, integer scanning, odd cases} {
set x {}
list [scan {+ } {%i} x] $x
diff --git a/tests/string.test b/tests/string.test
index 9b9b9f4..5b0bbeb 100644
--- a/tests/string.test
+++ b/tests/string.test
@@ -336,7 +336,7 @@ test string-6.57 {string is integer, false} {
} 0
test string-6.58 {string is integer, false on bad octal} {
list [string is integer 036963]
-} 0
+} 1
test string-6.59 {string is integer, false on bad hex} {
list [string is integer 0X345XYZ]
} 0