mirror of
https://github.com/fluencelabs/jsonpath
synced 2025-04-24 17:02:16 +00:00
fix return_type_for_child_object_not_matched
This commit is contained in:
parent
d855c17899
commit
218321a4bd
12
.idea/runConfigurations/filter.xml
generated
12
.idea/runConfigurations/filter.xml
generated
@ -1,12 +0,0 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="filter" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
|
|
||||||
<option name="channel" value="DEFAULT" />
|
|
||||||
<option name="command" value="test --package jsonpath_lib --test filter """ />
|
|
||||||
<option name="allFeatures" value="false" />
|
|
||||||
<option name="nocapture" value="false" />
|
|
||||||
<option name="backtrace" value="SHORT" />
|
|
||||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
|
||||||
<envs />
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
12
.idea/runConfigurations/lib.xml
generated
12
.idea/runConfigurations/lib.xml
generated
@ -1,12 +0,0 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="lib" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
|
|
||||||
<option name="channel" value="DEFAULT" />
|
|
||||||
<option name="command" value="test --package jsonpath_lib --test lib """ />
|
|
||||||
<option name="allFeatures" value="false" />
|
|
||||||
<option name="nocapture" value="false" />
|
|
||||||
<option name="backtrace" value="SHORT" />
|
|
||||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
|
||||||
<envs />
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
12
.idea/runConfigurations/mutable.xml
generated
12
.idea/runConfigurations/mutable.xml
generated
@ -1,12 +0,0 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="mutable" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
|
|
||||||
<option name="channel" value="DEFAULT" />
|
|
||||||
<option name="command" value="test --package jsonpath_lib --test mutable """ />
|
|
||||||
<option name="allFeatures" value="false" />
|
|
||||||
<option name="nocapture" value="false" />
|
|
||||||
<option name="backtrace" value="SHORT" />
|
|
||||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
|
||||||
<envs />
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
12
.idea/runConfigurations/readme.xml
generated
12
.idea/runConfigurations/readme.xml
generated
@ -1,12 +0,0 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="readme" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
|
|
||||||
<option name="channel" value="DEFAULT" />
|
|
||||||
<option name="command" value="test --package jsonpath_lib --test readme """ />
|
|
||||||
<option name="allFeatures" value="false" />
|
|
||||||
<option name="nocapture" value="false" />
|
|
||||||
<option name="backtrace" value="SHORT" />
|
|
||||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
|
||||||
<envs />
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
10
.travis.yml
10
.travis.yml
@ -24,15 +24,9 @@ matrix:
|
|||||||
before_script:
|
before_script:
|
||||||
- rustup component add clippy
|
- rustup component add clippy
|
||||||
script:
|
script:
|
||||||
- cargo clean
|
- ./clippy.sh
|
||||||
- cargo clippy -- -D warnings
|
|
||||||
- cargo build --verbose --all
|
|
||||||
- cargo clippy --all-targets --all-features -- -D warnings -A clippy::cognitive_complexity
|
|
||||||
- cargo test --verbose --all
|
|
||||||
- cd wasm && cargo clippy -- -D warnings -A clippy::suspicious_else_formatting
|
|
||||||
- cd ../../
|
|
||||||
after_success: |
|
after_success: |
|
||||||
cargo tarpaulin --exclude-files nodejs wasm parser/mod.rs --out Xml
|
cargo tarpaulin --exclude-files wasm parser/mod.rs --out Xml
|
||||||
bash <(curl -s https://codecov.io/bash)
|
bash <(curl -s https://codecov.io/bash)
|
||||||
- rust: stable
|
- rust: stable
|
||||||
os: osx
|
os: osx
|
||||||
|
11
clippy.sh
Executable file
11
clippy.sh
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cargo clean
|
||||||
|
cargo clippy -- -D warnings
|
||||||
|
cargo build --verbose --all
|
||||||
|
cargo clippy --all-targets --all-features -- -D warnings -A clippy::cognitive_complexity
|
||||||
|
cargo test --verbose --all
|
||||||
|
cd wasm && cargo clippy -- -D warnings -A clippy::suspicious_else_formatting
|
||||||
|
cd ../
|
@ -710,17 +710,37 @@ impl<'a, 'b> Selector<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn next_from_current_with_num(&mut self, index: f64) {
|
fn next_from_current_with_num(&mut self, index: f64) {
|
||||||
|
fn _collect<'a>(tmp: &mut Vec<&'a Value>, vec: &'a [Value], index: f64) {
|
||||||
|
let index = abs_index(index as isize, vec.len());
|
||||||
|
if let Some(v) = vec.get(index) {
|
||||||
|
tmp.push(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(current) = self.current.take() {
|
if let Some(current) = self.current.take() {
|
||||||
let mut tmp = Vec::new();
|
let mut tmp = Vec::new();
|
||||||
for c in current {
|
for c in current {
|
||||||
if let Value::Array(vec) = c {
|
match c {
|
||||||
let index = abs_index(index as isize, vec.len());
|
Value::Object(map) => {
|
||||||
if let Some(v) = c.get(index) {
|
for k in map.keys() {
|
||||||
tmp.push(v);
|
if let Some(Value::Array(vec)) = map.get(k) {
|
||||||
|
_collect(&mut tmp, vec, index);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Value::Array(vec) => {
|
||||||
|
_collect(&mut tmp, vec, index);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.current = Some(tmp);
|
|
||||||
|
if tmp.is_empty() {
|
||||||
|
self.terms.pop();
|
||||||
|
self.current = Some(vec![&Value::Null]);
|
||||||
|
} else {
|
||||||
|
self.current = Some(tmp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!(
|
debug!(
|
||||||
@ -729,27 +749,6 @@ impl<'a, 'b> Selector<'a, 'b> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn next_from_current_with_str(&mut self, keys: &[String]) {
|
|
||||||
if let Some(current) = self.current.take() {
|
|
||||||
let mut tmp = Vec::new();
|
|
||||||
for c in current {
|
|
||||||
if let Value::Object(map) = c {
|
|
||||||
for key in keys {
|
|
||||||
if let Some(v) = map.get(key) {
|
|
||||||
tmp.push(v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.current = Some(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
debug!(
|
|
||||||
"next_from_current_with_str : {:?}, {:?}",
|
|
||||||
keys, self.current
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn next_all_from_current(&mut self) {
|
fn next_all_from_current(&mut self) {
|
||||||
if let Some(current) = self.current.take() {
|
if let Some(current) = self.current.take() {
|
||||||
let mut tmp = Vec::new();
|
let mut tmp = Vec::new();
|
||||||
@ -774,6 +773,32 @@ impl<'a, 'b> Selector<'a, 'b> {
|
|||||||
debug!("next_all_from_current : {:?}", self.current);
|
debug!("next_all_from_current : {:?}", self.current);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn next_from_current_with_str(&mut self, keys: &[String]) {
|
||||||
|
if let Some(current) = self.current.take() {
|
||||||
|
let mut tmp = Vec::new();
|
||||||
|
for c in current {
|
||||||
|
if let Value::Object(map) = c {
|
||||||
|
for key in keys {
|
||||||
|
if let Some(v) = map.get(key) {
|
||||||
|
tmp.push(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if tmp.is_empty() {
|
||||||
|
self.current = Some(vec![&Value::Null]);
|
||||||
|
} else {
|
||||||
|
self.current = Some(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
debug!(
|
||||||
|
"next_from_current_with_str : {:?}, {:?}",
|
||||||
|
keys, self.current
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
fn all_from_current(&mut self) {
|
fn all_from_current(&mut self) {
|
||||||
if let Some(current) = self.current.take() {
|
if let Some(current) = self.current.take() {
|
||||||
let mut tmp = Vec::new();
|
let mut tmp = Vec::new();
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
|
|
||||||
|
use serde_json::Value;
|
||||||
|
|
||||||
use common::{read_json, select_and_then_compare, setup};
|
use common::{read_json, select_and_then_compare, setup};
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
@ -53,14 +55,14 @@ fn return_type_for_child_object_matched() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[test]
|
#[test]
|
||||||
fn return_type_for_child_object_not_matched() {
|
fn return_type_for_child_object_not_matched() {
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
select_and_then_compare(
|
select_and_then_compare(
|
||||||
"$.school[?(@.friends[10])]",
|
"$.school[?(@.friends[10])]",
|
||||||
read_json("./benchmark/data_obj.json"),
|
read_json("./benchmark/data_obj.json"),
|
||||||
json!([]),
|
json!([Value::Null]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user