Comparison

spec/util_format_spec.lua @ 12571:c4337ff4f1c4

tests: Remove special-casing of Lua 5.1 Part of #1600
author Kim Alvefur <zash@zash.se>
date Sat, 02 Jul 2022 17:29:03 +0200
parent 12220:25b853e64d83
child 12985:c0e3e0d79574
comparison
equal deleted inserted replaced
12570:e6f68b6c87e1 12571:c4337ff4f1c4
331 assert.equal("[inf]", format("%X", math.huge)) 331 assert.equal("[inf]", format("%X", math.huge))
332 assert.equal("7FFFFFFF", format("%X", 2147483647)) 332 assert.equal("7FFFFFFF", format("%X", 2147483647))
333 end); 333 end);
334 end); 334 end);
335 335
336 if _VERSION > "Lua 5.1" then -- COMPAT no %a or %A in Lua 5.1 336 describe("to %a", function ()
337 describe("to %a", function () 337 it("works", function ()
338 it("works", function () 338 assert.equal("0x1.84p+6", format("%a", 97))
339 assert.equal("0x1.84p+6", format("%a", 97)) 339 assert.equal("-0x1.81c8p+13", format("%a", -12345))
340 assert.equal("-0x1.81c8p+13", format("%a", -12345)) 340 assert.equal("0x1.8p+0", format("%a", 1.5))
341 assert.equal("0x1.8p+0", format("%a", 1.5)) 341 assert.equal("0x1p+66", format("%a", 73786976294838206464))
342 assert.equal("0x1p+66", format("%a", 73786976294838206464)) 342 assert.equal("inf", format("%a", math.huge))
343 assert.equal("inf", format("%a", math.huge)) 343 assert.equal("0x1.fffffffcp+30", format("%a", 2147483647))
344 assert.equal("0x1.fffffffcp+30", format("%a", 2147483647)) 344 end);
345 end); 345 end);
346 end); 346
347 347 describe("to %A", function ()
348 describe("to %A", function () 348 it("works", function ()
349 it("works", function () 349 assert.equal("0X1.84P+6", format("%A", 97))
350 assert.equal("0X1.84P+6", format("%A", 97)) 350 assert.equal("-0X1.81C8P+13", format("%A", -12345))
351 assert.equal("-0X1.81C8P+13", format("%A", -12345)) 351 assert.equal("0X1.8P+0", format("%A", 1.5))
352 assert.equal("0X1.8P+0", format("%A", 1.5)) 352 assert.equal("0X1P+66", format("%A", 73786976294838206464))
353 assert.equal("0X1P+66", format("%A", 73786976294838206464)) 353 assert.equal("INF", format("%A", math.huge))
354 assert.equal("INF", format("%A", math.huge)) 354 assert.equal("0X1.FFFFFFFCP+30", format("%A", 2147483647))
355 assert.equal("0X1.FFFFFFFCP+30", format("%A", 2147483647)) 355 end);
356 end); 356 end);
357 end);
358 end
359 357
360 describe("to %e", function () 358 describe("to %e", function ()
361 it("works", function () 359 it("works", function ()
362 assert.equal("9.700000e+01", format("%e", 97)) 360 assert.equal("9.700000e+01", format("%e", 97))
363 assert.equal("-1.234500e+04", format("%e", -12345)) 361 assert.equal("-1.234500e+04", format("%e", -12345))