diff options
| author | Li Jin <dragon-fly@qq.com> | 2023-07-28 11:53:04 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2023-07-28 11:53:04 +0800 |
| commit | 5497775534d20ba06ab9c13bc4db1c5bee877513 (patch) | |
| tree | be68d03cf0928efca4a579125e4ba15ef3ab9325 /spec/outputs/teal-lang.lua | |
| parent | f415df9617d251abd802257d9750618ccc71ca93 (diff) | |
| download | yuescript-5497775534d20ba06ab9c13bc4db1c5bee877513.tar.gz yuescript-5497775534d20ba06ab9c13bc4db1c5bee877513.tar.bz2 yuescript-5497775534d20ba06ab9c13bc4db1c5bee877513.zip | |
fix xpcall usages in different Lua version.
Diffstat (limited to 'spec/outputs/teal-lang.lua')
| -rw-r--r-- | spec/outputs/teal-lang.lua | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/spec/outputs/teal-lang.lua b/spec/outputs/teal-lang.lua deleted file mode 100644 index 28ba6f8..0000000 --- a/spec/outputs/teal-lang.lua +++ /dev/null | |||
| @@ -1,49 +0,0 @@ | |||
| 1 | local a = { | ||
| 2 | value = 123 | ||
| 3 | } | ||
| 4 | local b = a.value | ||
| 5 | local add = function(a, b) | ||
| 6 | return a + b | ||
| 7 | end | ||
| 8 | local s = add(a.value, b) | ||
| 9 | print(s) | ||
| 10 | local Point = {} | ||
| 11 | Point.new = function(x, y) | ||
| 12 | local point = setmetatable({ }, { | ||
| 13 | __index = Point | ||
| 14 | }) | ||
| 15 | point.x = x or 0 | ||
| 16 | point.y = y or 0 | ||
| 17 | return point | ||
| 18 | end | ||
| 19 | Point.move = function(self, dx, dy) | ||
| 20 | self.x = self.x + dx | ||
| 21 | self.y = self.y + dy | ||
| 22 | end | ||
| 23 | local p = Point.new(100, 100) | ||
| 24 | p:move(50, 50) | ||
| 25 | local filter = function(tab, handler) | ||
| 26 | local _accum_0 = { } | ||
| 27 | local _len_0 = 1 | ||
| 28 | for _index_0 = 1, #tab do | ||
| 29 | local item = tab[_index_0] | ||
| 30 | if handler(item) then | ||
| 31 | _accum_0[_len_0] = item | ||
| 32 | _len_0 = _len_0 + 1 | ||
| 33 | end | ||
| 34 | end | ||
| 35 | return _accum_0 | ||
| 36 | end | ||
| 37 | local cond = function(item) | ||
| 38 | return item ~= "a" | ||
| 39 | end | ||
| 40 | local res = filter({ | ||
| 41 | "a", | ||
| 42 | "b", | ||
| 43 | "c", | ||
| 44 | "a" | ||
| 45 | }, cond) | ||
| 46 | for _index_0 = 1, #res do | ||
| 47 | local s = res[_index_0] | ||
| 48 | print(s) | ||
| 49 | end | ||
