Skip to content

Commit

Permalink
Improve "this should raise a warning" testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Sainan committed Sep 7, 2023
1 parent 29d3c0d commit e4a8a54
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions testes/pluto/basic.pluto
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
print "Welcome to the test suite."

-- Testing warnings
do
local a = 1
local a = 2
local function assert_warn(code)
local had_warn = false
setwarnf(function(msg)
had_warn = true
end)
load(code)()
assert(had_warn)
end
assert_warn([[local a; local a]]) -- var-shadow
assert_warn([[local a = 69; local b: string = a]]) -- type mismatch in local-to-local assignment
assert_warn([[g = 69; local l: string = g]]) -- type mismatch in global-to-local assignment
end
print "Welcome to the test suite. There should have been exactly 1 parser warning."

-- Testing type hints (there should be no warnings here)
do
Expand Down

0 comments on commit e4a8a54

Please sign in to comment.