Add a test for rxi/classic

This commit is contained in:
Jasmijn Wellner 2024-12-29 17:54:42 +01:00
parent 608c1c4792
commit 3fd140cb28
3 changed files with 14 additions and 0 deletions

1
.gitignore vendored
View File

@ -12,3 +12,4 @@ luacov.*.out
# optional class libraries, used for testing
class.lua
slither.lua
classic.lua

View File

@ -8,3 +8,4 @@ luarocks install luacov-coveralls
luarocks install middleclass
wget https://raw.githubusercontent.com/bartbes/slither/b9cf6daa1e8995093aa80a40ee9ff98402eeb602/slither.lua
wget https://raw.githubusercontent.com/vrld/hump/038bc9025f1cb850355f4b073357b087b8122da9/class.lua
wget https://raw.githubusercontent.com/rxi/classic/e5610756c98ac2f8facd7ab90c94e1a097ecd2c6/classic.lua

View File

@ -195,6 +195,18 @@ describe("bitser", function()
assert.are.equal(new_bojack.__class, Horse)
bitser.unregisterClass('Horse')
end)
it("serializes Classic instances", function()
local Object = require("classic")
local Horse = bitser.registerClass('Horse', Object:extend())
function Horse:new(name)
self.name = name
self[1] = 'instance can be sequence'
end
local bojack = Horse('Bojack Horseman')
test_serdeser(bojack)
assert.are.equal(getmetatable(serdeser(bojack)), Horse)
bitser.unregisterClass('Horse')
end)
it("serializes custom class instances", function()
local Horse_mt = bitser.registerClass('Horse', {__index = {}}, nil, setmetatable)
local function Horse(name)