tests updated

pull/216/head
Dibyendu Majumdar 3 years ago
parent 754fcefc26
commit cb6943a1eb

@ -1,5 +1,5 @@
f = compiler.load([[
function doit(a, 25_bits.luawhat)
function doit(a, what)
local f: integer = ~0
if what == '&' then
return a&f
@ -25,4 +25,4 @@ assert(math.abs(doit(16, '|') - ~0) < 1e-15)
assert(math.abs(doit(16, '<<') - 32) < 1e-15)
assert(math.abs(doit(16, '>>') - 8) < 1e-15)
assert(math.abs(doit(16, '~') - ~16) < 1e-15)
print 'Ok'
print 'Ok'

@ -1842,6 +1842,42 @@ do
end
print 'Test 87 OK'
do
local function doit(a: integer, what)
local f: integer = ~0
if what == '&' then
return a&f
elseif what == '|' then
return a|f
elseif what == '<<' then
return a<<1
elseif what == '>>' then
return a>>1
elseif what == '~' then
return ~a
else
return 0
end
end
check(doit, 'TOINT', 'LOADK', 'EQ', 'JMP', 'BAND_II',
'RETURN', 'JMP', 'EQ', 'JMP', 'BOR_II', 'RETURN',
'JMP', 'EQ', 'JMP', 'SHL_II', 'RETURN', 'JMP', 'EQ',
'JMP', 'SHR_II', 'RETURN', 'JMP', 'EQ', 'JMP',
'BNOT_I', 'RETURN', 'JMP', 'LOADK', 'RETURN', 'RETURN')
assert(doit and type(doit) == 'function')
assert(math.abs(doit(16, '&') - 16) < 1e-15)
assert(math.abs(doit(16, '|') - ~0) < 1e-15)
assert(math.abs(doit(16, '<<') - 32) < 1e-15)
assert(math.abs(doit(16, '>>') - 8) < 1e-15)
assert(math.abs(doit(16, '~') - ~16) < 1e-15)
compile(doit)
assert(math.abs(doit(16, '&') - 16) < 1e-15)
assert(math.abs(doit(16, '|') - ~0) < 1e-15)
assert(math.abs(doit(16, '<<') - 32) < 1e-15)
assert(math.abs(doit(16, '>>') - 8) < 1e-15)
assert(math.abs(doit(16, '~') - ~16) < 1e-15)
end
print 'Test 88 OK'
for k,v in pairs(opcodes_coverage)
do

Loading…
Cancel
Save