From 9908a7e587af15ad277efcd31963db08c0af91bc Mon Sep 17 00:00:00 2001 From: Ara Park Date: Fri, 3 Jul 2026 21:33:15 +0900 Subject: [PATCH 1/2] test: cover P0 call binding and pattern rest cases --- compiler/p0_regression_test.go | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 compiler/p0_regression_test.go diff --git a/compiler/p0_regression_test.go b/compiler/p0_regression_test.go new file mode 100644 index 0000000..811c163 --- /dev/null +++ b/compiler/p0_regression_test.go @@ -0,0 +1,45 @@ +package compiler + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestP0VariadicAndCallUnpackingRegression(t *testing.T) { + t.Run("static tuple star call and keyword-only argument", func(t *testing.T) { + src := "def total(a: int, b: int, *, c: int = 3) -> int:\n" + + " return a + b + c\n" + + "args: tuple[int, int] = (1, 2)\n" + + "print(str(total(*args)))\n" + + "print(str(total(*args, c=4)))\n" + require.Equal(t, "6\n7\n", run(t, src)) + }) + + t.Run("duplicate keyword from positional binding is rejected", func(t *testing.T) { + errs := checkOnly(t, "def f(a: int) -> int:\n"+ + " return a\n"+ + "print(str(f(1, a=2)))\n") + require.NotEmpty(t, errs) + }) +} + +func TestP0MatchStarAndRestPatternsRegression(t *testing.T) { + t.Run("list starred rest capture", func(t *testing.T) { + src := "xs: list[int] = [1, 2, 3]\n" + + "match xs:\n" + + " case [head, *tail]:\n" + + " print(str(head))\n" + + " print(str(tail[0]))\n" + require.Equal(t, "1\n2\n", run(t, src)) + }) + + t.Run("mapping rest capture copies unconsumed keys", func(t *testing.T) { + src := "data: dict[str, int] = {\"x\": 1, \"y\": 2}\n" + + "match data:\n" + + " case {\"x\": x, **rest}:\n" + + " print(str(x))\n" + + " print(str(rest[\"y\"]))\n" + require.Equal(t, "1\n2\n", run(t, src)) + }) +} From c1c298647da14bdb43a6fe14369310b6b31852ac Mon Sep 17 00:00:00 2001 From: Ara Park Date: Fri, 3 Jul 2026 21:35:50 +0900 Subject: [PATCH 2/2] ci: run Go tests on pushes and pull requests --- .github/workflows/test.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..7eb9dd5 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,37 @@ +name: Test + +on: + push: + branches: + - main + pull_request: + branches: + - main + +permissions: + contents: read + +concurrency: + group: test-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + go-test: + name: Go test + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + + - name: Download dependencies + run: go mod download + + - name: Run tests + run: go test ./...