Created
January 26, 2016 01:13
-
-
Save davispuh/e029c9cea677b8d7e75e to your computer and use it in GitHub Desktop.
Chronic test_daylight_savings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/test/test_daylight_savings.rb b/test/test_daylight_savings.rb | |
index d6f303f..3dfdc26 100644 | |
--- a/test/test_daylight_savings.rb | |
+++ b/test/test_daylight_savings.rb | |
@@ -9,110 +9,91 @@ class TestDaylightSavings < TestCase | |
def test_begin_past | |
# ambiguous - resolve to last night | |
- t = Chronic::RepeaterTime.new('900') | |
- t.start = @begin_daylight_savings | |
- assert_equal Time.local(2008, 3, 8, 21), t.next(:past).begin | |
+ t = Chronic.parse('9:00', :guess => false, :now => @begin_daylight_savings) | |
+ assert_equal Time.local(2008, 3, 8, 21), t.begin | |
# ambiguous - resolve to this afternoon | |
- t = Chronic::RepeaterTime.new('900') | |
- t.start = Time.local(2008, 3, 9, 22, 0, 0, 0) | |
- assert_equal Time.local(2008, 3, 9, 21), t.next(:past).begin | |
+ t = Chronic.parse('9:00', :guess => false, :now => Time.local(2008, 3, 9, 22, 0, 0, 0)) | |
+ assert_equal Time.local(2008, 3, 9, 21), t.begin | |
# ambiguous - resolve to this morning | |
- t = Chronic::RepeaterTime.new('400') | |
- t.start = @begin_daylight_savings | |
- assert_equal Time.local(2008, 3, 9, 4), t.next(:past).begin | |
+ t = Chronic.parse('4:00', :guess => false, :now => @begin_daylight_savings) | |
+ assert_equal Time.local(2008, 3, 9, 4), t.begin | |
# unambiguous - resolve to today | |
- t = Chronic::RepeaterTime.new('0400') | |
- t.start = @begin_daylight_savings | |
- assert_equal Time.local(2008, 3, 9, 4), t.next(:past).begin | |
+ t = Chronic.parse('04:00', :guess => false, :now => @begin_daylight_savings) | |
+ assert_equal Time.local(2008, 3, 9, 4), t.begin | |
# unambiguous - resolve to yesterday | |
- t = Chronic::RepeaterTime.new('1300') | |
- t.start = @begin_daylight_savings | |
- assert_equal Time.local(2008, 3, 8, 13), t.next(:past).begin | |
+ t = Chronic.parse('13:00', :guess => false, :now => @begin_daylight_savings) | |
+ assert_equal Time.local(2008, 3, 8, 13), t.begin | |
end | |
def test_begin_future | |
# ambiguous - resolve to this morning | |
- t = Chronic::RepeaterTime.new('900') | |
- t.start = @begin_daylight_savings | |
- assert_equal Time.local(2008, 3, 9, 9), t.next(:future).begin | |
+ t = Chronic.parse('9:00', :guess => false, :now => @begin_daylight_savings) | |
+ assert_equal Time.local(2008, 3, 9, 9), t.begin | |
# ambiguous - resolve to this afternoon | |
- t = Chronic::RepeaterTime.new('900') | |
- t.start = Time.local(2008, 3, 9, 13, 0, 0, 0) | |
- assert_equal Time.local(2008, 3, 9, 21), t.next(:future).begin | |
+ t = Chronic.parse('9:00', :guess => false, :now => Time.local(2008, 3, 9, 13, 0, 0, 0)) | |
+ assert_equal Time.local(2008, 3, 9, 21), t.begin | |
# ambiguous - resolve to tomorrow | |
- t = Chronic::RepeaterTime.new('900') | |
- t.start = Time.local(2008, 3, 9, 22, 0, 0, 0) | |
- assert_equal Time.local(2008, 3, 10, 9), t.next(:future).begin | |
+ t = Chronic.parse('9:00', :guess => false, :now => Time.local(2008, 3, 9, 22, 0, 0, 0)) | |
+ assert_equal Time.local(2008, 3, 10, 9), t.begin | |
# unambiguous - resolve to today | |
- t = Chronic::RepeaterTime.new('0900') | |
- t.start = @begin_daylight_savings | |
- assert_equal Time.local(2008, 3, 9, 9), t.next(:future).begin | |
+ t = Chronic.parse('09:00', :guess => false, :now => @begin_daylight_savings) | |
+ assert_equal Time.local(2008, 3, 9, 9), t.begin | |
# unambiguous - resolve to tomorrow | |
- t = Chronic::RepeaterTime.new('0400') | |
- t.start = @begin_daylight_savings | |
- assert_equal Time.local(2008, 3, 10, 4), t.next(:future).begin | |
+ t = Chronic.parse('04:00', :guess => false, :now => @begin_daylight_savings) | |
+ assert_equal Time.local(2008, 3, 10, 4), t.begin | |
end | |
def test_end_past | |
# ambiguous - resolve to last night | |
- t = Chronic::RepeaterTime.new('900') | |
- t.start = @end_daylight_savings | |
- assert_equal Time.local(2008, 11, 1, 21), t.next(:past).begin | |
+ t = Chronic.parse('9:00', :guess => false, :now => @end_daylight_savings) | |
+ assert_equal Time.local(2008, 11, 1, 21), t.begin | |
# ambiguous - resolve to this afternoon | |
- t = Chronic::RepeaterTime.new('900') | |
- t.start = Time.local(2008, 11, 2, 22, 0, 0, 0) | |
- assert_equal Time.local(2008, 11, 2, 21), t.next(:past).begin | |
+ t = Chronic.parse('9:00', :guess => false, :now => Time.local(2008, 11, 2, 22, 0, 0, 0)) | |
+ assert_equal Time.local(2008, 11, 2, 21), t.begin | |
# ambiguous - resolve to this morning | |
- t = Chronic::RepeaterTime.new('400') | |
- t.start = @end_daylight_savings | |
- assert_equal Time.local(2008, 11, 2, 4), t.next(:past).begin | |
+ t = Chronic.parse('4:00', :guess => false, :now => @end_daylight_savings) | |
+ assert_equal Time.local(2008, 11, 2, 4), t.begin | |
# unambiguous - resolve to today | |
- t = Chronic::RepeaterTime.new('0400') | |
- t.start = @end_daylight_savings | |
- assert_equal Time.local(2008, 11, 2, 4), t.next(:past).begin | |
+ t = Chronic.parse('04:00', :guess => false, :now => @end_daylight_savings) | |
+ assert_equal Time.local(2008, 11, 2, 4), t.begin | |
# unambiguous - resolve to yesterday | |
- t = Chronic::RepeaterTime.new('1300') | |
- t.start = @end_daylight_savings | |
- assert_equal Time.local(2008, 11, 1, 13), t.next(:past).begin | |
+ t = Chronic.parse('13:00', :guess => false, :now => @end_daylight_savings) | |
+ assert_equal Time.local(2008, 11, 1, 13), t.begin | |
end | |
def test_end_future | |
# ambiguous - resolve to this morning | |
- t = Chronic::RepeaterTime.new('900') | |
+ t = Chronic.parse('9:00', :guess => false, :now => @begin_daylight_savings) | |
t.start = @end_daylight_savings | |
- assert_equal Time.local(2008, 11, 2, 9), t.next(:future).begin | |
+ assert_equal Time.local(2008, 11, 2, 9), t.begin | |
# ambiguous - resolve to this afternoon | |
- t = Chronic::RepeaterTime.new('900') | |
- t.start = Time.local(2008, 11, 2, 13, 0, 0, 0) | |
- assert_equal Time.local(2008, 11, 2, 21), t.next(:future).begin | |
+ t = Chronic.parse('9:00', :guess => false, :now => Time.local(2008, 11, 2, 13, 0, 0, 0)) | |
+ assert_equal Time.local(2008, 11, 2, 21), t.begin | |
# ambiguous - resolve to tomorrow | |
- t = Chronic::RepeaterTime.new('900') | |
- t.start = Time.local(2008, 11, 2, 22, 0, 0, 0) | |
- assert_equal Time.local(2008, 11, 3, 9), t.next(:future).begin | |
+ t = Chronic.parse('9:00', :guess => false, :now => Time.local(2008, 11, 2, 22, 0, 0, 0)) | |
+ assert_equal Time.local(2008, 11, 3, 9), t.begin | |
# unambiguous - resolve to today | |
- t = Chronic::RepeaterTime.new('0900') | |
- t.start = @end_daylight_savings | |
- assert_equal Time.local(2008, 11, 2, 9), t.next(:future).begin | |
+ t = Chronic.parse('09:00', :guess => false, :now => @end_daylight_savings) | |
+ assert_equal Time.local(2008, 11, 2, 9), t.begin | |
# unambiguous - resolve to tomorrow | |
- t = Chronic::RepeaterTime.new('0400') | |
- t.start = @end_daylight_savings | |
- assert_equal Time.local(2008, 11, 3, 4), t.next(:future).begin | |
+ t = Chronic.parse('04:00', :guess => false, :now => @end_daylight_savings) | |
+ assert_equal Time.local(2008, 11, 3, 4), t.begin | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment