aboutsummaryrefslogtreecommitdiff
path: root/testes
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2022-09-23 10:57:35 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2022-09-23 10:57:35 -0300
commitcfbe378f906061ee56f91acfbdf569d0d3fb9556 (patch)
tree26bde27fbb3ed4c158de4a9991a144dd3f2cd57b /testes
parenta1089b415a3f5c753aa1b40758ffdaf28d5701b0 (diff)
downloadlua-cfbe378f906061ee56f91acfbdf569d0d3fb9556.tar.gz
lua-cfbe378f906061ee56f91acfbdf569d0d3fb9556.tar.bz2
lua-cfbe378f906061ee56f91acfbdf569d0d3fb9556.zip
Small simplification in overflow check in 'getfield'
Subtracting a small non-negative int from a non-negative int cannot overflow, and adding a non-negative int to INT_MIN cannot overflow.
Diffstat (limited to 'testes')
-rw-r--r--testes/files.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/testes/files.lua b/testes/files.lua
index 16cf9b6a..78f962e5 100644
--- a/testes/files.lua
+++ b/testes/files.lua
@@ -825,8 +825,17 @@ checkerr("missing", os.time, {hour = 12}) -- missing date
825if string.packsize("i") == 4 then -- 4-byte ints 825if string.packsize("i") == 4 then -- 4-byte ints
826 checkerr("field 'year' is out-of-bound", os.time, 826 checkerr("field 'year' is out-of-bound", os.time,
827 {year = -(1 << 31) + 1899, month = 1, day = 1}) 827 {year = -(1 << 31) + 1899, month = 1, day = 1})
828
829 checkerr("field 'year' is out-of-bound", os.time,
830 {year = -(1 << 31), month = 1, day = 1})
831
832 if math.maxinteger > 2^31 then -- larger lua_integer?
833 checkerr("field 'year' is out-of-bound", os.time,
834 {year = (1 << 31) + 1900, month = 1, day = 1})
835 end
828end 836end
829 837
838
830if not _port then 839if not _port then
831 -- test Posix-specific modifiers 840 -- test Posix-specific modifiers
832 assert(type(os.date("%Ex")) == 'string') 841 assert(type(os.date("%Ex")) == 'string')