mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-27 16:49:31 +00:00
Add constants
This commit is contained in:
parent
3e658e4780
commit
95683a0ffd
17 changed files with 290 additions and 8 deletions
8
test/tests/constant object attribute.ans
Normal file
8
test/tests/constant object attribute.ans
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
% obj
|
||||
::a = 12
|
||||
|
||||
:x = obj()
|
||||
|
||||
{x.a}
|
||||
|
||||
{x.a := 52}
|
||||
14
test/tests/constant object attribute.lua
Normal file
14
test/tests/constant object attribute.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={tags=_[5],text="12"}
|
||||
_[3]={_[4]}
|
||||
_[2]={"error","can't change the value of a constant attribute; in Lua function \"_._\"; at test/tests/constant object attribute.ans:8"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "12"
|
||||
} } }
|
||||
{ "error", "can't change the value of a constant attribute; in Lua function \"_._\"; at test/tests/constant object attribute.ans:8" }
|
||||
]]--
|
||||
8
test/tests/constant object.ans
Normal file
8
test/tests/constant object.ans
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
% obj
|
||||
:a = 12
|
||||
|
||||
::x = obj()
|
||||
|
||||
{x.a}
|
||||
|
||||
{x.a := 52}
|
||||
14
test/tests/constant object.lua
Normal file
14
test/tests/constant object.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={tags=_[5],text="12"}
|
||||
_[3]={_[4]}
|
||||
_[2]={"error","can't change the value of an attribute of a constant object; in Lua function \"_._\"; at test/tests/constant object.ans:8"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "12"
|
||||
} } }
|
||||
{ "error", "can't change the value of an attribute of a constant object; in Lua function \"_._\"; at test/tests/constant object.ans:8" }
|
||||
]]--
|
||||
15
test/tests/constant values variable.ans
Normal file
15
test/tests/constant values variable.ans
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
:l = [1,2,3]
|
||||
|
||||
::x = l
|
||||
|
||||
{l}
|
||||
{x}
|
||||
|
||||
-----
|
||||
|
||||
~ l!remove()
|
||||
|
||||
{l}
|
||||
{x}
|
||||
|
||||
~ x!remove()
|
||||
40
test/tests/constant values variable.lua
Normal file
40
test/tests/constant values variable.lua
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
local _={}
|
||||
_[17]={}
|
||||
_[16]={}
|
||||
_[15]={}
|
||||
_[14]={}
|
||||
_[13]={}
|
||||
_[12]={text="[1, 2, 3]",tags=_[17]}
|
||||
_[11]={text="[1, 2]",tags=_[16]}
|
||||
_[10]={text="-----",tags=_[15]}
|
||||
_[9]={text="[1, 2, 3]",tags=_[14]}
|
||||
_[8]={text="[1, 2, 3]",tags=_[13]}
|
||||
_[7]={_[11],_[12]}
|
||||
_[6]={_[10]}
|
||||
_[5]={_[8],_[9]}
|
||||
_[4]={"error","can't remove values from a constant list; in Lua function \"remove\"; at test/tests/constant values variable.ans:15"}
|
||||
_[3]={"text",_[7]}
|
||||
_[2]={"text",_[6]}
|
||||
_[1]={"text",_[5]}
|
||||
return {_[1],_[2],_[3],_[4]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "[1, 2, 3]"
|
||||
}, {
|
||||
tags = {},
|
||||
text = "[1, 2, 3]"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "-----"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "[1, 2]"
|
||||
}, {
|
||||
tags = {},
|
||||
text = "[1, 2, 3]"
|
||||
} } }
|
||||
{ "error", "can't remove values from a constant list; in Lua function \"remove\"; at test/tests/constant values variable.ans:15" }
|
||||
]]--
|
||||
15
test/tests/constant values.ans
Normal file
15
test/tests/constant values.ans
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
:l = [1,2,3]
|
||||
|
||||
:x = constant(l)
|
||||
|
||||
{l}
|
||||
{x}
|
||||
|
||||
-----
|
||||
|
||||
~ l!remove()
|
||||
|
||||
{l}
|
||||
{x}
|
||||
|
||||
~ x!remove()
|
||||
40
test/tests/constant values.lua
Normal file
40
test/tests/constant values.lua
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
local _={}
|
||||
_[17]={}
|
||||
_[16]={}
|
||||
_[15]={}
|
||||
_[14]={}
|
||||
_[13]={}
|
||||
_[12]={text="[1, 2, 3]",tags=_[17]}
|
||||
_[11]={text="[1, 2]",tags=_[16]}
|
||||
_[10]={text="-----",tags=_[15]}
|
||||
_[9]={text="[1, 2, 3]",tags=_[14]}
|
||||
_[8]={text="[1, 2, 3]",tags=_[13]}
|
||||
_[7]={_[11],_[12]}
|
||||
_[6]={_[10]}
|
||||
_[5]={_[8],_[9]}
|
||||
_[4]={"error","can't remove values from a constant list; in Lua function \"remove\"; at test/tests/constant values.ans:15"}
|
||||
_[3]={"text",_[7]}
|
||||
_[2]={"text",_[6]}
|
||||
_[1]={"text",_[5]}
|
||||
return {_[1],_[2],_[3],_[4]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "[1, 2, 3]"
|
||||
}, {
|
||||
tags = {},
|
||||
text = "[1, 2, 3]"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "-----"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "[1, 2]"
|
||||
}, {
|
||||
tags = {},
|
||||
text = "[1, 2, 3]"
|
||||
} } }
|
||||
{ "error", "can't remove values from a constant list; in Lua function \"remove\"; at test/tests/constant values.ans:15" }
|
||||
]]--
|
||||
7
test/tests/constant variable list.ans
Normal file
7
test/tests/constant variable list.ans
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
::a = [3]
|
||||
|
||||
{a}
|
||||
|
||||
~ a!insert(52)
|
||||
|
||||
{a}
|
||||
14
test/tests/constant variable list.lua
Normal file
14
test/tests/constant variable list.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={tags=_[5],text="[3]"}
|
||||
_[3]={_[4]}
|
||||
_[2]={"error","can't insert values into a constant list; in Lua function \"insert\"; at test/tests/constant variable list.ans:5"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "[3]"
|
||||
} } }
|
||||
{ "error", "can't insert values into a constant list; in Lua function \"insert\"; at test/tests/constant variable list.ans:5" }
|
||||
]]--
|
||||
7
test/tests/constant variable.ans
Normal file
7
test/tests/constant variable.ans
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
::a = 3
|
||||
|
||||
{a}
|
||||
|
||||
~ a := 52
|
||||
|
||||
{a}
|
||||
14
test/tests/constant variable.lua
Normal file
14
test/tests/constant variable.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={tags=_[5],text="3"}
|
||||
_[3]={_[4]}
|
||||
_[2]={"error","can't change the value of a constant \"constant variable.a\"; while assigning value to variable \"constant variable.a\"; at test/tests/constant variable.ans:5"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "3"
|
||||
} } }
|
||||
{ "error", "can't change the value of a constant \"constant variable.a\"; while assigning value to variable \"constant variable.a\"; at test/tests/constant variable.ans:5" }
|
||||
]]--
|
||||
Loading…
Add table
Add a link
Reference in a new issue