~ubuntu-branches/ubuntu/raring/tcl8.5/raring

« back to all changes in this revision

Viewing changes to tests/ioCmd.test

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2007-12-25 16:10:04 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20071225161004-zr4n8bj42nh1ybll
Tags: 8.5.0-2
Again disabled stack checking on hppa architecture since it doesn't
work yet.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
# See the file "license.terms" for information on usage and redistribution
14
14
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
15
15
#
16
 
# RCS: @(#) $Id: ioCmd.test,v 1.32 2007/11/19 14:22:26 dkf Exp $
 
16
# RCS: @(#) $Id: ioCmd.test,v 1.35 2007/12/13 15:26:06 dgp Exp $
17
17
 
18
18
if {[lsearch [namespace children] ::tcltest] == -1} {
19
19
    package require tcltest 2
761
761
proc note  {item}  {global res; lappend res $item; return}
762
762
proc track {}      {upvar args item; note $item; return}
763
763
proc notes {items} {foreach i $items {note $i}}
 
764
# This forces the return options to be in the order that the test expects!
 
765
proc noteOpts opts {global res; lappend res [dict merge {
 
766
    -code !?! -level !?! -errorcode !?! -errorline !?! -errorinfo !?!
 
767
} $opts]; return}
764
768
 
765
769
# Helper command, canned result for 'initialize' method.
766
770
# Gets the optional methods as arguments. Use return features
858
862
    rename foo {}
859
863
    set res
860
864
} -result {{initialize rc* {read write}} rc* {finalize rc*} 1 *bad code*}
861
 
test iocmd-22.9 {chan finalize, for close, ignore level, close error} -match glob -body {
 
865
test iocmd-22.9 {chan finalize, for close, ignore level, close error} -match glob -setup {
862
866
    set res {}
 
867
} -body {
863
868
    proc foo {args} {track; oninit; return -level 5 -code 777 BANG}
864
869
    note [set c [chan create {r w} foo]]
865
 
    note [catch {close $c} msg opt]; note $msg; note $opt
 
870
    note [catch {close $c} msg opt]; note $msg; noteOpts $opt
 
871
    return $res
 
872
} -cleanup {
866
873
    rename foo {}
867
 
    set res
868
874
} -result {{initialize rc* {read write}} rc* {finalize rc*} 1 *bad code* {-code 1 -level 0 -errorcode NONE -errorline 1 -errorinfo *bad code*subcommand "finalize"*}}
869
875
 
870
876
# --- === *** ###########################
960
966
        return -level 55 -code 777 BOOM!
961
967
    }
962
968
    set c [chan create {r w} foo]
963
 
    note [catch {read $c 2} msg opt]; note $msg; note $opt
 
969
    note [catch {read $c 2} msg opt]; note $msg; noteOpts $opt
964
970
    close $c
965
971
    rename foo {}
966
972
    set res
1100
1106
    set c [chan create {r w} foo]
1101
1107
    note [catch {puts -nonewline $c snarfsnarfsnarf; flush $c} msg opt]
1102
1108
    note $msg
1103
 
    note $opt
 
1109
    noteOpts $opt
1104
1110
    close $c
1105
1111
    rename foo {}
1106
1112
    set res
1218
1224
        return -level 55 -code 777 BANG
1219
1225
    }
1220
1226
    set c [chan create {r w} foo]
1221
 
    note [catch {fconfigure $c} msg opt]; note $msg; note $opt
 
1227
    note [catch {fconfigure $c} msg opt]; note $msg; noteOpts $opt
1222
1228
    close $c
1223
1229
    rename foo {}
1224
1230
    set res
1302
1308
        return -level 55 -code 444 BANG
1303
1309
    }
1304
1310
    set c [chan create {r w} foo]
1305
 
    note [catch {fconfigure $c -rc-foo bar} msg opt]; note $msg; note $opt
 
1311
    note [catch {fconfigure $c -rc-foo bar} msg opt]; note $msg; noteOpts $opt
1306
1312
    close $c
1307
1313
    rename foo {}
1308
1314
    set res
1375
1381
        return -level 77 -code 333 BANG
1376
1382
    }
1377
1383
    set c [chan create {r w} foo]
1378
 
    note [catch {fconfigure $c -rc-foo} msg opt]; note $msg; note $opt
 
1384
    note [catch {fconfigure $c -rc-foo} msg opt]; note $msg; noteOpts $opt
1379
1385
    close $c
1380
1386
    rename foo {}
1381
1387
    set res
1433
1439
    set res {}
1434
1440
    proc foo {args} {oninit seek; onfinal; track; return -level 11 -code 222 BANG}
1435
1441
    set c [chan create {r w} foo]
1436
 
    note [catch {tell $c} msg opt]; note $msg; note $opt
 
1442
    note [catch {tell $c} msg opt]; note $msg; noteOpts $opt
1437
1443
    close $c
1438
1444
    rename foo {}
1439
1445
    set res
1514
1520
    set res {}
1515
1521
    proc foo {args} {oninit seek; onfinal; track; return -level 33 -code 99 BANG}
1516
1522
    set c [chan create {r w} foo]
1517
 
    note [catch {seek $c 0 start} msg opt]; note $msg; note $opt
 
1523
    note [catch {seek $c 0 start} msg opt]; note $msg; noteOpts $opt
1518
1524
    close $c
1519
1525
    rename foo {}
1520
1526
    set res
1650
1656
    rename foo {}
