basic future tests
[scpubgit/TenDotTcl.git] / t / future.t
CommitLineData
15e006dc 1BEGIN { exec(tclsh => 't/tcl/harness.tcl' => $0) }
2
3package require ten
4
5ten::future f1
6
7ok {![f1 is_ready]} "Future not yet ready"
8
9set ready_args ""
10set done_args ""
11
b0dd2971 12f1 on_ready [list set "[namespace current]::ready_args"]
15e006dc 13
b0dd2971 14f1 on_done [list set "[namespace current]::done_args"]
15e006dc 15
16f1 done foo bar
17
18ok {[f1 is_ready]} "Future ready"
19
b0dd2971 20is $ready_args {::f1} "Future passed to ready"
21
22cmp_ok == [llength $done_args] 2 "Both args passed to done"
23
24is [lindex $done_args 0] foo "Right first arg"
25
26is [lindex $done_args 1] bar "Right second arg"
27
28is [f1 get] "foo bar" "get return ok"
29
15e006dc 30done_testing