Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | say - Start on tests, and extended package to support output redirection, making the tests easier. |
---|---|
Timelines: | family | ancestors | descendants | both | say-more |
Files: | files | file ages | folders |
SHA1: |
2cc0a755b9d721668884f2a3e6bff215 |
User & Date: | andreask 2015-04-22 21:42:28.125 |
Context
2015-04-30
| ||
22:00 | More animations, extended the "operation" command with easy integration of animations, added examples. Added helper script "local" for easier execution of the examples without having cmdr::say installed. check-in: de4974db8f user: andreask tags: say-more | |
2015-04-22
| ||
21:42 | say - Start on tests, and extended package to support output redirection, making the tests easier. check-in: 2cc0a755b9 user: andreask tags: say-more | |
20:42 | Split the example file into many, and moved into the proper section. check-in: d1f3c1d5ee user: andreask tags: say-more | |
Changes
Changes to say.tcl.
︙ | ︙ | |||
37 38 39 40 41 42 43 | erase-screen erase-up erase-down \ erase-line erase-back erase-forw \ goto home line add line rewind lock-prefix clear-prefix \ next animate barberpole percent progress-counter progress \ operation \ \ auto-width barber-phases progress-phases larson-phases \ | | > > > > > > > > > > > > > > > > > > > | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | erase-screen erase-up erase-down \ erase-line erase-back erase-forw \ goto home line add line rewind lock-prefix clear-prefix \ next animate barberpole percent progress-counter progress \ operation \ \ auto-width barber-phases progress-phases larson-phases \ slider-phases pulse-phases \ \ to namespace ensemble create namespace import ::cmdr::color # State for "add", "lock-prefix", "clear-prefix", and "rewind" variable prefix {} variable pre {} # Channel to write to. Default is stdout. Mainly to allow # redirection during testing. variable to } # # ## ### ##### ######## ############# ##################### debug define cmdr/say debug level cmdr/say debug prefix cmdr/say {[debug caller] | } # # ## ### ##### ######## ############# ##################### ## output redirection proc ::cmdr::say::to {{chan {}}} { debug.cmdr/say {} variable to if {[llength [info level 0]] == 1} { return $chan } set to $chan return } # # ## ### ##### ######## ############# ##################### ## cursor movement proc ::cmdr::say::up {{n 1}} { debug.cmdr/say {} puts -nonewline stdout \033\[${n}A |
︙ | ︙ |
Added tests/say.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | # -*- tcl -*- tcl.tk//DSL tcltest//EN//2.0 # # ## ### ##### ######## ############# ##################### ## Testing the cmdr::say package. # # We are explicitly specifying the -width in all commands taking this # option and do not use widths < 0. This is done to avoid all code # paths actually requiring linenoise and interaction with the # terminal. # kt check Tcl 8.5 kt check tcltest 2 kt require support TclOO kt require support linenoise kt require support debug kt require support debug::caller kt local support cmdr::tty kt local support cmdr::color kt local testing cmdr::say # # ## ### ##### ######## ############# ##################### proc setup {} { cmdr say to [open TEST w] return } proc see {} { close [cmdr say to] cmdr say to {} set chan [open TEST rb] set d [read $chan] close $chan return $d } proc cleanup {} { cmdr say to {} return } # # ## ### ##### ######## ############# ##################### test cmdr-say-to-1.0 {to, wrong num args, too many} -body { cmdr say to C X } -returnCodes error \ -result {} # # ## ### ##### ######## ############# ##################### ## cursor movement foreach {n move response1 response2} { 0 up \033\[1A \033\[2A 1 down \033\[1B \033\[2B 2 forw \033\[1C \033\[2C 3 back \033\[1D \033\[2D } { test cmdr-say-${move}-1.0 "$move, wrong num args, too many" -body { cmdr say $move N X } -returnCodes error \ -result {} test cmdr-say-${move}-1.1 "$move, default" -body { cmdr say $move see } -setup setup -cleanup cleanup -result $response1 test cmdr-say-${move}-1.2 "$move, explicit" -body { cmdr say $move 2 see } -setup setup -cleanup cleanup -result $response2 } # # ## ### ##### ######## ############# ##################### ## erase screen # # ## ### ##### ######## ############# ##################### ## erase line # # ## ### ##### ######## ############# ##################### ## absolute moves # # ## ### ##### ######## ############# ##################### ## animations # # ## ### ##### ######## ############# ##################### cleanupTests return |