]> git.madduck.net Git - etc/awesome.git/blob - spec/timetable_spec.lua

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

653645921fbbc5aa876b66304b6f2b4ece8c7c33
[etc/awesome.git] / spec / timetable_spec.lua
1 describe ( "Time table library" , function ( )
2         local timetable = require "timetable"
3
4         it ( "Doomsday calculation" , function ( )
5                 local doomsday = timetable.doomsday
6
7                 -- Doomsday in Gregorian calendar for 2013 is Thursday.
8                 assert.are.same ( 5 , doomsday(2013) )
9
10                 assert.are.same ( 3 , doomsday(1967) )
11                 assert.are.same ( 5 , doomsday(1968) )
12         end )
13
14         it ( "Get day of week correct" , function ( )
15                 local function native_normalise ( tbl )
16                         return os.date("*t",os.time(tbl))
17                 end
18                 local tbl = {
19                         year = 2013 ;
20                         month = 7 ;
21                         day = 23 ;
22                 }
23                 assert.are.same ( native_normalise ( tbl ).wday  , timetable.normalise ( tbl ).wday )
24                 tbl.day=24
25                 assert.are.same ( native_normalise ( tbl ).wday  , timetable.normalise ( tbl ).wday )
26                 tbl.day=25
27                 assert.are.same ( native_normalise ( tbl ).wday  , timetable.normalise ( tbl ).wday )
28                 tbl.day=26
29                 assert.are.same ( native_normalise ( tbl ).wday  , timetable.normalise ( tbl ).wday )
30                 tbl.day=27
31                 assert.are.same ( native_normalise ( tbl ).wday  , timetable.normalise ( tbl ).wday )
32                 tbl.day=28
33                 assert.are.same ( native_normalise ( tbl ).wday  , timetable.normalise ( tbl ).wday )
34                 tbl.day=29
35                 assert.are.same ( native_normalise ( tbl ).wday  , timetable.normalise ( tbl ).wday )
36         end )
37 end )