Annotation For example/main.tcl

Lines of example/main.tcl from check-in aa08a4a749 that are changed by the sequence of edits moving toward check-in 5583d77f1c:

aa08a4a749 2019-09-14    1: set file "//xvfs:/example/foo"
                         2: 
                         3: set fd [open $file]
                         4: seek $fd 0 end
                         5: seek $fd -1 current
                         6: set check [read $fd 1]
                         7: if {$check != "\n"} {
                         8: 	error "EXPECTED: (new line); GOT: [binary encode hex $check]"
                         9: }
                        10: close $fd
                        11: 
                        12: set fd1 [open $file]
                        13: set fd2 [open $file]
                        14: set data1 [read $fd1]
                        15: close $fd1
                        16: set data2 [read $fd2]
                        17: close $fd2
                        18: if {$data1 != $data2} {
                        19: 	error "EXPECTED match, differs"
                        20: }
                        21: 
                        22: set fd [open $file]
                        23: seek $fd 0 end
                        24: set size [tell $fd]
                        25: close $fd
                        26: set fd [open $file]
                        27: set done false
                        28: set calls 0
                        29: set output ""
                        30: fileevent $fd readable [list apply {{fd} {
                        31: 	set pos [tell $fd]
                        32: 	set x [read $fd 1]
                        33: 	if {[string length $x] == 0} {
                        34: 		set ::done true
                        35: 		fileevent $fd readable ""
                        36: 	}
                        37: 
                        38: 	lappend ::output $pos
                        39: 	incr ::calls
                        40: }} $fd]
                        41: vwait done
                        42: if {$calls != ($size + 1)} {
                        43: 	error "EXPECTED [expr {$size + 1}], got $calls"
                        44: }
                        45: if {[lsort -integer $output] != $output} {
                        46: 	error "EXPECTED [lsort -integer $output], GOT $output"
                        47: }
                        48: close $fd
                        49: update idle
                        50: 
                        51: puts "ALL TESTS PASSED"