1
0
Fork 0
mirror of https://github.com/Reuh/anselme.git synced 2025-10-27 16:49:31 +00:00

Add constants

This commit is contained in:
Étienne Fildadut 2022-09-08 22:09:11 +09:00
parent 3e658e4780
commit 95683a0ffd
17 changed files with 290 additions and 8 deletions

View file

@ -0,0 +1,8 @@
% obj
::a = 12
:x = obj()
{x.a}
{x.a := 52}

View 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" }
]]--

View file

@ -0,0 +1,8 @@
% obj
:a = 12
::x = obj()
{x.a}
{x.a := 52}

View 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" }
]]--

View file

@ -0,0 +1,15 @@
:l = [1,2,3]
::x = l
{l}
{x}
-----
~ l!remove()
{l}
{x}
~ x!remove()

View 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" }
]]--

View file

@ -0,0 +1,15 @@
:l = [1,2,3]
:x = constant(l)
{l}
{x}
-----
~ l!remove()
{l}
{x}
~ x!remove()

View 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" }
]]--

View file

@ -0,0 +1,7 @@
::a = [3]
{a}
~ a!insert(52)
{a}

View 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" }
]]--

View file

@ -0,0 +1,7 @@
::a = 3
{a}
~ a := 52
{a}

View 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" }
]]--