Tk Source Code

Check-in [516a0cca]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Improved the tests a bit
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tip-438
Files: files | file ages | folders
SHA1: 516a0cca809ed04409505ccd8fba34f341ad0597
User & Date: fvogel 2015-11-21 09:08:52
Context
2015-11-21
12:47
Respect alphabetical order check-in: 09256d04 user: fvogel tags: tip-438
09:08
Improved the tests a bit check-in: 516a0cca user: fvogel tags: tip-438
08:43
Adjusted when <<WidgetViewSync>> fires. Also %d now only has boolean value. Implementation in sync with TIP #438 rev. 1.10 check-in: 615bbce0 user: fvogel tags: tip-438
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tests/text.test.

956
957
958
959
960
961
962
963
964

965
966


967
968








969

970
971
972
973
974
975
976
...
989
990
991
992
993
994
995


996











997
998

999
1000


1001
1002
1003

1004
1005
1006
1007
1008
1009
1010
....
1020
1021
1022
1023
1024
1025
1026


1027

1028
1029

1030
1031
1032
1033
1034
1035
1036
....
1048
1049
1050
1051
1052
1053
1054


1055
1056
1057
1058
1059
1060
1061
1062
} {{First second third} {1.0 1.5} {1.6 1.12} {1.6 1.12} {1.6 1.12}}
test text-11.10 {TextWidgetCmd procedure, "insert" option} {
    .t delete 1.0 end
    .t insert 1.0 "First" bold " second" silly
    list [.t get 1.0 1.end] [.t tag ranges bold] [.t tag ranges silly]
} {{First second} {1.0 1.5} {1.5 1.12}}

