|
1 | 1 | local is_leap_year = require('leap')
|
2 | 2 |
|
3 | 3 | 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() |
5 | 13 | assert.is_true(is_leap_year(1996))
|
6 | 14 | end)
|
7 | 15 |
|
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)) |
10 | 22 | end)
|
11 | 23 |
|
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() |
13 | 25 | assert.is_false(is_leap_year(1900))
|
14 | 26 | end)
|
15 | 27 |
|
16 |
| - it('turn of the 21st century', function() |
| 28 | + it('year divisible by 400 is leap year', function() |
17 | 29 | assert.is_true(is_leap_year(2000))
|
18 | 30 | 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) |
19 | 39 | end)
|
0 commit comments