mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 06:35:56 +02:00
add support for cell-paths to NUON (#12718)
# Description _cell paths_ can be easily serialized back and forth to NUON with the leading `$.` syntax. # User-Facing Changes ```nushell $.foo.bar.0 | to nuon ``` and ```nushell "$.foo.bar.0" | from nuon ``` are now possible # Tests + Formatting a new `cell_path` test has been added to `nuon` # After Submitting
This commit is contained in:
@ -14,7 +14,11 @@ pub use to::ToStyle;
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use chrono::DateTime;
|
||||
use nu_protocol::{ast::RangeInclusion, engine::Closure, record, IntRange, Range, Span, Value};
|
||||
use nu_protocol::{
|
||||
ast::{CellPath, PathMember, RangeInclusion},
|
||||
engine::Closure,
|
||||
record, IntRange, Range, Span, Value,
|
||||
};
|
||||
|
||||
use crate::{from_nuon, to_nuon, ToStyle};
|
||||
|
||||
@ -325,6 +329,20 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cell_path() {
|
||||
nuon_end_to_end(
|
||||
r#"$.foo.bar.0"#,
|
||||
Some(Value::test_cell_path(CellPath {
|
||||
members: vec![
|
||||
PathMember::string("foo".to_string(), false, Span::new(2, 5)),
|
||||
PathMember::string("bar".to_string(), false, Span::new(6, 9)),
|
||||
PathMember::int(0, false, Span::new(10, 11)),
|
||||
],
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn does_not_quote_strings_unnecessarily() {
|
||||
assert_eq!(
|
||||
|
Reference in New Issue
Block a user