From f38989358e768ebe17c5f191cf9026d513e6f6b7 Mon Sep 17 00:00:00 2001 From: Laurenz Stampfl <47084093+LaurenzV@users.noreply.github.com> Date: Tue, 25 Apr 2023 11:22:20 +0200 Subject: Add a zip method to arrays (#947) --- tests/typ/compiler/array.typ | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/typ/compiler/array.typ') diff --git a/tests/typ/compiler/array.typ b/tests/typ/compiler/array.typ index c52160b0..5d7e8b63 100644 --- a/tests/typ/compiler/array.typ +++ b/tests/typ/compiler/array.typ @@ -223,6 +223,17 @@ #test((2, 1, 3, -10, -5, 8, 6, -7, 2).sorted(key: x => x), (-10, -7, -5, 1, 2, 2, 3, 6, 8)) #test((2, 1, 3, -10, -5, 8, 6, -7, 2).sorted(key: x => x * x), (1, 2, 2, 3, -5, 6, -7, 8, -10)) +--- +// Test the `zip` method. +#test(().zip(()), ()) +#test((1,).zip(()), ()) +#test((1,).zip((2,)), ((1, 2),)) +#test((1, 2).zip((3, 4)), ((1, 3), (2, 4))) +#test((1, 2, 3, 4).zip((5, 6)), ((1, 5), (2, 6))) +#test(((1, 2), 3).zip((4, 5)), (((1, 2), 4), (3, 5))) +#test((1, "hi").zip((true, false)), ((1, true), ("hi", false))) + + --- // Error: 32-37 cannot divide by zero #(1, 2, 0, 3).sorted(key: x => 5 / x) -- cgit v1.2.3