Comparison

spec/util_dataforms_spec.lua @ 11880:d30c81b875f2

util.dataforms: Ensure larger integers are serialized as such Assumes that most number fields are integers, as most numeric types listed in XEP-0122 are, as are all such fields in Prosody as of this. Otherwise %g produces something like 1.1259e+15
author Kim Alvefur <zash@zash.se>
date Thu, 28 Oct 2021 13:00:24 +0200
parent 11879:b8b889ba8d27
child 12387:05c250fa335a
comparison
equal deleted inserted replaced
11879:b8b889ba8d27 11880:d30c81b875f2
456 local d,e = f:data(f:form({number = 100})); 456 local d,e = f:data(f:form({number = 100}));
457 assert.not_equal(100, d.number); 457 assert.not_equal(100, d.number);
458 assert.table(e); 458 assert.table(e);
459 assert.string(e.number); 459 assert.string(e.number);
460 end); 460 end);
461
462 it("serializes largeer ints okay", function ()
463 local x = f:form{number=1125899906842624}
464 assert.equal("1125899906842624", x:find("field/value#"))
465 end);
466
461 end) 467 end)
462 468
463 describe("datetime", function () 469 describe("datetime", function ()
464 local f = dataforms.new { { name = "when"; type = "text-single"; datatype = "xs:dateTime" } } 470 local f = dataforms.new { { name = "when"; type = "text-single"; datatype = "xs:dateTime" } }
465 471