Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: a0809073cecde4369ac3a52b4fd9ea542e17b6a3
Ticket: 218989ffffffffffffffffffffffffffffffffff
Some new tests for the clock command
User & Date: nobody on 2000-10-26 01:09:00
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 3671 RFE
    Version: 8.2.2
    SubmitDate: '1999-11-23'
    LastModified: '2000-01-12'
    Severity: LOW
    Status: Released
    Submitter: techsupp
    ChangedBy: ericm
    OS: Linux-SuSE
    FixedDate: '2000-01-12'
    FixedInVersion: 8.3
    ClosedDate: '2000-10-25'
    
    
    Name:
    
    Christian Krone
    
    
    
    DesiredBehavior:
    
    Two weeks ago Hume Smith wrote in comp.lang.tcl a nice application
    
    of the clock command:
    
    > >I have a question of the clock's scan format.
    
    > >How is the 2nd Monday in November expressed in Tcl?
    
    > best i can do is
    
    > % foreach i {90 91 92 93 94 95 96 97 98 99} {
    
    > puts [clock format [clock scan monday -base [clock scan 11/8/$i]]]
    
    > }
    
    I tried this in Jacl, and I found two errors in one command!
    
    Since both errors are not tested by clock.test, I added some tests
    
    for daynames and -base option.
    
    
    
    Patch:
    
    *** clock.test.orgSat Jun 26 05:54:10 1999
    
    --- clock.testMon Nov 22 10:57:28 1999
    
    ***************
    
    *** 209,214 ****
    
    --- 209,243 ----
    
          clock format $time -format %j -gmt true
    
      } {060}
    
      
    
    + # weekday specification and base.
    
    + test clock-7.1 {2nd monday in november} {
    
    +     set res {}
    
    +     foreach i {91 92 93 94 95 96} {
    
    + set nov8th [clock scan 11/8/$i -gmt true]
    
    + set monday [clock scan monday -base $nov8th -gmt true]
    
    + lappend res [clock format $monday -format %Y-%m-%d -gmt true]
    
    +     }
    
    +     set res
    
    + } {1991-11-11 1992-11-09 1993-11-08 1994-11-14 1995-11-13 1996-11-11}
    
    + test clock-7.2 {2nd monday in november (2nd try)} {
    
    +     set res {}
    
    +     foreach i {91 92 93 94 95 96} {
    
    + set nov1th [clock scan 11/1/$i -gmt true]
    
    + set monday [clock scan "2 monday" -base $nov1th -gmt true]
    
    + lappend res [clock format $monday -format %Y-%m-%d -gmt true]
    
    +     }
    
    +     set res
    
    + } {1991-11-11 1992-11-09 1993-11-08 1994-11-14 1995-11-13 1996-11-11}
    
    + test clock-7.3 {last monday in november} {
    
    +     set res {}
    
    +     foreach i {91 92 93 94 95 96} {
    
    + set dec1th [clock scan 12/1/$i -gmt true]
    
    + set monday [clock scan "monday 1 week ago" -base $dec1th -gmt true]
    
    + lappend res [clock format $monday -format %Y-%m-%d -gmt true]
    
    +     }
    
    +     set res
    
    + } {1991-11-25 1992-11-30 1993-11-29 1994-11-28 1995-11-27 1996-11-25}
    
    + 
    
      # cleanup
    
      ::tcltest::cleanupTests
    
      return
    
    
    
    PatchFiles:
    
    clock.test
    
    
    
    
    
    You don't want the -gmt true bits set though... 
    -- 01/12/2000 hobbs
    
    I added these tests (with the -gmt true bits dropped) to the test suite.  They are good tests of the relative time scans.  With regards to removing the -gmt true bits:
    
    For reasons we don't yet understand, adding -gmt true goofs the tests somehow.  This is true in 8.0, 8.2 and 8.3.  It would be worthwhile to investigate further and try to determine just what it is that causes the problem when -gmt is turned on; my suspicion is that it is related to DST corrections, which shouldn't be used if GMT mode is on.
    
    So that we remember to investigate next time we work on the clock command, I will add the unaltered tests, with the knownBug flag set, as well.
    
    - eric
    
    -- 01/12/2000 ericm
    
    
    
  4. foundin changed to: "obsolete: 8.2.2"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "48. Number Handling"
  10. title changed to: "Some new tests for the clock command"
  11. type changed to: "Bug"