aboutsummaryrefslogtreecommitdiff
path: root/testes
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-03-21 16:01:55 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-03-21 16:01:55 -0300
commit682054920ddc434fd4a7f8cc78027dbb03f47f00 (patch)
treec1f57903f57c9e13a338b09f2c625020aac31e7b /testes
parentf53eabeed855081fa38e9af5cf7c977915f5213f (diff)
downloadlua-682054920ddc434fd4a7f8cc78027dbb03f47f00.tar.gz
lua-682054920ddc434fd4a7f8cc78027dbb03f47f00.tar.bz2
lua-682054920ddc434fd4a7f8cc78027dbb03f47f00.zip
Details in the implementation of the integer 'for' loop
Changed some implementation details; in particular, it is back using an internal variable to keep the index, with the control variable being only a copy of that internal variable. (The direct use of the control variable demands a check of its type for each access, which offsets the gains from the use of a single variable.)
Diffstat (limited to 'testes')
-rw-r--r--testes/nextvar.lua6
1 files changed, 6 insertions, 0 deletions
diff --git a/testes/nextvar.lua b/testes/nextvar.lua
index e769ccdd..87a6bfa8 100644
--- a/testes/nextvar.lua
+++ b/testes/nextvar.lua
@@ -544,6 +544,12 @@ do
544 a = 0; for i=1.0, 0.99999, -1 do a=a+1 end; assert(a==1) 544 a = 0; for i=1.0, 0.99999, -1 do a=a+1 end; assert(a==1)
545end 545end
546 546
547do -- changing the control variable
548 local a
549 a = 0; for i = 1, 10 do a = a + 1; i = "x" end; assert(a == 10)
550 a = 0; for i = 10.0, 1, -1 do a = a + 1; i = "x" end; assert(a == 10)
551end
552
547-- conversion 553-- conversion
548a = 0; for i="10","1","-2" do a=a+1 end; assert(a==5) 554a = 0; for i="10","1","-2" do a=a+1 end; assert(a==5)
549 555