From c2f47533f654155fb250ed7a57a192b9abf3a84a Mon Sep 17 00:00:00 2001 From: Texas Toland Date: Mon, 25 Mar 2024 22:48:03 -0500 Subject: [PATCH] Initial recurse test --- stdlib-candidate/tests/mod.nu | 1 + stdlib-candidate/tests/recurse.nu | 32 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 stdlib-candidate/tests/recurse.nu diff --git a/stdlib-candidate/tests/mod.nu b/stdlib-candidate/tests/mod.nu index 1a40e7e0a..0f6d78d70 100644 --- a/stdlib-candidate/tests/mod.nu +++ b/stdlib-candidate/tests/mod.nu @@ -1,3 +1,4 @@ export module fs.nu export module record.nu +export module recurse.nu export module str_xpend.nu diff --git a/stdlib-candidate/tests/recurse.nu b/stdlib-candidate/tests/recurse.nu new file mode 100644 index 000000000..1b2b6edde --- /dev/null +++ b/stdlib-candidate/tests/recurse.nu @@ -0,0 +1,32 @@ +use std assert +use ../std-rfc recurse + +const fixture = [ + 0 + { a: 1 } + { + b: [ + 2 + [ + [c d]; + [3 4] + ] + ] + } +] + +export def test [] { + assert equal ($fixture | recurse) [ + $fixture # [0, {a: 1}, {b: [2, [[c, d]; [3, 4]]]}] + $fixture.0 # 0 + $fixture.1 # {a: 1} + $fixture.1.a # 1 + $fixture.2 # {b: [2, [[c, d]; [3, 4]]]} + $fixture.2.b # [2, [[c, d]; [3, 4]]] + $fixture.2.b.0 # 2 + $fixture.2.b.1 # [c, d]; [3, 4]] + $fixture.2.b.1.0 # {c: 3, d: 4} + $fixture.2.b.1.0.c # 3 + $fixture.2.b.1.0.d # 4 + ] +}