diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-12-20 11:14:52 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-12-20 11:14:52 -0300 |
| commit | 7d6a97e42bc3328b9c5ec1dabbd7e280e81c3efd (patch) | |
| tree | 24c32dddd2b6df02d22bdcacc0636a18f37f7471 /testes | |
| parent | d70a0c91ad42275af1f6f1b6e37c604442b3f0d1 (diff) | |
| download | lua-7d6a97e42bc3328b9c5ec1dabbd7e280e81c3efd.tar.gz lua-7d6a97e42bc3328b9c5ec1dabbd7e280e81c3efd.tar.bz2 lua-7d6a97e42bc3328b9c5ec1dabbd7e280e81c3efd.zip | |
Dump doesn't need to reuse 'source'
All strings are being reused now, including 'source'.
Diffstat (limited to 'testes')
| -rw-r--r-- | testes/calls.lua | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/testes/calls.lua b/testes/calls.lua index ee8cce73..cd2696e8 100644 --- a/testes/calls.lua +++ b/testes/calls.lua | |||
| @@ -487,5 +487,30 @@ do | |||
| 487 | end | 487 | end |
| 488 | end | 488 | end |
| 489 | 489 | ||
| 490 | |||
| 491 | do -- check reuse of strings in dumps | ||
| 492 | local str = "|" .. string.rep("X", 50) .. "|" | ||
| 493 | local foo = load(string.format([[ | ||
| 494 | local str <const> = "%s" | ||
| 495 | return { | ||
| 496 | function () return str end, | ||
| 497 | function () return str end, | ||
| 498 | function () return str end | ||
| 499 | } | ||
| 500 | ]], str)) | ||
| 501 | -- count occurrences of 'str' inside the dump | ||
| 502 | local dump = string.dump(foo) | ||
| 503 | local _, count = string.gsub(dump, str, {}) | ||
| 504 | -- there should be only two occurrences: | ||
| 505 | -- one inside the source, other the string itself. | ||
| 506 | assert(count == 2) | ||
| 507 | |||
| 508 | if T then -- check reuse of strings in undump | ||
| 509 | local funcs = load(dump)() | ||
| 510 | assert(string.format("%p", T.listk(funcs[1])[1]) == | ||
| 511 | string.format("%p", T.listk(funcs[3])[1])) | ||
| 512 | end | ||
| 513 | end | ||
| 514 | |||
| 490 | print('OK') | 515 | print('OK') |
| 491 | return deep | 516 | return deep |
