diff options
author | sebres <sebres@users.sourceforge.net> | 2020-05-13 11:10:36 (GMT) |
---|---|---|
committer | sebres <sebres@users.sourceforge.net> | 2020-05-13 11:10:36 (GMT) |
commit | be515de988c81feea02022fb95bc65fd032ea526 (patch) | |
tree | 9c10c23462bca81ce852de023c5fbd2dd778f00e /tests | |
parent | c1638f82167bd6b45849dea02d42f52ccff8d444 (diff) | |
download | tcl-be515de988c81feea02022fb95bc65fd032ea526.zip tcl-be515de988c81feea02022fb95bc65fd032ea526.tar.gz tcl-be515de988c81feea02022fb95bc65fd032ea526.tar.bz2 |
clock.test: more tests for negative month offsets over threshold of a year (important for C-implementation like clock-speedup branch, see https://github.com/sebres/tclclockmod/issues/20#issuecomment-627704993)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/clock.test | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/clock.test b/tests/clock.test index 862e78c..f2edd34 100644 --- a/tests/clock.test +++ b/tests/clock.test @@ -35028,6 +35028,24 @@ test clock-30.8 {clock add months, negative} { set x4 [clock format $f4 -format %Y-%m-%d -timezone :UTC] list $x1 $x2 $x3 $x4 } {2000-02-29 2000-01-31 1999-12-31 1999-11-30} +test clock-30.8a {clock add months, negative, over threshold of a year} { + set t [clock scan 2019-01-31 -format %Y-%m-%d -gmt 1] + list [clock format [clock add $t -1 month -gmt 1] -format %Y-%m-%d -gmt 1] \ + [clock format [clock add $t -2 month -gmt 1] -format %Y-%m-%d -gmt 1] \ + [clock format [clock add $t -3 month -gmt 1] -format %Y-%m-%d -gmt 1] \ + [clock format [clock add $t -4 month -gmt 1] -format %Y-%m-%d -gmt 1] +} {2018-12-31 2018-11-30 2018-10-31 2018-09-30} +test clock-30.8b {clock add months, negative, over threshold of a year} { + set t [clock scan 2000-01-28 -format %Y-%m-%d -gmt 1] + for {set i 1} {$i < 24} {incr i 1} { + set f1 [clock add $t -$i month -gmt 1] + set f2 [clock add $f1 $i month -gmt 1] + if {$f2 != $t} { + error "\[clock add $t -$i month -gmt 1\] does not consider\ + \[clock add $f1 $i month -gmt 1\] != $t" + } + } +} {} test clock-30.9 {clock add days} { set t [clock scan {2000-01-01 12:34:56} -format {%Y-%m-%d %H:%M:%S} \ -timezone :UTC] |