Skip to content

Commit

Permalink
Adapt tests to dynamically-generated field info
Browse files Browse the repository at this point in the history
No need to freeze the field info tables anymore
  • Loading branch information
lethosor committed Aug 13, 2023
1 parent fc6d4ca commit 396b2d7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
1 change: 0 additions & 1 deletion library/LuaTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,6 @@ static void PushFieldInfoSubTable(lua_State *state, const struct_field_info *fie
Lua::TableInsert(state, "original_name", field->extra->original_name);
}
}
// freeze_table(state); // TODO: make pairs() work
}

/**
Expand Down
15 changes: 10 additions & 5 deletions test/structures/struct_fields.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ end

function test.nonexistent()
expect.nil_(df.coord._fields.nonexistent)

expect.error_match('string expected', function()
expect.nil_(df.coord._fields[2])
end)
expect.error_match('string expected', function()
expect.nil_(df.coord._fields[nil])
end)
end

function test.readonly()
Expand All @@ -52,13 +59,11 @@ function test.readonly()
expect.error_match(READONLY_MSG, function()
df.coord._fields.nonexistent = 'foo'
end)
-- see TODOs in LuaTypes.cpp
-- expect.error_match(READONLY_MSG, function()
-- df.coord._fields.x.name = 'foo'
-- end)
expect.nil_(df.coord._fields.nonexistent)

-- should have no effect
df.coord._fields.x.name = 'foo'
expect.eq(df.coord._fields.x.name, 'x')
expect.nil_(df.coord._fields.nonexistent)
end

function test.circular_refs_init()
Expand Down

0 comments on commit 396b2d7

Please sign in to comment.