Port flatten (#512)

* A first working version of flatten. Needs a lot of cleanup. Committing to have a working version

* Typo fix

* Flatten tests pass

* Final cleanup, ready for push

* Final cleanup, ready for push

* Final cleanup, ready for push

* Final cleanup, ready for push

* Update flatten.rs

Co-authored-by: JT <547158+jntrnr@users.noreply.github.com>
This commit is contained in:
Ștefan
2021-12-17 21:44:51 +01:00
committed by GitHub
parent 6ba1e6172c
commit 6f6340186a
4 changed files with 287 additions and 0 deletions

View File

@ -1261,3 +1261,29 @@ fn comment_multiline() -> TestResult {
"10",
)
}
#[test]
fn flatten_simple_list() -> TestResult {
run_test("[[N, u, s, h, e, l, l]] | flatten", "N\nu\ns\nh\ne\nl\nl")
}
#[test]
fn flatten_get_simple_list() -> TestResult {
run_test("[[N, u, s, h, e, l, l]] | flatten | get 0", "N")
}
#[test]
fn flatten_table_get() -> TestResult {
run_test(
"[[origin, people]; [Ecuador, ([[name, meal]; ['Andres', 'arepa']])]] | flatten | get meal",
"arepa",
)
}
#[test]
fn flatten_table_column_get_last() -> TestResult {
run_test(
"[[origin, crate, versions]; [World, ([[name]; ['nu-cli']]), ['0.21', '0.22']]] | flatten versions | last | get versions",
"0.22",
)
}