From c735d4b45f2db336e2aff8d94da7a08bb1fad68f Mon Sep 17 00:00:00 2001 From: Zuhaitz Méndez Fernández de Aránguiz Date: Fri, 23 Jan 2026 15:55:02 +0000 Subject: Update for tuples. --- tests/features/test_tuples.zc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/features/test_tuples.zc (limited to 'tests/features') diff --git a/tests/features/test_tuples.zc b/tests/features/test_tuples.zc new file mode 100644 index 0000000..f8ccb1f --- /dev/null +++ b/tests/features/test_tuples.zc @@ -0,0 +1,29 @@ +fn get_pair() -> (int, int) { + return (10, 20); +} + +fn main() { + // Inferred type tuple literal + var p = (1, 2); + assert(p.0 == 1, "Tuple access 0"); + assert(p.1 == 2, "Tuple access 1"); + + // Function returning tuple + var p2 = get_pair(); + assert(p2.0 == 10, "Tuple return 0"); + assert(p2.1 == 20, "Tuple return 1"); + + // Explicit type tuple + var p3: (int, int) = (5, 6); + assert(p3.0 == 5, "Explicit tuple 0"); + assert(p3.1 == 6, "Explicit tuple 1"); + + // Different types + var mixed: (int, string) = (10, "Hello"); + assert(mixed.0 == 10, "Mixed 0"); + + // Tuple destructuring + var (a, b) = get_pair(); + assert(a == 10, "Destructured a"); + assert(b == 20, "Destructured b"); +} -- cgit v1.2.3