Add partial implementation of string.format.

Not yet implemented:
(1) '#' flag (use alternate format)
(2) Floating point formats

2 digit widths and precisions are not yet tested.
This commit is contained in:
Ian Farmer
2008-07-24 06:38:35 +00:00
parent 7f1c388919
commit 28f349a6fa
5 changed files with 338 additions and 34 deletions

View File

@@ -47,12 +47,14 @@ checkallerrors('string.find',{somestring,somestring,nonnumber},'bad argument #3'
-- string.format
local numfmts = {'%c','%d','%E','%e','%f','%g','%G','%i','%o','%u','%X','%x'}
local strfmts = {'%q','%s'}
local badfmts = {'%w'}
banner('string.format')
checkallpass('string.format',{somestring,anylua})
checkallpass('string.format',{numfmts,somenumber})
checkallpass('string.format',{strfmts,somestring})
checkallerrors('string.format',{numfmts,notanumber},'bad argument #2')
checkallerrors('string.format',{strfmts,notastring},'bad argument #2')
checkallerrors('string.format',{badfmts,somestring},"invalid option '%w'")
-- string.gmatch
banner('string.gmatch')