spacevim/bundle/calendar.vim/test/week.vim
JIe 2bb7059579
Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
init
2024-08-21 14:17:26 +08:00

107 lines
5.9 KiB
VimL

let s:suite = themis#suite('week')
let s:assert = themis#helper('assert')
function! s:suite.before_each()
language en_US.UTF-8
unlet! g:calendar_first_day
endfunction
function! s:suite.first_day_index()
call s:assert.equals(calendar#week#first_day_index(), 0)
let g:calendar_first_day = 'sunday'
call s:assert.equals(calendar#week#first_day_index(), 0)
let g:calendar_first_day = 'Monday'
call s:assert.equals(calendar#week#first_day_index(), 1)
let g:calendar_first_day = 'Tuesday'
call s:assert.equals(calendar#week#first_day_index(), 2)
let g:calendar_first_day = 'WEDNESDAY'
call s:assert.equals(calendar#week#first_day_index(), 3)
let g:calendar_first_day = 'thursday'
call s:assert.equals(calendar#week#first_day_index(), 4)
let g:calendar_first_day = 'friday'
call s:assert.equals(calendar#week#first_day_index(), 5)
let g:calendar_first_day = 'saturday'
call s:assert.equals(calendar#week#first_day_index(), 6)
endfunction
function! s:suite.last_day_index()
call s:assert.equals(calendar#week#last_day_index(), 6)
let g:calendar_first_day = 'sunday'
call s:assert.equals(calendar#week#last_day_index(), 6)
let g:calendar_first_day = 'Monday'
call s:assert.equals(calendar#week#last_day_index(), 0)
let g:calendar_first_day = 'Tuesday'
call s:assert.equals(calendar#week#last_day_index(), 1)
let g:calendar_first_day = 'WEDNESDAY'
call s:assert.equals(calendar#week#last_day_index(), 2)
let g:calendar_first_day = 'thursday'
call s:assert.equals(calendar#week#last_day_index(), 3)
let g:calendar_first_day = 'friday'
call s:assert.equals(calendar#week#last_day_index(), 4)
let g:calendar_first_day = 'saturday'
call s:assert.equals(calendar#week#last_day_index(), 5)
endfunction
function! s:suite.is_first_day()
call s:assert.equals(calendar#week#first_day_index(), 0)
call s:assert.equals(calendar#week#is_first_day(calendar#day#new(2000, 1, 1)), 0)
call s:assert.equals(calendar#week#is_first_day(calendar#day#new(2001, 1, 1)), 0)
call s:assert.equals(calendar#week#is_first_day(calendar#day#new(2004, 1, 1)), 0)
call s:assert.equals(calendar#week#is_first_day(calendar#day#new(2005, 1, 1)), 0)
call s:assert.equals(calendar#week#is_first_day(calendar#day#new(2006, 1, 1)), 1)
call s:assert.equals(calendar#week#is_first_day(calendar#day#new(2007, 1, 1)), 0)
endfunction
function! s:suite.is_last_day()
call s:assert.equals(calendar#week#is_last_day(calendar#day#new(2000, 1, 1)), 1)
call s:assert.equals(calendar#week#is_last_day(calendar#day#new(2001, 1, 1)), 0)
call s:assert.equals(calendar#week#is_last_day(calendar#day#new(2004, 1, 1)), 0)
call s:assert.equals(calendar#week#is_last_day(calendar#day#new(2005, 1, 1)), 1)
call s:assert.equals(calendar#week#is_last_day(calendar#day#new(2006, 1, 1)), 0)
call s:assert.equals(calendar#week#is_last_day(calendar#day#new(2007, 1, 1)), 0)
endfunction
function! s:suite.week_index()
call s:assert.equals(calendar#week#week_index(calendar#day#new(2000, 1, 1)), 6)
call s:assert.equals(calendar#week#week_index(calendar#day#new(2001, 1, 1)), 1)
call s:assert.equals(calendar#week#week_index(calendar#day#new(2004, 1, 1)), 4)
call s:assert.equals(calendar#week#week_index(calendar#day#new(2005, 1, 1)), 6)
call s:assert.equals(calendar#week#week_index(calendar#day#new(2006, 1, 1)), 0)
call s:assert.equals(calendar#week#week_index(calendar#day#new(2007, 1, 1)), 1)
let g:calendar_first_day = 'monday'
call s:assert.equals(calendar#week#week_index(calendar#day#new(2000, 1, 1)), 5)
call s:assert.equals(calendar#week#week_index(calendar#day#new(2001, 1, 1)), 0)
call s:assert.equals(calendar#week#week_index(calendar#day#new(2004, 1, 1)), 3)
call s:assert.equals(calendar#week#week_index(calendar#day#new(2005, 1, 1)), 5)
call s:assert.equals(calendar#week#week_index(calendar#day#new(2006, 1, 1)), 6)
call s:assert.equals(calendar#week#week_index(calendar#day#new(2007, 1, 1)), 0)
let g:calendar_first_day = 'saturday'
call s:assert.equals(calendar#week#week_index(calendar#day#new(2000, 1, 1)), 0)
call s:assert.equals(calendar#week#week_index(calendar#day#new(2001, 1, 1)), 2)
call s:assert.equals(calendar#week#week_index(calendar#day#new(2004, 1, 1)), 5)
call s:assert.equals(calendar#week#week_index(calendar#day#new(2005, 1, 1)), 0)
call s:assert.equals(calendar#week#week_index(calendar#day#new(2006, 1, 1)), 1)
call s:assert.equals(calendar#week#week_index(calendar#day#new(2007, 1, 1)), 2)
endfunction
function! s:suite.week_number()
call s:assert.equals(calendar#week#week_number(calendar#day#new(2000, 1, 1)), 1)
call s:assert.equals(calendar#week#week_number(calendar#day#new(2001, 1, 1)), 1)
call s:assert.equals(calendar#week#week_number(calendar#day#new(2004, 1, 1)), 1)
call s:assert.equals(calendar#week#week_number(calendar#day#new(2005, 1, 1)), 1)
call s:assert.equals(calendar#week#week_number(calendar#day#new(2006, 1, 1)), 1)
call s:assert.equals(calendar#week#week_number(calendar#day#new(2007, 1, 1)), 1)
call s:assert.equals(calendar#week#week_number(calendar#day#new(2010, 12, 31)), 53)
call s:assert.equals(calendar#week#week_number(calendar#day#new(2020, 5, 9)), 19)
call s:assert.equals(calendar#week#week_number(calendar#day#new(2020, 5, 10)), 20)
let g:calendar_first_day = 'monday'
call s:assert.equals(calendar#week#week_number(calendar#day#new(2000, 1, 1)), 52)
call s:assert.equals(calendar#week#week_number(calendar#day#new(2001, 1, 1)), 1)
call s:assert.equals(calendar#week#week_number(calendar#day#new(2004, 1, 1)), 1)
call s:assert.equals(calendar#week#week_number(calendar#day#new(2005, 1, 1)), 53)
call s:assert.equals(calendar#week#week_number(calendar#day#new(2006, 1, 1)), 52)
call s:assert.equals(calendar#week#week_number(calendar#day#new(2007, 1, 1)), 1)
call s:assert.equals(calendar#week#week_number(calendar#day#new(2009, 1, 1)), 1)
call s:assert.equals(calendar#week#week_number(calendar#day#new(2010, 1, 1)), 53)
endfunction