summaryrefslogtreecommitdiffstats
path: root/tests/compExpr.test
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2020-08-22 14:14:05 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2020-08-22 14:14:05 (GMT)
commit42a34d459e99c9e366e626e134d3e75e74e1f191 (patch)
tree65e81238673688720cb767c89c47f23c22dca5aa /tests/compExpr.test
parent5dfe6151b2c83fac63e73c24a45797c938c2fa5b (diff)
downloadtcl-42a34d459e99c9e366e626e134d3e75e74e1f191.zip
tcl-42a34d459e99c9e366e626e134d3e75e74e1f191.tar.gz
tcl-42a34d459e99c9e366e626e134d3e75e74e1f191.tar.bz2
Implementation of TIP 582: comments in expressions
Diffstat (limited to 'tests/compExpr.test')
-rw-r--r--tests/compExpr.test36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/compExpr.test b/tests/compExpr.test
index 3b44af8..8803f17 100644
--- a/tests/compExpr.test
+++ b/tests/compExpr.test
@@ -371,10 +371,46 @@ test compExpr-7.2 {[Bug 1869989]: expr parser memleak} -constraints memory -setu
unset end i tmp
rename getbytes {}
} -result 0
+
+proc extract {opcodes descriptor} {
+ set instructions [dict values [dict get $descriptor instructions]]
+ return [lmap i $instructions {
+ if {[lindex $i 0] in $opcodes} {string cat $i} else continue
+ }]
+}
+
+test compExpr-8.1 {TIP 582: expression comments} -setup {} -body {
+ extract {loadStk add} [tcl::unsupported::getbytecode script {expr {
+ $abc
+ # + $def
+ + $ghi
+ }}]
+} -result {loadStk loadStk add}
+test compExpr-8.2 {TIP 582: expression comments} -setup {} -body {
+ extract {loadStk add} [tcl::unsupported::getbytecode script {expr {
+ $abc
+ # + $def
+ # + $ghi }}]
+} -result loadStk
+test compExpr-8.3 {TIP 582: expression comments} -setup {} -body {
+ extract {loadStk add} [tcl::unsupported::getbytecode script {expr {
+ $abc
+ # + $def\
+ + $ghi
+ }}]
+} -result loadStk
+test compExpr-8.4 {TIP 582: expression comments} -setup {} -body {
+ extract {loadStk add} [tcl::unsupported::getbytecode script {expr {
+ $abc
+ # + $def\\
+ + $ghi
+ }}]
+} -result {loadStk loadStk add}
# cleanup
catch {unset a}
catch {unset b}
+catch {rename extract ""}
::tcltest::cleanupTests
return