1651
1657
    set res
1652
1658
} -result {{blocking rc* 0} 1 *bad code*}
1653
 
test iocmd-29.10 {chan blocking, level is ignored} -match glob -body {
 
1659
test iocmd-29.10 {chan blocking, level is ignored} -match glob -setup {
1654
1660
    set res {}
 
1661
} -body {
1655
1662
    proc foo {args} {oninit blocking; onfinal; track; return -level 99 -code 44 BANG}
1656
1663
    set c [chan create {r w} foo]
1657
 
    note [catch {fconfigure $c -blocking 0} msg opt]; note $msg; note $opt
 
1664
    note [catch {fconfigure $c -blocking 0} msg opt]; note $msg; noteOpts $opt
1658
1665
    catch {close $c}
 
1666
    return $res
 
1667
} -cleanup {
1659
1668
    rename foo {}
1660
 
    set res
1661
1669
} -result {{blocking rc* 0} 1 *bad code* {-code 1 -level 0 -errorcode NONE -errorline 1 -errorinfo *bad code*subcommand "blocking"*}}
1662
1670
test iocmd-29.11 {chan blocking, regular return ok, value ignored} -match glob -body {
1663
1671
    set res {}
1724
1732
    close $c
1725
1733
    removeFile goo
1726
1734
    set msg
1727
 
} -result {channel "file*" is not a reflected channel}
 
1735
} -result {can not find reflected channel named "file*"}
1728
1736
test iocmd-31.2 {chan postevent, unwanted events} -match glob -body {
1729
1737
    set res {}
1730
1738
    proc foo {args} {oninit; onfinal; track; return}
1840
1848
    testthread send $tid {
1841
1849
        proc note {item} {global notes; lappend notes $item}
1842
1850
        proc notes {} {global notes; return $notes}
 
1851
        proc noteOpts opts {global notes; lappend notes [dict merge {
 
1852
            -code !?! -level !?! -errorcode !?! -errorline !?! -errorinfo !?!
 
1853
        } $opts]}
1843
1854
    }
1844
1855
    testthread send $tid [list proc s {} [list uplevel 1 $script]]; # (*)
1845
1856
 
1960
1971
    proc foo {args} {track; oninit; return -level 5 -code 777 BANG}
1961
1972
    note [set c [chan create {r w} foo]]
1962
1973
    notes [inthread $c {
1963
 
        note [catch {close $c} msg opt]; note $msg; note $opt
 
1974
        note [catch {close $c} msg opt]; note $msg; noteOpts $opt
1964
1975
        notes
1965
1976
    } c]
1966
1977
    rename foo {}
2087
2098
    }
2088
2099
    set c [chan create {r w} foo]
2089
2100
    notes [inthread $c {
2090
 
        note [catch {read $c 2} msg opt]; note $msg; note $opt
 
2101
        note [catch {read $c 2} msg opt]; note $msg; noteOpts $opt
2091
2102
        close $c
2092
2103
        notes
2093
2104
    } c]
2273
2284
    notes [inthread $c {
2274
2285
        note [catch {puts -nonewline $c snarfsnarfsnarf; flush $c} msg opt]
2275
2286
        note $msg
2276
 
        note $opt
 
2287
        noteOpts $opt
2277
2288
        close $c
2278
2289
        notes
2279
2290
    } c]
2436
2447
    notes [inthread $c {
2437
2448
        note [catch {fconfigure $c} msg opt]
2438
2449
        note $msg
2439
 
        note $opt
 
2450
        noteOpts $opt
2440
2451
        close $c
2441
2452
        notes
2442
2453
    } c]
2551
2562
    notes [inthread $c {
2552
2563
        note [catch {fconfigure $c -rc-foo bar} msg opt]
2553
2564
        note $msg
2554
 
        note $opt
 
2565
        noteOpts $opt
2555
2566
        close $c
2556
2567
        notes
2557
2568
    } c]
2652
2663
    notes [inthread $c {
2653
2664
        note [catch {fconfigure $c -rc-foo} msg opt]
2654
2665
        note $msg
2655
 
        note $opt
 
2666
        noteOpts $opt
2656
2667
        close $c
2657
2668
        notes
2658
2669
    } c]
2740
2751
    notes [inthread $c {
2741
2752
        note [catch {tell $c} msg opt]
2742
2753
        note $msg
2743
 
        note $opt
 
2754
        noteOpts $opt
2744
2755
        close $c
2745
2756
        notes
2746
2757
    } c]
2866
2877
    notes [inthread $c {
2867
2878
        note [catch {seek $c 0 start} msg opt]
2868
2879
        note $msg
2869
 
        note $opt
 
2880
        noteOpts $opt
2870
2881
        close $c
2871
2882
        notes
2872
2883
    } c]
3070
3081
    notes [inthread $c {
3071
3082
        note [catch {fconfigure $c -blocking 0} msg opt]
3072
3083
        note $msg
3073
 
        note $opt
 
3084
        noteOpts $opt
3074
3085
        catch {close $c}
3075
3086
        notes
3076
3087
    } c]
3171
3182
    rename foo {}
3172
3183
    set res
3173
3184
} -constraints {testchannel testthread} \
3174
 
    -result {{postevent for channel "rc*" called from outside interpreter}}
 
3185
    -result {{can not find reflected channel named "rc*"}}
3175
3186
 
3176
3187
# ### ### ### ######### ######### #########
3177
3188