Tk Source Code

Check-in [54b68217]
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:Tests reordered. Two issues currently: 1. text-11a.22 currently hangs but should pass once [.text sync -command $cmd] will be correctly implemented. 2. text-11a.41 fails (unsure why)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tip-438
Files: files | file ages | folders
SHA1: 54b682178983e9eb31aeb740a8358b1259c0dbf3
User & Date: fvogel 2015-12-19 21:48:11
Context
2015-12-20
22:09
There could be false negatives with [.text pendingsync] when line metrics calculation is in the middle of a long line. check-in: 5fc26426 user: fvogel tags: tip-438
2015-12-19
21:48
Tests reordered. Two issues currently: 1. text-11a.22 currently hangs but should pass once [.text sync -command $cmd] will be correctly implemented. 2. text-11a.41 fails (unsure why) check-in: 54b68217 user: fvogel tags: tip-438
2015-12-13
20:58
Better (and more correct) description of what [.text sync -command $command] does check-in: 37ed6fc5 user: fvogel tags: tip-438
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tests/text.test.

953
954
955
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
....
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
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
....
1081
1082
1083
1084
1085
1086
1087

























1088
1089
1090
1091
1092
1093
1094
} {{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 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
    update
    # wait for end of line metrics calculation to get correct $fraction1
    # as a reference
    while {[.top.yt pendingsync]} {update}
    .top.yt yview moveto 1
    set fraction1 [lindex [.top.yt yview] 0]
    set res [expr {$fraction1 > 0}]
    .top.yt delete 1.0 end
    .top.yt insert 1.0 $content
    # ensure the test is relevant
    lappend res [.top.yt pendingsync]
    # 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
................................................................................
    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} {






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







<
<
<
<
<
<
<
<
|







 







<
<
<
<
<
<
<
<
<
<

<
>



|


|
|


>
>



|



|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
<
<
<







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







953
954
955
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
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004








1005
1006
1007
1008
1009
1010
1011
1012
....
1030
1031
1032
1033
1034
1035
1036










1037

1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074




1075
1076
1077
1078
1079
1080
1081
....
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
} {{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, "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.2 {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
    # wait for end of line metrics calculation to get correct $fraction1
    # as a reference
    while {[.top.yt pendingsync]} {update}
    .top.yt yview moveto 1
    set fraction1 [lindex [.top.yt yview] 0]
    set res [expr {$fraction1 > 0}]
    .top.yt delete 1.0 end
    .top.yt insert 1.0 $content
    # ensure the test is relevant
    lappend res [.top.yt pendingsync]
    # 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.11 {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.12 {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 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.21 {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.22 {TextWidgetCmd procedure, "sync" option with -command} -setup {
    destroy .top.yt .top
} -body {
    set res {}
    set ::x 0
    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
    # first case: line metrics calculation still running when launching 'sync -command'
    lappend res [.top.yt pendingsync]
    .top.yt sync -command [list set ::x 1]
    lappend res $::x
    # now finish line metrics calculations
    while {[.top.yt pendingsync]} {update}
    lappend res [.top.yt pendingsync] $::x
    # second case: line metrics calculation completed when launching 'sync -command'
    .top.yt sync -command [list set ::x 2]
    lappend res $::x
    vwait ::x
    lappend res $::x
} -cleanup {
    destroy .top.yt .top
} -result {1 0 0 1 1 2}

test text-11a.31 {"<<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
................................................................................
    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}

test text-11a.41 {"sync" "pendingsync" and <<WidgetViewSync>>} -setup {
    destroy .top.yt .top
} -body {
    set res {}
    toplevel .top
    pack [text .top.yt]
    set content {}
    for {set i 1} {$i < 300} {incr i} {
        append content [string repeat "$i " 50] \n
    }
    bind .top.yt <<WidgetViewSync>> {lappend res Sync:%d}
    .top.yt insert 1.0 $content
    update
    # ensure the test is relevant
    lappend res [.top.yt pendingsync]
    # - there is no more any pending sync after running 'sync'
    # - <<WidgetViewSync>> fires when sync returns if there was pending syncs 
    .top.yt sync
    lappend res [.top.yt pendingsync]
    update
    set res
} -cleanup {
    destroy .top.yt .top
} -result {Sync:0 1 0 Sync: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} {