]> git.madduck.net Git - etc/awesome.git/blobdiff - 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:

luatz/timetable.lua: Remove unused year_length function
[etc/awesome.git] / spec / timetable_spec.lua
index 930d36b32b94f398f260580352ee980a6e4497d8..6c9617e2c2dcce2a1e59dc94a0f0407c6534568b 100644 (file)
@@ -77,8 +77,8 @@ describe ( "Timetable library" , function ( )
                assert.same({ 2012,3,23,0,0,0 }, { timetable.normalise(2012,2,52,0,0,0) })
                assert.same({ 2013,3,24,0,0,0 }, { timetable.normalise(2013,2,52,0,0,0) })
 
                assert.same({ 2012,3,23,0,0,0 }, { timetable.normalise(2012,2,52,0,0,0) })
                assert.same({ 2013,3,24,0,0,0 }, { timetable.normalise(2013,2,52,0,0,0) })
 
-               assert.same({ 2012,2,26,0,0,0 }, { timetable.normalise(2012,3,-2,0,0,0) })
-               assert.same({ 2013,2,27,0,0,0 }, { timetable.normalise(2013,3,-2,0,0,0) })
+               assert.same({ 2012,2,27,0,0,0 }, { timetable.normalise(2012,3,-2,0,0,0) })
+               assert.same({ 2013,2,26,0,0,0 }, { timetable.normalise(2013,3,-2,0,0,0) })
 
                -- Also when more fields are out of range
                assert.same({ 2016,7,22,0,0,0 }, { timetable.normalise(2013,42,52,0,0,0) })
 
                -- Also when more fields are out of range
                assert.same({ 2016,7,22,0,0,0 }, { timetable.normalise(2013,42,52,0,0,0) })
@@ -98,6 +98,12 @@ describe ( "Timetable library" , function ( )
                assert.same({ 2017,02,3,0,0,0 }, { timetable.normalise(2017,02,13,0,-14400,0) })
        end )
 
                assert.same({ 2017,02,3,0,0,0 }, { timetable.normalise(2017,02,13,0,-14400,0) })
        end )
 
+       it ( "#normalise handles negative day carry (issue #13)", function()
+               assert.same({ 2016,11,30,00,00,00 }, { timetable.normalise(2016,12,0,0,0,0) })
+               assert.same({ 2017,11,30,00,00,00 }, { timetable.normalise(2017,12,0,0,0,0) })
+               assert.same({ 2018,11,30,00,00,00 }, { timetable.normalise(2018,12,0,0,0,0) })
+       end )
+
        local function round_trip_add(t, field, x)
                local before = t:clone()
                t[field]=t[field]+x;
        local function round_trip_add(t, field, x)
                local before = t:clone()
                t[field]=t[field]+x;