summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/basic.test26
-rw-r--r--tests/dict.test8
-rw-r--r--tests/lindex.test25
-rw-r--r--tests/listObj.test7
-rw-r--r--tests/llength.test13
5 files changed, 79 insertions, 0 deletions
diff --git a/tests/basic.test b/tests/basic.test
index e072bea..8054dbc 100644
--- a/tests/basic.test
+++ b/tests/basic.test
@@ -656,18 +656,38 @@ test basic-47.2.$noComp {Tcl_EvalEx: error during word expansion} -body {
run {{*}\{}
} -constraints $constraints -returnCodes error -result {unmatched open brace in list}
+test basic-47.2.$noComp.2 {Tcl_EvalEx: no error for non-list comment word} -body {
+ run {{#}\{}
+} -constraints $constraints
+
test basic-47.3.$noComp {Tcl_EvalEx, error during substitution} -body {
run {{*}[error foo]}
} -constraints $constraints -returnCodes error -result foo
+test basic-47.3.$noComp.2 {Tcl_EvalEx, error during substitution} -body {
+ run {{#}[error foo]}
+} -constraints $constraints -returnCodes error -result foo
+
test basic-47.4.$noComp {Tcl_EvalEx: no expansion} $constraints {
run {list {*} {*} {*}}
} {* * *}
+test basic-47.4.$noComp.2 {Tcl_EvalEx: not comment words} $constraints {
+ run {list {#} {#} {#}}
+} [list \# \# \#]
+
test basic-47.5.$noComp {Tcl_EvalEx: expansion} $constraints {
run {list {*}{} {*} {*}x {*}"y z"}
} {* x y z}
+test basic-47.5.$noComp.2 {Tcl_EvalEx: word comments} $constraints {
+ run {list {#}{} {#} {#}x {#}"y z"}
+} [list \#]
+
+test basic-47.5.$noComp.3 {Tcl_EvalEx: expansion/comment mix} $constraints {
+ run {list a {*}b {#}{c} {*} d {#}e {#}f\ g {*}h\ i {*}"j k" l}
+} {a b * d h i j k l}
+
test basic-47.6.$noComp {Tcl_EvalEx: expansion to zero args} $constraints {
run {list {*}{}}
} {}
@@ -686,6 +706,12 @@ test basic-47.9.$noComp {Tcl_EvalEx: expansion and subst order} $constraints {
{*}[list [incr x] [incr x]] [incr x]}
} {1 2 3 4 5 6}
+test basic-47.9.$noComp.2 {Tcl_EvalEx: word comment and subst order} $constraints {
+ set x 0
+ run {list [incr x] {#}[incr x] [incr x] \
+ {#}[list [incr x] [incr x]] [incr x]}
+} {1 3 6}
+
test basic-47.10.$noComp {Tcl_EvalEx: expand and memory management} $constraints {
run {concat {*}{} a b c d e f g h i j k l m n o p q r}
} {a b c d e f g h i j k l m n o p q r}
diff --git a/tests/dict.test b/tests/dict.test
index 5277cf6..695072b 100644
--- a/tests/dict.test
+++ b/tests/dict.test
@@ -122,6 +122,14 @@ test dict-3.15 {compiled dict get error cleanliness - Bug 2431847} -body {
} -returnCodes error -result {key "d" not known in dictionary}
test dict-3.16 {dict/list shimmering - Bug 3004007} {set l [list p 1 p 2 q 3];dict get $l q;set l} {p 1 p 2 q 3}
test dict-3.17 {dict/list shimmering - Bug 3004007} {set l [list p 1 p 2 q 3];dict get $l q;llength $l} 6
+test dict-3.18 {dict get command, comment words} -body {
+ dict get {
+ {#}"First heading"
+ key1 value1
+ {#}"Second heading" {#}{extra comment}
+ key2 {#}nothing value2
+ }
+} -result {key1 value1 key2 value2}
test dict-4.1 {dict replace command} {
dict replace {a b c d}
diff --git a/tests/lindex.test b/tests/lindex.test
index 07abff8..64c8fc5 100644
--- a/tests/lindex.test
+++ b/tests/lindex.test
@@ -130,6 +130,8 @@ test lindex-5.3 {three indices} testevalex {
testevalex {lindex {{{a b} {c d}} {{e f} {g h}}} 1 0 1}
} f
+# List parsing
+
test lindex-6.1 {error conditions in parsing list} testevalex {
list [catch {testevalex {lindex "a \{" 2}} msg] $msg
} {1 {unmatched open brace in list}}
@@ -341,6 +343,8 @@ test lindex-13.3 {three indices} {
set result
} f
+# List parsing
+
test lindex-14.1 {error conditions in parsing list} {
list [catch { lindex "a \{" 2 } msg] $msg
} {1 {unmatched open brace in list}}
@@ -350,6 +354,9 @@ test lindex-14.2 {error conditions in parsing list} {
test lindex-14.3 {error conditions in parsing list} {
list [catch { lindex {a "b c"def ghi} 2 } msg] $msg
} {1 {list element in quotes followed by "def" instead of space}}
+test lindex-14.4 {error conditions in parsing list} {
+ list [catch { lindex {a {#}"b c"def ghi} 2 } msg] $msg
+} {1 {list element in quotes followed by "def" instead of space}}
test lindex-15.1 {quoted elements} {
catch {
@@ -375,6 +382,24 @@ test lindex-15.4 {quoted elements} {
} result
set result
} {c d "e}
+test lindex-15.5 {comment words} {
+ catch {
+ lindex {a {#}b c d} 1
+ } result
+ set result
+} {c}
+test lindex-15.6 {comment words} {
+ catch {
+ lindex {a {#}"b c" d} 1
+ } result
+ set result
+} {d}
+test lindex-15.7 {comment words} {
+ catch {
+ lindex {{#}a "b c" {#}d} 0
+ } result
+ set result
+} {b c}
test lindex-16.1 {data reuse} {
set x 0
diff --git a/tests/listObj.test b/tests/listObj.test
index 53017b1..046df09 100644
--- a/tests/listObj.test
+++ b/tests/listObj.test
@@ -107,6 +107,10 @@ test listobj-5.8 {Tcl_ListObjIndex, error in conversion} {
set x " \{"
list [catch {lindex $x 0} msg] $msg
} {1 {unmatched open brace in list}}
+test listobj-5.9 {Tcl_ListObjIndex, error in conversion} {
+ set x " {#}{a b}c "
+ list [catch {lindex $x 0} msg] $msg
+} {1 {list element in braces followed by "c" instead of space}}
test listobj-6.1 {Tcl_ListObjLength} {
llength {a b c d}
@@ -170,6 +174,9 @@ test listobj-7.13 {Tcl_ListObjReplace, grow array, insert at end} {
test listobj-8.1 {SetListFromAny} {
lindex {0 foo\x00help 2} 1
} "foo\x00help"
+test listobj-8.2 {SetListFromAny, comment} {
+ lindex {0 {#}foo\ help 2} 1
+} 2
test listobj-9.1 {UpdateStringOfList} {
string length [list foo\x00help]
diff --git a/tests/llength.test b/tests/llength.test
index 169c7ca..77e167b 100644
--- a/tests/llength.test
+++ b/tests/llength.test
@@ -25,6 +25,19 @@ test llength-1.2 {length of list} {
test llength-1.3 {length of list} {
llength {}
} 0
+test llength-1.4 {length of list with comment word} {
+ llength {a b {#}c d}
+} 3
+test llength-1.5 {length of list with comment word} {
+ llength {a {#}"b c" d}
+} 2
+test llength-1.6 {length of list with comment words} {
+ llength {{#}{a b} c {#}\ d}
+} 1
+test llength-1.7 {length of list with comment words only} {
+ llength {{#}"a b" {#}c {#}{d}}
+} 0
+
test llength-2.1 {error conditions} {
list [catch {llength} msg] $msg