Tags: luau-lang/lute
Tags
stdlib: Introduce a small standard library utility for writing tests … …in lute (#393) Based on [frktest](https://github.com/itsfrank/frktest) This testing utility needs a bunch of assertions to be more useful, but this PR just scopes out what a simple, builtin testing api in Luau could look like. For some tests that look like: ``` local test = require("@std/test") local check = test.assert test.case("foo", function() check.eq(3, 3) check.eq(6, 1) end) test.case("bar", function() check.eq("a", "b") end) test.case("baz", function() check.neq("a", "b") end) test.suite("MySuite", function() test.case("subcase", function() check.eq(5 * 5, 3) end) end) test.run(); ``` this will render as: ``` ❯ ./build/xcode/debug/lute/cli/lute run examples/testing.luau ================================================== TEST RESULTS ================================================== Failed Tests (3): ❌ foo ./examples/testing.luau:5 eq: 6 ~= 1 ❌ bar ./examples/testing.luau:10 eq: a ~= b ❌ MySuite.subcase ./examples/testing.luau:20 eq: 25 ~= 3 -------------------------------------------------- Total: 4 Passed: 1 ✓ Failed: 3 ✗ ================================================== ``` Currently reports: - [x] Test suites and cases - [x] Line numbers - [x] Stack traces - [x] The expression that failed.
Update the bootstrap script to actually build two copies of lute (#386) The bootstrap script didn't correctly generate the lute standard library headers that the `luthier` script did. This PR: - generates a minimal header and implementation for the lute standard libraries during the bootstrap phase - uses these headers to build a `bootstrapped-lute` binary - uses that `bootstrapped-lute` to run `luthier.luau` which builds the actual `lute` executable with the `std` library correctly generated. - accepts an `--install` argument to install this `lute` binary to `$HOME/.lute/bin`. There are some additional improvements that have been made: 1. General README fixes 2. This script can now be run multiple times in sequence, and it correctly deletes artifacts generated by the bootstrapping process each time (e.g. generated std headers, dependencies). 3. Uses git commands to `clone` only the particular revision of the `extern` dependencies we care about, not the entire history. --------- Co-authored-by: ariel <aweiss@hey.com>
Manually get the full body including any \0 instead of relying on the… … string length (#379) Without this we would get a truncated body and curl would hang waiting for the missing bytes to send. Test: ```luau local net = require("@lute/net") local pp = require("@batteries/pp") local function test(payload: string) local response = net.request("https://httpbin.org/post", { method = "POST", headers = { ["Content-Type"] = "application/octet-stream", }, body = payload, }) print(response.status, pp(response.headers), response.ok, pp(response.body)) end test("Hello World") -- works test("Hello\0World") -- hangs ``` `Content-Length` is 11 for both.
Implement task.delay (#372) This PR implements task.delay in the form of `<T..., U...>(dur: number | time.Duration, routine: (T...) -> U..., ...: T...)`. `yieldLuaStateFor` was also changed to accept an `nargs` parameter, to support using that function for `task.delay`. Closes #260 --------- Co-authored-by: ariel <aweiss@hey.com>
Allow required modules to return string and numeric values (#373) Based on this PR in the Luau repository: luau-lang/luau#1967. I also spent a while trying to get newlines in error messages to play nicely, but we still have some issues that we'll need to address later. Main tension is that `lua_debugtrace` automatically puts a newline at the end of the trace, but a "regular" error on a thread is usually just a string with no newline.
RequireVfs: Remove all `default` blocks in favor of being explicit (#371 ) When first implementing this, I didn't realize that the compiler checks for exhaustivity when switching over an enum. This is an improvement that helps us catch errors at compile-time by being more explicit.
Add printStatement func to printer (#361) There are print cases not covered by `printBlock` and `printExpr`, so I figure this is useful to have If anything, we can replace `printBlock` with this function and export it as `print` instead, [since`visitStatement` encompasses blocks](https://github.com/luau-lang/lute/blob/primary/lute/std/libs/syntax/visitor.luau#L796), in addition to many statement types --------- Co-authored-by: ariel <aweiss@hey.com>
PreviousNext