Skip to content

tests/lapi: add builtin tests #139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 28, 2025
Merged

tests/lapi: add builtin tests #139

merged 5 commits into from
Jul 28, 2025

Conversation

ligurio
Copy link
Owner

@ligurio ligurio commented Jul 3, 2025

Depends on #142

@ligurio ligurio force-pushed the ligurio/gh-xxxx-lapi-builtin branch from 7a7d1f6 to 96bbfcc Compare July 3, 2025 11:33
@ligurio ligurio marked this pull request as draft July 3, 2025 11:39
@ligurio ligurio force-pushed the ligurio/gh-xxxx-lapi-builtin branch 3 times, most recently from 47603ce to 9957056 Compare July 8, 2025 11:37
@ligurio ligurio marked this pull request as ready for review July 8, 2025 11:56
@ligurio ligurio force-pushed the ligurio/gh-xxxx-lapi-builtin branch 2 times, most recently from 8800a82 to 7f7b4f2 Compare July 8, 2025 13:40
@ligurio ligurio requested a review from Buristan July 14, 2025 09:39
Copy link
Collaborator

@Buristan Buristan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, Sergey!
Thanks for the patch!
Please consider my comments below.

Also, I suggest separating commits related to the math operations and builtin base library. Also, I suppose they should be performed for double range (not integer).

@Buristan Buristan mentioned this pull request Jul 16, 2025
@Buristan Buristan assigned ligurio and unassigned Buristan Jul 17, 2025
@ligurio
Copy link
Owner Author

ligurio commented Jul 21, 2025

Also, I suggest separating commits related to the math operations and builtin base library

Done.

@ligurio ligurio force-pushed the ligurio/gh-xxxx-lapi-builtin branch 4 times, most recently from ed16a67 to afa9335 Compare July 22, 2025 11:52
@ligurio ligurio requested a review from Buristan July 22, 2025 12:16
@ligurio ligurio assigned Buristan and unassigned ligurio Jul 22, 2025
@ligurio ligurio force-pushed the ligurio/gh-xxxx-lapi-builtin branch from afa9335 to c8a6bbd Compare July 22, 2025 14:46
Copy link
Collaborator

@Buristan Buristan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, Sergey!
Thanks for the fixes!
LGTM, after resolving ignorable nits above.

@Buristan Buristan assigned ligurio and unassigned Buristan Jul 24, 2025
@ligurio ligurio force-pushed the ligurio/gh-xxxx-lapi-builtin branch from c8a6bbd to ab7e6e2 Compare July 24, 2025 14:42
@ligurio ligurio requested a review from Buristan July 24, 2025 14:50
@ligurio ligurio force-pushed the ligurio/gh-xxxx-lapi-builtin branch from ab7e6e2 to d16ef62 Compare July 25, 2025 10:34
ligurio added a commit to ligurio/lua-c-api-corpus that referenced this pull request Jul 28, 2025
@ligurio
Copy link
Owner Author

ligurio commented Jul 28, 2025

Fixed assertion:

--- a/tests/lapi/builtin_select_test.lua
+++ b/tests/lapi/builtin_select_test.lua
@@ -64,7 +64,9 @@ local function TestOneInput(buf)
     local err_handler = test_lib.err_handler(ignored_msgs)
     local ok, res = xpcall(select, err_handler, index, unpack(tbl))
     if not ok then return end
-    assert(type(res) == "number")
+    if index == "#" then
+        assert(type(res) == "number")
+    end
     assert(res == count)
 end
 

@ligurio ligurio force-pushed the ligurio/gh-xxxx-lapi-builtin branch 2 times, most recently from 2ad4ffb to bc5bedd Compare July 28, 2025 12:22
ligurio added a commit to ligurio/lua-c-api-corpus that referenced this pull request Jul 28, 2025
@ligurio ligurio assigned Buristan and unassigned ligurio Jul 28, 2025
Copy link
Collaborator

@Buristan Buristan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, Sergey!
Thanks for the fixes.
LGTM after fixing the last nit below.

@Buristan Buristan assigned ligurio and unassigned Buristan Jul 28, 2025
@ligurio ligurio force-pushed the ligurio/gh-xxxx-lapi-builtin branch from bc5bedd to 096aba1 Compare July 28, 2025 12:51
Copy link
Collaborator

@Buristan Buristan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, Sergey!
Thanks for the fixes!
LGTM, after fixing the last nit below.

@ligurio ligurio force-pushed the ligurio/gh-xxxx-lapi-builtin branch from 096aba1 to a71dbb9 Compare July 28, 2025 13:05
ligurio added 5 commits July 28, 2025 18:13
The `mktime()` function (which is used inside `os.time()`)
returns -1 for cases when the time since the Epoch cannot be
represented. In this case, `os.time()` returns `nil`:

```
luajit -e "print(os.time({year = 1970, month = 1, day = 1, sec = -9 * 60 * 60 - 1}))"
nil
```

The patch fixes an assertion in the test and allows `nil` as
a result of the function.

Follows up #141
The function `string.pack()` raises, the patch wraps it by `xpcall()`
and suppress errors with message "invalid format option".

Follows up #124
The function `utf8.offset()` raises, the patch wraps it by `xpcall()`
and suppress errors with message "initial position is a
continuation byte".

Follows up #143
Since commit 8e35f0c ("cmake: bump luzer version")
`fdp:oneof()` in luzer API returns two values: a table's item and
it's index. This breaks test `debug_torture_test.lua` with
a message below

> bad argument #2 to 'insert' (number expected, got string)

because `fdp:one()` passed to `table.insert()` makes a call with
three arguments: table, hook mask ("string") and index ("number"),
while `table.insert()` with three arguments expects table, `pos`
("number"), and a value (any type).

Follows up #144
The commit adds tests for Lua 5.1 builtin functions except the
following functions: `print`, `pcall`, `xpcall`, `type`.
@ligurio ligurio force-pushed the ligurio/gh-xxxx-lapi-builtin branch from a71dbb9 to cffa36d Compare July 28, 2025 15:36
@ligurio ligurio merged commit bbc1dae into master Jul 28, 2025
12 checks passed
@ligurio ligurio deleted the ligurio/gh-xxxx-lapi-builtin branch July 28, 2025 16:44
ligurio added a commit to ligurio/lua-c-api-corpus that referenced this pull request Jul 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants