Skip to content

Commit

Permalink
Fix test.assertraise treating return value of a call as its error
Browse files Browse the repository at this point in the history
  • Loading branch information
mpeterv committed Sep 21, 2018
1 parent 4d5aacf commit 52a1a24
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -17,7 +17,8 @@
- Fixed `pl.import_into` not importing some Penlight modules (#268).
- Fixed version number stuck at 1.5.2 (#260).
- Fixed `types.is_empty` returning `true` on tables containing `false` key (#267).
- Fixed `test.assertraise` throwing an error when passes an array with a function to call plus its arguments (#272).
- Fixed `test.assertraise` throwing an error when passed an array with a function to call plus its arguments (#272).
- Fixed `test.assertraise` not throwing an error when given function does not error but instead returns a string matching given error pattern.
- Fixed placeholder expressions being evaluated with wrong precedence of binary and unary negation.
- Fixed placeholder expressions being evaluated assuming wrong binary operator associativity (e.g. `_1-(_2+_3)` was evaluated as `(_1-_2)+_3`.
- Fixed placeholder expressions being evaluated as if unary operators take precedence over power operator (e.g. `(-_1)^_2`) was evaluated as `-(_1^2)`).
Expand Down
8 changes: 4 additions & 4 deletions lua/pl/test.lua
Expand Up @@ -85,13 +85,13 @@ end
-- @param e a string to match the error against
-- @param where extra level offset
function test.assertraise(fn,e,where)
local _, err
local ok, err
if type(fn) == 'table' then
_, err = pcall(unpack(fn))
ok, err = pcall(unpack(fn))
else
_, err = pcall(fn)
ok, err = pcall(fn)
end
if not err or err:match(e)==nil then
if ok or err:match(e)==nil then
complain (err,e,"these errors did not match",where)
end
end
Expand Down

0 comments on commit 52a1a24

Please sign in to comment.