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 tclconference@googlegroups.com
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 Side-by-Side Diffs Ignore Whitespace Patch

Changes to tests/text.test.

   956    956   } {{First second third} {1.0 1.5} {1.6 1.12} {1.6 1.12} {1.6 1.12}}
   957    957   test text-11.10 {TextWidgetCmd procedure, "insert" option} {
   958    958       .t delete 1.0 end
   959    959       .t insert 1.0 "First" bold " second" silly
   960    960       list [.t get 1.0 1.end] [.t tag ranges bold] [.t tag ranges silly]
   961    961   } {{First second} {1.0 1.5} {1.5 1.12}}
   962    962   
   963         -test text-11a.1 {TextWidgetCmd procedure, "sync" option} {
          963  +test text-11a.1 {TextWidgetCmd procedure, "sync" option} -setup {
   964    964       destroy .yt
          965  +} -body {
   965    966       text .yt
   966    967       list [catch {.yt sync mytext} msg] $msg
   967         -} {1 {wrong # args: should be ".yt sync ?-command command?"}}
   968         -test text-11a.2 {TextWidgetCmd procedure, "sync" option} {
          968  +} -cleanup {
          969  +    destroy .yt
          970  +} -result {1 {wrong # args: should be ".yt sync ?-command command?"}}
          971  +test text-11a.2 {TextWidgetCmd procedure, "sync" option with -command} -setup {
          972  +    destroy .yt
          973  +} -body {
          974  +    text .yt
          975  +    list [catch {.yt sync -comx foo} msg] $msg
          976  +} -cleanup {
          977  +    destroy .yt
          978  +} -result {1 {wrong option "-comx": should be "-command"}}
          979  +test text-11a.3 {TextWidgetCmd procedure, "sync" option} -setup {
   969    980       destroy .top.yt .top
          981  +} -body {
   970    982       toplevel .top
   971    983       pack [text .top.yt]
   972    984       set content {}
   973    985       for {set i 1} {$i < 30} {incr i} {
   974    986           append content [string repeat "$i " 15] \n
   975    987       }
   976    988       .top.yt insert 1.0 $content
................................................................................
   989   1001       # second case: wait for completion of line metrics calculation
   990   1002       .top.yt delete 1.0 end
   991   1003       .top.yt insert 1.0 $content
   992   1004       .top.yt sync
   993   1005       .top.yt yview moveto $fraction1
   994   1006       set fraction2 [lindex [.top.yt yview] 0]
   995   1007       lappend res [expr {$fraction1 == $fraction2}]
   996         -} {1 0 1}
   997         -test text-11a.11 {TextWidgetCmd procedure, "pendingsync" option} {
         1008  +} -cleanup {
         1009  +    destroy .top.yt .top
         1010  +} -result {1 0 1}
         1011  +test text-11a.4 {TextWidgetCmd procedure, "sync" option with -command} -setup {
         1012  +    destroy .yt
         1013  +} -body {
         1014  +    set ::x 0
         1015  +    pack [text .yt] -expand 1 -fill both
         1016  +    .yt sync -command [list set ::x 1]
         1017  +    set ::x
         1018  +} -cleanup {
         1019  +    destroy .yt
         1020  +} -result {1}
         1021  +
         1022  +test text-11a.11 {TextWidgetCmd procedure, "pendingsync" option} -setup {
   998   1023       destroy .yt
         1024  +} -body {
   999   1025       text .yt
  1000   1026       list [catch {.yt pendingsync mytext} msg] $msg
  1001         -} {1 {wrong # args: should be ".yt pendingsync"}}
  1002         -test text-11a.12 {TextWidgetCmd procedure, "pendingsync" option} {
         1027  +} -cleanup {
         1028  +    destroy .yt
         1029  +} -result {1 {wrong # args: should be ".yt pendingsync"}}
         1030  +test text-11a.12 {TextWidgetCmd procedure, "pendingsync" option} -setup {
  1003   1031       destroy .top.yt .top
         1032  +} -body {
  1004   1033       toplevel .top
  1005   1034       pack [text .top.yt]
  1006   1035       set content {}
  1007   1036       for {set i 1} {$i < 300} {incr i} {
  1008   1037           append content [string repeat "$i " 15] \n
  1009   1038       }
  1010   1039       .top.yt insert 1.0 $content
................................................................................
  1020   1049       # ensure the test is relevant
  1021   1050       lappend res [expr {[.top.yt pendingsync] > 0}]
  1022   1051       # asynchronously wait for completion of line metrics calculation
  1023   1052       while {[.top.yt pendingsync]} {update}
  1024   1053       .top.yt yview moveto $fraction1
  1025   1054       set fraction2 [lindex [.top.yt yview] 0]
  1026   1055       lappend res [expr {$fraction1 == $fraction2}]
  1027         -} {1 1 1}
  1028         -test text-11a.21 {"<<WidgetViewSync>>" event} {
         1056  +} -cleanup {
         1057  +    destroy .top.yt .top
         1058  +} -result {1 1 1}
         1059  +
         1060  +test text-11a.21 {"<<WidgetViewSync>>" event} -setup {
  1029   1061       destroy .top.yt .top
         1062  +} -body {
  1030   1063       toplevel .top
  1031   1064       pack [text .top.yt]
  1032   1065       set content {}
  1033   1066       for {set i 1} {$i < 300} {incr i} {
  1034   1067           append content [string repeat "$i " 15] \n
  1035   1068       }
  1036   1069       .top.yt insert 1.0 $content
................................................................................
  1048   1081       # and ensure the test is relevant
  1049   1082       set waited 0
  1050   1083       if {[.top.yt pendingsync]} {set waited 1 ; vwait yud(.top.yt)}
  1051   1084       lappend res $waited
  1052   1085       .top.yt yview moveto $fraction1
  1053   1086       set fraction2 [lindex [.top.yt yview] 0]
  1054   1087       lappend res [expr {$fraction1 == $fraction2}]
  1055         -} {1 1 1}
         1088  +} -cleanup {
         1089  +    destroy .top.yt .top
         1090  +} -result {1 1 1}
  1056   1091   
  1057   1092   # edit, mark, scan, search, see, tag, window, xview and yview actions are tested elsewhere.
  1058   1093   
  1059   1094   test text-12.1 {ConfigureText procedure} {
  1060   1095       list [catch {.t2 configure -state foobar} msg] $msg
  1061   1096   } {1 {bad state "foobar": must be disabled or normal}}
  1062   1097   test text-12.2 {ConfigureText procedure} {

Changes to tests/textDisp.test.

  4187   4187       update
  4188   4188       .t1 sync
  4189   4189       set negative
  4190   4190   } -cleanup {
  4191   4191       destroy .t1
  4192   4192   } -result {0}
  4193   4193   
  4194         -test textDisp-34.2 {text sync syntax} -body {
  4195         -} -body {
  4196         -    pack [text .t1] -expand 1 -fill both
  4197         -    .t1 sync foo
  4198         -} -cleanup {
  4199         -    destroy .t1
  4200         -} -returnCodes 1 -result {wrong # args: should be ".t1 sync ?-command command?"}
  4201         -
  4202         -test textDisp-34.3 {text sync syntax} -body {
  4203         -} -body {
  4204         -    pack [text .t1] -expand 1 -fill both
  4205         -    .t1 sync -comx foo
  4206         -} -cleanup {
  4207         -    destroy .t1
  4208         -} -returnCodes 1 -result {wrong option "-comx": should be "-command"}
  4209         -
  4210         -test textDisp-34.4 {text sync syntax} -body {
  4211         -} -body {
  4212         -    set ::x 0
  4213         -    pack [text .t1] -expand 1 -fill both
  4214         -    .t1 sync -comm [list set ::x 1]
  4215         -    set ::x
  4216         -} -cleanup {
  4217         -    destroy .t1
  4218         -} -result {1}
  4219         -
  4220   4194   deleteWindows
  4221   4195   option clear
  4222   4196   
  4223   4197   # cleanup
  4224   4198   cleanupTests
  4225   4199   return