Skip to content

Commit

Permalink
test: even more testcases extracted from still unprocessable X:R scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrian Nord authored and Andrian Nord committed Jan 12, 2014
1 parent 2a1e645 commit 71bc193
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 3 deletions.
12 changes: 10 additions & 2 deletions test/expression.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
--[[
--]]

print ("true or true")

b = true or true
Expand Down Expand Up @@ -41,13 +44,11 @@ print ("precalculated false expression with nil")
f = nil and ((x and y) or true)

print ("simple or expression")

b = x or y

print ("simple or not expression")

b = not x or y

print ("simple and expression")

b = x and y
Expand Down Expand Up @@ -178,3 +179,10 @@ a = x < 100 or (y < 100 and (x < 100 or z < 100))

print ("(not or (and (or)))")
a = (not (x < 100)) or (y < 100 and (x < 100 or z < 100))

local value = 1.0

value = scaleinfo.floorValue and math.floor(value) or math.ceil(value)

--[[
--]]
69 changes: 68 additions & 1 deletion test/ifs.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
--[[
--]]

if true then
print("if true")
end
Expand All @@ -18,6 +21,29 @@ if x and false then
print("if and false")
end

if x then
if false then
print("if and false")
end
end

if x then
if false then
print("if and false")
else
print("if and false with else!")
end
end

if x then
if false then
print("if and false")
else
print("if and false with else!")
end
else
print ("Else!")
end

if x and true then
print("if and true")
Expand All @@ -38,7 +64,6 @@ else
print ("else")
end


if x < 100 and y < 100 then
print ("semi-nested then")
else
Expand Down Expand Up @@ -79,6 +104,15 @@ else
print ("Else")
end

if x < 100 or z > 100 then
if y < 300 or x > 100 then
print ("Nested then")
else
print ("Nested else")
end
end


if x < 100 or z > 100 then
if y < 100 or x > 100 then
print ("Nested then")
Expand All @@ -87,6 +121,7 @@ else
print ("Else")
end


if x < 100 or z > 100 then
if y < 100 or x > 100 then
print ("Nested then")
Expand Down Expand Up @@ -115,6 +150,7 @@ if x < 100 or y < 100 then
print ("x or y with comparisons")
end


if x < 100 and y < 100 then
print ("x and y with comparisons")
end
Expand Down Expand Up @@ -402,5 +438,36 @@ end

print ("asd")

local value = 1.3

if scaleinfo.floorValue then
value = math.floor(value*scaleinfo.factor)
else
value = math.ceil(value*scaleinfo.factor)
end

function func(button, buttonElement)
local stateEntry = buttonElement.buttonState
local targetSlide = nil

if buttonElement.active then
if stateEntry.mouseClick or stateEntry.keyboardPress then
targetSlide = "click"
else
if stateEntry.mouseOver or stateEntry.keyboard then
targetSlide = "highlight"
else
targetSlide = "normal"
end
end
else
targetSlide = "unselect"
end

local _, curSide = getCurrentSlide(buttonElement.element)
end


--[[
--]]

14 changes: 14 additions & 0 deletions test/loop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,17 @@ until x < 3 and y < 3

--[[
--]]

if x then
for i=1,2,3 do
print ("something")

if y then
break
end

print ("something")
end
else
print("else")
end

0 comments on commit 71bc193

Please sign in to comment.