month.rb 0.11.0 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +74 -0
- data/Gemfile +2 -0
- data/LICENSE +21 -0
- data/README.md +145 -0
- data/TODO.txt +26 -0
- data/lib/Month/VERSION.rb +1 -1
- data/month.rb.gemspec +44 -0
- data/test/tc_Date_to_month.rb +21 -0
- data/test/tc_Month_begin_date.rb +21 -0
- data/test/tc_Month_beginning.rb +21 -0
- data/test/tc_Month_beginning_of_month.rb +21 -0
- data/test/tc_Month_beginning_of_the_month.rb +21 -0
- data/test/tc_Month_cdate.rb +34 -0
- data/test/tc_Month_cdates.rb +111 -0
- data/test/tc_Month_comparator.rb +17 -0
- data/test/tc_Month_date.rb +34 -0
- data/test/tc_Month_dates.rb +111 -0
- data/test/tc_Month_day.rb +226 -0
- data/test/tc_Month_day_long.rb +152 -0
- data/test/tc_Month_day_short.rb +152 -0
- data/test/tc_Month_day_shortest.rb +152 -0
- data/test/tc_Month_days.rb +21 -0
- data/test/tc_Month_days_in_month.rb +21 -0
- data/test/tc_Month_days_in_the_month.rb +21 -0
- data/test/tc_Month_each_day.rb +21 -0
- data/test/tc_Month_end.rb +21 -0
- data/test/tc_Month_end_date.rb +21 -0
- data/test/tc_Month_end_of_month.rb +21 -0
- data/test/tc_Month_end_of_the_month.rb +21 -0
- data/test/tc_Month_eqlQ.rb +13 -0
- data/test/tc_Month_finish.rb +21 -0
- data/test/tc_Month_finish_date.rb +21 -0
- data/test/tc_Month_finish_of_month.rb +21 -0
- data/test/tc_Month_finish_of_the_month.rb +21 -0
- data/test/tc_Month_initialize.rb +28 -0
- data/test/tc_Month_last.rb +11 -0
- data/test/tc_Month_last_month.rb +11 -0
- data/test/tc_Month_method_missing.rb +116 -0
- data/test/tc_Month_minus.rb +23 -0
- data/test/tc_Month_next.rb +12 -0
- data/test/tc_Month_next_month.rb +12 -0
- data/test/tc_Month_plus.rb +23 -0
- data/test/tc_Month_prev.rb +11 -0
- data/test/tc_Month_prev_month.rb +11 -0
- data/test/tc_Month_previous.rb +11 -0
- data/test/tc_Month_previous_month.rb +11 -0
- data/test/tc_Month_prior.rb +11 -0
- data/test/tc_Month_prior_month.rb +11 -0
- data/test/tc_Month_self.begin_date.rb +46 -0
- data/test/tc_Month_self.beginning.rb +46 -0
- data/test/tc_Month_self.beginning_of_month.rb +46 -0
- data/test/tc_Month_self.beginning_of_the_month.rb +46 -0
- data/test/tc_Month_self.cdate.rb +33 -0
- data/test/tc_Month_self.cdates.rb +325 -0
- data/test/tc_Month_self.date.rb +33 -0
- data/test/tc_Month_self.dates.rb +325 -0
- data/test/tc_Month_self.day.rb +226 -0
- data/test/tc_Month_self.day_long.rb +152 -0
- data/test/tc_Month_self.day_short.rb +152 -0
- data/test/tc_Month_self.day_shortest.rb +152 -0
- data/test/tc_Month_self.days.rb +124 -0
- data/test/tc_Month_self.days_in_month.rb +124 -0
- data/test/tc_Month_self.days_in_the_month.rb +124 -0
- data/test/tc_Month_self.end.rb +21 -0
- data/test/tc_Month_self.end_date.rb +21 -0
- data/test/tc_Month_self.end_of_month.rb +21 -0
- data/test/tc_Month_self.end_of_the_month.rb +21 -0
- data/test/tc_Month_self.finish.rb +21 -0
- data/test/tc_Month_self.finish_date.rb +21 -0
- data/test/tc_Month_self.finish_of_month.rb +21 -0
- data/test/tc_Month_self.finish_of_the_month.rb +21 -0
- data/test/tc_Month_self.from_date.rb +21 -0
- data/test/tc_Month_self.last.rb +47 -0
- data/test/tc_Month_self.last_month.rb +47 -0
- data/test/tc_Month_self.method_missing.rb +227 -0
- data/test/tc_Month_self.next.rb +23 -0
- data/test/tc_Month_self.next_month.rb +23 -0
- data/test/tc_Month_self.now.rb +9 -0
- data/test/tc_Month_self.of.rb +78 -0
- data/test/tc_Month_self.prev.rb +23 -0
- data/test/tc_Month_self.prev_month.rb +23 -0
- data/test/tc_Month_self.previous.rb +23 -0
- data/test/tc_Month_self.previous_month.rb +23 -0
- data/test/tc_Month_self.prior.rb +23 -0
- data/test/tc_Month_self.prior_month.rb +23 -0
- data/test/tc_Month_self.start.rb +21 -0
- data/test/tc_Month_self.start_date.rb +21 -0
- data/test/tc_Month_self.start_of_month.rb +21 -0
- data/test/tc_Month_self.start_of_the_month.rb +21 -0
- data/test/tc_Month_self.succ.rb +23 -0
- data/test/tc_Month_self.succ_month.rb +23 -0
- data/test/tc_Month_self.successor.rb +23 -0
- data/test/tc_Month_self.successor_month.rb +23 -0
- data/test/tc_Month_self.this.rb +23 -0
- data/test/tc_Month_self.to_i.rb +100 -0
- data/test/tc_Month_self.to_long.rb +100 -0
- data/test/tc_Month_self.to_num.rb +100 -0
- data/test/tc_Month_self.to_number.rb +100 -0
- data/test/tc_Month_self.to_short.rb +100 -0
- data/test/tc_Month_self.today.rb +9 -0
- data/test/tc_Month_self.wday.rb +292 -0
- data/test/tc_Month_start.rb +21 -0
- data/test/tc_Month_start_date.rb +21 -0
- data/test/tc_Month_start_of_month.rb +21 -0
- data/test/tc_Month_start_of_the_month.rb +21 -0
- data/test/tc_Month_succ.rb +11 -0
- data/test/tc_Month_succ_month.rb +11 -0
- data/test/tc_Month_successor.rb +11 -0
- data/test/tc_Month_successor_month.rb +11 -0
- data/test/tc_Month_to_date.rb +17 -0
- data/test/tc_Month_to_i.rb +20 -0
- data/test/tc_Month_to_long.rb +20 -0
- data/test/tc_Month_to_num.rb +20 -0
- data/test/tc_Month_to_number.rb +20 -0
- data/test/tc_Month_to_s.rb +40 -0
- data/test/tc_Month_to_short.rb +20 -0
- data/test/tc_gemspec.rb +42 -0
- data/test/ts_Month.rb +14 -0
- metadata +126 -5
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# test/tc_Month_day_shortest.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_self_day_shortest < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_num_as_num
|
|
6
|
+
assert_equal 'Su', Month.new(2006, 10).day_shortest(1)
|
|
7
|
+
assert_equal 'Mo', Month.new(2006, 10).day_shortest(2)
|
|
8
|
+
assert_equal 'Tu', Month.new(2006, 10).day_shortest(3)
|
|
9
|
+
assert_equal 'We', Month.new(2006, 10).day_shortest(4)
|
|
10
|
+
assert_equal 'Th', Month.new(2006, 10).day_shortest(5)
|
|
11
|
+
assert_equal 'Fr', Month.new(2006, 10).day_shortest(6)
|
|
12
|
+
assert_equal 'Sa', Month.new(2006, 10).day_shortest(7)
|
|
13
|
+
assert_equal 'Su', Month.new(2006, 10).day_shortest(8)
|
|
14
|
+
assert_equal 'Mo', Month.new(2006, 10).day_shortest(9)
|
|
15
|
+
assert_equal 'Tu', Month.new(2006, 10).day_shortest(10)
|
|
16
|
+
assert_equal 'We', Month.new(2006, 10).day_shortest(11)
|
|
17
|
+
assert_equal 'Th', Month.new(2006, 10).day_shortest(12)
|
|
18
|
+
assert_equal 'Fr', Month.new(2006, 10).day_shortest(13)
|
|
19
|
+
assert_equal 'Sa', Month.new(2006, 10).day_shortest(14)
|
|
20
|
+
assert_equal 'Su', Month.new(2006, 10).day_shortest(15)
|
|
21
|
+
assert_equal 'Mo', Month.new(2006, 10).day_shortest(16)
|
|
22
|
+
assert_equal 'Tu', Month.new(2006, 10).day_shortest(17)
|
|
23
|
+
assert_equal 'We', Month.new(2006, 10).day_shortest(18)
|
|
24
|
+
assert_equal 'Th', Month.new(2006, 10).day_shortest(19)
|
|
25
|
+
assert_equal 'Fr', Month.new(2006, 10).day_shortest(20)
|
|
26
|
+
assert_equal 'Sa', Month.new(2006, 10).day_shortest(21)
|
|
27
|
+
assert_equal 'Su', Month.new(2006, 10).day_shortest(22)
|
|
28
|
+
assert_equal 'Mo', Month.new(2006, 10).day_shortest(23)
|
|
29
|
+
assert_equal 'Tu', Month.new(2006, 10).day_shortest(24)
|
|
30
|
+
assert_equal 'We', Month.new(2006, 10).day_shortest(25)
|
|
31
|
+
assert_equal 'Th', Month.new(2006, 10).day_shortest(26)
|
|
32
|
+
assert_equal 'Fr', Month.new(2006, 10).day_shortest(27)
|
|
33
|
+
assert_equal 'Sa', Month.new(2006, 10).day_shortest(28)
|
|
34
|
+
assert_equal 'Su', Month.new(2006, 10).day_shortest(29)
|
|
35
|
+
assert_equal 'Mo', Month.new(2006, 10).day_shortest(30)
|
|
36
|
+
assert_equal 'Tu', Month.new(2006, 10).day_shortest(31)
|
|
37
|
+
assert_equal 'We', Month.new(2006, 11).day_shortest(1)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_num_as_string
|
|
41
|
+
assert_equal 'Su', Month.new(2006, 10).day_shortest('1')
|
|
42
|
+
assert_equal 'Mo', Month.new(2006, 10).day_shortest('2')
|
|
43
|
+
assert_equal 'Tu', Month.new(2006, 10).day_shortest('3')
|
|
44
|
+
assert_equal 'We', Month.new(2006, 10).day_shortest('4')
|
|
45
|
+
assert_equal 'Th', Month.new(2006, 10).day_shortest('5')
|
|
46
|
+
assert_equal 'Fr', Month.new(2006, 10).day_shortest('6')
|
|
47
|
+
assert_equal 'Sa', Month.new(2006, 10).day_shortest('7')
|
|
48
|
+
assert_equal 'Su', Month.new(2006, 10).day_shortest('8')
|
|
49
|
+
assert_equal 'Mo', Month.new(2006, 10).day_shortest('9')
|
|
50
|
+
assert_equal 'Tu', Month.new(2006, 10).day_shortest('10')
|
|
51
|
+
assert_equal 'We', Month.new(2006, 10).day_shortest('11')
|
|
52
|
+
assert_equal 'Th', Month.new(2006, 10).day_shortest('12')
|
|
53
|
+
assert_equal 'Fr', Month.new(2006, 10).day_shortest('13')
|
|
54
|
+
assert_equal 'Sa', Month.new(2006, 10).day_shortest('14')
|
|
55
|
+
assert_equal 'Su', Month.new(2006, 10).day_shortest('15')
|
|
56
|
+
assert_equal 'Mo', Month.new(2006, 10).day_shortest('16')
|
|
57
|
+
assert_equal 'Tu', Month.new(2006, 10).day_shortest('17')
|
|
58
|
+
assert_equal 'We', Month.new(2006, 10).day_shortest('18')
|
|
59
|
+
assert_equal 'Th', Month.new(2006, 10).day_shortest('19')
|
|
60
|
+
assert_equal 'Fr', Month.new(2006, 10).day_shortest('20')
|
|
61
|
+
assert_equal 'Sa', Month.new(2006, 10).day_shortest('21')
|
|
62
|
+
assert_equal 'Su', Month.new(2006, 10).day_shortest('22')
|
|
63
|
+
assert_equal 'Mo', Month.new(2006, 10).day_shortest('23')
|
|
64
|
+
assert_equal 'Tu', Month.new(2006, 10).day_shortest('24')
|
|
65
|
+
assert_equal 'We', Month.new(2006, 10).day_shortest('25')
|
|
66
|
+
assert_equal 'Th', Month.new(2006, 10).day_shortest('26')
|
|
67
|
+
assert_equal 'Fr', Month.new(2006, 10).day_shortest('27')
|
|
68
|
+
assert_equal 'Sa', Month.new(2006, 10).day_shortest('28')
|
|
69
|
+
assert_equal 'Su', Month.new(2006, 10).day_shortest('29')
|
|
70
|
+
assert_equal 'Mo', Month.new(2006, 10).day_shortest('30')
|
|
71
|
+
assert_equal 'Tu', Month.new(2006, 10).day_shortest('31')
|
|
72
|
+
assert_equal 'We', Month.new(2006, 11).day_shortest('1')
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_num_as_num_with_defaults
|
|
76
|
+
if Date.today.year == 2006 && Date.today.month == 10
|
|
77
|
+
assert_equal 'Su', Month.new(2006, 10).day_shortest(1)
|
|
78
|
+
assert_equal 'Mo', Month.new(2006, 10).day_shortest(2)
|
|
79
|
+
assert_equal 'Tu', Month.new(2006, 10).day_shortest(3)
|
|
80
|
+
assert_equal 'We', Month.new(2006, 10).day_shortest(4)
|
|
81
|
+
assert_equal 'Th', Month.new(2006, 10).day_shortest(5)
|
|
82
|
+
assert_equal 'Fr', Month.new(2006, 10).day_shortest(6)
|
|
83
|
+
assert_equal 'Sa', Month.new(2006, 10).day_shortest(7)
|
|
84
|
+
assert_equal 'Su', Month.new(2006, 10).day_shortest(8)
|
|
85
|
+
assert_equal 'Mo', Month.new(2006, 10).day_shortest(9)
|
|
86
|
+
assert_equal 'Tu', Month.new(2006, 10).day_shortest(10)
|
|
87
|
+
assert_equal 'We', Month.new(2006, 10).day_shortest(11)
|
|
88
|
+
assert_equal 'Th', Month.new(2006, 10).day_shortest(12)
|
|
89
|
+
assert_equal 'Fr', Month.new(2006, 10).day_shortest(13)
|
|
90
|
+
assert_equal 'Sa', Month.new(2006, 10).day_shortest(14)
|
|
91
|
+
assert_equal 'Su', Month.new(2006, 10).day_shortest(15)
|
|
92
|
+
assert_equal 'Mo', Month.new(2006, 10).day_shortest(16)
|
|
93
|
+
assert_equal 'Tu', Month.new(2006, 10).day_shortest(17)
|
|
94
|
+
assert_equal 'We', Month.new(2006, 10).day_shortest(18)
|
|
95
|
+
assert_equal 'Th', Month.new(2006, 10).day_shortest(19)
|
|
96
|
+
assert_equal 'Fr', Month.new(2006, 10).day_shortest(20)
|
|
97
|
+
assert_equal 'Sa', Month.new(2006, 10).day_shortest(21)
|
|
98
|
+
assert_equal 'Su', Month.new(2006, 10).day_shortest(22)
|
|
99
|
+
assert_equal 'Mo', Month.new(2006, 10).day_shortest(23)
|
|
100
|
+
assert_equal 'Tu', Month.new(2006, 10).day_shortest(24)
|
|
101
|
+
assert_equal 'We', Month.new(2006, 10).day_shortest(25)
|
|
102
|
+
assert_equal 'Th', Month.new(2006, 10).day_shortest(26)
|
|
103
|
+
assert_equal 'Fr', Month.new(2006, 10).day_shortest(27)
|
|
104
|
+
assert_equal 'Sa', Month.new(2006, 10).day_shortest(28)
|
|
105
|
+
assert_equal 'Su', Month.new(2006, 10).day_shortest(29)
|
|
106
|
+
assert_equal 'Mo', Month.new(2006, 10).day_shortest(30)
|
|
107
|
+
assert_equal 'Tu', Month.new(2006, 10).day_shortest(31)
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def test_num_as_string_with_defaults
|
|
112
|
+
if Date.today.year == 2006 && Date.today.month == 10
|
|
113
|
+
assert_equal 'Su', Month.new(2006, 10).day_shortest('1')
|
|
114
|
+
assert_equal 'Mo', Month.new(2006, 10).day_shortest('2')
|
|
115
|
+
assert_equal 'Tu', Month.new(2006, 10).day_shortest('3')
|
|
116
|
+
assert_equal 'We', Month.new(2006, 10).day_shortest('4')
|
|
117
|
+
assert_equal 'Th', Month.new(2006, 10).day_shortest('5')
|
|
118
|
+
assert_equal 'Fr', Month.new(2006, 10).day_shortest('6')
|
|
119
|
+
assert_equal 'Sa', Month.new(2006, 10).day_shortest('7')
|
|
120
|
+
assert_equal 'Su', Month.new(2006, 10).day_shortest('8')
|
|
121
|
+
assert_equal 'Mo', Month.new(2006, 10).day_shortest('9')
|
|
122
|
+
assert_equal 'Tu', Month.new(2006, 10).day_shortest('10')
|
|
123
|
+
assert_equal 'We', Month.new(2006, 10).day_shortest('11')
|
|
124
|
+
assert_equal 'Th', Month.new(2006, 10).day_shortest('12')
|
|
125
|
+
assert_equal 'Fr', Month.new(2006, 10).day_shortest('13')
|
|
126
|
+
assert_equal 'Sa', Month.new(2006, 10).day_shortest('14')
|
|
127
|
+
assert_equal 'Su', Month.new(2006, 10).day_shortest('15')
|
|
128
|
+
assert_equal 'Mo', Month.new(2006, 10).day_shortest('16')
|
|
129
|
+
assert_equal 'Tu', Month.new(2006, 10).day_shortest('17')
|
|
130
|
+
assert_equal 'We', Month.new(2006, 10).day_shortest('18')
|
|
131
|
+
assert_equal 'Th', Month.new(2006, 10).day_shortest('19')
|
|
132
|
+
assert_equal 'Fr', Month.new(2006, 10).day_shortest('20')
|
|
133
|
+
assert_equal 'Sa', Month.new(2006, 10).day_shortest('21')
|
|
134
|
+
assert_equal 'Su', Month.new(2006, 10).day_shortest('22')
|
|
135
|
+
assert_equal 'Mo', Month.new(2006, 10).day_shortest('23')
|
|
136
|
+
assert_equal 'Tu', Month.new(2006, 10).day_shortest('24')
|
|
137
|
+
assert_equal 'We', Month.new(2006, 10).day_shortest('25')
|
|
138
|
+
assert_equal 'Th', Month.new(2006, 10).day_shortest('26')
|
|
139
|
+
assert_equal 'Fr', Month.new(2006, 10).day_shortest('27')
|
|
140
|
+
assert_equal 'Sa', Month.new(2006, 10).day_shortest('28')
|
|
141
|
+
assert_equal 'Su', Month.new(2006, 10).day_shortest('29')
|
|
142
|
+
assert_equal 'Mo', Month.new(2006, 10).day_shortest('30')
|
|
143
|
+
assert_equal 'Tu', Month.new(2006, 10).day_shortest('31')
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def test_crap
|
|
148
|
+
assert_nil Month.day_shortest('random')
|
|
149
|
+
assert_nil Month.day_shortest(32)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# test/tc_Month_days.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_days < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_days
|
|
6
|
+
assert_equal 31, Month.new(2006, 1).days
|
|
7
|
+
assert_equal 28, Month.new(2006, 2).days
|
|
8
|
+
assert_equal 29, Month.new(2008, 2).days
|
|
9
|
+
assert_equal 31, Month.new(2006, 3).days
|
|
10
|
+
assert_equal 30, Month.new(2006, 4).days
|
|
11
|
+
assert_equal 31, Month.new(2006, 5).days
|
|
12
|
+
assert_equal 30, Month.new(2006, 6).days
|
|
13
|
+
assert_equal 31, Month.new(2006, 7).days
|
|
14
|
+
assert_equal 31, Month.new(2006, 8).days
|
|
15
|
+
assert_equal 30, Month.new(2006, 9).days
|
|
16
|
+
assert_equal 31, Month.new(2006, 10).days
|
|
17
|
+
assert_equal 30, Month.new(2006, 11).days
|
|
18
|
+
assert_equal 31, Month.new(2006, 12).days
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# test/tc_Month_days_in_month.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_days_in_month < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_days_in_month
|
|
6
|
+
assert_equal 31, Month.new(2006, 1).days_in_month
|
|
7
|
+
assert_equal 28, Month.new(2006, 2).days_in_month
|
|
8
|
+
assert_equal 29, Month.new(2008, 2).days_in_month
|
|
9
|
+
assert_equal 31, Month.new(2006, 3).days_in_month
|
|
10
|
+
assert_equal 30, Month.new(2006, 4).days_in_month
|
|
11
|
+
assert_equal 31, Month.new(2006, 5).days_in_month
|
|
12
|
+
assert_equal 30, Month.new(2006, 6).days_in_month
|
|
13
|
+
assert_equal 31, Month.new(2006, 7).days_in_month
|
|
14
|
+
assert_equal 31, Month.new(2006, 8).days_in_month
|
|
15
|
+
assert_equal 30, Month.new(2006, 9).days_in_month
|
|
16
|
+
assert_equal 31, Month.new(2006, 10).days_in_month
|
|
17
|
+
assert_equal 30, Month.new(2006, 11).days_in_month
|
|
18
|
+
assert_equal 31, Month.new(2006, 12).days_in_month
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# test/tc_Month_days_in_the_month.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_days_in_the_month < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_days_in_the_month
|
|
6
|
+
assert_equal 31, Month.new(2006, 1).days_in_the_month
|
|
7
|
+
assert_equal 28, Month.new(2006, 2).days_in_the_month
|
|
8
|
+
assert_equal 29, Month.new(2008, 2).days_in_the_month
|
|
9
|
+
assert_equal 31, Month.new(2006, 3).days_in_the_month
|
|
10
|
+
assert_equal 30, Month.new(2006, 4).days_in_the_month
|
|
11
|
+
assert_equal 31, Month.new(2006, 5).days_in_the_month
|
|
12
|
+
assert_equal 30, Month.new(2006, 6).days_in_the_month
|
|
13
|
+
assert_equal 31, Month.new(2006, 7).days_in_the_month
|
|
14
|
+
assert_equal 31, Month.new(2006, 8).days_in_the_month
|
|
15
|
+
assert_equal 30, Month.new(2006, 9).days_in_the_month
|
|
16
|
+
assert_equal 31, Month.new(2006, 10).days_in_the_month
|
|
17
|
+
assert_equal 30, Month.new(2006, 11).days_in_the_month
|
|
18
|
+
assert_equal 31, Month.new(2006, 12).days_in_the_month
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# test/tc_Month_each_day.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_each_day < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_each_day
|
|
6
|
+
assert_equal 1..31, Month.new(2006, 1).each_day{}
|
|
7
|
+
assert_equal 1..28, Month.new(2006, 2).each_day{}
|
|
8
|
+
assert_equal 1..29, Month.new(2008, 2).each_day{}
|
|
9
|
+
assert_equal 1..31, Month.new(2006, 3).each_day{}
|
|
10
|
+
assert_equal 1..30, Month.new(2006, 4).each_day{}
|
|
11
|
+
assert_equal 1..31, Month.new(2006, 5).each_day{}
|
|
12
|
+
assert_equal 1..30, Month.new(2006, 6).each_day{}
|
|
13
|
+
assert_equal 1..31, Month.new(2006, 7).each_day{}
|
|
14
|
+
assert_equal 1..31, Month.new(2006, 8).each_day{}
|
|
15
|
+
assert_equal 1..30, Month.new(2006, 9).each_day{}
|
|
16
|
+
assert_equal 1..31, Month.new(2006, 10).each_day{}
|
|
17
|
+
assert_equal 1..30, Month.new(2006, 11).each_day{}
|
|
18
|
+
assert_equal 1..31, Month.new(2006, 12).each_day{}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# test/tc_Month_end.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_end < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_end
|
|
6
|
+
assert_equal Date.new(2006, 1, 31), Month.new(2006, 1).end
|
|
7
|
+
assert_equal Date.new(2006, 2, 28), Month.new(2006, 2).end
|
|
8
|
+
assert_equal Date.new(2008, 2, 29), Month.new(2008, 2).end
|
|
9
|
+
assert_equal Date.new(2006, 3, 31), Month.new(2006, 3).end
|
|
10
|
+
assert_equal Date.new(2006, 4, 30), Month.new(2006, 4).end
|
|
11
|
+
assert_equal Date.new(2006, 5, 31), Month.new(2006, 5).end
|
|
12
|
+
assert_equal Date.new(2006, 6, 30), Month.new(2006, 6).end
|
|
13
|
+
assert_equal Date.new(2006, 7, 31), Month.new(2006, 7).end
|
|
14
|
+
assert_equal Date.new(2006, 8, 31), Month.new(2006, 8).end
|
|
15
|
+
assert_equal Date.new(2006, 9, 30), Month.new(2006, 9).end
|
|
16
|
+
assert_equal Date.new(2006, 10, 31), Month.new(2006, 10).end
|
|
17
|
+
assert_equal Date.new(2006, 11, 30), Month.new(2006, 11).end
|
|
18
|
+
assert_equal Date.new(2006, 12, 31), Month.new(2006, 12).end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# test/tc_Month_end_date.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_end_date < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_end_date
|
|
6
|
+
assert_equal Date.new(2006, 1, 31), Month.new(2006, 1).end_date
|
|
7
|
+
assert_equal Date.new(2006, 2, 28), Month.new(2006, 2).end_date
|
|
8
|
+
assert_equal Date.new(2008, 2, 29), Month.new(2008, 2).end_date
|
|
9
|
+
assert_equal Date.new(2006, 3, 31), Month.new(2006, 3).end_date
|
|
10
|
+
assert_equal Date.new(2006, 4, 30), Month.new(2006, 4).end_date
|
|
11
|
+
assert_equal Date.new(2006, 5, 31), Month.new(2006, 5).end_date
|
|
12
|
+
assert_equal Date.new(2006, 6, 30), Month.new(2006, 6).end_date
|
|
13
|
+
assert_equal Date.new(2006, 7, 31), Month.new(2006, 7).end_date
|
|
14
|
+
assert_equal Date.new(2006, 8, 31), Month.new(2006, 8).end_date
|
|
15
|
+
assert_equal Date.new(2006, 9, 30), Month.new(2006, 9).end_date
|
|
16
|
+
assert_equal Date.new(2006, 10, 31), Month.new(2006, 10).end_date
|
|
17
|
+
assert_equal Date.new(2006, 11, 30), Month.new(2006, 11).end_date
|
|
18
|
+
assert_equal Date.new(2006, 12, 31), Month.new(2006, 12).end_date
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# test/tc_Month_end_of_month.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_end_of_month < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_end_of_month
|
|
6
|
+
assert_equal Date.new(2006, 1, 31), Month.new(2006, 1).end_of_month
|
|
7
|
+
assert_equal Date.new(2006, 2, 28), Month.new(2006, 2).end_of_month
|
|
8
|
+
assert_equal Date.new(2008, 2, 29), Month.new(2008, 2).end_of_month
|
|
9
|
+
assert_equal Date.new(2006, 3, 31), Month.new(2006, 3).end_of_month
|
|
10
|
+
assert_equal Date.new(2006, 4, 30), Month.new(2006, 4).end_of_month
|
|
11
|
+
assert_equal Date.new(2006, 5, 31), Month.new(2006, 5).end_of_month
|
|
12
|
+
assert_equal Date.new(2006, 6, 30), Month.new(2006, 6).end_of_month
|
|
13
|
+
assert_equal Date.new(2006, 7, 31), Month.new(2006, 7).end_of_month
|
|
14
|
+
assert_equal Date.new(2006, 8, 31), Month.new(2006, 8).end_of_month
|
|
15
|
+
assert_equal Date.new(2006, 9, 30), Month.new(2006, 9).end_of_month
|
|
16
|
+
assert_equal Date.new(2006, 10, 31), Month.new(2006, 10).end_of_month
|
|
17
|
+
assert_equal Date.new(2006, 11, 30), Month.new(2006, 11).end_of_month
|
|
18
|
+
assert_equal Date.new(2006, 12, 31), Month.new(2006, 12).end_of_month
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# test/tc_Month_end_of_the_month.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_end_of_the_month < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_end_of_the_month
|
|
6
|
+
assert_equal Date.new(2006, 1, 31), Month.new(2006, 1).end_of_the_month
|
|
7
|
+
assert_equal Date.new(2006, 2, 28), Month.new(2006, 2).end_of_the_month
|
|
8
|
+
assert_equal Date.new(2008, 2, 29), Month.new(2008, 2).end_of_the_month
|
|
9
|
+
assert_equal Date.new(2006, 3, 31), Month.new(2006, 3).end_of_the_month
|
|
10
|
+
assert_equal Date.new(2006, 4, 30), Month.new(2006, 4).end_of_the_month
|
|
11
|
+
assert_equal Date.new(2006, 5, 31), Month.new(2006, 5).end_of_the_month
|
|
12
|
+
assert_equal Date.new(2006, 6, 30), Month.new(2006, 6).end_of_the_month
|
|
13
|
+
assert_equal Date.new(2006, 7, 31), Month.new(2006, 7).end_of_the_month
|
|
14
|
+
assert_equal Date.new(2006, 8, 31), Month.new(2006, 8).end_of_the_month
|
|
15
|
+
assert_equal Date.new(2006, 9, 30), Month.new(2006, 9).end_of_the_month
|
|
16
|
+
assert_equal Date.new(2006, 10, 31), Month.new(2006, 10).end_of_the_month
|
|
17
|
+
assert_equal Date.new(2006, 11, 30), Month.new(2006, 11).end_of_the_month
|
|
18
|
+
assert_equal Date.new(2006, 12, 31), Month.new(2006, 12).end_of_the_month
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# test/tc_Month_eqlQ.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_eqlQ < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_eqlQ
|
|
6
|
+
assert_equal true, Month.new(2011, 1).eql?(Month.new(2011, 1))
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def test_equal_literal
|
|
10
|
+
assert_equal true, Month.new(2011, 1) == Month.new(2011, 1)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# test/tc_Month_finish.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_finish < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_finish
|
|
6
|
+
assert_equal Date.new(2006, 1, 31), Month.new(2006, 1).finish
|
|
7
|
+
assert_equal Date.new(2006, 2, 28), Month.new(2006, 2).finish
|
|
8
|
+
assert_equal Date.new(2008, 2, 29), Month.new(2008, 2).finish
|
|
9
|
+
assert_equal Date.new(2006, 3, 31), Month.new(2006, 3).finish
|
|
10
|
+
assert_equal Date.new(2006, 4, 30), Month.new(2006, 4).finish
|
|
11
|
+
assert_equal Date.new(2006, 5, 31), Month.new(2006, 5).finish
|
|
12
|
+
assert_equal Date.new(2006, 6, 30), Month.new(2006, 6).finish
|
|
13
|
+
assert_equal Date.new(2006, 7, 31), Month.new(2006, 7).finish
|
|
14
|
+
assert_equal Date.new(2006, 8, 31), Month.new(2006, 8).finish
|
|
15
|
+
assert_equal Date.new(2006, 9, 30), Month.new(2006, 9).finish
|
|
16
|
+
assert_equal Date.new(2006, 10, 31), Month.new(2006, 10).finish
|
|
17
|
+
assert_equal Date.new(2006, 11, 30), Month.new(2006, 11).finish
|
|
18
|
+
assert_equal Date.new(2006, 12, 31), Month.new(2006, 12).finish
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# test/tc_Month_finish_date.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_finish_date < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_finish_date
|
|
6
|
+
assert_equal Date.new(2006, 1, 31), Month.new(2006, 1).finish_date
|
|
7
|
+
assert_equal Date.new(2006, 2, 28), Month.new(2006, 2).finish_date
|
|
8
|
+
assert_equal Date.new(2008, 2, 29), Month.new(2008, 2).finish_date
|
|
9
|
+
assert_equal Date.new(2006, 3, 31), Month.new(2006, 3).finish_date
|
|
10
|
+
assert_equal Date.new(2006, 4, 30), Month.new(2006, 4).finish_date
|
|
11
|
+
assert_equal Date.new(2006, 5, 31), Month.new(2006, 5).finish_date
|
|
12
|
+
assert_equal Date.new(2006, 6, 30), Month.new(2006, 6).finish_date
|
|
13
|
+
assert_equal Date.new(2006, 7, 31), Month.new(2006, 7).finish_date
|
|
14
|
+
assert_equal Date.new(2006, 8, 31), Month.new(2006, 8).finish_date
|
|
15
|
+
assert_equal Date.new(2006, 9, 30), Month.new(2006, 9).finish_date
|
|
16
|
+
assert_equal Date.new(2006, 10, 31), Month.new(2006, 10).finish_date
|
|
17
|
+
assert_equal Date.new(2006, 11, 30), Month.new(2006, 11).finish_date
|
|
18
|
+
assert_equal Date.new(2006, 12, 31), Month.new(2006, 12).finish_date
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# test/tc_Month_finish_of_month.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_end < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_finish_of_month
|
|
6
|
+
assert_equal Date.new(2006, 1, 31), Month.new(2006, 1).finish_of_month
|
|
7
|
+
assert_equal Date.new(2006, 2, 28), Month.new(2006, 2).finish_of_month
|
|
8
|
+
assert_equal Date.new(2008, 2, 29), Month.new(2008, 2).finish_of_month
|
|
9
|
+
assert_equal Date.new(2006, 3, 31), Month.new(2006, 3).finish_of_month
|
|
10
|
+
assert_equal Date.new(2006, 4, 30), Month.new(2006, 4).finish_of_month
|
|
11
|
+
assert_equal Date.new(2006, 5, 31), Month.new(2006, 5).finish_of_month
|
|
12
|
+
assert_equal Date.new(2006, 6, 30), Month.new(2006, 6).finish_of_month
|
|
13
|
+
assert_equal Date.new(2006, 7, 31), Month.new(2006, 7).finish_of_month
|
|
14
|
+
assert_equal Date.new(2006, 8, 31), Month.new(2006, 8).finish_of_month
|
|
15
|
+
assert_equal Date.new(2006, 9, 30), Month.new(2006, 9).finish_of_month
|
|
16
|
+
assert_equal Date.new(2006, 10, 31), Month.new(2006, 10).finish_of_month
|
|
17
|
+
assert_equal Date.new(2006, 11, 30), Month.new(2006, 11).finish_of_month
|
|
18
|
+
assert_equal Date.new(2006, 12, 31), Month.new(2006, 12).finish_of_month
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# test/tc_Month_finish_of_the_month.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_finish_of_the_month < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_finish_of_the_month
|
|
6
|
+
assert_equal Date.new(2006, 1, 31), Month.new(2006, 1).finish_of_the_month
|
|
7
|
+
assert_equal Date.new(2006, 2, 28), Month.new(2006, 2).finish_of_the_month
|
|
8
|
+
assert_equal Date.new(2008, 2, 29), Month.new(2008, 2).finish_of_the_month
|
|
9
|
+
assert_equal Date.new(2006, 3, 31), Month.new(2006, 3).finish_of_the_month
|
|
10
|
+
assert_equal Date.new(2006, 4, 30), Month.new(2006, 4).finish_of_the_month
|
|
11
|
+
assert_equal Date.new(2006, 5, 31), Month.new(2006, 5).finish_of_the_month
|
|
12
|
+
assert_equal Date.new(2006, 6, 30), Month.new(2006, 6).finish_of_the_month
|
|
13
|
+
assert_equal Date.new(2006, 7, 31), Month.new(2006, 7).finish_of_the_month
|
|
14
|
+
assert_equal Date.new(2006, 8, 31), Month.new(2006, 8).finish_of_the_month
|
|
15
|
+
assert_equal Date.new(2006, 9, 30), Month.new(2006, 9).finish_of_the_month
|
|
16
|
+
assert_equal Date.new(2006, 10, 31), Month.new(2006, 10).finish_of_the_month
|
|
17
|
+
assert_equal Date.new(2006, 11, 30), Month.new(2006, 11).finish_of_the_month
|
|
18
|
+
assert_equal Date.new(2006, 12, 31), Month.new(2006, 12).finish_of_the_month
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# test/tc_Month_initialize.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_initialize < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_no_arguments
|
|
6
|
+
assert_equal Date.today.year, Month.new.year
|
|
7
|
+
assert_equal Date.today.month, Month.new.month
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def test_one_argument
|
|
11
|
+
assert_equal Date.today.year, Month.new(12).year
|
|
12
|
+
assert_equal 12, Month.new(12).month
|
|
13
|
+
assert_equal Date.today.year, Month.new(11).year
|
|
14
|
+
assert_equal 11, Month.new(11).month
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_two_arguments
|
|
18
|
+
assert_equal 2011, Month.new(2011, 12).year
|
|
19
|
+
assert_equal 12, Month.new(2011, 12).month
|
|
20
|
+
assert_equal 2011, Month.new(2011, 11).year
|
|
21
|
+
assert_equal 11, Month.new(2011, 11).month
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_three_arguments
|
|
25
|
+
assert_raises(ArgumentError){Month.new(1, 2, 3)}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# test/tc_Month_last.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_last < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_plus
|
|
6
|
+
assert_equal Month.new(2010, 12), Month.new(2011, 1).last
|
|
7
|
+
assert_equal Month.new(2011, 11), Month.new(2011, 12).last
|
|
8
|
+
assert_equal Month.new(2011, 10), Month.new(2011, 11).last
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# test/tc_Month_last_month.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_last_month < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_plus
|
|
6
|
+
assert_equal Month.new(2010, 12), Month.new(2011, 1).last_month
|
|
7
|
+
assert_equal Month.new(2011, 11), Month.new(2011, 12).last_month
|
|
8
|
+
assert_equal Month.new(2011, 10), Month.new(2011, 11).last_month
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
end
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# test/tc_Month_method_missing.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_method_missing < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_method_missing
|
|
6
|
+
if Date.today.year == 2011 && Date.today.month == 1
|
|
7
|
+
assert_equal [3, 10, 17, 24, 31], Month.new(2011, 1).mondays
|
|
8
|
+
assert_equal [4, 11, 18, 25], Month.new(2011, 1).tuesdays
|
|
9
|
+
assert_equal [5, 12, 19, 26], Month.new(2011, 1).wednesdays
|
|
10
|
+
assert_equal [6, 13, 20, 27], Month.new(2011, 1).thursdays
|
|
11
|
+
assert_equal [7, 14, 21, 28], Month.new(2011, 1).fridays
|
|
12
|
+
assert_equal [1, 8, 15, 22, 29], Month.new(2011, 1).saturdays
|
|
13
|
+
assert_equal [2, 9, 16, 23, 30], Month.new(2011, 1).sundays
|
|
14
|
+
end
|
|
15
|
+
if Date.today.year == 2011 && Date.today.month == 2
|
|
16
|
+
assert_equal [7, 14, 21, 28], Month.new(2011, 2).mondays
|
|
17
|
+
assert_equal [1, 8, 15, 22], Month.new(2011, 2).tuesdays
|
|
18
|
+
assert_equal [2, 9, 16, 23], Month.new(2011, 2).wednesdays
|
|
19
|
+
assert_equal [3, 10, 17, 24], Month.new(2011, 2).thursdays
|
|
20
|
+
assert_equal [4, 11, 18, 25], Month.new(2011, 2).fridays
|
|
21
|
+
assert_equal [5, 12, 19, 26], Month.new(2011, 2).saturdays
|
|
22
|
+
assert_equal [6, 13, 20, 27], Month.new(2011, 2).sundays
|
|
23
|
+
end
|
|
24
|
+
if Date.today.year == 2011 && Date.today.month == 3
|
|
25
|
+
assert_equal [7, 14, 21, 28], Month.new(2011, 3).mondays
|
|
26
|
+
assert_equal [1, 8, 15, 22, 29], Month.new(2011, 3).tuesdays
|
|
27
|
+
assert_equal [2, 9, 16, 23, 30], Month.new(2011, 3).wednesdays
|
|
28
|
+
assert_equal [3, 10, 17, 24, 31], Month.new(2011, 3).thursdays
|
|
29
|
+
assert_equal [4, 11, 18, 25], Month.new(2011, 3).fridays
|
|
30
|
+
assert_equal [5, 12, 19, 26], Month.new(2011, 3).saturdays
|
|
31
|
+
assert_equal [6, 13, 20, 27], Month.new(2011, 3).sundays
|
|
32
|
+
end
|
|
33
|
+
if Date.today.year == 2011 && Date.today.month == 4
|
|
34
|
+
assert_equal [4, 11, 18, 25], Month.new(2011, 4).mondays
|
|
35
|
+
assert_equal [5, 12, 19, 26], Month.new(2011, 4).tuesdays
|
|
36
|
+
assert_equal [6, 13, 20, 27], Month.new(2011, 4).wednesdays
|
|
37
|
+
assert_equal [7, 14, 21, 28], Month.new(2011, 4).thursdays
|
|
38
|
+
assert_equal [1, 8, 15, 22, 29], Month.new(2011, 4).fridays
|
|
39
|
+
assert_equal [2, 9, 16, 23, 30], Month.new(2011, 4).saturdays
|
|
40
|
+
assert_equal [3, 10, 17, 24], Month.new(2011, 4).sundays
|
|
41
|
+
end
|
|
42
|
+
if Date.today.year == 2011 && Date.today.month == 5
|
|
43
|
+
assert_equal [2, 9, 16, 23, 30], Month.new(2011, 5).mondays
|
|
44
|
+
assert_equal [3, 10, 17, 24, 31], Month.new(2011, 5).tuesdays
|
|
45
|
+
assert_equal [4, 11, 18, 25], Month.new(2011, 5).wednesdays
|
|
46
|
+
assert_equal [5, 12, 19, 26], Month.new(2011, 5).thursdays
|
|
47
|
+
assert_equal [6, 13, 20, 27], Month.new(2011, 5).fridays
|
|
48
|
+
assert_equal [7, 14, 21, 28], Month.new(2011, 5).saturdays
|
|
49
|
+
assert_equal [1, 8, 15, 22, 29], Month.new(2011, 5).sundays
|
|
50
|
+
end
|
|
51
|
+
if Date.today.year == 2011 && Date.today.month == 6
|
|
52
|
+
assert_equal [6, 13, 20, 27], Month.new(2011, 6).mondays
|
|
53
|
+
assert_equal [7, 14, 21, 28], Month.new(2011, 6).tuesdays
|
|
54
|
+
assert_equal [1, 8, 15, 22, 29], Month.new(2011, 6).wednesdays
|
|
55
|
+
assert_equal [2, 9, 16, 23, 30], Month.new(2011, 6).thursdays
|
|
56
|
+
assert_equal [3, 10, 17, 24], Month.new(2011, 6).fridays
|
|
57
|
+
assert_equal [4, 11, 18, 25], Month.new(2011, 6).saturdays
|
|
58
|
+
assert_equal [5, 12, 19, 26], Month.new(2011, 6).sundays
|
|
59
|
+
end
|
|
60
|
+
if Date.today.year == 2011 && Date.today.month == 7
|
|
61
|
+
assert_equal [4, 11, 18, 25], Month.new(2011, 7).mondays
|
|
62
|
+
assert_equal [5, 12, 19, 26], Month.new(2011, 7).tuesdays
|
|
63
|
+
assert_equal [6, 13, 20, 27], Month.new(2011, 7).wednesdays
|
|
64
|
+
assert_equal [7, 14, 21, 28], Month.new(2011, 7).thursdays
|
|
65
|
+
assert_equal [1, 8, 15, 22, 29], Month.new(2011, 7).fridays
|
|
66
|
+
assert_equal [2, 9, 16, 23, 30], Month.new(2011, 7).saturdays
|
|
67
|
+
assert_equal [3, 10, 17, 24, 31], Month.new(2011, 7).sundays
|
|
68
|
+
end
|
|
69
|
+
if Date.today.year == 2011 && Date.today.month == 8
|
|
70
|
+
assert_equal [1, 8, 15, 22, 29], Month.new(2011, 8).mondays
|
|
71
|
+
assert_equal [2, 9, 16, 23, 30], Month.new(2011, 8).tuesdays
|
|
72
|
+
assert_equal [3, 10, 17, 24, 31], Month.new(2011, 8).wednesdays
|
|
73
|
+
assert_equal [4, 11, 18, 25], Month.new(2011, 8).thursdays
|
|
74
|
+
assert_equal [5, 12, 19, 26], Month.new(2011, 8).fridays
|
|
75
|
+
assert_equal [6, 13, 20, 27], Month.new(2011, 8).saturdays
|
|
76
|
+
assert_equal [7, 14, 21, 28], Month.new(2011, 8).sundays
|
|
77
|
+
end
|
|
78
|
+
if Date.today.year == 2011 && Date.today.month == 9
|
|
79
|
+
assert_equal [5, 12, 19, 26], Month.new(2011, 9).mondays
|
|
80
|
+
assert_equal [6, 13, 20, 27], Month.new(2011, 9).tuesdays
|
|
81
|
+
assert_equal [7, 14, 21, 28], Month.new(2011, 9).wednesdays
|
|
82
|
+
assert_equal [1, 8, 15, 22, 29], Month.new(2011, 9).thursdays
|
|
83
|
+
assert_equal [2, 9, 16, 23, 30], Month.new(2011, 9).fridays
|
|
84
|
+
assert_equal [3, 10, 17, 24], Month.new(2011, 9).saturdays
|
|
85
|
+
assert_equal [4, 11, 18, 25], Month.new(2011, 9).sundays
|
|
86
|
+
end
|
|
87
|
+
if Date.today.year == 2011 && Date.today.month == 10
|
|
88
|
+
assert_equal [3, 10, 17, 24, 31], Month.new(2011, 10).mondays
|
|
89
|
+
assert_equal [4, 11, 18, 25], Month.new(2011, 10).tuesdays
|
|
90
|
+
assert_equal [5, 12, 19, 26], Month.new(2011, 10).wednesdays
|
|
91
|
+
assert_equal [6, 13, 20, 27], Month.new(2011, 10).thursdays
|
|
92
|
+
assert_equal [7, 14, 21, 28], Month.new(2011, 10).fridays
|
|
93
|
+
assert_equal [1, 8, 15, 22, 29], Month.new(2011, 10).saturdays
|
|
94
|
+
assert_equal [2, 9, 16, 23, 30], Month.new(2011, 10).sundays
|
|
95
|
+
end
|
|
96
|
+
if Date.today.year == 2011 && Date.today.month == 11
|
|
97
|
+
assert_equal [7, 14, 21, 28], Month.new(2011, 11).mondays
|
|
98
|
+
assert_equal [1, 8, 15, 22, 29], Month.new(2011, 11).tuesdays
|
|
99
|
+
assert_equal [2, 9, 16, 23, 30], Month.new(2011, 11).wednesdays
|
|
100
|
+
assert_equal [3, 10, 17, 24], Month.new(2011, 11).thursdays
|
|
101
|
+
assert_equal [4, 11, 18, 25], Month.new(2011, 11).fridays
|
|
102
|
+
assert_equal [5, 12, 19, 26], Month.new(2011, 11).saturdays
|
|
103
|
+
assert_equal [6, 13, 20, 27], Month.new(2011, 11).sundays
|
|
104
|
+
end
|
|
105
|
+
if Date.today.year == 2011 && Date.today.month == 12
|
|
106
|
+
assert_equal [5, 12, 19, 26], Month.new(2011, 12).mondays
|
|
107
|
+
assert_equal [6, 13, 20, 27], Month.new(2011, 12).tuesdays
|
|
108
|
+
assert_equal [7, 14, 21, 28], Month.new(2011, 12).wednesdays
|
|
109
|
+
assert_equal [1, 8, 15, 22, 29], Month.new(2011, 12).thursdays
|
|
110
|
+
assert_equal [2, 9, 16, 23, 30], Month.new(2011, 12).fridays
|
|
111
|
+
assert_equal [3, 10, 17, 24, 31], Month.new(2011, 12).saturdays
|
|
112
|
+
assert_equal [4, 11, 18, 25], Month.new(2011, 12).sundays
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# test/tc_Month_minus.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_minus < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_minus_method
|
|
6
|
+
assert_equal Month.new(2010, 9), Month.new(2011, 1).minus(4)
|
|
7
|
+
assert_equal Month.new(2011, 11), Month.new(2011, 12).minus(1)
|
|
8
|
+
assert_equal Month.new(2011, 9), Month.new(2011, 11).minus(2)
|
|
9
|
+
assert_equal Month.new(2010, 11), Month.new(2011, 11).minus(12)
|
|
10
|
+
assert_equal Month.new(2009, 11), Month.new(2011, 11).minus(24)
|
|
11
|
+
assert_equal Month.new(2010, 12), Month.new(2011, 1).minus(1)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_minus_literal
|
|
15
|
+
assert_equal Month.new(2010, 9), Month.new(2011, 1) - 4
|
|
16
|
+
assert_equal Month.new(2011, 11), Month.new(2011, 12) - 1
|
|
17
|
+
assert_equal Month.new(2011, 9), Month.new(2011, 11) - 2
|
|
18
|
+
assert_equal Month.new(2010, 11), Month.new(2011, 11) - 12
|
|
19
|
+
assert_equal Month.new(2009, 11), Month.new(2011, 11) - 24
|
|
20
|
+
assert_equal Month.new(2010, 12), Month.new(2011, 1) - 1
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# test/tc_Month_next.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_next < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_next
|
|
6
|
+
assert_equal Month.new(2011, 2), Month.new(2011, 1).next
|
|
7
|
+
assert_equal Month.new(2012, 1), Month.new(2011, 12).next
|
|
8
|
+
assert_equal Month.new(2012, 1), Month.new(2011, 12).next
|
|
9
|
+
assert_equal Month.new(2011, 12), Month.new(2011, 11).next
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# test/tc_Month_next_month.rb
|
|
2
|
+
|
|
3
|
+
class TC_Month_next_month < Minitest::Test
|
|
4
|
+
|
|
5
|
+
def test_next_month
|
|
6
|
+
assert_equal Month.new(2011, 2), Month.new(2011, 1).next_month
|
|
7
|
+
assert_equal Month.new(2012, 1), Month.new(2011, 12).next_month
|
|
8
|
+
assert_equal Month.new(2012, 1), Month.new(2011, 12).next_month
|
|
9
|
+
assert_equal Month.new(2011, 12), Month.new(2011, 11).next_month
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
end
|