-
Notifications
You must be signed in to change notification settings - Fork 11
Add tests of selector that follows another selector. Resolves #96 #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests of selector that follows another selector. Resolves #96 #102
Conversation
tests/filter.json
Outdated
], | ||
"result": [ 1, null ], | ||
"result_paths": [ | ||
"$['a']['x']", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one does not seem right. The root element of the document is an array, so any path must start with $[0]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$[0]
would select the first array element, which is the hash. This is not what is wanted here - the filter selector is supposed to be applied to the array, not the hash.
For comparison, see the other tests within filter.json
.
5 "selector": "$[? @.a]",
31 "selector": "$[?\n@.a]",
57 "selector": "$[?\t@.a]",
83 "selector": "$[?\r@.a]",
...
In every test, the document is an array, and the filter selector is applied directly to the root identifer.
Maybe it's confusing that I only put one element in the array, so there's nothing to show what is not being selected by the filter. Would it help to add another array element?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The root element of the document in this test is an array with a single element:
[
{
"a": { "x": 1, "y": null, "z": "_" }
}
]
therefore anything in the "result_paths" has to start with an array index: $[0]
, but the result paths provided start with $['a']
as if the root element was an object. Does the document have extra square brackets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, you were referring to the result_paths
, which is exactly what your comment is on. I should have seen that.
Yes I agree. I'll correct that and re-test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed an updated version.
I corrected the paths and changed the document for this test, which did not match the selector.
(The { "a": ... } hash should not have been there, only the single value it contains.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "followed by child segment that selects multiple elements" seems off.
It's named that way because when cts.json is built, this name is appended onto the name of the file. Is that the issue? |
Sorry, I didn't mean the name itself. See the comment here: #102 (comment) |
346584e
to
d88c87c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Passes on my implementation. @gregsdennis can you please check on your end? |
Add test slice selector followed by slice selector
Add test filter selector followed by child segment that selects multiple elements
Add test filter selector followed by name selector