# HG changeset patch # User Kim Alvefur # Date 1587658674 -7200 # Node ID 4fc224c9798670e2bc26dbcef72c09787e6651e0 # Parent b53193bb21ccfbb34116fdbbad5c3978db31a567 util.rsm: Test that Lua 5.3 floats are not encoded with decimal point The 'max' 'count' and 'index' fields are integers and should be encoded as such on the wire. Care needs to be taken because tostring(1.0) in Lua 5.3+ returns to "1.0" while in previous Lua versions it would return "1". diff -r b53193bb21cc -r 4fc224c97986 spec/util_rsm_spec.lua --- a/spec/util_rsm_spec.lua Thu Apr 23 18:16:36 2020 +0200 +++ b/spec/util_rsm_spec.lua Thu Apr 23 18:17:54 2020 +0200 @@ -77,6 +77,13 @@ assert.same(test:get_child_text("before"), res:get_child_text("before")); end); + it("handles floats", function () + local r1 = rsm.generate({ max = 10.0, count = 100.0, first = { index = 1.0, "foo" } }); + assert.equal("10", r1:get_child_text("max")); + assert.equal("100", r1:get_child_text("count")); + assert.equal("1", r1:get_child("first").attr.index); + end); + end); end);