Skip to content

Commit

Permalink
Change tests of deleted methods to test_throws MethodError
Browse files Browse the repository at this point in the history
  • Loading branch information
tkelman committed Jan 26, 2017
1 parent e3268cd commit cf95a04
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/dates/arithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -429,3 +429,13 @@ t5 = [Dates.Time(0, 0, 0) Dates.Time(0, 0, 1) Dates.Time(0, 0, 2); Dates.Time(0,
@test t4 - t3 == [Dates.Millisecond(1000), Dates.Millisecond(60000), Dates.Millisecond(3600000)]
@test (Dates.Date(2009, 1, 1):Dates.Week(1):Dates.Date(2009, 1, 21)) - (Dates.Date(2009, 1, 1):Dates.Day(1):Dates.Date(2009, 1, 3)) == [Dates.Day(0), Dates.Day(6), Dates.Day(12)]
@test (Dates.DateTime(2009, 1, 1, 1, 1, 1):Dates.Second(1):Dates.DateTime(2009, 1, 1, 1, 1, 3)) - (Dates.DateTime(2009, 1, 1, 1, 1):Dates.Second(1):Dates.DateTime(2009, 1, 1, 1, 1, 2)) == [Dates.Second(1), Dates.Second(1), Dates.Second(1)]

# ensure no non-commutative subtraction methods are defined, #20205
@test_throws MethodError Dates.Day(1) .- t1
@test_throws MethodError Dates.Hour(1) .- t3
@test_throws MethodError Dates.Day(1) - t1
@test_throws MethodError Dates.Hour(1) - t3
@test_throws MethodError (Dates.Month(1) + Dates.Day(1)) .- t1
@test_throws MethodError (Dates.Hour(1) + Dates.Minute(1)) .- t3
@test_throws MethodError (Dates.Month(1) + Dates.Day(1)) - t1
@test_throws MethodError (Dates.Hour(1) + Dates.Minute(1)) - t3
1 change: 1 addition & 0 deletions test/dates/periods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ emptyperiod = ((y + d) - d) - y
@test Dates.canonicalize(-y + m - w + d - h + mi - s + ms).periods == Dates.Period[-11m, -6d, -59mi, -999ms]

@test Dates.Date(2009, 2, 1) - (Dates.Month(1) + Dates.Day(1)) == Dates.Date(2008, 12, 31)
@test_throws MethodError (Dates.Month(1) + Dates.Day(1)) - Dates.Date(2009,2,1)

pa = [1y 1m 1w 1d; 1h 1mi 1s 1ms]
cpa = [1y + 1s 1m + 1s 1w + 1s 1d + 1s; 1h + 1s 1mi + 1s 2m + 1s 1s + 1ms]
Expand Down

0 comments on commit cf95a04

Please sign in to comment.