-
Notifications
You must be signed in to change notification settings - Fork 24
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
"Array slice with interval of -1" case doesn't match the path $[2:1] #30
Comments
Secondarily, since the consensus is |
Goessner mentions ECMASCRIPT 4 proposal for the array slices syntax; ES4 was abandoned, but the proposal itself can be seen here. In fact, the proposal tells us that it's "strikingly similar" to the one implemented in Python; that allows to use Python as a convenient acceptance testing tool for our own slices implementations:
|
While interesting, you don't really answer the specifics of my question. How is that slice to be interpreted? |
Well, you can consider iterating slice as: starting at "start" index, adding "step" on each iteration until index is outside of range (something close to "for" control structure in many languages). Note that I've said "index", not "start":
You can see that both
Let's follow the steps of the last example:
Now let's look at your exapmple:
Let's follow the steps:
So, back to your question:
The default step is still 1 for |
The name including "interval -1" is a recent one. Happy to clarify and
rename.
Note that following the name documentation, the name of the query is
supposed to describe the selector (and document the selector operates on),
not the intent/outcome of the query. This should help us stay as unbiased
as possible.
What would you suggest?
|
Just a proposal: |
Would you also rename the query currently called "interval 0"? If so, how?
I am trying to aim for some consistency to help clarify (less is more) and
help in grouping similar queries (currently done via alphabetic ordering).
|
I guess you can operate |
And I think it would be good to clearly separate the query description from test data. For example: Query: array slice with negative range and positive step. In this case, you can group similar (not always exactly the same) queries running on different data, thus giving more clear picture of query behavior. |
And I think it would be good to clearly separate the *query description*
from *test data*. For example:
Query: array slice with negative range and positive step.
Data: array containing whole range.
This I wanted to tackle using the "on" phrase structure. Omitting it for
the default scenario and adding it for further cases on different input.
Can you see the relevant paragraph in the naming schema description?
… |
Yep, and that will work, of course. Yet I feel that splitting the description into separate descriptions for query and data:
As I've said, it's just a proposal. On my job I deal a lot with all sorts of unit-like tests and it's always a huge problem to put all the details in standard 3-part (object - pre-condition - behavior). |
Let's separate the two issues. Feel free to raise a PR for the "interval" issue here. For a clearer separation of selector and document (the pair I call query) I also welcome a concrete suggestion as issue or PR. |
@remorhaz thank you for the explanation. Separating the concepts of interval vs step is the key here. |
Does PR #31 match your expectation? |
Yeah. My main source of confusion was the "interval" thing. I didn't understand and was reading it as the step. It's all good. |
Merged. |
Given the title, I would expect the path to be
$[2:1:-1]
(which Manatee.Json will happily return successfully).Is the -1 implied by the fact that the start is greater than the end? If that's the case, then maybe change the title to "Array slice with implied interval of -1".
The text was updated successfully, but these errors were encountered: