Skip to content

Commit

Permalink
#225 #172 fix type assertion inconsistencies
Browse files Browse the repository at this point in the history
  • Loading branch information
dibyendumajumdar committed May 22, 2021
1 parent d31d447 commit a781fc5
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions tests/language/ravi_tests1.ravi
Original file line number Diff line number Diff line change
Expand Up @@ -1936,6 +1936,64 @@ do
end
print 'Test 92 OK'


do
local data = { "a", function() end, false }
for i = 1,4 do -- check nil too
local y = data[i]
local function x()
return @number y
end
assert(not pcall(x))
compile(x)
assert(not pcall(x))
end
end
print 'Test 93 OK'

do
local y = 56
local function x()
return @number y
end
local _,z = pcall(x)
assert(_)
assert(math.type(z) == 'float')
compile(x)
_,z = pcall(x)
assert(_)
assert(math.type(z) == 'float')
end
print 'Test 94 OK'

do
local data = { "a", function() end, false }
for i = 1,4 do -- check nil too
local y = data[i]
local function x(y: number)
return y
end
assert(not pcall(x))
compile(x)
assert(not pcall(x))
end
end
print 'Test 95 OK'

do
local function x(y: number)
return y
end
local _,z = pcall(x, 56)
assert(_)
assert(math.type(z) == 'float')
compile(x)
_,z = pcall(x, 56)
assert(_)
assert(math.type(z) == 'float')
end
print 'Test 96 OK'

for k,v in pairs(opcodes_coverage)
do
print(k, v)
Expand Down

0 comments on commit a781fc5

Please sign in to comment.