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