}
test html-27.5 {html::foreach--multiple vars, multiple iterations} {
html::foreach {x y} {a b c d} {
$x
$y
}
} {
a
b
c
d
}
test html-27.6 {html::foreach--multiple varlists and vallists} {
html::foreach {a b} {1 2 3 4} {c d} {5 6 7 8} {e f} {9 10 11 12} {
$a$b$c$d$e$f}
} {
1256910
34781112}
test html-27.7 {html::foreach--subst body w/ vars and procs} {
html::foreach x {2 8} {
$x
[incr x]
}
} {
2
3
8
9
}
test html-27.8 {html::foreach--subst body w/ nested foreach} {
html::foreach x {a b} {
[html::foreach y {c d} {$x$y}]
}
} {
acad
bcbd
}
test html-27.9 {html::foreach--subst body w/ multiple nested foreach's} {
html::foreach x {a b} {
[html::foreach y {c d} {$x$y
[html::foreach z {e f} {$z}]
}]}
} {
ac
ef
ad
ef
bc
ef
bd
ef
}
test html-28.1 {html::for--1 iteration} {
html::for {set i 0} {$i < 1} {incr i} {
$i
}
} {
0
}
test html-28.2 {html::for--multiple iterations} {
html::for {set i 0} {$i < 3} {incr i} {
$i
}
} {
0
1
2
}
test html-28.3 {html::for--0 iterations} {
html::for {set i 0} {$i < 0} {incr i} {
$i
}
} {}
test html-28.4 {html::for--complex start, text, and next} {
html::for {set i 0; set j 10} {$i < 1 && $j < 11} {incr i; incr j} {$i $j}
} {0 10}
test html-28.5 {html::for--subst body w/ vars and procs} {
html::for {set i 0} {$i < 3} {incr i} {$i [expr {$i + 5}] }
} {0 5 1 6 2 7 }
test html-28.6 {html::for--subst body w/ nested for} {
set result [html::for {set i 0} {$i < 3} {incr i} {
[html::for {set j $i} {$j < 3} {incr j} {${i}__${j} }]
}]
regsub -all "\n" $result " " result
regsub -all " +" $result " " result
set result
} { 0__0 0__1 0__2 1__1 1__2 2__2 }
test html-28.7 {html::for--subst body w/ multiple nested for's} {
set result [html::for {set i 0} {$i < 3} {incr i} {
[html::for {set j $i} {$j < 3} {incr j} {
[html::for {set k $j} {$k < 3} {incr k} {${i}__${j}__${k} }]
}]
}]
regsub -all "\n" $result " " result
regsub -all " +" $result " " result
set result
} { 0__0__0 0__0__1 0__0__2 0__1__1 0__1__2 0__2__2 1__1__1 1__1__2 1__2__2 2__2__2 }
test html-29.1 {html::while--1 iteration} {
set i 0
html::while {$i < 1} {
$i, [incr i]
}
} {
0, 1
}
test html-29.2 {html::while--multiple iterations} {
set i 0
html::while {$i < 3} {
$i, [incr i]
}
} {
0, 1
1, 2
2, 3
}
test html-29.3 {html::while--0 iterations} {
set i 0
html::while {$i < 0} {
$i
}
} {}
test html-29.4 {html::while--complex start, text, and next} {
set i 0
set j 10
html::while {$i < 1 && $j < 11} {$i $j, [incr i] [incr j]}
} {0 10, 1 11}
test html-29.5 {html::while--subst body w/ nested while} {
set i 0
set result [html::while {$i < 3} {
[set j $i]
[html::while {$j < 3} {
${i}__${j}
[incr j]
}]
[incr i]
}]
regsub -all "\n" $result " " result
regsub -all " +" $result " " result
set result
} { 0 0__0 1 0__1 2 0__2 3 1 1 1__1 2 1__2 3 2 2 2__2 3 3 }
test html-29.7 {html::while--subst body w/ multiple nested while's} {
set i 0
set result [html::while {$i < 3} {
[set j $i]
[html::while {$j != 3} {
[set k $j]
[html::while {$k != 3} {
${i}__${j}__${k}
[incr k]
}]
[incr j]
}]
[incr i]
}]
regsub -all "\n" $result " " result
regsub -all " +" $result " " result
set result
} { 0 0 0__0__0 1 0__0__1 2 0__0__2 3 1 1 0__1__1 2 0__1__2 3 2 2 0__2__2 3 3 1 1 1 1__1__1 2 1__1__2 3 2 2 1__2__2 3 3 2 2 2 2__2__2 3 3 3 }
test html-30.1 {html::if--eval then clause} {
set i 0
html::if {$i < 1} {$i, [incr i]}
} {0, 1}
test html-30.2 {html::if--don't eval then clause} {
set i 0
html::if {$i == 1} {$i, [incr i]}
} {}
test html-30.3 {html::if--eval else clause} {
set i 0
html::if {$i == 1} {then clause} else {$i, [incr i]}
} {0, 1}
test html-30.4 {html::if--1 elseif clause, eval else cause} {
set i 0
html::if {$i < 0} {
then clause
} elseif {$i == 1} {
elseif clause
} else {$i, [incr i]}
} {0, 1}
test html-30.5 {html::if--1 elseif clause, eval elseif cause} {
set i 0
html::if {$i < 0} {
then clause
} elseif {$i == 0} {$i, [incr i]}
} {0, 1}
test html-30.6 {html::if--1 elseif clause, eval elseif cause} {
set i 0
html::if {$i < 0} {
then clause
} elseif {$i == 1} {
$i, [incr i]
}
} {}
test html-30.7 {html::if--1 elseif clause, eval elseif cause} {
set i 0
html::if {$i < 0} {
then clause
} elseif {$i == 0} {$i, [incr i]} else {
else clause
}
} {0, 1}
test html-30.8 {html::if--1 elseif clause, eval elseif cause} {
set i 0
html::if {$i < 0} {
then clause
} elseif {$i == 1} {
elseif1 clause
} elseif {$i == 0} {$i, [incr i]} elseif {$i == 2} {
elseif3 clause
} else {
else clause
}
} {0, 1}
test html-30.9 {html::if--1 elseif clause, eval elseif cause} {
set i 0
html::if {$i < 0} {
then clause
} elseif {$i == 1} {
elseif3 clause
} elseif {$i == 2} {
elseif1 clause
} elseif {$i == 0} {$i, [incr i]} else {
else clause
}
} {0, 1}
test html-30.10 {html::if--multiple nested} {
set i 0
set result [html::if {$i < 1} {
begin1
[html::if {$i > -1} {
begin2
[html::if {$i == 0} {
begin3
[html::if {$i} {4}]
end3
}]
end2
}]
end1
}]
regsub -all "\n" $result " " result
regsub -all " +" $result " " result
set result
} { begin1 begin2 begin3 end3 end2 end1 }
test html-31.1 {html::set--set a new variable} {
set result [html::set x 1]
list $result $x
} {{} 1}
test html-31.2 {html::set--set an existing variable} {
set x 0
set result [html::set x 1]
list $result $x
} {{} 1}
test html-32.1 {single argument} {
set x 0
set result [html::eval {set x [format 22]}]
list $result $x
} {{} 22}
test html-32.2 {multiple arguments} {
set a {$b}
set b xyzzy
set x 0
set result [html::eval {set x [eval format $a]}]
list $result $x
} {{} xyzzy}
test html-32.3 {single argument} {
set x [list]
set y 1
set result [html::eval lappend x a b c d {$y} e f g]
list $result $x
} {{} {a b c d 1 e f g}}
test html-32.4 {error: not enough arguments} -body {
html::eval
} -returnCodes error -result {wrong # args: should be "uplevel ?level? command ?arg ...?"}
test html-32.6 {error in eval'ed command} -body {
html::eval {error "test error"}
} -returnCodes error -result {test error}
test html-33.0 {html::font} -body {
html::font
} -result {}
test html-33.1 {html::font} -body {
html::font size=18
} -result {}
test html-34.0 {html::nl2br} -body {
html::nl2br "a\n\rb\nc\rd"
} -result {a b c d}
test html-34.1 {html::nl2br, ticket 1742078} -body {
html::nl2br "a\r\nb"
} -result {a b}
# -------------------------------------------------------------------------
test html-tkt3439702-35.0 {html::css, not enough arguments} -body {
html::css
} -returnCodes error -result {wrong # args: should be "html::css href"}
test html-tkt3439702-35.1 {html::css, too many arguments} -body {
html::css REF X
} -returnCodes error -result {wrong # args: should be "html::css href"}
test html-tkt3439702-35.2 {html::css, single ref} -setup {
html::css-clear
} -body {
html::css "http://test.css"
string trim [html::head T]
} -cleanup {
html::css-clear
} -result "\n\tT\n\t\n\t\n"
test html-tkt3439702-35.3 {html::css, multiple ref} -setup {
html::css-clear
} -body {
html::css "http://test1.css"
html::css "http://test2.css"
string trim [html::head T]
} -cleanup {
html::css-clear
} -result {
T
}
# -------------------------------------------------------------------------
test html-tkt3439702-36.0 {html::js, not enough arguments} -body {
html::js
} -returnCodes error -result {wrong # args: should be "html::js href"}
test html-tkt3439702-36.1 {html::js, too many arguments} -body {
html::js REF X
} -returnCodes error -result {wrong # args: should be "html::js href"}
test html-tkt3439702-36.2 {html::js, single ref} -setup {
html::js-clear
} -body {
html::js "http://test.js"
string trim [html::head T]
} -cleanup {
html::js-clear
} -result {
T
}
test html-tkt3439702-36.3 {html::js, multiple ref} -setup {
html::js-clear
} -body {
html::js "http://test1.js"
html::js "http://test2.js"
string trim [html::head T]
} -cleanup {
html::js-clear
} -result {
T
}
test html-tkt3439702-37.0 {html::js, html::css, mixed} -setup {
html::css-clear
html::js-clear
} -body {
html::css "http://test.css"
html::js "http://test.js"
string trim [html::head T]
} -cleanup {
html::js-clear
html::css-clear
} -result {
T
}
# -------------------------------------------------------------------------
# TODO: html::css-clear, html::js-clear
test html-tkt-afe4366e2e-38.0 {html::doctype, not enough args} -body {
html::doctype
} -returnCodes error -result {wrong # args: should be "html::doctype arg"}
test html-tkt-afe4366e2e-38.1 {html::doctype, too many args} -body {
html::doctype HTML401T X
} -returnCodes error -result {wrong # args: should be "html::doctype arg"}
test html-tkt-afe4366e2e-38.2 {html::doctype, unknown type} -body {
html::doctype HTML401TXXX
} -returnCodes error -result {Unknown doctype "HTML401TXXX"}
test html-tkt-afe4366e2e-38.3 {html::doctype} -body {
html::doctype HTML401T
} -result {}
# -------------------------------------------------------------------------
test html-tkt-1076403-39.0 {html::wrapTag, not enough args} -body {
html::wrapTag
} -returnCodes error -result [tcltest::wrongNumArgs html::wrapTag {tag ?text? args} 0]
test html-tkt-1076403-39.1 {html::wrapTag, tag alone} -body {
html::wrapTag p
} -result {}
test html-tkt-1076403-39.2 {html::wrapTag, tag and text} -body {
html::wrapTag p "test"
} -result {
test
}
test html-tkt-1076403-39.3 {html::wrapTag, tag, text, and attribute} -body {
html::wrapTag p "test" align left
} -result {
test
}
test html-tkt-1076403-39.4 {html::wrapTag, tag, text, and attributes} -body {
html::wrapTag pre "test" align left width 20
} -result {