Conversation
|
(rust-highfive has picked a reviewer for you, use r? to override) |
|
r? @jyn514 |
|
jyn514
left a comment
There was a problem hiding this comment.
Can you post an example of what the error looks like if a @set command is written incorrectly or an @is command is false?
| // @is - "$.index[*][?(@.name=='l3')].inner.is_crate" false | ||
| // @count - "$.index[*][?(@.name=='l3')].inner.items[*]" 1 | ||
| // @set l3_id = - "$.index[*][?(@.name=='l3')].id" | ||
| // @has - "$.index[*][?(@.name=='l1')].inner.items[*]" $l3_id |
There was a problem hiding this comment.
$ already has a meaning in JSONPath, it means the root. I guess that shouldn't overlap here because you're testing a JSON value, it's not part of the path syntax? What happens if you want to match a string with $ in it?
There was a problem hiding this comment.
$foo -> Variable foo,
"$foo" -> String $foo
Because json can only start with ", {, or [, it is unambiguous
There was a problem hiding this comment.
But this should be documented
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
test // @set var = failing.json "foo.bar.baz"
// @is failing.json root "not_root"the relavent output It's the same as anything, as currently the only way we report errors is returning (This is not tecnicly true) as some errors are panics, eg variable reassignment, lookup of variable not in hashmap |
|
@rustbot modify labels: -S-waiting-on-author +S-waiting-on-review |
|
@rustbot modify labels: -S-waiting-on-author +S-waiting-on-review |
|
@bors r+ Thanks! |
|
📌 Commit 4c949a4 has been approved by |
|
I know this was already approved, but +1 from me. I appreciate the ability to check both 'any match' and 'exactly 1 matches' easily |
…s, r=jyn514 Jsondocck improvements Adds 2 new commands, ``@is`` and ``@set`.` ``@is`` works like ``@has`,` except instead of checking if any value matches, it checks that there is exactly one value, and it matches. This allows more precise testing. ``@set`` gets a value, and saves it to be used later. This makes it possible to check that an item appears in the correct module. Once this lands, the rest of the test suite can be upgraded to use these. cc `@CraftSpider` `@rustbot` modify labels: +T-rustdoc +A-rustdoc-json +A-testsuite
Rollup of 10 pull requests Successful merges: - rust-lang#81629 (Point out implicit deref coercions in borrow) - rust-lang#82113 (Improve non_fmt_panic lint.) - rust-lang#82258 (Implement -Z hir-stats for nested foreign items) - rust-lang#82296 (Support `pub` on `macro_rules`) - rust-lang#82297 (Consider auto derefs before warning about write only fields) - rust-lang#82305 (Remove many RefCells from DocContext) - rust-lang#82308 (Lower condition of `if` expression before it's "then" block) - rust-lang#82311 (Jsondocck improvements) - rust-lang#82362 (Fix mir-cfg dumps) - rust-lang#82391 (disable atomic_max/min tests in Miri) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Adds 2 new commands,
@isand@set.@isworks like@has, except instead of checking if any value matches, it checks that there is exactly one value, and it matches. This allows more precise testing.@setgets a value, and saves it to be used later. This makes it possible to check that an item appears in the correct module.Once this lands, the rest of the test suite can be upgraded to use these.
cc @CraftSpider
@rustbot modify labels: +T-rustdoc +A-rustdoc-json +A-testsuite