Skip to content

Commit

Permalink
feature: support interval type
Browse files Browse the repository at this point in the history
Support interval type checks [1] (added in Tarantool 2.10.0).

1. tarantool/tarantool#5941

Part of tarantool/tarantool#7726
  • Loading branch information
DifferentialOrange committed Jan 16, 2023
1 parent 09afdcc commit a11224f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions checks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -354,4 +354,6 @@ if has_datetime then
checkers.datetime = datetime.is_datetime
end

add_ffi_type_checker('interval', 'struct interval')

return checks
36 changes: 36 additions & 0 deletions test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a11224f

Please sign in to comment.