From 1d15d5f08032acf1b7bceacbb450d617ff6e0931 Mon Sep 17 00:00:00 2001 From: eregon Date: Wed, 20 Sep 2017 20:18:52 +0000 Subject: Move spec/rubyspec to spec/ruby for consistency * Other ruby implementations use the spec/ruby directory. [Misc #13792] [ruby-core:82287] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- spec/ruby/library/date/accessor_spec.rb | 91 +++++++++++++ spec/ruby/library/date/add_month_spec.rb | 38 ++++++ spec/ruby/library/date/add_spec.rb | 30 +++++ spec/ruby/library/date/ajd_spec.rb | 6 + spec/ruby/library/date/ajd_to_amjd_spec.rb | 6 + spec/ruby/library/date/ajd_to_jd_spec.rb | 6 + spec/ruby/library/date/amjd_spec.rb | 6 + spec/ruby/library/date/amjd_to_ajd_spec.rb | 6 + spec/ruby/library/date/append_spec.rb | 6 + spec/ruby/library/date/asctime_spec.rb | 6 + spec/ruby/library/date/boat_spec.rb | 24 ++++ spec/ruby/library/date/case_compare_spec.rb | 6 + spec/ruby/library/date/civil_spec.rb | 12 ++ spec/ruby/library/date/commercial_spec.rb | 18 +++ spec/ruby/library/date/commercial_to_jd_spec.rb | 6 + spec/ruby/library/date/comparison_spec.rb | 6 + spec/ruby/library/date/constants_spec.rb | 44 ++++++ spec/ruby/library/date/conversions_spec.rb | 43 ++++++ spec/ruby/library/date/ctime_spec.rb | 6 + spec/ruby/library/date/cwday_spec.rb | 6 + spec/ruby/library/date/cweek_spec.rb | 6 + spec/ruby/library/date/cwyear_spec.rb | 6 + spec/ruby/library/date/day_fraction_spec.rb | 6 + .../ruby/library/date/day_fraction_to_time_spec.rb | 6 + spec/ruby/library/date/day_spec.rb | 6 + spec/ruby/library/date/downto_spec.rb | 18 +++ spec/ruby/library/date/england_spec.rb | 6 + spec/ruby/library/date/eql_spec.rb | 12 ++ .../library/date/format/bag/method_missing_spec.rb | 6 + spec/ruby/library/date/format/bag/to_hash_spec.rb | 6 + spec/ruby/library/date/gregorian_leap_spec.rb | 16 +++ spec/ruby/library/date/gregorian_spec.rb | 16 +++ spec/ruby/library/date/hash_spec.rb | 8 ++ spec/ruby/library/date/infinity/abs_spec.rb | 6 + spec/ruby/library/date/infinity/coerce_spec.rb | 6 + spec/ruby/library/date/infinity/comparison_spec.rb | 6 + spec/ruby/library/date/infinity/d_spec.rb | 6 + spec/ruby/library/date/infinity/finite_spec.rb | 6 + spec/ruby/library/date/infinity/infinite_spec.rb | 6 + spec/ruby/library/date/infinity/nan_spec.rb | 6 + spec/ruby/library/date/infinity/uminus_spec.rb | 6 + spec/ruby/library/date/infinity/uplus_spec.rb | 6 + spec/ruby/library/date/infinity/zero_spec.rb | 6 + spec/ruby/library/date/infinity_spec.rb | 67 +++++++++ spec/ruby/library/date/inspect_spec.rb | 6 + spec/ruby/library/date/italy_spec.rb | 6 + spec/ruby/library/date/jd_spec.rb | 15 +++ spec/ruby/library/date/jd_to_ajd_spec.rb | 6 + spec/ruby/library/date/jd_to_civil_spec.rb | 6 + spec/ruby/library/date/jd_to_commercial_spec.rb | 6 + spec/ruby/library/date/jd_to_ld_spec.rb | 6 + spec/ruby/library/date/jd_to_mjd_spec.rb | 6 + spec/ruby/library/date/jd_to_ordinal_spec.rb | 6 + spec/ruby/library/date/jd_to_wday_spec.rb | 6 + spec/ruby/library/date/julian_leap_spec.rb | 15 +++ spec/ruby/library/date/julian_spec.rb | 16 +++ spec/ruby/library/date/ld_spec.rb | 6 + spec/ruby/library/date/ld_to_jd_spec.rb | 6 + spec/ruby/library/date/leap_spec.rb | 10 ++ spec/ruby/library/date/mday_spec.rb | 6 + spec/ruby/library/date/minus_month_spec.rb | 34 +++++ spec/ruby/library/date/minus_spec.rb | 30 +++++ spec/ruby/library/date/mjd_spec.rb | 6 + spec/ruby/library/date/mjd_to_jd_spec.rb | 6 + spec/ruby/library/date/mon_spec.rb | 6 + spec/ruby/library/date/month_spec.rb | 6 + spec/ruby/library/date/new_spec.rb | 8 ++ spec/ruby/library/date/new_start_spec.rb | 6 + spec/ruby/library/date/next_day_spec.rb | 10 ++ spec/ruby/library/date/next_spec.rb | 6 + spec/ruby/library/date/next_year_spec.rb | 12 ++ spec/ruby/library/date/ordinal_spec.rb | 8 ++ spec/ruby/library/date/ordinal_to_jd_spec.rb | 6 + spec/ruby/library/date/parse_spec.rb | 137 +++++++++++++++++++ spec/ruby/library/date/plus_spec.rb | 20 +++ spec/ruby/library/date/prev_year_spec.rb | 12 ++ spec/ruby/library/date/relationship_spec.rb | 20 +++ spec/ruby/library/date/right_shift_spec.rb | 6 + spec/ruby/library/date/shared/civil.rb | 57 ++++++++ spec/ruby/library/date/shared/commercial.rb | 39 ++++++ spec/ruby/library/date/shared/jd.rb | 14 ++ spec/ruby/library/date/shared/new_bang.rb | 14 ++ spec/ruby/library/date/shared/ordinal.rb | 22 +++ spec/ruby/library/date/shared/parse.rb | 54 ++++++++ spec/ruby/library/date/shared/parse_eu.rb | 37 +++++ spec/ruby/library/date/shared/parse_us.rb | 36 +++++ spec/ruby/library/date/shared/valid_civil.rb | 36 +++++ spec/ruby/library/date/shared/valid_commercial.rb | 34 +++++ spec/ruby/library/date/shared/valid_jd.rb | 15 +++ spec/ruby/library/date/shared/valid_ordinal.rb | 26 ++++ spec/ruby/library/date/start_spec.rb | 6 + spec/ruby/library/date/step_spec.rb | 56 ++++++++ spec/ruby/library/date/strftime_spec.rb | 40 ++++++ spec/ruby/library/date/strptime_spec.rb | 149 +++++++++++++++++++++ spec/ruby/library/date/succ_spec.rb | 6 + .../ruby/library/date/time_to_day_fraction_spec.rb | 6 + spec/ruby/library/date/to_s_spec.rb | 6 + spec/ruby/library/date/today_spec.rb | 6 + spec/ruby/library/date/upto_spec.rb | 16 +++ spec/ruby/library/date/valid_civil_spec.rb | 10 ++ spec/ruby/library/date/valid_commercial_spec.rb | 10 ++ spec/ruby/library/date/valid_date_spec.rb | 7 + spec/ruby/library/date/valid_jd_spec.rb | 10 ++ spec/ruby/library/date/valid_ordinal_spec.rb | 10 ++ spec/ruby/library/date/valid_time_spec.rb | 6 + spec/ruby/library/date/wday_spec.rb | 6 + spec/ruby/library/date/yday_spec.rb | 6 + spec/ruby/library/date/year_spec.rb | 6 + spec/ruby/library/date/zone_to_diff_spec.rb | 6 + 109 files changed, 1836 insertions(+) create mode 100644 spec/ruby/library/date/accessor_spec.rb create mode 100644 spec/ruby/library/date/add_month_spec.rb create mode 100644 spec/ruby/library/date/add_spec.rb create mode 100644 spec/ruby/library/date/ajd_spec.rb create mode 100644 spec/ruby/library/date/ajd_to_amjd_spec.rb create mode 100644 spec/ruby/library/date/ajd_to_jd_spec.rb create mode 100644 spec/ruby/library/date/amjd_spec.rb create mode 100644 spec/ruby/library/date/amjd_to_ajd_spec.rb create mode 100644 spec/ruby/library/date/append_spec.rb create mode 100644 spec/ruby/library/date/asctime_spec.rb create mode 100644 spec/ruby/library/date/boat_spec.rb create mode 100644 spec/ruby/library/date/case_compare_spec.rb create mode 100644 spec/ruby/library/date/civil_spec.rb create mode 100644 spec/ruby/library/date/commercial_spec.rb create mode 100644 spec/ruby/library/date/commercial_to_jd_spec.rb create mode 100644 spec/ruby/library/date/comparison_spec.rb create mode 100644 spec/ruby/library/date/constants_spec.rb create mode 100644 spec/ruby/library/date/conversions_spec.rb create mode 100644 spec/ruby/library/date/ctime_spec.rb create mode 100644 spec/ruby/library/date/cwday_spec.rb create mode 100644 spec/ruby/library/date/cweek_spec.rb create mode 100644 spec/ruby/library/date/cwyear_spec.rb create mode 100644 spec/ruby/library/date/day_fraction_spec.rb create mode 100644 spec/ruby/library/date/day_fraction_to_time_spec.rb create mode 100644 spec/ruby/library/date/day_spec.rb create mode 100644 spec/ruby/library/date/downto_spec.rb create mode 100644 spec/ruby/library/date/england_spec.rb create mode 100644 spec/ruby/library/date/eql_spec.rb create mode 100644 spec/ruby/library/date/format/bag/method_missing_spec.rb create mode 100644 spec/ruby/library/date/format/bag/to_hash_spec.rb create mode 100644 spec/ruby/library/date/gregorian_leap_spec.rb create mode 100644 spec/ruby/library/date/gregorian_spec.rb create mode 100644 spec/ruby/library/date/hash_spec.rb create mode 100644 spec/ruby/library/date/infinity/abs_spec.rb create mode 100644 spec/ruby/library/date/infinity/coerce_spec.rb create mode 100644 spec/ruby/library/date/infinity/comparison_spec.rb create mode 100644 spec/ruby/library/date/infinity/d_spec.rb create mode 100644 spec/ruby/library/date/infinity/finite_spec.rb create mode 100644 spec/ruby/library/date/infinity/infinite_spec.rb create mode 100644 spec/ruby/library/date/infinity/nan_spec.rb create mode 100644 spec/ruby/library/date/infinity/uminus_spec.rb create mode 100644 spec/ruby/library/date/infinity/uplus_spec.rb create mode 100644 spec/ruby/library/date/infinity/zero_spec.rb create mode 100644 spec/ruby/library/date/infinity_spec.rb create mode 100644 spec/ruby/library/date/inspect_spec.rb create mode 100644 spec/ruby/library/date/italy_spec.rb create mode 100644 spec/ruby/library/date/jd_spec.rb create mode 100644 spec/ruby/library/date/jd_to_ajd_spec.rb create mode 100644 spec/ruby/library/date/jd_to_civil_spec.rb create mode 100644 spec/ruby/library/date/jd_to_commercial_spec.rb create mode 100644 spec/ruby/library/date/jd_to_ld_spec.rb create mode 100644 spec/ruby/library/date/jd_to_mjd_spec.rb create mode 100644 spec/ruby/library/date/jd_to_ordinal_spec.rb create mode 100644 spec/ruby/library/date/jd_to_wday_spec.rb create mode 100644 spec/ruby/library/date/julian_leap_spec.rb create mode 100644 spec/ruby/library/date/julian_spec.rb create mode 100644 spec/ruby/library/date/ld_spec.rb create mode 100644 spec/ruby/library/date/ld_to_jd_spec.rb create mode 100644 spec/ruby/library/date/leap_spec.rb create mode 100644 spec/ruby/library/date/mday_spec.rb create mode 100644 spec/ruby/library/date/minus_month_spec.rb create mode 100644 spec/ruby/library/date/minus_spec.rb create mode 100644 spec/ruby/library/date/mjd_spec.rb create mode 100644 spec/ruby/library/date/mjd_to_jd_spec.rb create mode 100644 spec/ruby/library/date/mon_spec.rb create mode 100644 spec/ruby/library/date/month_spec.rb create mode 100644 spec/ruby/library/date/new_spec.rb create mode 100644 spec/ruby/library/date/new_start_spec.rb create mode 100644 spec/ruby/library/date/next_day_spec.rb create mode 100644 spec/ruby/library/date/next_spec.rb create mode 100644 spec/ruby/library/date/next_year_spec.rb create mode 100644 spec/ruby/library/date/ordinal_spec.rb create mode 100644 spec/ruby/library/date/ordinal_to_jd_spec.rb create mode 100644 spec/ruby/library/date/parse_spec.rb create mode 100644 spec/ruby/library/date/plus_spec.rb create mode 100644 spec/ruby/library/date/prev_year_spec.rb create mode 100644 spec/ruby/library/date/relationship_spec.rb create mode 100644 spec/ruby/library/date/right_shift_spec.rb create mode 100644 spec/ruby/library/date/shared/civil.rb create mode 100644 spec/ruby/library/date/shared/commercial.rb create mode 100644 spec/ruby/library/date/shared/jd.rb create mode 100644 spec/ruby/library/date/shared/new_bang.rb create mode 100644 spec/ruby/library/date/shared/ordinal.rb create mode 100644 spec/ruby/library/date/shared/parse.rb create mode 100644 spec/ruby/library/date/shared/parse_eu.rb create mode 100644 spec/ruby/library/date/shared/parse_us.rb create mode 100644 spec/ruby/library/date/shared/valid_civil.rb create mode 100644 spec/ruby/library/date/shared/valid_commercial.rb create mode 100644 spec/ruby/library/date/shared/valid_jd.rb create mode 100644 spec/ruby/library/date/shared/valid_ordinal.rb create mode 100644 spec/ruby/library/date/start_spec.rb create mode 100644 spec/ruby/library/date/step_spec.rb create mode 100644 spec/ruby/library/date/strftime_spec.rb create mode 100644 spec/ruby/library/date/strptime_spec.rb create mode 100644 spec/ruby/library/date/succ_spec.rb create mode 100644 spec/ruby/library/date/time_to_day_fraction_spec.rb create mode 100644 spec/ruby/library/date/to_s_spec.rb create mode 100644 spec/ruby/library/date/today_spec.rb create mode 100644 spec/ruby/library/date/upto_spec.rb create mode 100644 spec/ruby/library/date/valid_civil_spec.rb create mode 100644 spec/ruby/library/date/valid_commercial_spec.rb create mode 100644 spec/ruby/library/date/valid_date_spec.rb create mode 100644 spec/ruby/library/date/valid_jd_spec.rb create mode 100644 spec/ruby/library/date/valid_ordinal_spec.rb create mode 100644 spec/ruby/library/date/valid_time_spec.rb create mode 100644 spec/ruby/library/date/wday_spec.rb create mode 100644 spec/ruby/library/date/yday_spec.rb create mode 100644 spec/ruby/library/date/year_spec.rb create mode 100644 spec/ruby/library/date/zone_to_diff_spec.rb (limited to 'spec/ruby/library/date') diff --git a/spec/ruby/library/date/accessor_spec.rb b/spec/ruby/library/date/accessor_spec.rb new file mode 100644 index 0000000000..91e0c3fc88 --- /dev/null +++ b/spec/ruby/library/date/accessor_spec.rb @@ -0,0 +1,91 @@ +require 'date' +require File.expand_path('../../../spec_helper', __FILE__) + +describe "Date#ajd" do + it "determines the Astronomical Julian day" do + Date.civil(2007, 1, 17).ajd.should == 4908235.to_r / 2 + end +end + +describe "Date#amjd" do + it "determines the Astronomical Modified Julian day" do + Date.civil(2007, 1, 17).amjd.should == 54117 + end +end + +describe "Date#day_fraction" do + it "determines the day fraction" do + Date.civil(2007, 1, 17).day_fraction.should == 0 + end +end + +describe "Date#mjd" do + it "determines the Modified Julian day" do + Date.civil(2007, 1, 17).mjd.should == 54117 + end +end + +describe "Date#ld" do + it "determines the Modified Julian day" do + Date.civil(2007, 1, 17).ld.should == 154958 + end +end + +describe "Date#year" do + it "determines the year" do + Date.civil(2007, 1, 17).year.should == 2007 + end +end + +describe "Date#yday" do + it "determines the year" do + Date.civil(2007, 1, 17).yday.should == 17 + Date.civil(2008, 10, 28).yday.should == 302 + end +end + +describe "Date#mon" do + it "determines the month" do + Date.civil(2007, 1, 17).mon.should == 1 + Date.civil(2008, 10, 28).mon.should == 10 + end +end + +describe "Date#mday" do + it "determines the day of the month" do + Date.civil(2007, 1, 17).mday.should == 17 + Date.civil(2008, 10, 28).mday.should == 28 + end +end + +describe "Date#wday" do + it "determines the week day" do + Date.civil(2007, 1, 17).wday.should == 3 + Date.civil(2008, 10, 26).wday.should == 0 + end +end + +describe "Date#cwyear" do + it "determines the commercial year" do + Date.civil(2007, 1, 17).cwyear.should == 2007 + Date.civil(2008, 10, 28).cwyear.should == 2008 + Date.civil(2007, 12, 31).cwyear.should == 2008 + Date.civil(2010, 1, 1).cwyear.should == 2009 + end +end + +describe "Date#cweek" do + it "determines the commercial week" do + Date.civil(2007, 1, 17).cweek.should == 3 + Date.civil(2008, 10, 28).cweek.should == 44 + Date.civil(2007, 12, 31).cweek.should == 1 + Date.civil(2010, 1, 1).cweek.should == 53 + end +end + +describe "Date#cwday" do + it "determines the commercial week day" do + Date.civil(2007, 1, 17).cwday.should == 3 + Date.civil(2008, 10, 26).cwday.should == 7 + end +end diff --git a/spec/ruby/library/date/add_month_spec.rb b/spec/ruby/library/date/add_month_spec.rb new file mode 100644 index 0000000000..46f1915b70 --- /dev/null +++ b/spec/ruby/library/date/add_month_spec.rb @@ -0,0 +1,38 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#>>" do + it "adds the number of months to a Date" do + d = Date.civil(2007,2,27) >> 10 + d.should == Date.civil(2007, 12, 27) + end + + it "sets the day to the last day of a month if the day doesn't exist" do + d = Date.civil(2008,3,31) >> 1 + d.should == Date.civil(2008, 4, 30) + end + + it "returns the day of the reform if date falls within calendar reform" do + calendar_reform_italy = Date.new(1582, 10, 4) + d1 = Date.new(1582, 9, 9) >> 1 + d2 = Date.new(1582, 9, 10) >> 1 + d1.should == calendar_reform_italy + d2.should == calendar_reform_italy + end + + it "raise a TypeError when passed a Symbol" do + lambda { Date.civil(2007,2,27) >> :hello }.should raise_error(TypeError) + end + + it "raise a TypeError when passed a String" do + lambda { Date.civil(2007,2,27) >> "hello" }.should raise_error(TypeError) + end + + it "raise a TypeError when passed a Date" do + lambda { Date.civil(2007,2,27) >> Date.new }.should raise_error(TypeError) + end + + it "raise a TypeError when passed an Object" do + lambda { Date.civil(2007,2,27) >> Object.new }.should raise_error(TypeError) + end +end diff --git a/spec/ruby/library/date/add_spec.rb b/spec/ruby/library/date/add_spec.rb new file mode 100644 index 0000000000..022b793318 --- /dev/null +++ b/spec/ruby/library/date/add_spec.rb @@ -0,0 +1,30 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#+" do + it "adds the number of days to a Date" do + d = Date.civil(2007,2,27) + 10 + d.should == Date.civil(2007, 3, 9) + end + + it "adds a negative number of days to a Date" do + d = Date.civil(2007,2,27).+(-10) + d.should == Date.civil(2007, 2, 17) + end + + it "raises a TypeError when passed a Symbol" do + lambda { Date.civil(2007,2,27) + :hello }.should raise_error(TypeError) + end + + it "raises a TypeError when passed a String" do + lambda { Date.civil(2007,2,27) + "hello" }.should raise_error(TypeError) + end + + it "raises a TypeError when passed a Date" do + lambda { Date.civil(2007,2,27) + Date.new }.should raise_error(TypeError) + end + + it "raises a TypeError when passed an Object" do + lambda { Date.civil(2007,2,27) + Object.new }.should raise_error(TypeError) + end +end diff --git a/spec/ruby/library/date/ajd_spec.rb b/spec/ruby/library/date/ajd_spec.rb new file mode 100644 index 0000000000..fcbcea2426 --- /dev/null +++ b/spec/ruby/library/date/ajd_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#ajd" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/ajd_to_amjd_spec.rb b/spec/ruby/library/date/ajd_to_amjd_spec.rb new file mode 100644 index 0000000000..fc6a35d0c6 --- /dev/null +++ b/spec/ruby/library/date/ajd_to_amjd_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date.ajd_to_amjd" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/ajd_to_jd_spec.rb b/spec/ruby/library/date/ajd_to_jd_spec.rb new file mode 100644 index 0000000000..1d8d6d0eb5 --- /dev/null +++ b/spec/ruby/library/date/ajd_to_jd_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date.ajd_to_jd" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/amjd_spec.rb b/spec/ruby/library/date/amjd_spec.rb new file mode 100644 index 0000000000..212871ee18 --- /dev/null +++ b/spec/ruby/library/date/amjd_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#amjd" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/amjd_to_ajd_spec.rb b/spec/ruby/library/date/amjd_to_ajd_spec.rb new file mode 100644 index 0000000000..f45f202a40 --- /dev/null +++ b/spec/ruby/library/date/amjd_to_ajd_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date.amjd_to_ajd" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/append_spec.rb b/spec/ruby/library/date/append_spec.rb new file mode 100644 index 0000000000..d90eff9a7a --- /dev/null +++ b/spec/ruby/library/date/append_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#<<" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/asctime_spec.rb b/spec/ruby/library/date/asctime_spec.rb new file mode 100644 index 0000000000..13dede0f05 --- /dev/null +++ b/spec/ruby/library/date/asctime_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#asctime" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/boat_spec.rb b/spec/ruby/library/date/boat_spec.rb new file mode 100644 index 0000000000..3004c6bfbc --- /dev/null +++ b/spec/ruby/library/date/boat_spec.rb @@ -0,0 +1,24 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#<=>" do + it "returns 0 when two dates are equal" do + (Date.civil(2000, 04, 06) <=> Date.civil(2000, 04, 06)).should == 0 + end + + it "returns -1 when self is less than another date" do + (Date.civil(2000, 04, 05) <=> Date.civil(2000, 04, 06)).should == -1 + end + + it "returns -1 when self is less than a Numeric" do + (Date.civil(2000, 04, 05) <=> Date.civil(2000, 04, 06).jd).should == -1 + end + + it "returns 1 when self is greater than another date" do + (Date.civil(2001, 04, 05) <=> Date.civil(2000, 04, 06)).should == 1 + end + + it "returns 1 when self is greater than a Numeric" do + (Date.civil(2001, 04, 05) <=> Date.civil(2000, 04, 06).jd).should == 1 + end +end diff --git a/spec/ruby/library/date/case_compare_spec.rb b/spec/ruby/library/date/case_compare_spec.rb new file mode 100644 index 0000000000..2144a616a3 --- /dev/null +++ b/spec/ruby/library/date/case_compare_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#===" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/civil_spec.rb b/spec/ruby/library/date/civil_spec.rb new file mode 100644 index 0000000000..36e790aecd --- /dev/null +++ b/spec/ruby/library/date/civil_spec.rb @@ -0,0 +1,12 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require File.expand_path('../shared/civil', __FILE__) +require 'date' + +describe "Date#civil" do + it_behaves_like(:date_civil, :civil) +end + + +describe "Date.civil" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/commercial_spec.rb b/spec/ruby/library/date/commercial_spec.rb new file mode 100644 index 0000000000..bb6671eda1 --- /dev/null +++ b/spec/ruby/library/date/commercial_spec.rb @@ -0,0 +1,18 @@ +require 'date' +require File.expand_path('../../../spec_helper', __FILE__) +require File.expand_path('../shared/commercial', __FILE__) + +describe "Date#commercial" do + + it_behaves_like(:date_commercial, :commercial) + +end + +# 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 + diff --git a/spec/ruby/library/date/commercial_to_jd_spec.rb b/spec/ruby/library/date/commercial_to_jd_spec.rb new file mode 100644 index 0000000000..61631a7977 --- /dev/null +++ b/spec/ruby/library/date/commercial_to_jd_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date.commercial_to_jd" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/comparison_spec.rb b/spec/ruby/library/date/comparison_spec.rb new file mode 100644 index 0000000000..04bfa2e8f7 --- /dev/null +++ b/spec/ruby/library/date/comparison_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#<=>" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/constants_spec.rb b/spec/ruby/library/date/constants_spec.rb new file mode 100644 index 0000000000..8e564fe665 --- /dev/null +++ b/spec/ruby/library/date/constants_spec.rb @@ -0,0 +1,44 @@ +require 'date' +require File.expand_path('../../../spec_helper', __FILE__) + +describe "Date constants" do + + it "defines JULIAN" do + (Date::JULIAN <=> Date::Infinity.new).should == 0 + end + + it "defines GREGORIAN" do + (Date::GREGORIAN <=> -Date::Infinity.new).should == 0 + end + + it "defines ITALY" do + Date::ITALY.should == 2299161 # 1582-10-15 + end + + it "defines ENGLAND" do + Date::ENGLAND.should == 2361222 # 1752-09-14 + end + + it "defines MONTHNAMES" do + Date::MONTHNAMES.should == [nil] + %w(January February March April May June July + August September October November December) + end + + it "defines DAYNAMES" do + Date::DAYNAMES.should == %w(Sunday Monday Tuesday Wednesday Thursday Friday Saturday) + end + + it "defines ABBR_MONTHNAMES" do + Date::ABBR_DAYNAMES.should == %w(Sun Mon Tue Wed Thu Fri Sat) + end + + it "freezes MONTHNAMES, DAYNAMES, ABBR_MONTHNAMES, ABBR_DAYSNAMES" do + [Date::MONTHNAMES, Date::DAYNAMES, Date::ABBR_MONTHNAMES, Date::ABBR_DAYNAMES].each do |ary| + lambda { ary << "Unknown" }.should raise_error + ary.compact.each do |name| + lambda { name << "modified" }.should raise_error + end + end + end + +end diff --git a/spec/ruby/library/date/conversions_spec.rb b/spec/ruby/library/date/conversions_spec.rb new file mode 100644 index 0000000000..c52ade7012 --- /dev/null +++ b/spec/ruby/library/date/conversions_spec.rb @@ -0,0 +1,43 @@ +require 'date' +require File.expand_path('../../../spec_helper', __FILE__) + + +describe "Date#new_start" do + it "converts a date object into another with a new calendar reform" do + Date.civil(1582, 10, 14, Date::ENGLAND).new_start.should == Date.civil(1582, 10, 24) + Date.civil(1582, 10, 4, Date::ENGLAND).new_start.should == Date.civil(1582, 10, 4) + Date.civil(1582, 10, 15).new_start(Date::ENGLAND).should == Date.civil(1582, 10, 5, Date::ENGLAND) + Date.civil(1752, 9, 14).new_start(Date::ENGLAND).should == Date.civil(1752, 9, 14, Date::ENGLAND) + Date.civil(1752, 9, 13).new_start(Date::ENGLAND).should == Date.civil(1752, 9, 2, Date::ENGLAND) + end +end + +describe "Date#italy" do + it "converts a date object into another with the Italian calendar reform" do + Date.civil(1582, 10, 14, Date::ENGLAND).italy.should == Date.civil(1582, 10, 24) + Date.civil(1582, 10, 4, Date::ENGLAND).italy.should == Date.civil(1582, 10, 4) + end +end + +describe "Date#england" do + it "converts a date object into another with the English calendar reform" do + Date.civil(1582, 10, 15).england.should == Date.civil(1582, 10, 5, Date::ENGLAND) + Date.civil(1752, 9, 14).england.should == Date.civil(1752, 9, 14, Date::ENGLAND) + Date.civil(1752, 9, 13).england.should == Date.civil(1752, 9, 2, Date::ENGLAND) + end +end + +describe "Date#julian" do + it "converts a date object into another with the Julian calendar" do + Date.civil(1582, 10, 15).julian.should == Date.civil(1582, 10, 5, Date::JULIAN) + Date.civil(1752, 9, 14).julian.should == Date.civil(1752, 9, 3, Date::JULIAN) + Date.civil(1752, 9, 13).julian.should == Date.civil(1752, 9, 2, Date::JULIAN) + end +end + +describe "Date#gregorian" do + it "converts a date object into another with the Gregorian calendar" do + Date.civil(1582, 10, 4).gregorian.should == Date.civil(1582, 10, 14, Date::GREGORIAN) + Date.civil(1752, 9, 14).gregorian.should == Date.civil(1752, 9, 14, Date::GREGORIAN) + end +end diff --git a/spec/ruby/library/date/ctime_spec.rb b/spec/ruby/library/date/ctime_spec.rb new file mode 100644 index 0000000000..0f5d594842 --- /dev/null +++ b/spec/ruby/library/date/ctime_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#ctime" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/cwday_spec.rb b/spec/ruby/library/date/cwday_spec.rb new file mode 100644 index 0000000000..33ede37b2c --- /dev/null +++ b/spec/ruby/library/date/cwday_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#cwday" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/cweek_spec.rb b/spec/ruby/library/date/cweek_spec.rb new file mode 100644 index 0000000000..d988bdd9db --- /dev/null +++ b/spec/ruby/library/date/cweek_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#cweek" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/cwyear_spec.rb b/spec/ruby/library/date/cwyear_spec.rb new file mode 100644 index 0000000000..00544927bc --- /dev/null +++ b/spec/ruby/library/date/cwyear_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#cwyear" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/day_fraction_spec.rb b/spec/ruby/library/date/day_fraction_spec.rb new file mode 100644 index 0000000000..64896a421e --- /dev/null +++ b/spec/ruby/library/date/day_fraction_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#day_fraction" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/day_fraction_to_time_spec.rb b/spec/ruby/library/date/day_fraction_to_time_spec.rb new file mode 100644 index 0000000000..609367371a --- /dev/null +++ b/spec/ruby/library/date/day_fraction_to_time_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date.day_fraction_to_time" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/day_spec.rb b/spec/ruby/library/date/day_spec.rb new file mode 100644 index 0000000000..7dfca4d77c --- /dev/null +++ b/spec/ruby/library/date/day_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#day" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/downto_spec.rb b/spec/ruby/library/date/downto_spec.rb new file mode 100644 index 0000000000..ab9bf11952 --- /dev/null +++ b/spec/ruby/library/date/downto_spec.rb @@ -0,0 +1,18 @@ +require 'date' +require File.expand_path('../../../spec_helper', __FILE__) + +describe "Date#downto" do + + it "creates earlier dates when passed a negative step" do + ds = Date.civil(2000, 4, 14) + de = Date.civil(2000, 3, 29) + count = 0 + ds.step(de, -1) do |d| + d.should <= ds + d.should >= de + count += 1 + end + count.should == 17 + end + +end diff --git a/spec/ruby/library/date/england_spec.rb b/spec/ruby/library/date/england_spec.rb new file mode 100644 index 0000000000..6c67c6ee86 --- /dev/null +++ b/spec/ruby/library/date/england_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#england" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/eql_spec.rb b/spec/ruby/library/date/eql_spec.rb new file mode 100644 index 0000000000..efecde8944 --- /dev/null +++ b/spec/ruby/library/date/eql_spec.rb @@ -0,0 +1,12 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#eql?" do + it "returns true if self is equal to another date" do + Date.civil(2007, 10, 11).eql?(Date.civil(2007, 10, 11)).should be_true + end + + it "returns false if self is not equal to another date" do + Date.civil(2007, 10, 11).eql?(Date.civil(2007, 10, 12)).should be_false + end +end diff --git a/spec/ruby/library/date/format/bag/method_missing_spec.rb b/spec/ruby/library/date/format/bag/method_missing_spec.rb new file mode 100644 index 0000000000..529fde05d2 --- /dev/null +++ b/spec/ruby/library/date/format/bag/method_missing_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../../../spec_helper', __FILE__) +require 'date' + +describe "Date::Format::Bag#method_missing" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/format/bag/to_hash_spec.rb b/spec/ruby/library/date/format/bag/to_hash_spec.rb new file mode 100644 index 0000000000..ba9525e5e8 --- /dev/null +++ b/spec/ruby/library/date/format/bag/to_hash_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../../../spec_helper', __FILE__) +require 'date' + +describe "Date::Format::Bag#to_hash" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/gregorian_leap_spec.rb b/spec/ruby/library/date/gregorian_leap_spec.rb new file mode 100644 index 0000000000..043d57aa93 --- /dev/null +++ b/spec/ruby/library/date/gregorian_leap_spec.rb @@ -0,0 +1,16 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#gregorian_leap?" do + it "returns true if a year is a leap year in the Gregorian calendar" do + Date.gregorian_leap?(2000).should be_true + Date.gregorian_leap?(2004).should be_true + end + + it "returns false if a year is not a leap year in the Gregorian calendar" do + Date.gregorian_leap?(1900).should be_false + Date.gregorian_leap?(1999).should be_false + Date.gregorian_leap?(2002).should be_false + end +end + diff --git a/spec/ruby/library/date/gregorian_spec.rb b/spec/ruby/library/date/gregorian_spec.rb new file mode 100644 index 0000000000..5d8b38b2d8 --- /dev/null +++ b/spec/ruby/library/date/gregorian_spec.rb @@ -0,0 +1,16 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#gregorian?" do + + it "marks a day before the calendar reform as Julian" do + Date.civil(1007, 2, 27).gregorian?.should be_false + Date.civil(1907, 2, 27, Date.civil(1930, 1, 1).jd).gregorian?.should be_false + end + + it "marks a day after the calendar reform as Julian" do + Date.civil(2007, 2, 27).gregorian?.should == true + Date.civil(1607, 2, 27, Date.civil(1582, 1, 1).jd).gregorian?.should be_true + end + +end diff --git a/spec/ruby/library/date/hash_spec.rb b/spec/ruby/library/date/hash_spec.rb new file mode 100644 index 0000000000..271d565253 --- /dev/null +++ b/spec/ruby/library/date/hash_spec.rb @@ -0,0 +1,8 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#hash" do + it "returns the same value for equal dates" do + Date.civil(2004, 7, 12).hash.should == Date.civil(2004, 7, 12).hash + end +end diff --git a/spec/ruby/library/date/infinity/abs_spec.rb b/spec/ruby/library/date/infinity/abs_spec.rb new file mode 100644 index 0000000000..a1107679f6 --- /dev/null +++ b/spec/ruby/library/date/infinity/abs_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../../spec_helper', __FILE__) +require 'date' + +describe "Date::Infinity#abs" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/infinity/coerce_spec.rb b/spec/ruby/library/date/infinity/coerce_spec.rb new file mode 100644 index 0000000000..e09b948064 --- /dev/null +++ b/spec/ruby/library/date/infinity/coerce_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../../spec_helper', __FILE__) +require 'date' + +describe "Date::Infinity#coerce" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/infinity/comparison_spec.rb b/spec/ruby/library/date/infinity/comparison_spec.rb new file mode 100644 index 0000000000..7bf8fb7b9f --- /dev/null +++ b/spec/ruby/library/date/infinity/comparison_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../../spec_helper', __FILE__) +require 'date' + +describe "Date::Infinity#<=>" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/infinity/d_spec.rb b/spec/ruby/library/date/infinity/d_spec.rb new file mode 100644 index 0000000000..9ef1f71408 --- /dev/null +++ b/spec/ruby/library/date/infinity/d_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../../spec_helper', __FILE__) +require 'date' + +describe "Date::Infinity#d" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/infinity/finite_spec.rb b/spec/ruby/library/date/infinity/finite_spec.rb new file mode 100644 index 0000000000..92806935fc --- /dev/null +++ b/spec/ruby/library/date/infinity/finite_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../../spec_helper', __FILE__) +require 'date' + +describe "Date::Infinity#finite?" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/infinity/infinite_spec.rb b/spec/ruby/library/date/infinity/infinite_spec.rb new file mode 100644 index 0000000000..8c7e0bc86a --- /dev/null +++ b/spec/ruby/library/date/infinity/infinite_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../../spec_helper', __FILE__) +require 'date' + +describe "Date::Infinity#infinite?" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/infinity/nan_spec.rb b/spec/ruby/library/date/infinity/nan_spec.rb new file mode 100644 index 0000000000..19c7ae0af3 --- /dev/null +++ b/spec/ruby/library/date/infinity/nan_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../../spec_helper', __FILE__) +require 'date' + +describe "Date::Infinity#nan?" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/infinity/uminus_spec.rb b/spec/ruby/library/date/infinity/uminus_spec.rb new file mode 100644 index 0000000000..110e197231 --- /dev/null +++ b/spec/ruby/library/date/infinity/uminus_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../../spec_helper', __FILE__) +require 'date' + +describe "Date::Infinity#-@" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/infinity/uplus_spec.rb b/spec/ruby/library/date/infinity/uplus_spec.rb new file mode 100644 index 0000000000..dfc60b6b61 --- /dev/null +++ b/spec/ruby/library/date/infinity/uplus_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../../spec_helper', __FILE__) +require 'date' + +describe "Date::Infinity#+@" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/infinity/zero_spec.rb b/spec/ruby/library/date/infinity/zero_spec.rb new file mode 100644 index 0000000000..2f4347255b --- /dev/null +++ b/spec/ruby/library/date/infinity/zero_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../../spec_helper', __FILE__) +require 'date' + +describe "Date::Infinity#zero?" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/infinity_spec.rb b/spec/ruby/library/date/infinity_spec.rb new file mode 100644 index 0000000000..127fb8c2f4 --- /dev/null +++ b/spec/ruby/library/date/infinity_spec.rb @@ -0,0 +1,67 @@ +require 'date' +require File.expand_path('../../../spec_helper', __FILE__) + +describe "Date::Infinity" do + + it "should be able to check whether Infinity is zero" do + i = Date::Infinity.new + i.zero?.should == false + end + + it "should be able to check whether Infinity is finite" do + i1 = Date::Infinity.new + i1.finite?.should == false + i2 = Date::Infinity.new(-1) + i2.finite?.should == false + i3 = Date::Infinity.new(0) + i3.finite?.should == false + end + + it "should be able to check whether Infinity is infinite" do + i1 = Date::Infinity.new + i1.infinite?.should == 1 + i2 = Date::Infinity.new(-1) + i2.infinite?.should == -1 + i3 = Date::Infinity.new(0) + i3.infinite?.should == nil + end + + it "should be able to check whether Infinity is not a number" do + i1 = Date::Infinity.new + i1.nan?.should == false + i2 = Date::Infinity.new(-1) + i2.nan?.should == false + i3 = Date::Infinity.new(0) + i3.nan?.should == true + end + + it "should be able to compare Infinity objects" do + i1 = Date::Infinity.new + i2 = Date::Infinity.new(-1) + i3 = Date::Infinity.new(0) + i4 = Date::Infinity.new + (i4 <=> i1).should == 0 + (i3 <=> i1).should == -1 + (i2 <=> i1).should == -1 + (i3 <=> i2).should == 1 + end + + it "should be able to return plus Infinity for abs" do + i1 = Date::Infinity.new + i2 = Date::Infinity.new(-1) + i3 = Date::Infinity.new(0) + (i2.abs <=> i1).should == 0 + (i3.abs <=> i1).should == 0 + end + + it "should be able to use -@ and +@ for Date::Infinity" do + (Date::Infinity.new <=> +Date::Infinity.new).should == 0 + (Date::Infinity.new(-1) <=> -Date::Infinity.new).should == 0 + end + + it "should be able to coerce a Date::Infinity object" do + Date::Infinity.new.coerce(1).should == [-1, 1] + Date::Infinity.new(0).coerce(2).should == [0, 0] + Date::Infinity.new(-1).coerce(1.5).should == [1, -1] + end +end diff --git a/spec/ruby/library/date/inspect_spec.rb b/spec/ruby/library/date/inspect_spec.rb new file mode 100644 index 0000000000..150eb6bf24 --- /dev/null +++ b/spec/ruby/library/date/inspect_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#inspect" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/italy_spec.rb b/spec/ruby/library/date/italy_spec.rb new file mode 100644 index 0000000000..2d251db1b0 --- /dev/null +++ b/spec/ruby/library/date/italy_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#italy" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/jd_spec.rb b/spec/ruby/library/date/jd_spec.rb new file mode 100644 index 0000000000..ccf6b93e06 --- /dev/null +++ b/spec/ruby/library/date/jd_spec.rb @@ -0,0 +1,15 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require File.expand_path('../shared/jd', __FILE__) +require 'date' + +describe "Date#jd" do + + it "determines the Julian day for a Date object" do + Date.civil(2008, 1, 16).jd.should == 2454482 + end + +end + +describe "Date.jd" do + it_behaves_like :date_jd, :jd +end diff --git a/spec/ruby/library/date/jd_to_ajd_spec.rb b/spec/ruby/library/date/jd_to_ajd_spec.rb new file mode 100644 index 0000000000..38a12bd65d --- /dev/null +++ b/spec/ruby/library/date/jd_to_ajd_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date.jd_to_ajd" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/jd_to_civil_spec.rb b/spec/ruby/library/date/jd_to_civil_spec.rb new file mode 100644 index 0000000000..8608de2698 --- /dev/null +++ b/spec/ruby/library/date/jd_to_civil_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date.jd_to_civil" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/jd_to_commercial_spec.rb b/spec/ruby/library/date/jd_to_commercial_spec.rb new file mode 100644 index 0000000000..97d76130f2 --- /dev/null +++ b/spec/ruby/library/date/jd_to_commercial_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date.jd_to_commercial" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/jd_to_ld_spec.rb b/spec/ruby/library/date/jd_to_ld_spec.rb new file mode 100644 index 0000000000..d27ada6b6c --- /dev/null +++ b/spec/ruby/library/date/jd_to_ld_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date.jd_to_ld" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/jd_to_mjd_spec.rb b/spec/ruby/library/date/jd_to_mjd_spec.rb new file mode 100644 index 0000000000..064134c7ed --- /dev/null +++ b/spec/ruby/library/date/jd_to_mjd_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date.jd_to_mjd" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/jd_to_ordinal_spec.rb b/spec/ruby/library/date/jd_to_ordinal_spec.rb new file mode 100644 index 0000000000..a5f5c79641 --- /dev/null +++ b/spec/ruby/library/date/jd_to_ordinal_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date.jd_to_ordinal" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/jd_to_wday_spec.rb b/spec/ruby/library/date/jd_to_wday_spec.rb new file mode 100644 index 0000000000..569a53e409 --- /dev/null +++ b/spec/ruby/library/date/jd_to_wday_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date.jd_to_wday" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/julian_leap_spec.rb b/spec/ruby/library/date/julian_leap_spec.rb new file mode 100644 index 0000000000..3915f97693 --- /dev/null +++ b/spec/ruby/library/date/julian_leap_spec.rb @@ -0,0 +1,15 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date.julian_leap?" do + it "determines whether a year is a leap year in the Julian calendar" do + Date.julian_leap?(1900).should be_true + Date.julian_leap?(2000).should be_true + Date.julian_leap?(2004).should be_true + end + + it "determines whether a year is not a leap year in the Julian calendar" do + Date.julian_leap?(1999).should be_false + Date.julian_leap?(2002).should be_false + end +end diff --git a/spec/ruby/library/date/julian_spec.rb b/spec/ruby/library/date/julian_spec.rb new file mode 100644 index 0000000000..8cbe27b881 --- /dev/null +++ b/spec/ruby/library/date/julian_spec.rb @@ -0,0 +1,16 @@ +require 'date' +require File.expand_path('../../../spec_helper', __FILE__) + +describe "Date#julian?" do + + it "marks a day before the calendar reform as Julian" do + Date.civil(1007, 2, 27).julian?.should == true + Date.civil(1907, 2, 27, Date.civil(1930, 1, 1).jd).julian?.should be_true + end + + it "marks a day after the calendar reform as Julian" do + Date.civil(2007, 2, 27).julian?.should == false + Date.civil(1607, 2, 27, Date.civil(1582, 1, 1).jd).julian?.should be_false + end + +end diff --git a/spec/ruby/library/date/ld_spec.rb b/spec/ruby/library/date/ld_spec.rb new file mode 100644 index 0000000000..a59b519c04 --- /dev/null +++ b/spec/ruby/library/date/ld_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#ld" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/ld_to_jd_spec.rb b/spec/ruby/library/date/ld_to_jd_spec.rb new file mode 100644 index 0000000000..7adbbede37 --- /dev/null +++ b/spec/ruby/library/date/ld_to_jd_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date.ld_to_jd" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/leap_spec.rb b/spec/ruby/library/date/leap_spec.rb new file mode 100644 index 0000000000..bb8e920a3e --- /dev/null +++ b/spec/ruby/library/date/leap_spec.rb @@ -0,0 +1,10 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#leap?" do + it "needs to be reviewed for spec completeness" +end + +describe "Date.leap?" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/mday_spec.rb b/spec/ruby/library/date/mday_spec.rb new file mode 100644 index 0000000000..8a1d6e8d59 --- /dev/null +++ b/spec/ruby/library/date/mday_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#mday" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/minus_month_spec.rb b/spec/ruby/library/date/minus_month_spec.rb new file mode 100644 index 0000000000..b6b20c5578 --- /dev/null +++ b/spec/ruby/library/date/minus_month_spec.rb @@ -0,0 +1,34 @@ +require 'date' +require File.expand_path('../../../spec_helper', __FILE__) + +describe "Date#<<" do + + it "substracts a number of months from a date" do + d = Date.civil(2007,2,27) << 10 + d.should == Date.civil(2006, 4, 27) + end + + it "returns the last day of a month if the day doesn't exist" do + d = Date.civil(2008,3,31) << 1 + d.should == Date.civil(2008, 2, 29) + end + + ruby_version_is ""..."2.3" do + it "raises an error on non numeric parameters" do + lambda { Date.civil(2007,2,27) << :hello }.should raise_error + lambda { Date.civil(2007,2,27) << "hello" }.should raise_error + lambda { Date.civil(2007,2,27) << Date.new }.should raise_error + lambda { Date.civil(2007,2,27) << Object.new }.should raise_error + end + end + + ruby_version_is "2.3" do + it "raises an error on non numeric parameters" do + lambda { Date.civil(2007,2,27) << :hello }.should raise_error(TypeError) + lambda { Date.civil(2007,2,27) << "hello" }.should raise_error(TypeError) + lambda { Date.civil(2007,2,27) << Date.new }.should raise_error(TypeError) + lambda { Date.civil(2007,2,27) << Object.new }.should raise_error(TypeError) + end + end + +end diff --git a/spec/ruby/library/date/minus_spec.rb b/spec/ruby/library/date/minus_spec.rb new file mode 100644 index 0000000000..09da595872 --- /dev/null +++ b/spec/ruby/library/date/minus_spec.rb @@ -0,0 +1,30 @@ +require 'date' +require File.expand_path('../../../spec_helper', __FILE__) + +describe "Date#-" do + + it "substracts a number of days from a Date" do + d = Date.civil(2007, 5 ,2) - 13 + d.should == Date.civil(2007, 4, 19) + end + + it "substracts a negative number of days from a Date" do + d = Date.civil(2007, 4, 19).-(-13) + d.should == Date.civil(2007, 5 ,2) + end + + it "computes the difference between two dates" do + (Date.civil(2007,2,27) - Date.civil(2007,2,27)).should == 0 + (Date.civil(2007,2,27) - Date.civil(2007,2,26)).should == 1 + (Date.civil(2006,2,27) - Date.civil(2007,2,27)).should == -365 + (Date.civil(2008,2,27) - Date.civil(2007,2,27)).should == 365 + + end + + it "raises an error for non Numeric arguments" do + lambda { Date.civil(2007,2,27) - :hello }.should raise_error(TypeError) + lambda { Date.civil(2007,2,27) - "hello" }.should raise_error(TypeError) + lambda { Date.civil(2007,2,27) - Object.new }.should raise_error(TypeError) + end + +end diff --git a/spec/ruby/library/date/mjd_spec.rb b/spec/ruby/library/date/mjd_spec.rb new file mode 100644 index 0000000000..7de39f0047 --- /dev/null +++ b/spec/ruby/library/date/mjd_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#mjd" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/mjd_to_jd_spec.rb b/spec/ruby/library/date/mjd_to_jd_spec.rb new file mode 100644 index 0000000000..fdda1330e5 --- /dev/null +++ b/spec/ruby/library/date/mjd_to_jd_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date.mjd_to_jd" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/mon_spec.rb b/spec/ruby/library/date/mon_spec.rb new file mode 100644 index 0000000000..c3508b53bf --- /dev/null +++ b/spec/ruby/library/date/mon_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#mon" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/month_spec.rb b/spec/ruby/library/date/month_spec.rb new file mode 100644 index 0000000000..7a98f572b6 --- /dev/null +++ b/spec/ruby/library/date/month_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#month" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/new_spec.rb b/spec/ruby/library/date/new_spec.rb new file mode 100644 index 0000000000..f468036a01 --- /dev/null +++ b/spec/ruby/library/date/new_spec.rb @@ -0,0 +1,8 @@ +require 'date' +require File.expand_path('../../../spec_helper', __FILE__) +require File.expand_path('../shared/civil', __FILE__) +require File.expand_path('../shared/new_bang', __FILE__) + +describe "Date.new" do + it_behaves_like(:date_civil, :new) +end diff --git a/spec/ruby/library/date/new_start_spec.rb b/spec/ruby/library/date/new_start_spec.rb new file mode 100644 index 0000000000..94ec6bee46 --- /dev/null +++ b/spec/ruby/library/date/new_start_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#new_start" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/next_day_spec.rb b/spec/ruby/library/date/next_day_spec.rb new file mode 100644 index 0000000000..1ccb4df257 --- /dev/null +++ b/spec/ruby/library/date/next_day_spec.rb @@ -0,0 +1,10 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#next_day" do + it "returns the next day" do + d = Date.new(2000, 1, 5) + d1 = Date.new(2000, 1, 4).next_day + d1.should == d + end +end diff --git a/spec/ruby/library/date/next_spec.rb b/spec/ruby/library/date/next_spec.rb new file mode 100644 index 0000000000..d88d31e974 --- /dev/null +++ b/spec/ruby/library/date/next_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#next" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/next_year_spec.rb b/spec/ruby/library/date/next_year_spec.rb new file mode 100644 index 0000000000..70f2f7ab77 --- /dev/null +++ b/spec/ruby/library/date/next_year_spec.rb @@ -0,0 +1,12 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#next_year" do + it "returns the day of the reform if date falls within calendar reform" do + calendar_reform_italy = Date.new(1582, 10, 4) + d1 = Date.new(1581, 10, 9).next_year + d2 = Date.new(1581, 10, 10).next_year + d1.should == calendar_reform_italy + d2.should == calendar_reform_italy + end +end diff --git a/spec/ruby/library/date/ordinal_spec.rb b/spec/ruby/library/date/ordinal_spec.rb new file mode 100644 index 0000000000..a373692a7b --- /dev/null +++ b/spec/ruby/library/date/ordinal_spec.rb @@ -0,0 +1,8 @@ +require 'date' +require File.expand_path('../../../spec_helper', __FILE__) +require File.expand_path('../shared/ordinal', __FILE__) + +describe "Date.ordinal" do + it_behaves_like :date_ordinal, :ordinal +end + diff --git a/spec/ruby/library/date/ordinal_to_jd_spec.rb b/spec/ruby/library/date/ordinal_to_jd_spec.rb new file mode 100644 index 0000000000..0a76c69c00 --- /dev/null +++ b/spec/ruby/library/date/ordinal_to_jd_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date.ordinal_to_jd" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/parse_spec.rb b/spec/ruby/library/date/parse_spec.rb new file mode 100644 index 0000000000..092c658809 --- /dev/null +++ b/spec/ruby/library/date/parse_spec.rb @@ -0,0 +1,137 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require File.expand_path('../shared/parse', __FILE__) +require File.expand_path('../shared/parse_us', __FILE__) +require File.expand_path('../shared/parse_eu', __FILE__) +require 'date' + +describe "Date#parse" do + # The space separator is also different, doesn't work for only numbers + it "parses a day name into a Date object" do + d = Date.parse("friday") + d.should == Date.commercial(d.cwyear, d.cweek, 5) + end + + it "parses a month name into a Date object" do + d = Date.parse("october") + d.should == Date.civil(Date.today.year, 10) + end + + it "parses a month day into a Date object" do + d = Date.parse("5th") + d.should == Date.civil(Date.today.year, Date.today.month, 5) + end + + # Specs using numbers + it "throws an argument error for a single digit" do + lambda{ Date.parse("1") }.should raise_error(ArgumentError) + end + + it "parses DD as month day number" do + d = Date.parse("10") + d.should == Date.civil(Date.today.year, Date.today.month, 10) + end + + it "parses DDD as year day number" do + d = Date.parse("100") + if Date.gregorian_leap?(Date.today.year) + d.should == Date.civil(Date.today.year, 4, 9) + else + d.should == Date.civil(Date.today.year, 4, 10) + end + end + + it "parses MMDD as month and day" do + d = Date.parse("1108") + d.should == Date.civil(Date.today.year, 11, 8) + end + + it "parses YYDDD as year and day number in 1969--2068" do + d = Date.parse("10100") + d.should == Date.civil(2010, 4, 10) + end + + it "parses YYMMDD as year, month and day in 1969--2068" do + d = Date.parse("201023") + d.should == Date.civil(2020, 10, 23) + end + + it "parses YYYYDDD as year and day number" do + d = Date.parse("1910100") + d.should == Date.civil(1910, 4, 10) + end + + it "parses YYYYMMDD as year, month and day number" do + d = Date.parse("19101101") + d.should == Date.civil(1910, 11, 1) + end +end + +describe "Date#parse with '.' separator" do + before :all do + @sep = '.' + end + + it_should_behave_like "date_parse" +end + +describe "Date#parse with '/' separator" do + before :all do + @sep = '/' + end + + it_should_behave_like "date_parse" +end + +describe "Date#parse with ' ' separator" do + before :all do + @sep = ' ' + end + + it_should_behave_like "date_parse" +end + +describe "Date#parse with '/' separator US-style" do + before :all do + @sep = '/' + end + + it_should_behave_like "date_parse_us" +end + +describe "Date#parse with '-' separator EU-style" do + before :all do + @sep = '-' + end + + it_should_behave_like "date_parse_eu" +end + +describe "Date#parse(.)" do + it "parses YYYY.MM.DD into a Date object" do + d = Date.parse("2007.10.01") + d.year.should == 2007 + d.month.should == 10 + d.day.should == 1 + end + + it "parses DD.MM.YYYY into a Date object" do + d = Date.parse("10.01.2007") + d.year.should == 2007 + d.month.should == 1 + d.day.should == 10 + end + + it "parses YY.MM.DD into a Date object using the year 20YY" do + d = Date.parse("10.01.07") + d.year.should == 2010 + d.month.should == 1 + d.day.should == 7 + end + + it "parses YY.MM.DD using the year digits as 20YY when given true as additional argument" do + d = Date.parse("10.01.07", true) + d.year.should == 2010 + d.month.should == 1 + d.day.should == 7 + end +end diff --git a/spec/ruby/library/date/plus_spec.rb b/spec/ruby/library/date/plus_spec.rb new file mode 100644 index 0000000000..e33fb199eb --- /dev/null +++ b/spec/ruby/library/date/plus_spec.rb @@ -0,0 +1,20 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#+" do + before :all do + @date = Date.civil(2000, 1, 1) + end + + it "returns a new Date object that is n days later than the current one" do + (@date + 31).should == Date.civil(2000, 2, 1) + end + + it "accepts a negative argument and returns a new Date that is earlier than the current one" do + (@date + -1).should == Date.civil(1999, 12, 31) + end + + it "raises TypeError if argument is not Numeric" do + lambda { Date.today + Date.today }.should raise_error(TypeError) + end +end diff --git a/spec/ruby/library/date/prev_year_spec.rb b/spec/ruby/library/date/prev_year_spec.rb new file mode 100644 index 0000000000..4f27d1d1f9 --- /dev/null +++ b/spec/ruby/library/date/prev_year_spec.rb @@ -0,0 +1,12 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#prev_year" do + it "returns the day of the reform if date falls within calendar reform" do + calendar_reform_italy = Date.new(1582, 10, 4) + d1 = Date.new(1583, 10, 9).prev_year + d2 = Date.new(1583, 10, 10).prev_year + d1.should == calendar_reform_italy + d2.should == calendar_reform_italy + end +end diff --git a/spec/ruby/library/date/relationship_spec.rb b/spec/ruby/library/date/relationship_spec.rb new file mode 100644 index 0000000000..7c09457228 --- /dev/null +++ b/spec/ruby/library/date/relationship_spec.rb @@ -0,0 +1,20 @@ +require 'date' +require File.expand_path('../../../spec_helper', __FILE__) + +describe "Date#===" do + + it "returns 0 when comparing two equal dates" do + (Date.civil(2000, 04, 06) <=> Date.civil(2000, 04, 06)).should == 0 + end + + it "computes the difference between two dates" do + (Date.civil(2000, 04, 05) <=> Date.civil(2000, 04, 06)).should == -1 + (Date.civil(2001, 04, 05) <=> Date.civil(2000, 04, 06)).should == 1 + end + + it "compares to another numeric" do + (Date.civil(2000, 04, 05) <=> Date.civil(2000, 04, 06).jd).should == -1 + (Date.civil(2001, 04, 05) <=> Date.civil(2000, 04, 06).jd).should == 1 + end + +end diff --git a/spec/ruby/library/date/right_shift_spec.rb b/spec/ruby/library/date/right_shift_spec.rb new file mode 100644 index 0000000000..3d55e5abed --- /dev/null +++ b/spec/ruby/library/date/right_shift_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#>>" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/shared/civil.rb b/spec/ruby/library/date/shared/civil.rb new file mode 100644 index 0000000000..47dbed49fc --- /dev/null +++ b/spec/ruby/library/date/shared/civil.rb @@ -0,0 +1,57 @@ +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/ruby/library/date/shared/commercial.rb b/spec/ruby/library/date/shared/commercial.rb new file mode 100644 index 0000000000..354a5d5cd0 --- /dev/null +++ b/spec/ruby/library/date/shared/commercial.rb @@ -0,0 +1,39 @@ +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/ruby/library/date/shared/jd.rb b/spec/ruby/library/date/shared/jd.rb new file mode 100644 index 0000000000..511557b4f7 --- /dev/null +++ b/spec/ruby/library/date/shared/jd.rb @@ -0,0 +1,14 @@ +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/ruby/library/date/shared/new_bang.rb b/spec/ruby/library/date/shared/new_bang.rb new file mode 100644 index 0000000000..90f1b432f0 --- /dev/null +++ b/spec/ruby/library/date/shared/new_bang.rb @@ -0,0 +1,14 @@ +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/ruby/library/date/shared/ordinal.rb b/spec/ruby/library/date/shared/ordinal.rb new file mode 100644 index 0000000000..4b182d5a25 --- /dev/null +++ b/spec/ruby/library/date/shared/ordinal.rb @@ -0,0 +1,22 @@ +# 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/ruby/library/date/shared/parse.rb b/spec/ruby/library/date/shared/parse.rb new file mode 100644 index 0000000000..1015285e04 --- /dev/null +++ b/spec/ruby/library/date/shared/parse.rb @@ -0,0 +1,54 @@ +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/ruby/library/date/shared/parse_eu.rb b/spec/ruby/library/date/shared/parse_eu.rb new file mode 100644 index 0000000000..ecb15e3c0e --- /dev/null +++ b/spec/ruby/library/date/shared/parse_eu.rb @@ -0,0 +1,37 @@ +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/ruby/library/date/shared/parse_us.rb b/spec/ruby/library/date/shared/parse_us.rb new file mode 100644 index 0000000000..7be62b1af1 --- /dev/null +++ b/spec/ruby/library/date/shared/parse_us.rb @@ -0,0 +1,36 @@ +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/ruby/library/date/shared/valid_civil.rb b/spec/ruby/library/date/shared/valid_civil.rb new file mode 100644 index 0000000000..545c207bbe --- /dev/null +++ b/spec/ruby/library/date/shared/valid_civil.rb @@ -0,0 +1,36 @@ +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/ruby/library/date/shared/valid_commercial.rb b/spec/ruby/library/date/shared/valid_commercial.rb new file mode 100644 index 0000000000..117dfe1d3d --- /dev/null +++ b/spec/ruby/library/date/shared/valid_commercial.rb @@ -0,0 +1,34 @@ +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/ruby/library/date/shared/valid_jd.rb b/spec/ruby/library/date/shared/valid_jd.rb new file mode 100644 index 0000000000..d8a35992b3 --- /dev/null +++ b/spec/ruby/library/date/shared/valid_jd.rb @@ -0,0 +1,15 @@ +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/ruby/library/date/shared/valid_ordinal.rb b/spec/ruby/library/date/shared/valid_ordinal.rb new file mode 100644 index 0000000000..1ed961be23 --- /dev/null +++ b/spec/ruby/library/date/shared/valid_ordinal.rb @@ -0,0 +1,26 @@ +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 diff --git a/spec/ruby/library/date/start_spec.rb b/spec/ruby/library/date/start_spec.rb new file mode 100644 index 0000000000..285037b094 --- /dev/null +++ b/spec/ruby/library/date/start_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#start" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/step_spec.rb b/spec/ruby/library/date/step_spec.rb new file mode 100644 index 0000000000..249633e807 --- /dev/null +++ b/spec/ruby/library/date/step_spec.rb @@ -0,0 +1,56 @@ +require 'date' +require File.expand_path('../../../spec_helper', __FILE__) + +describe "Date#step" do + + it "steps forward in time" do + ds = Date.civil(2008, 10, 11) + de = Date.civil(2008, 9, 29) + count = 0 + de.step(ds) do |d| + d.should <= ds + d.should >= de + count += 1 + end + count.should == 13 + + count = 0 + de.step(ds, 5) do |d| + d.should <= ds + d.should >= de + count += 1 + end + count.should == 3 + + count = 0 + ds.step(de) do |d|; count += 1; end + count.should == 0 + + end + + it "steps backward in time" do + ds = Date.civil(2000, 4, 14) + de = Date.civil(2000, 3, 29) + count = 0 + ds.step(de, -1) do |d| + d.should <= ds + d.should >= de + count += 1 + end + count.should == 17 + + count = 0 + ds.step(de, -5) do |d| + d.should <= ds + d.should >= de + count += 1 + end + count.should == 4 + + count = 0 + de.step(ds, -1) do |d|; count += 1; end + count.should == 0 + + end + +end diff --git a/spec/ruby/library/date/strftime_spec.rb b/spec/ruby/library/date/strftime_spec.rb new file mode 100644 index 0000000000..81bb162ff7 --- /dev/null +++ b/spec/ruby/library/date/strftime_spec.rb @@ -0,0 +1,40 @@ +require 'date' +require File.expand_path('../../../shared/time/strftime_for_date', __FILE__) + +describe "Date#strftime" do + before :all do + @new_date = lambda { |y,m,d| Date.civil(y,m,d) } + + @date = Date.civil(2000, 4, 9) + end + + it_behaves_like :strftime_date, :strftime + + # Differences with Time + it "should be able to print the date with no argument" do + @date.strftime.should == "2000-04-09" + @date.strftime.should == @date.to_s + end + + # %Z is %:z for Date/DateTime + it "should be able to show the timezone with a : separator" do + @date.strftime("%Z").should == "+00:00" + end + + # %v is %e-%b-%Y for Date/DateTime + it "should be able to show the commercial week" do + @date.strftime("%v").should == " 9-Apr-2000" + @date.strftime("%v").should == @date.strftime('%e-%b-%Y') + end + + # additional conversion specifiers only in Date/DateTime + it 'shows the number of milliseconds since epoch' do + DateTime.new(1970, 1, 1).strftime('%Q').should == "0" + @date.strftime("%Q").should == "955238400000" + end + + it "should be able to show a full notation" do + @date.strftime("%+").should == "Sun Apr 9 00:00:00 +00:00 2000" + @date.strftime("%+").should == @date.strftime('%a %b %e %H:%M:%S %Z %Y') + end +end diff --git a/spec/ruby/library/date/strptime_spec.rb b/spec/ruby/library/date/strptime_spec.rb new file mode 100644 index 0000000000..21a73da086 --- /dev/null +++ b/spec/ruby/library/date/strptime_spec.rb @@ -0,0 +1,149 @@ +require 'date' +require File.expand_path('../../../spec_helper', __FILE__) + +describe "Date#strptime" do + + it "returns January 1, 4713 BCE when given no arguments" do + Date.strptime.should == Date.civil(-4712, 1, 1) + end + + it "uses the default format when not given a date format" do + Date.strptime("2000-04-06").should == Date.civil(2000, 4, 6) + Date.civil(2000, 4, 6).strftime.should == Date.civil(2000, 4, 6).to_s + end + + it "parses a full day name" do + d = Date.today + expected_date = Date.commercial(d.cwyear, d.cweek, 4) + # strptime assumed week that start on sunday, not monday + expected_date += 7 if d.cwday == 7 + Date.strptime("Thursday", "%A").should == expected_date + end + + it "parses a short day name" do + d = Date.today + expected_date = Date.commercial(d.cwyear, d.cweek, 4) + # strptime assumed week that start on sunday, not monday + expected_date += 7 if d.cwday == 7 + Date.strptime("Thu", "%a").should == expected_date + end + + it "parses a full month name" do + d = Date.today + Date.strptime("April", "%B").should == Date.civil(d.year, 4, 1) + end + + it "parses a short month name" do + d = Date.today + Date.strptime("Apr", "%b").should == Date.civil(d.year, 4, 1) + Date.strptime("Apr", "%h").should == Date.civil(d.year, 4, 1) + end + + it "parses a century" do + Date.strptime("06 20", "%y %C").should == Date.civil(2006, 1, 1) + end + + it "parses a month day with leading zeroes" do + d = Date.today + Date.strptime("06", "%d").should == Date.civil(d.year, d.month, 6) + end + + it "parses a month day with leading spaces" do + d = Date.today + Date.strptime(" 6", "%e").should == Date.civil(d.year, d.month, 6) + end + + it "parses a commercial year with leading zeroes" do + Date.strptime("2000", "%G").should == Date.civil(2000, 1, 3) + Date.strptime("2002", "%G").should == Date.civil(2001, 12, 31) + end + + it "parses a commercial year with only two digits" do + Date.strptime("68", "%g").should == Date.civil(2068, 1, 2) + Date.strptime("69", "%g").should == Date.civil(1968, 12, 30) + end + + it "parses a year day with leading zeroes" do + d = Date.today + if Date.gregorian_leap?(Date.today.year) + Date.strptime("097", "%j").should == Date.civil(d.year, 4, 6) + else + Date.strptime("097", "%j").should == Date.civil(d.year, 4, 7) + end + end + + it "parses a month with leading zeroes" do + d = Date.today + Date.strptime("04", "%m").should == Date.civil(d.year, 4, 1) + end + + it "parses a week number for a week starting on Sunday" do + Date.strptime("2010/1", "%Y/%U").should == Date.civil(2010, 1, 3) + end + + # See http://redmine.ruby-lang.org/repositories/diff/ruby-19?rev=24500 + it "parses a week number for a week starting on Monday" do + Date.strptime("2010/1", "%Y/%W").should == Date.civil(2010, 1, 4) + end + + it "parses a commercial week day" do + Date.strptime("2008 1", "%G %u").should == Date.civil(2007, 12, 31) + end + + it "parses a commercial week" do + d = Date.commercial(Date.today.cwyear,1,1) + Date.strptime("1", "%V").should == d + Date.strptime("15", "%V").should == Date.commercial(d.cwyear, 15, 1) + end + + it "parses a week day" do + Date.strptime("2007 4", "%Y %w").should == Date.civil(2007, 1, 4) + end + + it "parses a year in YYYY format" do + Date.strptime("2007", "%Y").should == Date.civil(2007, 1, 1) + end + + it "parses a year in YY format" do + Date.strptime("00", "%y").should == Date.civil(2000, 1, 1) + end + + ############################ + # Specs that combine stuff # + ############################ + + it "parses a full date" do + Date.strptime("Thu Apr 6 00:00:00 2000", "%c").should == Date.civil(2000, 4, 6) + Date.strptime("Thu Apr 6 00:00:00 2000", "%a %b %e %H:%M:%S %Y").should == Date.civil(2000, 4, 6) + end + + it "parses a date with slashes" do + Date.strptime("04/06/00", "%D").should == Date.civil(2000, 4, 6) + Date.strptime("04/06/00", "%m/%d/%y").should == Date.civil(2000, 4, 6) + end + + it "parses a date given as YYYY-MM-DD" do + Date.strptime("2000-04-06", "%F").should == Date.civil(2000, 4, 6) + Date.strptime("2000-04-06", "%Y-%m-%d").should == Date.civil(2000, 4, 6) + end + + it "parses a commercial week" do + Date.strptime(" 9-Apr-2000", "%v").should == Date.civil(2000, 4, 9) + Date.strptime(" 9-Apr-2000", "%e-%b-%Y").should == Date.civil(2000, 4, 9) + end + + it "parses a date given MM/DD/YY" do + Date.strptime("04/06/00", "%x").should == Date.civil(2000, 4, 6) + Date.strptime("04/06/00", "%m/%d/%y").should == Date.civil(2000, 4, 6) + end + + it "parses a date given in full notation" do + Date.strptime("Sun Apr 9 00:00:00 +00:00 2000", "%+").should == Date.civil(2000, 4, 9) + Date.strptime("Sun Apr 9 00:00:00 +00:00 2000", "%a %b %e %H:%M:%S %Z %Y").should == Date.civil(2000, 4, 9) + end + +end + +describe "Date.strptime" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/succ_spec.rb b/spec/ruby/library/date/succ_spec.rb new file mode 100644 index 0000000000..2650810e73 --- /dev/null +++ b/spec/ruby/library/date/succ_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#succ" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/time_to_day_fraction_spec.rb b/spec/ruby/library/date/time_to_day_fraction_spec.rb new file mode 100644 index 0000000000..06d477b601 --- /dev/null +++ b/spec/ruby/library/date/time_to_day_fraction_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date.time_to_day_fraction" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/to_s_spec.rb b/spec/ruby/library/date/to_s_spec.rb new file mode 100644 index 0000000000..a81297d689 --- /dev/null +++ b/spec/ruby/library/date/to_s_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#to_s" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/today_spec.rb b/spec/ruby/library/date/today_spec.rb new file mode 100644 index 0000000000..09e8ed6006 --- /dev/null +++ b/spec/ruby/library/date/today_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date.today" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/upto_spec.rb b/spec/ruby/library/date/upto_spec.rb new file mode 100644 index 0000000000..c99aabd1d7 --- /dev/null +++ b/spec/ruby/library/date/upto_spec.rb @@ -0,0 +1,16 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#upto" do + it "returns future dates for the default step value" do + ds = Date.civil(2008, 10, 11) + de = Date.civil(2008, 9, 29) + count = 0 + de.upto(ds) do |d| + d.should <= ds + d.should >= de + count += 1 + end + count.should == 13 + end +end diff --git a/spec/ruby/library/date/valid_civil_spec.rb b/spec/ruby/library/date/valid_civil_spec.rb new file mode 100644 index 0000000000..09185674ee --- /dev/null +++ b/spec/ruby/library/date/valid_civil_spec.rb @@ -0,0 +1,10 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require File.expand_path('../shared/valid_civil', __FILE__) +require 'date' + +describe "Date#valid_civil?" do + + it_behaves_like :date_valid_civil?, :valid_civil? + +end + diff --git a/spec/ruby/library/date/valid_commercial_spec.rb b/spec/ruby/library/date/valid_commercial_spec.rb new file mode 100644 index 0000000000..187d818233 --- /dev/null +++ b/spec/ruby/library/date/valid_commercial_spec.rb @@ -0,0 +1,10 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require File.expand_path('../shared/valid_commercial', __FILE__) +require 'date' + +describe "Date#valid_commercial?" do + + it_behaves_like :date_valid_commercial?, :valid_commercial? +end + + diff --git a/spec/ruby/library/date/valid_date_spec.rb b/spec/ruby/library/date/valid_date_spec.rb new file mode 100644 index 0000000000..ffaf007cd1 --- /dev/null +++ b/spec/ruby/library/date/valid_date_spec.rb @@ -0,0 +1,7 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require File.expand_path('../shared/valid_civil', __FILE__) +require 'date' + +describe "Date#valid_date?" do + it_behaves_like :date_valid_civil?, :valid_date? +end diff --git a/spec/ruby/library/date/valid_jd_spec.rb b/spec/ruby/library/date/valid_jd_spec.rb new file mode 100644 index 0000000000..9764c02f2b --- /dev/null +++ b/spec/ruby/library/date/valid_jd_spec.rb @@ -0,0 +1,10 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require File.expand_path('../shared/valid_jd', __FILE__) +require 'date' + +describe "Date.valid_jd?" do + + it_behaves_like :date_valid_jd?, :valid_jd? + +end + diff --git a/spec/ruby/library/date/valid_ordinal_spec.rb b/spec/ruby/library/date/valid_ordinal_spec.rb new file mode 100644 index 0000000000..e197bb2051 --- /dev/null +++ b/spec/ruby/library/date/valid_ordinal_spec.rb @@ -0,0 +1,10 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require File.expand_path('../shared/valid_ordinal', __FILE__) +require 'date' + +describe "Date.valid_ordinal?" do + + it_behaves_like :date_valid_ordinal?, :valid_ordinal? + +end + diff --git a/spec/ruby/library/date/valid_time_spec.rb b/spec/ruby/library/date/valid_time_spec.rb new file mode 100644 index 0000000000..e96f9041b7 --- /dev/null +++ b/spec/ruby/library/date/valid_time_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date.valid_time?" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/wday_spec.rb b/spec/ruby/library/date/wday_spec.rb new file mode 100644 index 0000000000..1d40b0c96c --- /dev/null +++ b/spec/ruby/library/date/wday_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#wday" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/yday_spec.rb b/spec/ruby/library/date/yday_spec.rb new file mode 100644 index 0000000000..92bf616406 --- /dev/null +++ b/spec/ruby/library/date/yday_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#yday" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/year_spec.rb b/spec/ruby/library/date/year_spec.rb new file mode 100644 index 0000000000..cca95dbe2a --- /dev/null +++ b/spec/ruby/library/date/year_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#year" do + it "needs to be reviewed for spec completeness" +end diff --git a/spec/ruby/library/date/zone_to_diff_spec.rb b/spec/ruby/library/date/zone_to_diff_spec.rb new file mode 100644 index 0000000000..a39de0b58e --- /dev/null +++ b/spec/ruby/library/date/zone_to_diff_spec.rb @@ -0,0 +1,6 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date.zone_to_diff" do + it "needs to be reviewed for spec completeness" +end -- cgit v1.2.3