From 1fddf02f8e7b8a20d595f12881e9d09c58a58a29 Mon Sep 17 00:00:00 2001 From: Mateusz Gienieczko Date: Mon, 30 Dec 2024 03:02:07 +0100 Subject: [PATCH] test: added snapshot tests for the serde feature Added snapshot tests based on `insta` to both the rsonpath-syntax and rsonpath-lib serialization features. Ref: #624 --- Cargo.lock | 36 ++++++-- Cargo.toml | 1 + crates/rsonpath-lib/Cargo.toml | 1 + .../tests/engine_serialization_snapshots.rs | 43 ++++++++++ ...alization_snapshots__ron__empty_query.snap | 21 +++++ ...napshots__ron__jsonpath_example_query.snap | 84 +++++++++++++++++++ ...lization_snapshots__ron__readme_query.snap | 37 ++++++++ ...ation_snapshots__ron__real_life_query.snap | 81 ++++++++++++++++++ ...e_serialization_snapshots__ron__slice.snap | 50 +++++++++++ crates/rsonpath-syntax/Cargo.toml | 2 +- .../tests/query_serialization_snapshots.rs | 55 ++++++++++++ ...alization_snapshots__ron__empty_query.snap | 8 ++ ...napshots__ron__jsonpath_example_query.snap | 28 +++++++ ...ization_snapshots__ron__nested_filter.snap | 56 +++++++++++++ ...lization_snapshots__ron__readme_query.snap | 21 +++++ ...ation_snapshots__ron__real_life_query.snap | 51 +++++++++++ ...y_serialization_snapshots__ron__slice.snap | 47 +++++++++++ 17 files changed, 616 insertions(+), 6 deletions(-) create mode 100644 crates/rsonpath-lib/tests/engine_serialization_snapshots.rs create mode 100644 crates/rsonpath-lib/tests/snapshots/engine_serialization_snapshots__ron__empty_query.snap create mode 100644 crates/rsonpath-lib/tests/snapshots/engine_serialization_snapshots__ron__jsonpath_example_query.snap create mode 100644 crates/rsonpath-lib/tests/snapshots/engine_serialization_snapshots__ron__readme_query.snap create mode 100644 crates/rsonpath-lib/tests/snapshots/engine_serialization_snapshots__ron__real_life_query.snap create mode 100644 crates/rsonpath-lib/tests/snapshots/engine_serialization_snapshots__ron__slice.snap create mode 100644 crates/rsonpath-syntax/tests/query_serialization_snapshots.rs create mode 100644 crates/rsonpath-syntax/tests/snapshots/query_serialization_snapshots__ron__empty_query.snap create mode 100644 crates/rsonpath-syntax/tests/snapshots/query_serialization_snapshots__ron__jsonpath_example_query.snap create mode 100644 crates/rsonpath-syntax/tests/snapshots/query_serialization_snapshots__ron__nested_filter.snap create mode 100644 crates/rsonpath-syntax/tests/snapshots/query_serialization_snapshots__ron__readme_query.snap create mode 100644 crates/rsonpath-syntax/tests/snapshots/query_serialization_snapshots__ron__real_life_query.snap create mode 100644 crates/rsonpath-syntax/tests/snapshots/query_serialization_snapshots__ron__slice.snap diff --git a/Cargo.lock b/Cargo.lock index 027e2980..de2233f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -122,6 +122,12 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + [[package]] name = "bit-set" version = "0.8.0" @@ -137,6 +143,12 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bitflags" version = "2.6.0" @@ -572,7 +584,7 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b903b73e45dc0c6c596f2d37eccece7c1c8bb6e4407b001096387c63d0d93724" dependencies = [ - "bitflags", + "bitflags 2.6.0", "libc", "libgit2-sys", "log", @@ -793,6 +805,8 @@ dependencies = [ "console", "lazy_static", "linked-hash-map", + "ron", + "serde", "similar", ] @@ -856,7 +870,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags", + "bitflags 2.6.0", "libc", "redox_syscall", ] @@ -1070,7 +1084,7 @@ checksum = "14cae93065090804185d3b75f0bf93b8eeda30c7a9b4a33d3bdb3988d6229e50" dependencies = [ "bit-set", "bit-vec", - "bitflags", + "bitflags 2.6.0", "lazy_static", "num-traits", "rand 0.8.5", @@ -1203,7 +1217,7 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" dependencies = [ - "bitflags", + "bitflags 2.6.0", ] [[package]] @@ -1257,6 +1271,17 @@ dependencies = [ "serde", ] +[[package]] +name = "ron" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88073939a61e5b7680558e6be56b419e208420c2adb92be54921fa6b72283f1a" +dependencies = [ + "base64", + "bitflags 1.3.2", + "serde", +] + [[package]] name = "rsonpath" version = "0.9.3" @@ -1281,6 +1306,7 @@ version = "0.9.3" dependencies = [ "cfg-if", "ciborium", + "insta", "itertools", "log", "memmap2", @@ -1380,7 +1406,7 @@ version = "0.38.42" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" dependencies = [ - "bitflags", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", diff --git a/Cargo.toml b/Cargo.toml index 3da2d865..b951fb99 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,7 @@ log = "0.4.22" thiserror = "2.0.9" # Dev-dependencies ciborium = { version = "0.2.2", default-features = false } +insta = { version = "1.41.1" } itertools = "0.13.0" pretty_assertions = "1.4.1" proptest = "1.5.0" diff --git a/crates/rsonpath-lib/Cargo.toml b/crates/rsonpath-lib/Cargo.toml index 39b0f01a..be9516ef 100644 --- a/crates/rsonpath-lib/Cargo.toml +++ b/crates/rsonpath-lib/Cargo.toml @@ -39,6 +39,7 @@ vector-map = "1.0.1" [dev-dependencies] ciborium = { workspace = true, default-features = true } +insta = { workspace = true, features = ["ron"] } itertools = { workspace = true } pretty_assertions = { workspace = true } proptest = { workspace = true } diff --git a/crates/rsonpath-lib/tests/engine_serialization_snapshots.rs b/crates/rsonpath-lib/tests/engine_serialization_snapshots.rs new file mode 100644 index 00000000..0d0d9c1b --- /dev/null +++ b/crates/rsonpath-lib/tests/engine_serialization_snapshots.rs @@ -0,0 +1,43 @@ +use insta::assert_ron_snapshot; +use rsonpath::engine::{Compiler, RsonpathEngine}; + +mod ron { + use super::*; + use std::error::Error; + + fn engine(string: &str) -> Result> { + let query = rsonpath_syntax::parse(string)?; + let engine = RsonpathEngine::compile_query(&query)?; + Ok(engine) + } + + #[test] + fn empty_query() -> Result<(), Box> { + assert_ron_snapshot!(&engine("$")?); + Ok(()) + } + + #[test] + fn readme_query() -> Result<(), Box> { + assert_ron_snapshot!(&engine("$.jsonpath[*]")?); + Ok(()) + } + + #[test] + fn jsonpath_example_query() -> Result<(), Box> { + assert_ron_snapshot!(&engine("$..phoneNumbers[*].number")?); + Ok(()) + } + + #[test] + fn real_life_query() -> Result<(), Box> { + assert_ron_snapshot!(&engine("$.personal.details.contact.information.phones.home")?); + Ok(()) + } + + #[test] + fn slice() -> Result<(), Box> { + assert_ron_snapshot!(&engine("$..entries[3:5:7]")?); + Ok(()) + } +} diff --git a/crates/rsonpath-lib/tests/snapshots/engine_serialization_snapshots__ron__empty_query.snap b/crates/rsonpath-lib/tests/snapshots/engine_serialization_snapshots__ron__empty_query.snap new file mode 100644 index 00000000..7b6e463d --- /dev/null +++ b/crates/rsonpath-lib/tests/snapshots/engine_serialization_snapshots__ron__empty_query.snap @@ -0,0 +1,21 @@ +--- +source: crates/rsonpath-lib/tests/engine_serialization_snapshots.rs +expression: "&engine(\"$\")?" +snapshot_kind: text +--- +(V1, Automaton( + states: [ + StateTable( + attributes: StateAttributes(2), + member_transitions: [], + array_transitions: [], + fallback_state: State(0), + ), + StateTable( + attributes: StateAttributes(1), + member_transitions: [], + array_transitions: [], + fallback_state: State(0), + ), + ], +)) diff --git a/crates/rsonpath-lib/tests/snapshots/engine_serialization_snapshots__ron__jsonpath_example_query.snap b/crates/rsonpath-lib/tests/snapshots/engine_serialization_snapshots__ron__jsonpath_example_query.snap new file mode 100644 index 00000000..f9042dd5 --- /dev/null +++ b/crates/rsonpath-lib/tests/snapshots/engine_serialization_snapshots__ron__jsonpath_example_query.snap @@ -0,0 +1,84 @@ +--- +source: crates/rsonpath-lib/tests/engine_serialization_snapshots.rs +expression: "&engine(\"$..phoneNumbers[*].number\")?" +snapshot_kind: text +--- +(V1, Automaton( + states: [ + StateTable( + attributes: StateAttributes(2), + member_transitions: [], + array_transitions: [], + fallback_state: State(0), + ), + StateTable( + attributes: StateAttributes(0), + member_transitions: [ + (StringPattern(JsonString( + quoted: "\"phoneNumbers\"", + )), State(2)), + ], + array_transitions: [], + fallback_state: State(1), + ), + StateTable( + attributes: StateAttributes(0), + member_transitions: [ + (StringPattern(JsonString( + quoted: "\"phoneNumbers\"", + )), State(4)), + ], + array_transitions: [], + fallback_state: State(3), + ), + StateTable( + attributes: StateAttributes(8), + member_transitions: [ + (StringPattern(JsonString( + quoted: "\"phoneNumbers\"", + )), State(2)), + (StringPattern(JsonString( + quoted: "\"number\"", + )), State(6)), + ], + array_transitions: [], + fallback_state: State(1), + ), + StateTable( + attributes: StateAttributes(8), + member_transitions: [ + (StringPattern(JsonString( + quoted: "\"phoneNumbers\"", + )), State(4)), + (StringPattern(JsonString( + quoted: "\"number\"", + )), State(5)), + ], + array_transitions: [], + fallback_state: State(3), + ), + StateTable( + attributes: StateAttributes(9), + member_transitions: [ + (StringPattern(JsonString( + quoted: "\"phoneNumbers\"", + )), State(2)), + (StringPattern(JsonString( + quoted: "\"number\"", + )), State(6)), + ], + array_transitions: [], + fallback_state: State(1), + ), + StateTable( + attributes: StateAttributes(1), + member_transitions: [ + (StringPattern(JsonString( + quoted: "\"phoneNumbers\"", + )), State(2)), + ], + array_transitions: [], + fallback_state: State(1), + ), + ], +)) diff --git a/crates/rsonpath-lib/tests/snapshots/engine_serialization_snapshots__ron__readme_query.snap b/crates/rsonpath-lib/tests/snapshots/engine_serialization_snapshots__ron__readme_query.snap new file mode 100644 index 00000000..e40ccafb --- /dev/null +++ b/crates/rsonpath-lib/tests/snapshots/engine_serialization_snapshots__ron__readme_query.snap @@ -0,0 +1,37 @@ +--- +source: crates/rsonpath-lib/tests/engine_serialization_snapshots.rs +expression: "&engine(\"$.jsonpath[*]\")?" +snapshot_kind: text +--- +(V1, Automaton( + states: [ + StateTable( + attributes: StateAttributes(2), + member_transitions: [], + array_transitions: [], + fallback_state: State(0), + ), + StateTable( + attributes: StateAttributes(4), + member_transitions: [ + (StringPattern(JsonString( + quoted: "\"jsonpath\"", + )), State(2)), + ], + array_transitions: [], + fallback_state: State(0), + ), + StateTable( + attributes: StateAttributes(8), + member_transitions: [], + array_transitions: [], + fallback_state: State(3), + ), + StateTable( + attributes: StateAttributes(1), + member_transitions: [], + array_transitions: [], + fallback_state: State(0), + ), + ], +)) diff --git a/crates/rsonpath-lib/tests/snapshots/engine_serialization_snapshots__ron__real_life_query.snap b/crates/rsonpath-lib/tests/snapshots/engine_serialization_snapshots__ron__real_life_query.snap new file mode 100644 index 00000000..29240077 --- /dev/null +++ b/crates/rsonpath-lib/tests/snapshots/engine_serialization_snapshots__ron__real_life_query.snap @@ -0,0 +1,81 @@ +--- +source: crates/rsonpath-lib/tests/engine_serialization_snapshots.rs +expression: "&engine(\"$.personal.details.contact.information.phones.home\")?" +snapshot_kind: text +--- +(V1, Automaton( + states: [ + StateTable( + attributes: StateAttributes(2), + member_transitions: [], + array_transitions: [], + fallback_state: State(0), + ), + StateTable( + attributes: StateAttributes(4), + member_transitions: [ + (StringPattern(JsonString( + quoted: "\"personal\"", + )), State(2)), + ], + array_transitions: [], + fallback_state: State(0), + ), + StateTable( + attributes: StateAttributes(4), + member_transitions: [ + (StringPattern(JsonString( + quoted: "\"details\"", + )), State(3)), + ], + array_transitions: [], + fallback_state: State(0), + ), + StateTable( + attributes: StateAttributes(4), + member_transitions: [ + (StringPattern(JsonString( + quoted: "\"contact\"", + )), State(4)), + ], + array_transitions: [], + fallback_state: State(0), + ), + StateTable( + attributes: StateAttributes(4), + member_transitions: [ + (StringPattern(JsonString( + quoted: "\"information\"", + )), State(5)), + ], + array_transitions: [], + fallback_state: State(0), + ), + StateTable( + attributes: StateAttributes(4), + member_transitions: [ + (StringPattern(JsonString( + quoted: "\"phones\"", + )), State(6)), + ], + array_transitions: [], + fallback_state: State(0), + ), + StateTable( + attributes: StateAttributes(12), + member_transitions: [ + (StringPattern(JsonString( + quoted: "\"home\"", + )), State(7)), + ], + array_transitions: [], + fallback_state: State(0), + ), + StateTable( + attributes: StateAttributes(1), + member_transitions: [], + array_transitions: [], + fallback_state: State(0), + ), + ], +)) diff --git a/crates/rsonpath-lib/tests/snapshots/engine_serialization_snapshots__ron__slice.snap b/crates/rsonpath-lib/tests/snapshots/engine_serialization_snapshots__ron__slice.snap new file mode 100644 index 00000000..212a92ec --- /dev/null +++ b/crates/rsonpath-lib/tests/snapshots/engine_serialization_snapshots__ron__slice.snap @@ -0,0 +1,50 @@ +--- +source: crates/rsonpath-lib/tests/engine_serialization_snapshots.rs +expression: "&engine(\"$..entries[3:5:7]\")?" +snapshot_kind: text +--- +(V1, Automaton( + states: [ + StateTable( + attributes: StateAttributes(2), + member_transitions: [], + array_transitions: [], + fallback_state: State(0), + ), + StateTable( + attributes: StateAttributes(0), + member_transitions: [ + (StringPattern(JsonString( + quoted: "\"entries\"", + )), State(2)), + ], + array_transitions: [], + fallback_state: State(1), + ), + StateTable( + attributes: StateAttributes(56), + member_transitions: [ + (StringPattern(JsonString( + quoted: "\"entries\"", + )), State(2)), + ], + array_transitions: [ + ArrayTransition( + label: Index(JsonUInt(3)), + target: State(3), + ), + ], + fallback_state: State(1), + ), + StateTable( + attributes: StateAttributes(1), + member_transitions: [ + (StringPattern(JsonString( + quoted: "\"entries\"", + )), State(2)), + ], + array_transitions: [], + fallback_state: State(1), + ), + ], +)) diff --git a/crates/rsonpath-syntax/Cargo.toml b/crates/rsonpath-syntax/Cargo.toml index d6508eb2..9a9b87ef 100644 --- a/crates/rsonpath-syntax/Cargo.toml +++ b/crates/rsonpath-syntax/Cargo.toml @@ -27,7 +27,7 @@ unicode-width = "0.2.0" [dev-dependencies] ciborium = { workspace = true, default-features = true } -insta = "1.41.1" +insta = { workspace = true, features = ["ron"] } pretty_assertions = { workspace = true } proptest = { workspace = true } rmp-serde = { workspace = true } diff --git a/crates/rsonpath-syntax/tests/query_serialization_snapshots.rs b/crates/rsonpath-syntax/tests/query_serialization_snapshots.rs new file mode 100644 index 00000000..510624cd --- /dev/null +++ b/crates/rsonpath-syntax/tests/query_serialization_snapshots.rs @@ -0,0 +1,55 @@ +use insta::assert_ron_snapshot; +use rsonpath_syntax::parse; + +mod ron { + use super::*; + use std::error::Error; + + #[test] + fn empty_query() -> Result<(), Box> { + assert_ron_snapshot!(&parse("$")?); + Ok(()) + } + + #[test] + fn readme_query() -> Result<(), Box> { + assert_ron_snapshot!(&parse("$.jsonpath[*]")?); + Ok(()) + } + + #[test] + fn jsonpath_example_query() -> Result<(), Box> { + assert_ron_snapshot!(&parse("$..phoneNumbers[*].number")?); + Ok(()) + } + + #[test] + fn real_life_query() -> Result<(), Box> { + assert_ron_snapshot!(&parse("$.personal.details.contact.information.phones.home")?); + Ok(()) + } + + #[test] + fn slice() -> Result<(), Box> { + assert_ron_snapshot!(&parse("$..entries[3:5:7]")?); + Ok(()) + } + + #[test] + fn multiple_selectors() -> Result<(), Box> { + assert_ron_snapshot!(&parse("$..entries['abc', 4, 7:10:13]")?); + Ok(()) + } + + #[test] + fn filter() -> Result<(), Box> { + assert_ron_snapshot!(&parse("$..user[?@.id == 'value']..entities..url")?); + Ok(()) + } + + #[test] + fn nested_filter() -> Result<(), Box> { + assert_ron_snapshot!(&parse(r#"$.a[?@.b == "abc" && $[*][?@.c > 3.13]]"#)?); + Ok(()) + } +} diff --git a/crates/rsonpath-syntax/tests/snapshots/query_serialization_snapshots__ron__empty_query.snap b/crates/rsonpath-syntax/tests/snapshots/query_serialization_snapshots__ron__empty_query.snap new file mode 100644 index 00000000..e5c574c5 --- /dev/null +++ b/crates/rsonpath-syntax/tests/snapshots/query_serialization_snapshots__ron__empty_query.snap @@ -0,0 +1,8 @@ +--- +source: crates/rsonpath-syntax/tests/query_serialization_snapshots.rs +expression: "&query" +snapshot_kind: text +--- +JsonPathQuery( + segments: [], +) diff --git a/crates/rsonpath-syntax/tests/snapshots/query_serialization_snapshots__ron__jsonpath_example_query.snap b/crates/rsonpath-syntax/tests/snapshots/query_serialization_snapshots__ron__jsonpath_example_query.snap new file mode 100644 index 00000000..ed3a1b11 --- /dev/null +++ b/crates/rsonpath-syntax/tests/snapshots/query_serialization_snapshots__ron__jsonpath_example_query.snap @@ -0,0 +1,28 @@ +--- +source: crates/rsonpath-syntax/tests/query_serialization_snapshots.rs +expression: "&parse(\"$..phoneNumbers[*].number\")?" +snapshot_kind: text +--- +JsonPathQuery( + segments: [ + Descendant(Selectors( + inner: [ + Name(JsonString( + quoted: "\"phoneNumbers\"", + )), + ], + )), + Child(Selectors( + inner: [ + Wildcard, + ], + )), + Child(Selectors( + inner: [ + Name(JsonString( + quoted: "\"number\"", + )), + ], + )), + ], +) diff --git a/crates/rsonpath-syntax/tests/snapshots/query_serialization_snapshots__ron__nested_filter.snap b/crates/rsonpath-syntax/tests/snapshots/query_serialization_snapshots__ron__nested_filter.snap new file mode 100644 index 00000000..b58c31a2 --- /dev/null +++ b/crates/rsonpath-syntax/tests/snapshots/query_serialization_snapshots__ron__nested_filter.snap @@ -0,0 +1,56 @@ +--- +source: crates/rsonpath-syntax/tests/query_serialization_snapshots.rs +expression: "&parse(r#\"$.a[?@.b == \"abc\" && $[*][?@.c > 3.13]]\"#)?" +snapshot_kind: text +--- +JsonPathQuery( + segments: [ + Child(Selectors( + inner: [ + Name(JsonString( + quoted: "\"a\"", + )), + ], + )), + Child(Selectors( + inner: [ + Filter(And(Comparison(ComparisonExpr( + lhs: RelativeSingularQuery(SingularJsonPathQuery( + segments: [ + Name(JsonString( + quoted: "\"b\"", + )), + ], + )), + op: EqualTo, + rhs: Literal(String(JsonString( + quoted: "\"abc\"", + ))), + )), Test(Absolute(JsonPathQuery( + segments: [ + Child(Selectors( + inner: [ + Wildcard, + ], + )), + Child(Selectors( + inner: [ + Filter(Comparison(ComparisonExpr( + lhs: RelativeSingularQuery(SingularJsonPathQuery( + segments: [ + Name(JsonString( + quoted: "\"c\"", + )), + ], + )), + op: GreaterThan, + rhs: Literal(Number(Float(JsonFloat(3.13)))), + ))), + ], + )), + ], + ))))), + ], + )), + ], +) diff --git a/crates/rsonpath-syntax/tests/snapshots/query_serialization_snapshots__ron__readme_query.snap b/crates/rsonpath-syntax/tests/snapshots/query_serialization_snapshots__ron__readme_query.snap new file mode 100644 index 00000000..181d1067 --- /dev/null +++ b/crates/rsonpath-syntax/tests/snapshots/query_serialization_snapshots__ron__readme_query.snap @@ -0,0 +1,21 @@ +--- +source: crates/rsonpath-syntax/tests/query_serialization_snapshots.rs +expression: "&parse(\"$.jsonpath[*]\")?" +snapshot_kind: text +--- +JsonPathQuery( + segments: [ + Child(Selectors( + inner: [ + Name(JsonString( + quoted: "\"jsonpath\"", + )), + ], + )), + Child(Selectors( + inner: [ + Wildcard, + ], + )), + ], +) diff --git a/crates/rsonpath-syntax/tests/snapshots/query_serialization_snapshots__ron__real_life_query.snap b/crates/rsonpath-syntax/tests/snapshots/query_serialization_snapshots__ron__real_life_query.snap new file mode 100644 index 00000000..6fb33382 --- /dev/null +++ b/crates/rsonpath-syntax/tests/snapshots/query_serialization_snapshots__ron__real_life_query.snap @@ -0,0 +1,51 @@ +--- +source: crates/rsonpath-syntax/tests/query_serialization_snapshots.rs +expression: "&parse(\"$.personal.details.contact.information.phones.home\")?" +snapshot_kind: text +--- +JsonPathQuery( + segments: [ + Child(Selectors( + inner: [ + Name(JsonString( + quoted: "\"personal\"", + )), + ], + )), + Child(Selectors( + inner: [ + Name(JsonString( + quoted: "\"details\"", + )), + ], + )), + Child(Selectors( + inner: [ + Name(JsonString( + quoted: "\"contact\"", + )), + ], + )), + Child(Selectors( + inner: [ + Name(JsonString( + quoted: "\"information\"", + )), + ], + )), + Child(Selectors( + inner: [ + Name(JsonString( + quoted: "\"phones\"", + )), + ], + )), + Child(Selectors( + inner: [ + Name(JsonString( + quoted: "\"home\"", + )), + ], + )), + ], +) diff --git a/crates/rsonpath-syntax/tests/snapshots/query_serialization_snapshots__ron__slice.snap b/crates/rsonpath-syntax/tests/snapshots/query_serialization_snapshots__ron__slice.snap new file mode 100644 index 00000000..957c6fe7 --- /dev/null +++ b/crates/rsonpath-syntax/tests/snapshots/query_serialization_snapshots__ron__slice.snap @@ -0,0 +1,47 @@ +--- +source: crates/rsonpath-syntax/tests/query_serialization_snapshots.rs +expression: "&parse(\"$..user[?@.id == 'value']..entities..url\")?" +snapshot_kind: text +--- +JsonPathQuery( + segments: [ + Descendant(Selectors( + inner: [ + Name(JsonString( + quoted: "\"user\"", + )), + ], + )), + Child(Selectors( + inner: [ + Filter(Comparison(ComparisonExpr( + lhs: RelativeSingularQuery(SingularJsonPathQuery( + segments: [ + Name(JsonString( + quoted: "\"id\"", + )), + ], + )), + op: EqualTo, + rhs: Literal(String(JsonString( + quoted: "\"value\"", + ))), + ))), + ], + )), + Descendant(Selectors( + inner: [ + Name(JsonString( + quoted: "\"entities\"", + )), + ], + )), + Descendant(Selectors( + inner: [ + Name(JsonString( + quoted: "\"url\"", + )), + ], + )), + ], +)