diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-06-13 14:14:50 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-06-13 14:14:50 -0300 |
| commit | 0cecf1ab6d76e6a7d200fb01bdd999b61835fe21 (patch) | |
| tree | fbd3d4b2928d50bc2e8ef7712920f6a572eaadfd /testes/code.lua | |
| parent | e657a48ea5698bbd9982d878eb65e6615ec94f7e (diff) | |
| download | lua-0cecf1ab6d76e6a7d200fb01bdd999b61835fe21.tar.gz lua-0cecf1ab6d76e6a7d200fb01bdd999b61835fe21.tar.bz2 lua-0cecf1ab6d76e6a7d200fb01bdd999b61835fe21.zip | |
Dump uses varints also for integer constants
Unlike sizes, these constants can be negative, so it encodes those
integers into unsigned integers in a way that keeps small numbers
small.
Diffstat (limited to 'testes/code.lua')
| -rw-r--r-- | testes/code.lua | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/testes/code.lua b/testes/code.lua index 633f4896..380ff70c 100644 --- a/testes/code.lua +++ b/testes/code.lua | |||
| @@ -482,5 +482,23 @@ do -- basic check for SETLIST | |||
| 482 | assert(count == 1) | 482 | assert(count == 1) |
| 483 | end | 483 | end |
| 484 | 484 | ||
| 485 | |||
| 486 | do print("testing code for integer limits") | ||
| 487 | local function checkints (n) | ||
| 488 | local source = string.format( | ||
| 489 | "local a = {[true] = 0X%x}; return a[true]", n) | ||
| 490 | local f = assert(load(source)) | ||
| 491 | checkKlist(f, {n}) | ||
| 492 | assert(f() == n) | ||
| 493 | f = load(string.dump(f)) | ||
| 494 | assert(f() == n) | ||
| 495 | end | ||
| 496 | |||
| 497 | checkints(math.maxinteger) | ||
| 498 | checkints(math.mininteger) | ||
| 499 | checkints(-1) | ||
| 500 | |||
| 501 | end | ||
| 502 | |||
| 485 | print 'OK' | 503 | print 'OK' |
| 486 | 504 | ||
