[PATCH] Add tests for matching semi-complicated tuples
[Thread Prev] | [Thread Next]
[Date Prev] | [Date Next]
- Subject: [PATCH] Add tests for matching semi-complicated tuples
- From: "S. Gilles" <sgilles@xxxxxxxxxxxx>
- Reply-to: myrddin-dev@xxxxxxxxxxxxxx
- Date: Wed, 16 Oct 2019 03:37:38 -0400
- To: "myrddin-dev" <myrddin-dev@xxxxxxxxxxxxxx>
- Cc: "S. Gilles" <sgilles@xxxxxxx>, Mura Li <mura@xxxxxxx>
---
This is a test case based on something I mentioned in IRC the other day.
Mura Li's PR 193 ( https://github.com/oridb/mc/pull/193/ ) allows the
test to pass, so this should probably wait for that.
(I'd add this as a comment/PR/whatever to Github, but it seems they
think I'm a bot now, and tend to ban me.)
test/matchctup.myr | 32 ++++++++++++++++++++++++++++++++
test/tests | 1 +
2 files changed, 33 insertions(+)
create mode 100644 test/matchctup.myr
diff --git a/test/matchctup.myr b/test/matchctup.myr
new file mode 100644
index 00000000..07d51e6a
--- /dev/null
+++ b/test/matchctup.myr
@@ -0,0 +1,32 @@
+use std
+
+const main = {
+ match (gen_a(), gen_b())
+ | (`std.Err _, _): std.put("error case 1")
+ | (_, `std.Err _): std.put("error case 2")
+ | (`std.Ok L, `std.Ok N):
+ std.put("l = {} n = {}\n", L, N)
+ ;;
+}
+
+var gen_a : (-> std.result(byte[:][:], void)) = {
+ var ret = [][:]
+
+ for var j = 0; j < 4; ++j
+ std.slpush(&ret, std.fmt("{}", j))
+ ;;
+
+ if 1 + 1 > 3
+ -> `std.Err void
+ ;;
+
+ -> `std.Ok ret
+}
+
+var gen_b : (-> std.result(int, void)) = {
+ if 1 + 1 > 3
+ -> `std.Err void
+ ;;
+
+ -> `std.Ok 5
+}
diff --git a/test/tests b/test/tests
index b4d95477..9ffa7470 100644
--- a/test/tests
+++ b/test/tests
@@ -126,6 +126,7 @@ B matchptr P 'worked'
B matchnest P 'abcdef'
F matchmixed
F matchoverlap
+B matchctup P 'l = [0, 1, 2, 3] n = 5'
B bigliteral P 34359738368
B fltabs P '42.0'
B arraylit-ni E 2
--
2.23.0
- Next by Date: [PATCH] Tie return value of mbld to results of specified targets
- Next by thread: [PATCH] Tie return value of mbld to results of specified targets
- Index(es):