aboutsummaryrefslogtreecommitdiff
path: root/testes/coroutine.lua
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-08-24 10:17:54 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-08-24 10:17:54 -0300
commit8c8a91f2ef7acccb99e3737913faad8d48b39571 (patch)
tree0807151944b7f7fd00eedfcfe94b4ee26fe25b21 /testes/coroutine.lua
parentf99509581ee73c1c2dbddb3398e87c098771d31f (diff)
downloadlua-8c8a91f2ef7acccb99e3737913faad8d48b39571.tar.gz
lua-8c8a91f2ef7acccb99e3737913faad8d48b39571.tar.bz2
lua-8c8a91f2ef7acccb99e3737913faad8d48b39571.zip
Deprecated the emulation of '__le' using '__lt'
As hinted in the manual for Lua 5.3, the emulation of the metamethod for '__le' using '__le' has been deprecated. It is slow, complicates the logic, and it is easy to avoid this emulation by defining a proper '__le' function. Moreover, often this emulation was used wrongly, with a programmer assuming that an order is total when it is not (e.g., NaN in floating-point numbers).
Diffstat (limited to 'testes/coroutine.lua')
-rw-r--r--testes/coroutine.lua8
1 files changed, 3 insertions, 5 deletions
diff --git a/testes/coroutine.lua b/testes/coroutine.lua
index 182c1e18..36eae44a 100644
--- a/testes/coroutine.lua
+++ b/testes/coroutine.lua
@@ -1,4 +1,4 @@
1-- $Id: testes/coroutine.lua $ 1-- $Id: testes/coroutine.lua 2018-07-25 15:31:04 -0300 $
2-- See Copyright Notice in file all.lua 2-- See Copyright Notice in file all.lua
3 3
4print "testing coroutines" 4print "testing coroutines"
@@ -619,10 +619,8 @@ end
619 619
620assert(run(function () if (a>=b) then return '>=' else return '<' end end, 620assert(run(function () if (a>=b) then return '>=' else return '<' end end,
621 {"le", "sub"}) == "<") 621 {"le", "sub"}) == "<")
622-- '<=' using '<'
623mt.__le = nil
624assert(run(function () if (a<=b) then return '<=' else return '>' end end, 622assert(run(function () if (a<=b) then return '<=' else return '>' end end,
625 {"lt"}) == "<=") 623 {"le", "sub"}) == "<=")
626assert(run(function () if (a==b) then return '==' else return '~=' end end, 624assert(run(function () if (a==b) then return '==' else return '~=' end end,
627 {"eq"}) == "~=") 625 {"eq"}) == "~=")
628 626
@@ -677,7 +675,7 @@ do -- a few more tests for comparsion operators
677 return val(a) < val(b) 675 return val(a) < val(b)
678 end, 676 end,
679 } 677 }
680 local mt2 = { __lt = mt1.__lt } -- no __le 678 local mt2 = { __lt = mt1.__lt, __le = mt1.__le }
681 679
682 local function run (f) 680 local function run (f)
683 local co = coroutine.wrap(f) 681 local co = coroutine.wrap(f)