mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 01:15:14 +02:00
Rust 1.85, edition=2024 (#15741)
This commit is contained in:
@ -3,19 +3,20 @@ mod from;
|
||||
mod to;
|
||||
|
||||
pub use from::from_nuon;
|
||||
pub use to::to_nuon;
|
||||
pub use to::ToStyle;
|
||||
pub use to::to_nuon;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use chrono::DateTime;
|
||||
use nu_protocol::{
|
||||
BlockId, IntRange, Range, Span, Value,
|
||||
ast::{CellPath, PathMember, RangeInclusion},
|
||||
engine::{Closure, EngineState},
|
||||
record, BlockId, IntRange, Range, Span, Value,
|
||||
record,
|
||||
};
|
||||
|
||||
use crate::{from_nuon, to_nuon, ToStyle};
|
||||
use crate::{ToStyle, from_nuon, to_nuon};
|
||||
|
||||
/// test something of the form
|
||||
/// ```nushell
|
||||
@ -180,19 +181,21 @@ mod tests {
|
||||
fn to_nuon_errs_on_closure() {
|
||||
let engine_state = EngineState::new();
|
||||
|
||||
assert!(to_nuon(
|
||||
&engine_state,
|
||||
&Value::test_closure(Closure {
|
||||
block_id: BlockId::new(0),
|
||||
captures: vec![]
|
||||
}),
|
||||
ToStyle::Default,
|
||||
None,
|
||||
false,
|
||||
)
|
||||
.unwrap_err()
|
||||
.to_string()
|
||||
.contains("Unsupported input"));
|
||||
assert!(
|
||||
to_nuon(
|
||||
&engine_state,
|
||||
&Value::test_closure(Closure {
|
||||
block_id: BlockId::new(0),
|
||||
captures: vec![]
|
||||
}),
|
||||
ToStyle::Default,
|
||||
None,
|
||||
false,
|
||||
)
|
||||
.unwrap_err()
|
||||
.to_string()
|
||||
.contains("Unsupported input")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -325,29 +328,31 @@ mod tests {
|
||||
fn to_nuon_converts_columns_with_spaces() {
|
||||
let engine_state = EngineState::new();
|
||||
|
||||
assert!(from_nuon(
|
||||
&to_nuon(
|
||||
&engine_state,
|
||||
&Value::test_list(vec![
|
||||
Value::test_record(record!(
|
||||
"a" => Value::test_int(1),
|
||||
"b" => Value::test_int(2),
|
||||
"c d" => Value::test_int(3)
|
||||
)),
|
||||
Value::test_record(record!(
|
||||
"a" => Value::test_int(4),
|
||||
"b" => Value::test_int(5),
|
||||
"c d" => Value::test_int(6)
|
||||
))
|
||||
]),
|
||||
ToStyle::Default,
|
||||
assert!(
|
||||
from_nuon(
|
||||
&to_nuon(
|
||||
&engine_state,
|
||||
&Value::test_list(vec![
|
||||
Value::test_record(record!(
|
||||
"a" => Value::test_int(1),
|
||||
"b" => Value::test_int(2),
|
||||
"c d" => Value::test_int(3)
|
||||
)),
|
||||
Value::test_record(record!(
|
||||
"a" => Value::test_int(4),
|
||||
"b" => Value::test_int(5),
|
||||
"c d" => Value::test_int(6)
|
||||
))
|
||||
]),
|
||||
ToStyle::Default,
|
||||
None,
|
||||
false,
|
||||
)
|
||||
.unwrap(),
|
||||
None,
|
||||
false,
|
||||
)
|
||||
.unwrap(),
|
||||
None,
|
||||
)
|
||||
.is_ok());
|
||||
.is_ok()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -485,10 +490,12 @@ mod tests {
|
||||
// }
|
||||
// ```
|
||||
fn read_code_should_fail_rather_than_panic() {
|
||||
assert!(from_nuon(
|
||||
include_str!("../../../tests/fixtures/formats/code.nu"),
|
||||
None,
|
||||
)
|
||||
.is_err());
|
||||
assert!(
|
||||
from_nuon(
|
||||
include_str!("../../../tests/fixtures/formats/code.nu"),
|
||||
None,
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user