diff options
Diffstat (limited to 'testes')
| -rw-r--r-- | testes/calls.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/testes/calls.lua b/testes/calls.lua index 56a12ae6..739a624f 100644 --- a/testes/calls.lua +++ b/testes/calls.lua | |||
| @@ -151,6 +151,23 @@ end | |||
| 151 | print('+') | 151 | print('+') |
| 152 | 152 | ||
| 153 | 153 | ||
| 154 | do -- testing chains of '__call' | ||
| 155 | local N = 20 | ||
| 156 | local u = table.pack | ||
| 157 | for i = 1, N do | ||
| 158 | u = setmetatable({i}, {__call = u}) | ||
| 159 | end | ||
| 160 | |||
| 161 | local Res = u("a", "b", "c") | ||
| 162 | |||
| 163 | assert(Res.n == N + 3) | ||
| 164 | for i = 1, N do | ||
| 165 | assert(Res[i][1] == i) | ||
| 166 | end | ||
| 167 | assert(Res[N + 1] == "a" and Res[N + 2] == "b" and Res[N + 3] == "c") | ||
| 168 | end | ||
| 169 | |||
| 170 | |||
| 154 | a = nil | 171 | a = nil |
| 155 | (function (x) a=x end)(23) | 172 | (function (x) a=x end)(23) |
| 156 | assert(a == 23 and (function (x) return x*2 end)(20) == 40) | 173 | assert(a == 23 and (function (x) return x*2 end)(20) == 40) |
