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 + ] +}