From 6ca19d33a0f30ac390630b55d29b001dd51ec905 Mon Sep 17 00:00:00 2001 From: Joshua Ogunyinka Date: Fri, 12 Nov 2021 13:43:07 +0400 Subject: [PATCH] Test correct layers iteration when layer names are numbers Related to: https://github.com/aseprite/aseprite/issues/3045 --- scripts/layers.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/scripts/layers.lua b/scripts/layers.lua index 361ef4a58..6fec6899f 100644 --- a/scripts/layers.lua +++ b/scripts/layers.lua @@ -185,3 +185,22 @@ do -- life with "undo" app.range.layers = { b } end + +-- Test layer name bug when iterating over layers where names given to +-- some layers are integers and also are valid ranges/indexes in the +-- list of layers +do + local layerNames = { "2", "4", "Non-integer", "1" } + local s = Sprite(4, 4) + local layer1 = s.layers[1] layer1.name = layerNames[1] + local layer2 = s:newLayer() layer2.name = layerNames[2] + local layer3 = s:newLayer() layer3.name = layerNames[3] + local layer4 = s:newLayer() layer4.name = layerNames[4] + + local i = 1 + for index, layer in ipairs(app.activeSprite.layers) do + assert(index == i) + assert(layer.name == layerNames[i]) + i = i + 1 + end +end