return describe("const attribute", function() it("should declare const variable", function() local a = 123 return assert.same(a, 123) end) it("should prevent reassignment", function() local b = 456 return assert.same(b, 456) end) it("should work with strings", function() local name = "test" return assert.same(name, "test") end) it("should support const with destructuring", function() local tb = { a = 1, b = 2, 3, 4 } local a, b, c, d a, b, c, d = tb.a, tb.b, tb[1], tb[2] assert.same(a, 1) assert.same(b, 2) assert.same(c, 3) return assert.same(d, 4) end) it("should handle nested const", function() local nested = { inner = { value = 10 } } return assert.same(nested.inner.value, 10) end) it("should work with arrays", function() local items items = { 1, 2, 3 } return assert.same(items[1], 1) end) it("should support const in function scope", function() local fn fn = function() local local_const = "local" return local_const end local result = fn() return assert.same(result, "local") end) it("should work with multiple const declarations", function() local x = 1 local y = 2 local z = 3 return assert.same(x + y + z, 6) end) it("should handle const functions", function() local add add = function(a, b) return a + b end return assert.same(add(5, 10), 15) end) it("should work with const tables", function() local config = { host = "localhost", port = 8080 } assert.same(config.host, "localhost") return assert.same(config.port, 8080) end) it("should support global const", function() GLOBAL_CONST = 999 return assert.same(GLOBAL_CONST, 999) end) it("should work with boolean const", function() local flag = true local another = false assert.is_true(flag) return assert.is_false(another) end) it("should handle nil const", function() local nil_value = nil return assert.same(nil_value, nil) end) it("should work with expressions", function() local calculated = 10 + 20 return assert.same(calculated, 30) end) it("should work in table comprehension", function() local multiplier = 2 local items = { 1, 2, 3 } local result do local _accum_0 = { } local _len_0 = 1 for _index_0 = 1, #items do local item = items[_index_0] _accum_0[_len_0] = item * multiplier _len_0 = _len_0 + 1 end result = _accum_0 end return assert.same(result, { 2, 4, 6 }) end) return it("should work with complex expressions", function() local complex = { data = { 1, 2, 3 }, nested = { key = "value" } } assert.same(complex.data[1], 1) return assert.same(complex.nested.key, "value") end) end)