Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More nuon tests, fix table print #4762

Merged
merged 1 commit into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
More nuon tests, fix table print
  • Loading branch information
sophiajt committed Mar 7, 2022
commit ac44cc65c448073255aaa2e359e584e2946d74f8
36 changes: 36 additions & 0 deletions crates/nu-command/tests/format_conversions/nuon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,39 @@ fn binary_roundtrip() {

assert_eq!(actual.out, "0x[1FFF]");
}

#[test]
fn read_binary_data() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
open sample.nuon | get 5.3
"#
));

assert_eq!(actual.out, "31")
}

#[test]
fn read_record() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
open sample.nuon | get 4.name
"#
));

assert_eq!(actual.out, "Bobby")
}

#[test]
fn read_bool() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
open sample.nuon | get 3 | $in == $true
"#
));

assert_eq!(actual.out, "true")
}
2 changes: 2 additions & 0 deletions crates/nu-engine/src/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ pub fn get_columns(input: &[Value]) -> Vec<String> {
columns.push(col.to_string());
}
}
} else {
return vec![];
}
}

Expand Down
20 changes: 20 additions & 0 deletions tests/fixtures/formats/sample.nuon
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Some sample nuon values
[
# The nuon compact table format
[[a, nuon, table]; [1, 2, 3], [4, 5, 6]],

# A filesize
100kib,

# A duration
100sec

# A boolean
true,

# A record
{name: "Bobby", age: 99}

# Binary data
0x[11, ff, ee, 1f]
]