summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/age_spec.rb23
1 files changed, 18 insertions, 5 deletions
diff --git a/spec/age_spec.rb b/spec/age_spec.rb
index 7c447e0..23d54cb 100644
--- a/spec/age_spec.rb
+++ b/spec/age_spec.rb
@@ -16,6 +16,10 @@ end
def full_check birth, at, y, m, d, hh, mm, ss
r = birth.age at
r[0].should eql y
+ if r[1]<0 or r[1]>11 or r[2]<0 or r[2]>31
+ puts birth
+ puts at
+ end
r[1].should eql m
r[2].should eql d
r[3].should eql hh
@@ -49,6 +53,14 @@ describe DateTime do
(0..10000).each do |n|
at = @b+n
r = @b.age at
+ r[1].should >= 0
+ r[1].should <= 11
+ r[2].should >= 0
+ if r[2]>31
+ puts @b
+ puts at
+ end
+ r[2].should <= 31
x = (@b>>(12*r[0]+r[1]))+r[2]
x.year.should eql at.year
x.month.should eql at.month
@@ -56,6 +68,12 @@ describe DateTime do
end
end
it "should pass time computation" do
+ # change years
+ full_check @b, DateTime.civil( 2010, 6, 27, 4, 40, 0), 0, 11, 0, 0, 0, 0
+ full_check @b, DateTime.civil( 2010, 7, 27, 3, 40, 0), 0, 11, 29, 23, 0, 0
+ full_check @b, DateTime.civil( 2010, 7, 27, 4, 39, 0), 0, 11, 29, 23, 59, 0
+ full_check @b, DateTime.civil( 2010, 7, 27, 4, 39, 59), 0, 11, 29, 23, 59, 59
+ full_check @b, DateTime.civil( 2010, 7, 27, 4, 40, 0), 1, 0, 0, 0, 0, 0
full_check @b, DateTime.civil( 2010, 9, 25, 3, 40, 0), 1, 1, 28, 23, 0, 0
full_check @b, DateTime.civil( 2010, 9, 25, 4, 39, 0), 1, 1, 28, 23, 59, 0
full_check @b, DateTime.civil( 2010, 9, 25, 4, 39, 59), 1, 1, 28, 23, 59, 59
@@ -73,10 +91,5 @@ describe DateTime do
full_check @b, DateTime.civil( 2010, 9, 28, 4, 39, 59), 1, 2, 0, 23, 59, 59
full_check @b, DateTime.civil( 2010, 9, 28, 4, 40, 0), 1, 2, 1, 0, 0, 0
full_check @b, DateTime.civil( 2010, 9, 29, 3, 40, 0), 1, 2, 1, 23, 0, 0
- # change years
- full_check @b, DateTime.civil( 2010, 7, 27, 4, 40, 0), 1, 0, 0, 0, 0, 0
- full_check @b, DateTime.civil( 2010, 7, 27, 3, 40, 0), 0, 11, 29, 23, 0, 0
- full_check @b, DateTime.civil( 2010, 7, 27, 4, 39, 0), 0, 11, 29, 23, 59, 0
- full_check @b, DateTime.civil( 2010, 7, 27, 4, 39, 59), 0, 11, 29, 23, 59, 59
end
end