mirror of
https://github.com/nushell/nushell.git
synced 2024-11-24 09:23:38 +01:00
c4dca5fe03
This PR should close #7147 # Description Merged src/tests into /tests to produce a single binary. ![image](https://github.com/nushell/nushell/assets/94604837/84726469-d447-4619-b6d1-2d1415d0f42e) # User-Facing Changes No user facing changes # Tests + Formatting Moved tests. Tollkit check pr pass. # After Submitting --------- Co-authored-by: Ian Manske <ian.manske@pm.me>
56 lines
1.3 KiB
Rust
56 lines
1.3 KiB
Rust
use crate::repl::tests::{run_test, TestResult};
|
|
|
|
#[test]
|
|
fn from_json_1() -> TestResult {
|
|
run_test(r#"('{"name": "Fred"}' | from json).name"#, "Fred")
|
|
}
|
|
|
|
#[test]
|
|
fn from_json_2() -> TestResult {
|
|
run_test(
|
|
r#"('{"name": "Fred"}
|
|
{"name": "Sally"}' | from json -o).name.1"#,
|
|
"Sally",
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn to_json_raw_flag_1() -> TestResult {
|
|
run_test(
|
|
"[[a b]; [jim susie] [3 4]] | to json -r",
|
|
r#"[{"a":"jim","b":"susie"},{"a":3,"b":4}]"#,
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn to_json_raw_flag_2() -> TestResult {
|
|
run_test(
|
|
"[[\"a b\" c]; [jim susie] [3 4]] | to json -r",
|
|
r#"[{"a b":"jim","c":"susie"},{"a b":3,"c":4}]"#,
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn to_json_raw_flag_3() -> TestResult {
|
|
run_test(
|
|
"[[\"a b\" \"c d\"]; [\"jim smith\" \"susie roberts\"] [3 4]] | to json -r",
|
|
r#"[{"a b":"jim smith","c d":"susie roberts"},{"a b":3,"c d":4}]"#,
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn to_json_escaped() -> TestResult {
|
|
run_test(
|
|
r#"{foo: {bar: '[{"a":"b","c": 2}]'}} | to json --raw"#,
|
|
r#"{"foo":{"bar":"[{\"a\":\"b\",\"c\": 2}]"}}"#,
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn to_json_raw_backslash_in_quotes() -> TestResult {
|
|
run_test(
|
|
r#"{a: '\', b: 'some text'} | to json -r"#,
|
|
r#"{"a":"\\","b":"some text"}"#,
|
|
)
|
|
}
|