From 4cbbf6c068ef01af09086745992f3806799dcce7 Mon Sep 17 00:00:00 2001 From: TurtleP Date: Mon, 20 Mar 2023 09:48:56 -0400 Subject: [PATCH] address pr comment --- assert.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/assert.lua b/assert.lua index 9d6f95c..8cfccb0 100644 --- a/assert.lua +++ b/assert.lua @@ -84,16 +84,17 @@ end --assert a value is one of those in a table of options function assert:one_of(a, t, msg, stack_level) - local pass = false - for index = 1, #t do - if t[index] == a then - pass = true - break + for _, value in ipairs(t) do + if value == a then + return a end end - assert:equal(pass, true, msg, stack_level) - return a + error(("assertion failed: %s not one of %s %s"):format( + tostring(a), + table.concat(t, ", "), + _extra(msg) + ), 2 + (stack_level or 0)) end --replace everything in assert with nop functions that just return their second argument, for near-zero overhead on release