test text-11a.1 {TextWidgetCmd procedure, "sync" option} {
    destroy .yt

    text .yt
    list [catch {.yt sync mytext} msg] $msg


} {1 {wrong # args: should be ".yt sync ?-command command?"}}
test text-11a.2 {TextWidgetCmd procedure, "sync" option} {








    destroy .top.yt .top

    toplevel .top
    pack [text .top.yt]
    set content {}
    for {set i 1} {$i < 30} {incr i} {
        append content [string repeat "$i " 15] \n
    }
    .top.yt insert 1.0 $content
................................................................................
    # second case: wait for completion of line metrics calculation
    .top.yt delete 1.0 end
    .top.yt insert 1.0 $content
    .top.yt sync
    .top.yt yview moveto $fraction1
    set fraction2 [lindex [.top.yt yview] 0]
    lappend res [expr {$fraction1 == $fraction2}]


} {1 0 1}











test text-11a.11 {TextWidgetCmd procedure, "pendingsync" option} {
    destroy .yt

    text .yt
    list [catch {.yt pendingsync mytext} msg] $msg


} {1 {wrong # args: should be ".yt pendingsync"}}
test text-11a.12 {TextWidgetCmd procedure, "pendingsync" option} {
    destroy .top.yt .top

    toplevel .top
    pack [text .top.yt]
    set content {}
    for {set i 1} {$i < 300} {incr i} {
        append content [string repeat "$i " 15] \n
    }
    .top.yt insert 1.0 $content
................................................................................
    # ensure the test is relevant
    lappend res [expr {[.top.yt pendingsync] > 0}]
    # asynchronously wait for completion of line metrics calculation
    while {[.top.yt pendingsync]} {update}
    .top.yt yview moveto $fraction1
    set fraction2 [lindex [.top.yt yview] 0]
    lappend res [expr {$fraction1 == $fraction2}]


} {1 1 1}

test text-11a.21 {"<<WidgetViewSync>>" event} {
    destroy .top.yt .top

    toplevel .top
    pack [text .top.yt]
    set content {}
    for {set i 1} {$i < 300} {incr i} {
        append content [string repeat "$i " 15] \n
    }
    .top.yt insert 1.0 $content
................................................................................
    # and ensure the test is relevant
    set waited 0
    if {[.top.yt pendingsync]} {set waited 1 ; vwait yud(.top.yt)}
    lappend res $waited
    .top.yt yview moveto $fraction1
    set fraction2 [lindex [.top.yt yview] 0]
    lappend res [expr {$fraction1 == $fraction2}]


} {1 1 1}

# edit, mark, scan, search, see, tag, window, xview and yview actions are tested elsewhere.

test text-12.1 {ConfigureText procedure} {
    list [catch {.t2 configure -state foobar} msg] $msg
} {1 {bad state "foobar": must be disabled or normal}}
test text-12.2 {ConfigureText procedure} {






|

>


>
>
|
|
>
>
>
>
>
>
>
>

>







 







>
>
|
>
>
>
>
>
>
>
>
>
>
>
|

>


>
>
|
|

>







 







>
>
|
>
|

>







 







>
>
|







956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
....
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
....
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
....
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
} {{First second third} {1.0 1.5} {1.6 1.12} {1.6 1.12} {1.6 1.12}}
test text-11.10 {TextWidgetCmd procedure, "insert" option} {
    .t delete 1.0 end
    .t insert 1.0 "First" bold " second" silly
    list [.t get 1.0 1.end] [.t tag ranges bold] [.t tag ranges silly]
} {{First second} {1.0 1.5} {1.5 1.12}}

test text-11a.1 {TextWidgetCmd procedure, "sync" option} -setup {
    destroy .yt
} -body {
    text .yt
    list [catch {.yt sync mytext} msg] $msg
} -cleanup {
    destroy .yt
} -result {1 {wrong # args: should be ".yt sync ?-command command?"}}
test text-11a.2 {TextWidgetCmd procedure, "sync" option with -command} -setup {
    destroy .yt
} -body {
    text .yt
    list [catch {.yt sync -comx foo} msg] $msg
} -cleanup {
    destroy .yt
} -result {1 {wrong option "-comx": should be "-command"}}
test text-11a.3 {TextWidgetCmd procedure, "sync" option} -setup {
    destroy .top.yt .top
} -body {
    toplevel .top
    pack [text .top.yt]
    set content {}
    for {set i 1} {$i < 30} {incr i} {
        append content [string repeat "$i " 15] \n
    }
    .top.yt insert 1.0 $content
................................................................................
    # second case: wait for completion of line metrics calculation
    .top.yt delete 1.0 end
    .top.yt insert 1.0 $content
    .top.yt sync
    .top.yt yview moveto $fraction1
    set fraction2 [lindex [.top.yt yview] 0]
    lappend res [expr {$fraction1 == $fraction2}]
} -cleanup {
    destroy .top.yt .top
} -result {1 0 1}
test text-11a.4 {TextWidgetCmd procedure, "sync" option with -command} -setup {
    destroy .yt
} -body {
    set ::x 0
    pack [text .yt] -expand 1 -fill both
    .yt sync -command [list set ::x 1]
    set ::x
} -cleanup {
    destroy .yt
} -result {1}

test text-11a.11 {TextWidgetCmd procedure, "pendingsync" option} -setup {
    destroy .yt
} -body {
    text .yt
    list [catch {.yt pendingsync mytext} msg] $msg
} -cleanup {
    destroy .yt
} -result {1 {wrong # args: should be ".yt pendingsync"}}
test text-11a.12 {TextWidgetCmd procedure, "pendingsync" option} -setup {
    destroy .top.yt .top
} -body {
    toplevel .top
    pack [text .top.yt]
    set content {}
    for {set i 1} {$i < 300} {incr i} {
        append content [string repeat "$i " 15] \n
    }
    .top.yt insert 1.0 $content
................................................................................
    # ensure the test is relevant
    lappend res [expr {[.top.yt pendingsync] > 0}]
    # asynchronously wait for completion of line metrics calculation
    while {[.top.yt pendingsync]} {update}
    .top.yt yview moveto $fraction1
    set fraction2 [lindex [.top.yt yview] 0]
    lappend res [expr {$fraction1 == $fraction2}]
} -cleanup {
    destroy .top.yt .top
} -result {1 1 1}

test text-11a.21 {"<<WidgetViewSync>>" event} -setup {
    destroy .top.yt .top
} -body {
    toplevel .top
    pack [text .top.yt]
    set content {}
    for {set i 1} {$i < 300} {incr i} {
        append content [string repeat "$i " 15] \n
    }
    .top.yt insert 1.0 $content
................................................................................
    # and ensure the test is relevant
    set waited 0
    if {[.top.yt pendingsync]} {set waited 1 ; vwait yud(.top.yt)}
    lappend res $waited
    .top.yt yview moveto $fraction1
    set fraction2 [lindex [.top.yt yview] 0]
    lappend res [expr {$fraction1 == $fraction2}]
} -cleanup {
    destroy .top.yt .top
} -result {1 1 1}

# edit, mark, scan, search, see, tag, window, xview and yview actions are tested elsewhere.

test text-12.1 {ConfigureText procedure} {
    list [catch {.t2 configure -state foobar} msg] $msg
} {1 {bad state "foobar": must be disabled or normal}}
test text-12.2 {ConfigureText procedure} {

Changes to tests/textDisp.test.

4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
    update
    .t1 sync
    set negative
} -cleanup {
    destroy .t1
} -result {0}

test textDisp-34.2 {text sync syntax} -body {
} -body {
    pack [text .t1] -expand 1 -fill both
    .t1 sync foo
} -cleanup {
    destroy .t1
} -returnCodes 1 -result {wrong # args: should be ".t1 sync ?-command command?"}

test textDisp-34.3 {text sync syntax} -body {
} -body {
    pack [text .t1] -expand 1 -fill both
    .t1 sync -comx foo
} -cleanup {
    destroy .t1
} -returnCodes 1 -result {wrong option "-comx": should be "-command"}

test textDisp-34.4 {text sync syntax} -body {
} -body {
    set ::x 0
    pack [text .t1] -expand 1 -fill both
    .t1 sync -comm [list set ::x 1]
    set ::x
} -cleanup {
    destroy .t1
} -result {1}

deleteWindows
option clear

# cleanup
cleanupTests
return






<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






4187
4188
4189
4190
4191
4192
4193


























4194
4195
4196
4197
4198
4199
    update
    .t1 sync
    set negative
} -cleanup {
    destroy .t1
} -result {0}



























deleteWindows
option clear

# cleanup
cleanupTests
return