Add tests to compare different sprites (Sprite vs Layer mainly)

Related to: https://github.com/aseprite/aseprite/issues/3218
This commit is contained in:
David Capello 2022-05-23 17:23:16 -03:00
parent 09958449c3
commit dd30981e8b
4 changed files with 23 additions and 3 deletions

View File

@ -1,4 +1,4 @@
Copyright (c) 2018-2021 Igara Studio S.A.
Copyright (c) 2018-2022 Igara Studio S.A.
Copyright (c) 2018 David Capello
Permission is hereby granted, free of charge, to any person obtaining

View File

@ -1,3 +1,4 @@
-- Copyright (C) 2022 Igara Studio S.A.
-- Copyright (C) 2018 David Capello
--
-- This file is released under the terms of the MIT license.
@ -41,3 +42,4 @@ assert(b.saturation == 0.4)
assert(b.value == 0.5)
assert(b.alpha == 200)
assert(a == b)
assert(a ~= 1) -- Comparing with other type fails

View File

@ -1,4 +1,4 @@
-- Copyright (C) 2019 Igara Studio S.A.
-- Copyright (C) 2019-2022 Igara Studio S.A.
-- Copyright (C) 2018 David Capello
--
-- This file is released under the terms of the MIT license.
@ -204,3 +204,12 @@ do
i = i + 1
end
end
-- Compare layers vs sprites (just return false)
do
local s = Sprite(2, 2)
assert(s.layers[1].parent == s)
assert(s.layers[1] ~= s) -- Uses Layer_eq() to compare
assert(s ~= s.layers[1]) -- Uses Sprite_eq() to compare
end

View File

@ -1,4 +1,4 @@
-- Copyright (C) 2019-2021 Igara Studio S.A.
-- Copyright (C) 2019-2022 Igara Studio S.A.
-- Copyright (C) 2018 David Capello
--
-- This file is released under the terms of the MIT license.
@ -197,3 +197,12 @@ do
assert(s.cels[1].image:getPixel(0, 0) == 2)
assert(s.cels[1].image:getPixel(1, 0) == 1) -- Get the color of the first layer
end
-- Compare sprite IDs
do
local a = Sprite(1, 1)
local b = Sprite(1, 1)
assert(a == a)
assert(a ~= b) -- Compares IDs, not sprite size
end