Skip to content

Commit 1f4ceab

Browse files
Buristanigormunkin
authored andcommitted
test: add test for conversions folding
This patch adds the test for commit 1a40162 ("Fix assertions."). This patch removes incorrect assertions in the fold optimizations for conversions from numbers to different integer types. Since the issue affects only branch 2.0, there is no need to fix it. Nevertheless, the test is required to avoid regressions in the future. Part of tarantool/tarantool#9145 Reviewed-by: Maxim Kokryashkin <[email protected]> Reviewed-by: Sergey Bronnikov <[email protected]> Signed-off-by: Igor Munkin <[email protected]> (cherry picked from commit 5bb1901)
1 parent 6d87459 commit 1f4ceab

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
local tap = require('tap')
2+
3+
-- XXX: Test the behaviour of fold optimizations from numbers to
4+
-- different integer types. The test itself doesn't fail before
5+
-- the commit since these changes relate only to version 2.0.
6+
7+
local test = tap.test('lj-833-fold-conv-from-num'):skipcond({
8+
['Test requires JIT enabled'] = not jit.status(),
9+
})
10+
11+
local ffi = require('ffi')
12+
13+
test:plan(3)
14+
15+
local arr_i64 = ffi.new('int64_t [2]')
16+
local arr_u64 = ffi.new('uint64_t [2]')
17+
local arr_u32 = ffi.new('uint32_t [2]')
18+
19+
jit.opt.start('hotloop=1')
20+
21+
for _ = 1, 4 do
22+
-- Test conversion to type (at store). Also, check the
23+
-- conversion from number to int64_t at C array indexing.
24+
arr_i64[1.1] = 1.1
25+
arr_u64[1.1] = 1.1
26+
arr_u32[1.1] = 1.1
27+
end
28+
29+
test:is(arr_i64[1], 1LL, 'correct conversion to int64_t')
30+
test:is(arr_u64[1], 1ULL, 'correct conversion to uint64_t')
31+
test:is(arr_u32[1], 1ULL, 'correct conversion to uint32_t')
32+
33+
test:done(true)

0 commit comments

Comments
 (0)