Skip to content

Commit 4ee3068

Browse files
Sync leap tests (#542)
* Sync `leap` tests * Fix formatting --------- Co-authored-by: Ryan Hartlage <[email protected]>
1 parent 5f395b3 commit 4ee3068

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

exercises/practice/leap/leap_spec.lua

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,39 @@
11
local is_leap_year = require('leap')
22

33
describe('leap', function()
4-
it('a known leap year', function()
4+
it('year not divisible by 4 is common year', function()
5+
assert.is_false(is_leap_year(2015))
6+
end)
7+
8+
it('year divisible by 2, not divisible by 4 is common year', function()
9+
assert.is_false(is_leap_year(1970))
10+
end)
11+
12+
it('year divisible by 4, not divisible by 100 is leap year', function()
513
assert.is_true(is_leap_year(1996))
614
end)
715

8-
it('any old year', function()
9-
assert.is_false(is_leap_year(1997))
16+
it('year divisible by 4 and 5 is still a leap year', function()
17+
assert.is_true(is_leap_year(1960))
18+
end)
19+
20+
it('year divisible by 100, not divisible by 400 is common year', function()
21+
assert.is_false(is_leap_year(2100))
1022
end)
1123

12-
it('turn of the 20th century', function()
24+
it('year divisible by 100 but not by 3 is still not a leap year', function()
1325
assert.is_false(is_leap_year(1900))
1426
end)
1527

16-
it('turn of the 21st century', function()
28+
it('year divisible by 400 is leap year', function()
1729
assert.is_true(is_leap_year(2000))
1830
end)
31+
32+
it('year divisible by 400 but not by 125 is still a leap year', function()
33+
assert.is_true(is_leap_year(2400))
34+
end)
35+
36+
it('year divisible by 200, not divisible by 400 is common year', function()
37+
assert.is_false(is_leap_year(1800))
38+
end)
1939
end)

0 commit comments

Comments
 (0)