From 4bd1513262a61071b07f5efe2a3cb9356ce6c8c2 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Wed, 17 May 2023 15:11:09 +0800 Subject: fix spec. --- spec/inputs/existential.yue | 2 +- spec/inputs/metatable.yue | 16 ++++++++-------- spec/outputs/existential.lua | 2 +- spec/outputs/metatable.lua | 35 +++++++++++++++++++++++++++-------- 4 files changed, 37 insertions(+), 18 deletions(-) diff --git a/spec/inputs/existential.yue b/spec/inputs/existential.yue index e73b421..27891dc 100644 --- a/spec/inputs/existential.yue +++ b/spec/inputs/existential.yue @@ -49,7 +49,7 @@ with? io.open "test.txt", "w" \write "hello" \close! -tb?.? 123 +tb?.? 123 with? tb.<>?. .a = 1 diff --git a/spec/inputs/metatable.yue b/spec/inputs/metatable.yue index 61cc266..38b7ce5 100644 --- a/spec/inputs/metatable.yue +++ b/spec/inputs/metatable.yue @@ -37,14 +37,14 @@ a. = tb mt = a.<> tb\func #list -tb\list -tb\ list +tb\<"func">list +tb\<"func"> list import "module" as :, :setFunc with tb print ., .x\ "key" - a = ..\ 123 + a = ..\<"new"> 123 b = t#..test c = t #. .test @@ -70,13 +70,13 @@ do return tb\<["value" .. tostring x > y]>(123, ...) do - f = tb\(123, ...) - f tb\(123, ...) - tb\(123, ...) - return tb\ 123, ... + f = tb\<'value'>(123, ...) + f tb\<'value'>(123, ...) + tb\<'value'>(123, ...) + return tb\<'value'> 123, ... do - f = tb. 123, ... + f = tb.<["value"]> 123, ... f = tb.<"value#{x < y}">(123, ...) f tb.<'value'> 123, ... tb.<[[ value diff --git a/spec/outputs/existential.lua b/spec/outputs/existential.lua index b241b3b..391f553 100644 --- a/spec/outputs/existential.lua +++ b/spec/outputs/existential.lua @@ -201,7 +201,7 @@ do local _obj_0 = tb if _obj_0 ~= nil then do - local _obj_1 = getmetatable(_obj_0).__a + local _obj_1 = getmetatable(_obj_0).__call if _obj_1 ~= nil then _obj_1(123) end diff --git a/spec/outputs/metatable.lua b/spec/outputs/metatable.lua index 907a584..9f95787 100644 --- a/spec/outputs/metatable.lua +++ b/spec/outputs/metatable.lua @@ -76,8 +76,14 @@ getmetatable(a).__index = tb getmetatable(a).__index = tb local mt = getmetatable(a) tb:func(#list) -getmetatable(tb):__func(list) -getmetatable(tb):__func(list) +do + local _obj_0 = getmetatable(tb) + _obj_0["func"](_obj_0, list) +end +do + local _obj_0 = getmetatable(tb) + _obj_0["func"](_obj_0, list) +end local index, setFunc do local _obj_0 = getmetatable(require("module")) @@ -86,7 +92,10 @@ end do local _with_0 = tb print(getmetatable(_with_0).__add, getmetatable(_with_0.x):__index("key")) - a = getmetatable(getmetatable(getmetatable(_with_0).__index).__add):__new(123) + do + local _obj_0 = getmetatable(getmetatable(getmetatable(_with_0).__index).__add) + a = _obj_0["new"](_obj_0, 123) + end b = t(#getmetatable(_with_0).__close.test) c = t(#getmetatable(_with_0).__close(_with_0.test)) end @@ -132,13 +141,23 @@ do return _obj_0["value" .. tostring(x > y)](_obj_0, 123, ...) end do - f = getmetatable(tb):__value(123, ...) - f(getmetatable(tb):__value(123, ...)) - getmetatable(tb):__value(123, ...) - return getmetatable(tb):__value(123, ...) + do + local _obj_0 = getmetatable(tb) + f = _obj_0['value'](_obj_0, 123, ...) + end + f((function(...) + local _obj_0 = getmetatable(tb) + return _obj_0['value'](_obj_0, 123, ...) + end)(...)) + do + local _obj_0 = getmetatable(tb) + _obj_0['value'](_obj_0, 123, ...) + end + local _obj_0 = getmetatable(tb) + return _obj_0['value'](_obj_0, 123, ...) end do - f = getmetatable(tb).__value(123, ...) + f = getmetatable(tb)["value"](123, ...) f = getmetatable(tb)["value" .. tostring(x < y)](123, ...) f(getmetatable(tb)['value'](123, ...)) getmetatable(tb)[ [[ value -- cgit v1.2.3-55-g6feb