diff --git a/.travis.yml b/.travis.yml index 8a61cdb..0c5e25a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ install: - luarocks install busted - luarocks install luacov - luarocks install luacov-coveralls + - luarocks install middleclass script: - luacheck --std max+busted bitser.lua spec diff --git a/README.md b/README.md index 0e116e8..6d3ca54 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # bitser +[![Build Status](https://travis-ci.org/gvx/bitser.svg?branch=master)](https://travis-ci.org/gvx/bitser) + Serializes and deserializes Lua values with LuaJIT. local bitser = require 'bitser' diff --git a/bitser.lua b/bitser.lua index 9f13823..a0c0886 100644 --- a/bitser.lua +++ b/bitser.lua @@ -77,7 +77,7 @@ local class_deserialize_registry = {} local serialize_value -local function write_number(value, buffer, seen) +local function write_number(value, buffer, _) if floor(value) == value and value >= -2147483648 and value <= 2147483647 then if value >= -27 and value <= 100 then --small int @@ -110,11 +110,11 @@ local function write_string(value, buffer, seen) Buffer_write_string(buffer, value) end -local function write_nil(value, buffer, seen) +local function write_nil(_, buffer, _) Buffer_write_byte(buffer, 247) end -local function write_boolean(value, buffer, seen) +local function write_boolean(value, buffer, _) Buffer_write_byte(buffer, value and 249 or 248) end diff --git a/spec/bitser_spec.lua b/spec/bitser_spec.lua index 0c7962a..90eb013 100644 --- a/spec/bitser_spec.lua +++ b/spec/bitser_spec.lua @@ -73,4 +73,23 @@ describe("bitser", function() bitser.unregister(tostring(i)) end end) + it("serializes deeply nested tables", function() + local max = 1000 + local t = {} + for _ = 1, max do + t.t = {} + t = t.t + end + test_serdeser(t) + end) + it("serializes MiddleClass instances", function() + local class = require("middleclass") + local Horse = class('Horse') + function Horse:initialize(name) + self.name = name + end + local bojack = Horse('Bojack Horseman') + test_serdeser(bojack) + assert.is_true(serdeser(bojack):isInstanceOf(Horse)) + end) end) \ No newline at end of file