summaryrefslogtreecommitdiff
path: root/spec/rubyspec/library/date/shared
diff options
context:
space:
mode:
Diffstat (limited to 'spec/rubyspec/library/date/shared')
-rw-r--r--spec/rubyspec/library/date/shared/civil.rb57
-rw-r--r--spec/rubyspec/library/date/shared/commercial.rb39
-rw-r--r--spec/rubyspec/library/date/shared/jd.rb14
-rw-r--r--spec/rubyspec/library/date/shared/new_bang.rb14
-rw-r--r--spec/rubyspec/library/date/shared/ordinal.rb22
-rw-r--r--spec/rubyspec/library/date/shared/parse.rb54
-rw-r--r--spec/rubyspec/library/date/shared/parse_eu.rb37
-rw-r--r--spec/rubyspec/library/date/shared/parse_us.rb36
-rw-r--r--spec/rubyspec/library/date/shared/valid_civil.rb36
-rw-r--r--spec/rubyspec/library/date/shared/valid_commercial.rb34
-rw-r--r--spec/rubyspec/library/date/shared/valid_jd.rb15
-rw-r--r--spec/rubyspec/library/date/shared/valid_ordinal.rb26
12 files changed, 0 insertions, 384 deletions
diff --git a/spec/rubyspec/library/date/shared/civil.rb b/spec/rubyspec/library/date/shared/civil.rb
deleted file mode 100644
index 47dbed49fc..0000000000
--- a/spec/rubyspec/library/date/shared/civil.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-describe :date_civil, shared: true do
- it "creates a Date for -4712 by default" do
- # the #chomp calls are necessary because of RSpec
- d = Date.send(@method)
- d.year.should == -4712
- d.month.should == 1
- d.day.should == 1
- d.julian?.should == true
- d.jd.should == 0
- end
-
- it "creates a date with arguments" do
- d = Date.send(@method, 2000, 3, 5)
- d.year.should == 2000
- d.month.should == 3
- d.day.should == 5
- d.julian?.should == false
- d.jd.should == 2451609
-
- # Should also work with years far in the past and future
-
- d = Date.send(@method, -9000, 7, 5)
- d.year.should == -9000
- d.month.should == 7
- d.day.should == 5
- d.julian?.should == true
- d.jd.should == -1566006
-
- d = Date.send(@method, 9000, 10, 14)
- d.year.should == 9000
- d.month.should == 10
- d.day.should == 14
- d.julian?.should == false
- d.jd.should == 5008529
-
- end
-
- it "doesn't create dates for invalid arguments" do
- lambda { Date.send(@method, 2000, 13, 31) }.should raise_error(ArgumentError)
- lambda { Date.send(@method, 2000, 12, 32) }.should raise_error(ArgumentError)
- lambda { Date.send(@method, 2000, 2, 30) }.should raise_error(ArgumentError)
- lambda { Date.send(@method, 1900, 2, 29) }.should raise_error(ArgumentError)
- lambda { Date.send(@method, 2000, 2, 29) }.should_not raise_error(ArgumentError)
-
- lambda { Date.send(@method, 1582, 10, 14) }.should raise_error(ArgumentError)
- lambda { Date.send(@method, 1582, 10, 15) }.should_not raise_error(ArgumentError)
-
- end
-
- it "creates a Date for different calendar reform dates" do
- d1 = Date.send(@method, 1582, 10, 4)
- d1.succ.day.should == 15
-
- d2 = Date.send(@method, 1582, 10, 4, Date::ENGLAND)
- d2.succ.day.should == 5
- end
-end
diff --git a/spec/rubyspec/library/date/shared/commercial.rb b/spec/rubyspec/library/date/shared/commercial.rb
deleted file mode 100644
index 354a5d5cd0..0000000000
--- a/spec/rubyspec/library/date/shared/commercial.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-describe :date_commercial, shared: true do
- it "creates a Date for Julian Day Number day 0 by default" do
- d = Date.send(@method)
- d.year.should == -4712
- d.month.should == 1
- d.day.should == 1
- end
-
- it "creates a Date for the monday in the year and week given" do
- d = Date.send(@method, 2000, 1)
- d.year.should == 2000
- d.month.should == 1
- d.day.should == 3
- d.cwday.should == 1
- end
-
- it "creates a Date for the correct day given the year, week and day number" do
- d = Date.send(@method, 2004, 1, 1)
- d.year.should == 2003
- d.month.should == 12
- d.day.should == 29
- d.cwday.should == 1
- d.cweek.should == 1
- d.cwyear.should == 2004
- end
-
- it "creates only Date objects for valid weeks" do
- lambda { Date.send(@method, 2004, 53, 1) }.should_not raise_error(ArgumentError)
- lambda { Date.send(@method, 2004, 53, 0) }.should raise_error(ArgumentError)
- lambda { Date.send(@method, 2004, 53, 8) }.should raise_error(ArgumentError)
- lambda { Date.send(@method, 2004, 54, 1) }.should raise_error(ArgumentError)
- lambda { Date.send(@method, 2004, 0, 1) }.should raise_error(ArgumentError)
-
- lambda { Date.send(@method, 2003, 52, 1) }.should_not raise_error(ArgumentError)
- lambda { Date.send(@method, 2003, 53, 1) }.should raise_error(ArgumentError)
- lambda { Date.send(@method, 2003, 52, 0) }.should raise_error(ArgumentError)
- lambda { Date.send(@method, 2003, 52, 8) }.should raise_error(ArgumentError)
- end
-end
diff --git a/spec/rubyspec/library/date/shared/jd.rb b/spec/rubyspec/library/date/shared/jd.rb
deleted file mode 100644
index 511557b4f7..0000000000
--- a/spec/rubyspec/library/date/shared/jd.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-describe :date_jd, shared: true do
- it "constructs a Date object if passed a Julian day" do
- Date.send(@method, 2454482).should == Date.civil(2008, 1, 16)
- end
-
- it "returns a Date object representing Julian day 0 (-4712-01-01) if no arguments passed" do
- Date.send(@method).should == Date.civil(-4712, 1, 1)
- end
-
- it "constructs a Date object if passed a negative number" do
- Date.send(@method, -1).should == Date.civil(-4713, 12, 31)
- end
-
-end
diff --git a/spec/rubyspec/library/date/shared/new_bang.rb b/spec/rubyspec/library/date/shared/new_bang.rb
deleted file mode 100644
index 90f1b432f0..0000000000
--- a/spec/rubyspec/library/date/shared/new_bang.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-describe :date_new_bang, shared: true do
-
- it "returns a new Date object set to Astronomical Julian Day 0 if no arguments passed" do
- d = Date.send(@method)
- d.ajd.should == 0
- end
-
- it "accepts astronomical julian day number, offset as a fraction of a day and returns a new Date object" do
- d = Date.send(@method, 10, 0.5)
- d.ajd.should == 10
- d.jd.should == 11
- end
-
-end
diff --git a/spec/rubyspec/library/date/shared/ordinal.rb b/spec/rubyspec/library/date/shared/ordinal.rb
deleted file mode 100644
index 4b182d5a25..0000000000
--- a/spec/rubyspec/library/date/shared/ordinal.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# reference:
-# October 1582 (the Gregorian calendar, Civil Date)
-# S M Tu W Th F S
-# 1 2 3 4 15 16
-# 17 18 19 20 21 22 23
-# 24 25 26 27 28 29 30
-# 31
-
-describe :date_ordinal, shared: true do
- it "constructs a Date object from an ordinal date" do
- # October 1582 (the Gregorian calendar, Ordinal Date)
- # S M Tu W Th F S
- # 274 275 276 277 278 279
- # 280 281 282 283 284 285 286
- # 287 288 289 290 291 292 293
- # 294
- Date.send(@method, 1582, 274).should == Date.civil(1582, 10, 1)
- Date.send(@method, 1582, 277).should == Date.civil(1582, 10, 4)
- Date.send(@method, 1582, 278).should == Date.civil(1582, 10, 15)
- Date.send(@method, 1582, 287, Date::ENGLAND).should == Date.civil(1582, 10, 14, Date::ENGLAND)
- end
-end
diff --git a/spec/rubyspec/library/date/shared/parse.rb b/spec/rubyspec/library/date/shared/parse.rb
deleted file mode 100644
index 1015285e04..0000000000
--- a/spec/rubyspec/library/date/shared/parse.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-describe :date_parse, shared: true do
- it "can parse a mmm-YYYY string into a Date object" do
- d = Date.parse("feb#{@sep}2008")
- d.year.should == 2008
- d.month.should == 2
- d.day.should == 1
- end
-
- it "can parse a 'DD mmm YYYY' string into a Date object" do
- d = Date.parse("23#{@sep}feb#{@sep}2008")
- d.year.should == 2008
- d.month.should == 2
- d.day.should == 23
- end
-
- it "can parse a 'mmm DD YYYY' string into a Date object" do
- d = Date.parse("23#{@sep}feb#{@sep}2008")
- d.year.should == 2008
- d.month.should == 2
- d.day.should == 23
- end
-
- it "can parse a 'YYYY mmm DD' string into a Date object" do
- d = Date.parse("2008#{@sep}feb#{@sep}23")
- d.year.should == 2008
- d.month.should == 2
- d.day.should == 23
- end
-
- it "can parse a month name and day into a Date object" do
- d = Date.parse("november#{@sep}5th")
- d.should == Date.civil(Date.today.year, 11, 5)
- end
-
- it "can parse a month name, day and year into a Date object" do
- d = Date.parse("november#{@sep}5th#{@sep}2005")
- d.should == Date.civil(2005, 11, 5)
- end
-
- it "can parse a year, month name and day into a Date object" do
- d = Date.parse("2005#{@sep}november#{@sep}5th")
- d.should == Date.civil(2005, 11, 5)
- end
-
- it "can parse a year, day and month name into a Date object" do
- d = Date.parse("5th#{@sep}november#{@sep}2005")
- d.should == Date.civil(2005, 11, 5)
- end
-
- it "can handle negative year numbers" do
- d = Date.parse("5th#{@sep}november#{@sep}-2005")
- d.should == Date.civil(-2005, 11, 5)
- end
-end
diff --git a/spec/rubyspec/library/date/shared/parse_eu.rb b/spec/rubyspec/library/date/shared/parse_eu.rb
deleted file mode 100644
index ecb15e3c0e..0000000000
--- a/spec/rubyspec/library/date/shared/parse_eu.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-describe :date_parse_eu, shared: true do
- # The - separator let's it work like European format, so it as a different spec
- it "can parse a YYYY-MM-DD string into a Date object" do
- d = Date.parse("2007#{@sep}10#{@sep}01")
- d.year.should == 2007
- d.month.should == 10
- d.day.should == 1
- end
-
- it "can parse a MM-DD-YYYY string into a Date object" do
- d = Date.parse("10#{@sep}01#{@sep}2007")
- d.year.should == 2007
- d.month.should == 1
- d.day.should == 10
- end
-
- it "can parse a MM-DD-YY string into a Date object" do
- d = Date.parse("10#{@sep}01#{@sep}07")
- d.year.should == 2010
- d.month.should == 1
- d.day.should == 7
- end
-
- it "can parse a MM-DD-YY string into a Date object NOT using the year digits as 20XX" do
- d = Date.parse("10#{@sep}01#{@sep}07", false)
- d.year.should == 10
- d.month.should == 1
- d.day.should == 7
- end
-
- it "can parse a MM-DD-YY string into a Date object using the year digits as 20XX" do
- d = Date.parse("10#{@sep}01#{@sep}07", true)
- d.year.should == 2010
- d.month.should == 1
- d.day.should == 7
- end
-end
diff --git a/spec/rubyspec/library/date/shared/parse_us.rb b/spec/rubyspec/library/date/shared/parse_us.rb
deleted file mode 100644
index 7be62b1af1..0000000000
--- a/spec/rubyspec/library/date/shared/parse_us.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-describe :date_parse_us, shared: true do
- it "parses a YYYY#{@sep}MM#{@sep}DD string into a Date object" do
- d = Date.parse("2007#{@sep}10#{@sep}01")
- d.year.should == 2007
- d.month.should == 10
- d.day.should == 1
- end
-
- it "parses a MM#{@sep}DD#{@sep}YYYY string into a Date object" do
- d = Date.parse("10#{@sep}01#{@sep}2007")
- d.year.should == 2007
- d.month.should == 1
- d.day.should == 10
- end
-
- it "parses a MM#{@sep}DD#{@sep}YY string into a Date object" do
- d = Date.parse("10#{@sep}01#{@sep}07")
- d.year.should == 2010
- d.month.should == 1
- d.day.should == 7
- end
-
- it "parses a MM#{@sep}DD#{@sep}YY string into a Date object NOT using the year digits as 20XX" do
- d = Date.parse("10#{@sep}01#{@sep}07", false)
- d.year.should == 10
- d.month.should == 1
- d.day.should == 7
- end
-
- it "parses a MM#{@sep}DD#{@sep}YY string into a Date object using the year digits as 20XX" do
- d = Date.parse("10#{@sep}01#{@sep}07", true)
- d.year.should == 2010
- d.month.should == 1
- d.day.should == 7
- end
-end
diff --git a/spec/rubyspec/library/date/shared/valid_civil.rb b/spec/rubyspec/library/date/shared/valid_civil.rb
deleted file mode 100644
index 545c207bbe..0000000000
--- a/spec/rubyspec/library/date/shared/valid_civil.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-describe :date_valid_civil?, shared: true do
-
- # reference:
- # October 1582 (the Gregorian calendar, Civil Date)
- # S M Tu W Th F S
- # 1 2 3 4 15 16
- # 17 18 19 20 21 22 23
- # 24 25 26 27 28 29 30
- # 31
-
- it "returns true if it is a valid civil date" do
- Date.send(@method, 1582, 10, 15).should be_true
- Date.send(@method, 1582, 10, 14, Date::ENGLAND).should be_true
- end
-
- it "returns false if it is not a valid civil date" do
- Date.send(@method, 1582, 10, 14).should == false
- end
-
- it "handles negative months and days" do
- # October 1582 (the Gregorian calendar, Civil Date)
- # S M Tu W Th F S
- # -21 -20 -19 -18 -17 -16
- # -15 -14 -13 -12 -11 -10 -9
- # -8 -7 -6 -5 -4 -3 -2
- # -1
- Date.send(@method, 1582, -3, -22).should be_false
- Date.send(@method, 1582, -3, -21).should be_true
- Date.send(@method, 1582, -3, -18).should be_true
- Date.send(@method, 1582, -3, -17).should be_true
-
- Date.send(@method, 2007, -11, -10).should be_true
- Date.send(@method, 2008, -11, -10).should be_true
- end
-
-end
diff --git a/spec/rubyspec/library/date/shared/valid_commercial.rb b/spec/rubyspec/library/date/shared/valid_commercial.rb
deleted file mode 100644
index 117dfe1d3d..0000000000
--- a/spec/rubyspec/library/date/shared/valid_commercial.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-describe :date_valid_commercial?, shared: true do
-
- it "returns true if it is a valid commercial date" do
- # October 1582 (the Gregorian calendar, Commercial Date)
- # M Tu W Th F Sa Su
- # 39: 1 2 3 4 5 6 7
- # 40: 1 2 3 4 5 6 7
- # 41: 1 2 3 4 5 6 7
- Date.send(@method, 1582, 39, 4).should be_true
- Date.send(@method, 1582, 39, 5).should be_true
- Date.send(@method, 1582, 41, 4).should be_true
- Date.send(@method, 1582, 41, 5).should be_true
- Date.send(@method, 1582, 41, 4, Date::ENGLAND).should be_true
- Date.send(@method, 1752, 37, 4, Date::ENGLAND).should be_true
- end
-
- it "returns false it is not a valid commercial date" do
- Date.send(@method, 1999, 53, 1).should be_false
- end
-
- it "handles negative week and day numbers" do
- # October 1582 (the Gregorian calendar, Commercial Date)
- # M Tu W Th F Sa Su
- # -12: -7 -6 -5 -4 -3 -2 -1
- # -11: -7 -6 -5 -4 -3 -2 -1
- # -10: -7 -6 -5 -4 -3 -2 -1
- Date.send(@method, 1582, -12, -4).should be_true
- Date.send(@method, 1582, -12, -3).should be_true
- Date.send(@method, 2007, -44, -2).should be_true
- Date.send(@method, 2008, -44, -2).should be_true
- Date.send(@method, 1999, -53, -1).should be_false
- end
-
-end
diff --git a/spec/rubyspec/library/date/shared/valid_jd.rb b/spec/rubyspec/library/date/shared/valid_jd.rb
deleted file mode 100644
index d8a35992b3..0000000000
--- a/spec/rubyspec/library/date/shared/valid_jd.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-describe :date_valid_jd?, shared: true do
- it "returns true if passed any value other than nil" do
- Date.send(@method, -100).should be_true
- Date.send(@method, :number).should be_true
- Date.send(@method, Rational(1,2)).should be_true
- end
-
- it "returns false if passed nil" do
- Date.send(@method, nil).should be_false
- end
-
- it "returns true if passed false" do
- Date.send(@method, false).should be_true
- end
-end
diff --git a/spec/rubyspec/library/date/shared/valid_ordinal.rb b/spec/rubyspec/library/date/shared/valid_ordinal.rb
deleted file mode 100644
index 1ed961be23..0000000000
--- a/spec/rubyspec/library/date/shared/valid_ordinal.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-describe :date_valid_ordinal?, shared: true do
- it "determines if the date is a valid ordinal date" do
- # October 1582 (the Gregorian calendar, Ordinal Date)
- # S M Tu W Th F S
- # 274 275 276 277 278 279
- # 280 281 282 283 284 285 286
- # 287 288 289 290 291 292 293
- # 294
- Date.send(@method, 1582, 277).should == true
- Date.send(@method, 1582, 278).should == true
- Date.send(@method, 1582, 287).should == true
- Date.send(@method, 1582, 288).should == true
- end
-
- it "handles negative day numbers" do
- # October 1582 (the Gregorian calendar, Ordinal Date)
- # S M Tu W Th F S
- # -82 -81 -80 -79 -78 -77
- # -76 -75 -74 -73 -72 -71 -70
- # -69 -68 -67 -66 -65 -64 -63
- # -62
- Date.send(@method, 1582, -79).should == true
- Date.send(@method, 1582, -78).should == true
- Date.send(@method, 2007, -100).should == true
- end
-end