forked from extern/nushell
Hi there, The case which was presented must be addressed. But I did not test it properly... I'd encourage you to do so. Take care. --------- Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
This commit is contained in:
@ -180,6 +180,92 @@ fn table_expand_flatten_and_deep_1() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn table_expand_record_0() {
|
||||
let actual = nu!(r#"[{c: {d: 1}}] | table --expand"#);
|
||||
|
||||
assert_eq!(
|
||||
actual.out,
|
||||
"╭───┬───────────╮\
|
||||
│ # │ c │\
|
||||
├───┼───────────┤\
|
||||
│ 0 │ ╭───┬───╮ │\
|
||||
│ │ │ d │ 1 │ │\
|
||||
│ │ ╰───┴───╯ │\
|
||||
╰───┴───────────╯"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn table_expand_record_1() {
|
||||
let actual =
|
||||
nu!(r#"[[a b, c]; [1 2 3] [4 5 [1 2 {a: 123, b: 234, c: 345}]]] | table --expand"#);
|
||||
|
||||
assert_eq!(
|
||||
actual.out,
|
||||
"╭───┬───┬───┬─────────────────────╮\
|
||||
│ # │ a │ b │ c │\
|
||||
├───┼───┼───┼─────────────────────┤\
|
||||
│ 0 │ 1 │ 2 │ 3 │\
|
||||
│ 1 │ 4 │ 5 │ ╭───┬─────────────╮ │\
|
||||
│ │ │ │ │ 0 │ 1 │ │\
|
||||
│ │ │ │ │ 1 │ 2 │ │\
|
||||
│ │ │ │ │ 2 │ ╭───┬─────╮ │ │\
|
||||
│ │ │ │ │ │ │ a │ 123 │ │ │\
|
||||
│ │ │ │ │ │ │ b │ 234 │ │ │\
|
||||
│ │ │ │ │ │ │ c │ 345 │ │ │\
|
||||
│ │ │ │ │ │ ╰───┴─────╯ │ │\
|
||||
│ │ │ │ ╰───┴─────────────╯ │\
|
||||
╰───┴───┴───┴─────────────────────╯"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn table_expand_record_2() {
|
||||
let structure = "{\
|
||||
field1: [ a, b, c ],\
|
||||
field2: [ 123, 234, 345 ],\
|
||||
field3: [ [ head1, head2, head3 ]; [ 1 2 3 ] [ 79 79 79 ] [ { f1: 'a string', f2: 1000 }, 1, 2 ] ],\
|
||||
field4: { f1: 1, f2: 3, f3: { f1: f1, f2: f2, f3: f3 } }\
|
||||
}";
|
||||
let actual = nu!(format!("{} | table --expand", structure));
|
||||
|
||||
assert_eq!(
|
||||
actual.out,
|
||||
"╭────────┬───────────────────────────────────────────╮\
|
||||
│ │ ╭───┬───╮ │\
|
||||
│ field1 │ │ 0 │ a │ │\
|
||||
│ │ │ 1 │ b │ │\
|
||||
│ │ │ 2 │ c │ │\
|
||||
│ │ ╰───┴───╯ │\
|
||||
│ │ ╭───┬─────╮ │\
|
||||
│ field2 │ │ 0 │ 123 │ │\
|
||||
│ │ │ 1 │ 234 │ │\
|
||||
│ │ │ 2 │ 345 │ │\
|
||||
│ │ ╰───┴─────╯ │\
|
||||
│ │ ╭───┬───────────────────┬───────┬───────╮ │\
|
||||
│ field3 │ │ # │ head1 │ head2 │ head3 │ │\
|
||||
│ │ ├───┼───────────────────┼───────┼───────┤ │\
|
||||
│ │ │ 0 │ 1 │ 2 │ 3 │ │\
|
||||
│ │ │ 1 │ 79 │ 79 │ 79 │ │\
|
||||
│ │ │ 2 │ ╭────┬──────────╮ │ 1 │ 2 │ │\
|
||||
│ │ │ │ │ f1 │ a string │ │ │ │ │\
|
||||
│ │ │ │ │ f2 │ 1000 │ │ │ │ │\
|
||||
│ │ │ │ ╰────┴──────────╯ │ │ │ │\
|
||||
│ │ ╰───┴───────────────────┴───────┴───────╯ │\
|
||||
│ │ ╭────┬─────────────╮ │\
|
||||
│ field4 │ │ f1 │ 1 │ │\
|
||||
│ │ │ f2 │ 3 │ │\
|
||||
│ │ │ │ ╭────┬────╮ │ │\
|
||||
│ │ │ f3 │ │ f1 │ f1 │ │ │\
|
||||
│ │ │ │ │ f2 │ f2 │ │ │\
|
||||
│ │ │ │ │ f3 │ f3 │ │ │\
|
||||
│ │ │ │ ╰────┴────╯ │ │\
|
||||
│ │ ╰────┴─────────────╯ │\
|
||||
╰────────┴───────────────────────────────────────────╯"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(windows))]
|
||||
fn external_with_too_much_stdout_should_not_hang_nu() {
|
||||
|
Reference in New Issue
Block a user