package require substify tcltest::test substify-1.1 "Handle default escaping for <% %> tags" -body { subst [substify::substify {Test is <%expr {1+1}%>} "<%" "%>"] } -result {Test is 2} tcltest::test substify-1.2 "Handle complex command when escaping for <% %> tags" -body { subst [substify::substify {Test is <%set id 2; expr {$id+1}%>} "<%" "%>"] } -result {Test is 3} tcltest::test substify-1.3 "Handle variables for <% %> tags" -body { set id 4 subst [substify::substify {Test is <%=$id%>} "<%" "%>"] } -result {Test is 4} tcltest::test substify-2.1 "Test various characters outside scoping" -body { set res "" for {set c 0} {$c < 65536} {incr c} { set str [format "String %c%c%c" $c $c $c] if {![string equal [subst [substify::substify "$str <%expr {1}%>" "<%" "%>"]] "$str 1"]} { append res " $c" } } set res } -result {} tcltest::test substify-2.2 "Test various characters inside scoping" -body { set res "" for {set c 0} {$c < 65536} {incr c} { set str [format "String %c%c%c" $c $c $c] if {![string equal [subst [substify::substify "<%format %s [list $str]%>" "<%" "%>"]] "$str"]} { append res " $c" } } set res } -result {} tcltest::test substify-2.3 "Test various characters as scoping" -body { set res "" for {set c 0} {$c < 65536} {incr c} { set ch [format %c%c $c $c] if {![string equal [subst [substify::substify "<${ch}expr 1${ch}>" "<${ch}" "${ch}>"]] "1"]} { append res " $c" } } set res } -result {}