-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Labels
0.12.1enhancementNew feature or requestNew feature or requestprio 2ready for verifyingsuccessfully tested
Milestone
Description
I wanted to know what happens if I use multiple '+' and '-' operators in indices
In pure Python it's like this:
listvalues = [1,2,3]
element = listvalues[1] # -> result: 2
element = listvalues[+1] # -> result: 2
element = listvalues[+++1] # -> result: 2
element = listvalues[-1] # -> result: 3
element = listvalues[--1] # -> result: 2
element = listvalues[---1] # -> result: 3
element = listvalues[+-1] # -> result: 3
element = listvalues[-+1] # -> result: 3
element = listvalues[+-+1] # -> result: 3
The same in JsonPreprocessor (with hard coded index and with parameter as index)
"index" : 1,
"listvalues" : [1, 2, 3],
"param" : ${listvalues}[+1] // -> result: 2
"param" : ${listvalues}[+${index}] // -> result: '[1, 2, 3][+1]'
"param" : ${listvalues}[+++1] // -> result: '[1, 2, 3][+++1]'
"param" : ${listvalues}[+++${index}] // -> result: '[1, 2, 3][+++1]'
"param" : ${listvalues}[-1] // -> result: Error: 'Slicing is not supported!
"param" : ${listvalues}[-${index}] // -> result: Error: 'Slicing is not supported!
"param" : ${listvalues}[--1] // -> result: Error: 'invalid literal for int() with base 10: '--1''!
"param" : ${listvalues}[--${index}] // -> result: Error: 'invalid literal for int() with base 10: '--1''!
"param" : ${listvalues}[---1] // -> result: Error: 'invalid literal for int() with base 10: '---1''!
"param" : ${listvalues}[---${index}] // -> result: Error: 'invalid literal for int() with base 10: '---1''!
"param" : ${listvalues}[+-1] // -> result: '[1, 2, 3][+-1]'
"param" : ${listvalues}[+-${index}] // -> result: '[1, 2, 3][+-1]'
"param" : ${listvalues}[-+1] // -> result: '[1, 2, 3][-+1]'
"param" : ${listvalues}[-+${index}] // -> result: '[1, 2, 3][-+1]'
"param" : ${listvalues}[+-+1] // -> result: '[1, 2, 3][+-+1]'
"param" : ${listvalues}[+-+${index}] // -> result: '[1, 2, 3][+-+1]'
In my opinion it's not a must for the JsonPreprocessor to react in the same way as Python in these cases. But in a lot of cases the index expressions are not resolved completely.
This should be fixed.
Suggestion:
- Remove all '
+' from expressions inside[]. They must have no effect. - Either more than one '
-' is handled as invalid expression or simply consider only the first '-' on the left hand side of the index (ignoring all further ones). - Or do it exactly like Python:
3.1--1is+1(- * - = +)
3.2---1is-1(- * - * - = -)
Metadata
Metadata
Assignees
Labels
0.12.1enhancementNew feature or requestNew feature or requestprio 2ready for verifyingsuccessfully tested
Projects
Status
Done