diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-08-07 11:21:44 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-08-07 11:21:44 -0300 |
| commit | 7c3cb71fa48fbe84d9d9c664eb646446fb80898b (patch) | |
| tree | 43d2b2282853b882877e42a0b8ec7467c9bb0e9e /testes | |
| parent | 68109afcdb59a7eeb75bacf055abce3e56a53645 (diff) | |
| download | lua-7c3cb71fa48fbe84d9d9c664eb646446fb80898b.tar.gz lua-7c3cb71fa48fbe84d9d9c664eb646446fb80898b.tar.bz2 lua-7c3cb71fa48fbe84d9d9c664eb646446fb80898b.zip | |
Free bit 7 of GC 'marked' field
Tables were using this bit to indicate their array sizes were real
('isrealasize'), but this bit can be useful for tests. Instead, they
can use bit 7 of their 'flag' field for that purpose. (There are only
six fast-access metamethods.) This 'flag' field only exists in tables,
so this use does not affect other types.
Diffstat (limited to 'testes')
| -rw-r--r-- | testes/events.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/testes/events.lua b/testes/events.lua index 8a01330e..17a73664 100644 --- a/testes/events.lua +++ b/testes/events.lua | |||
| @@ -305,6 +305,17 @@ t[Set{1,3,5}] = 1 | |||
| 305 | assert(t[Set{1,3,5}] == undef) | 305 | assert(t[Set{1,3,5}] == undef) |
| 306 | 306 | ||
| 307 | 307 | ||
| 308 | do -- test invalidating flags | ||
| 309 | local mt = {__eq = true} | ||
| 310 | local a = setmetatable({10}, mt) | ||
| 311 | local b = setmetatable({10}, mt) | ||
| 312 | mt.__eq = nil | ||
| 313 | assert(a ~= b) -- no metamethod | ||
| 314 | mt.__eq = function (x,y) return x[1] == y[1] end | ||
| 315 | assert(a == b) -- must use metamethod now | ||
| 316 | end | ||
| 317 | |||
| 318 | |||
| 308 | if not T then | 319 | if not T then |
| 309 | (Message or print)('\n >>> testC not active: skipping tests for \z | 320 | (Message or print)('\n >>> testC not active: skipping tests for \z |
| 310 | userdata <<<\n') | 321 | userdata <<<\n') |
