mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 02:55:07 +02:00
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:
26
src/tests.rs
26
src/tests.rs
@ -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",
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user