diff --git a/CHANGELOG.md b/CHANGELOG.md index b623030..f9f7ca7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - "error" type supported. - "datetime" type supported. +- "interval" type supported. ### Fixed diff --git a/checks.lua b/checks.lua index 649de38..3154a8e 100644 --- a/checks.lua +++ b/checks.lua @@ -354,4 +354,6 @@ if has_datetime then checkers.datetime = datetime.is_datetime end +add_ffi_type_checker('interval', 'struct interval') + return checks diff --git a/test.lua b/test.lua index c359006..151278f 100755 --- a/test.lua +++ b/test.lua @@ -633,6 +633,12 @@ if has_datetime then testdata.datetime = datetime end +function testdata.fn_interval(arg) -- luacheck: no unused args + checks('interval') +end + +local has_interval = has_datetime and datetime.interval ~= nil + local ret_cases = { -- fn_int64 { @@ -1037,6 +1043,36 @@ local ret_cases = { code = 'fn_datetime({year=2023, month=1, day=11})', ok = false, }, + + -- fn_interval + { + skip = not has_interval, + code = 'fn_interval(datetime.interval.new())', + ok = true, + additional_data = {'datetime'}, + }, + { + skip = not has_interval, + code = 'fn_interval(datetime.interval.new{day=1})', + ok = true, + additional_data = {'datetime'}, + }, + { + skip = not has_interval, + code = 'fn_interval(datetime.interval.new{month=1, adjust="last"})', + ok = true, + additional_data = {'datetime'}, + }, + { + skip = not has_interval, + code = 'fn_interval()', + ok = false, + }, + { + skip = not has_interval, + code = 'fn_interval({month=1, adjust="last"})', + ok = false, + }, } for _, case in pairs(ret_cases) do