fix(cell-path): update tests and examples

This commit is contained in:
Bahex 2025-05-04 12:05:07 +03:00
parent 05ff3c8e8e
commit ea31bd3918
3 changed files with 11 additions and 3 deletions

View File

@ -93,11 +93,12 @@ impl Command for IntoCellPath {
},
Example {
description: "Convert table into cell path",
example: "[[value, optional]; [5 true] [c false]] | into cell-path",
example: "[[value, optional, insensitive]; [5 true false] [c false false] [d false true]] | into cell-path",
result: Some(Value::test_cell_path(CellPath {
members: vec![
PathMember::test_int(5, true),
PathMember::test_string("c".into(), false, false),
PathMember::test_string("d".into(), false, true),
],
})),
},

View File

@ -77,36 +77,43 @@ impl Command for SplitCellPath {
Value::test_record(record! {
"value" => Value::test_int(5),
"optional" => Value::test_bool(true),
"insensitive" => Value::test_bool(false),
}),
Value::test_record(record! {
"value" => Value::test_string("c"),
"optional" => Value::test_bool(false),
"insensitive" => Value::test_bool(false),
}),
])),
},
Example {
description: "Split a complex cell-path",
example: r#"$.a.b?.1."2"."c.d" | split cell-path"#,
example: r#"$.a!.b?.1."2"."c.d" | split cell-path"#,
result: Some(Value::test_list(vec![
Value::test_record(record! {
"value" => Value::test_string("a"),
"optional" => Value::test_bool(false),
"insensitive" => Value::test_bool(true),
}),
Value::test_record(record! {
"value" => Value::test_string("b"),
"optional" => Value::test_bool(true),
"insensitive" => Value::test_bool(false),
}),
Value::test_record(record! {
"value" => Value::test_int(1),
"optional" => Value::test_bool(false),
"insensitive" => Value::test_bool(false),
}),
Value::test_record(record! {
"value" => Value::test_string("2"),
"optional" => Value::test_bool(false),
"insensitive" => Value::test_bool(false),
}),
Value::test_record(record! {
"value" => Value::test_string("c.d"),
"optional" => Value::test_bool(false),
"insensitive" => Value::test_bool(false),
}),
])),
},

View File

@ -307,7 +307,7 @@ fn nullify_holes() -> TestResult {
#[test]
fn get_insensitive() -> TestResult {
run_test(
r#"[[name, age]; [a, 1] [b, 2]] | get NAmE | select 0 | get 0"#,
r#"[[name, age]; [a, 1] [b, 2]] | get -I NAmE | select 0 | get 0"#,
"a",
)
}