From ca4cf235125c7aa821e8a3f3ac6b9c1cd2a22ab9 Mon Sep 17 00:00:00 2001 From: killeroonie Date: Thu, 14 Aug 2025 15:52:53 -0700 Subject: [PATCH 1/4] Refactored test_lex.json to use test_lex.json for test case data. --- tests/test_lex.json | 1986 +++++++++++++++++++++++++++++++++++++++++++ tests/test_lex.py | 1782 +------------------------------------- 2 files changed, 2025 insertions(+), 1743 deletions(-) create mode 100644 tests/test_lex.json diff --git a/tests/test_lex.json b/tests/test_lex.json new file mode 100644 index 0000000..171f8e8 --- /dev/null +++ b/tests/test_lex.json @@ -0,0 +1,1986 @@ +{ + "description" : "Test cases for test_lex unit tests.", + "tests" : [ { + "description" : "just root", + "path" : "$", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$" + } ] + }, { + "description" : "just pseudo root", + "path" : "^", + "want" : [ { + "kind" : "TOKEN_PSEUDO_ROOT", + "value" : "^", + "index" : 0, + "path" : "^" + } ] + }, { + "description" : "root dot property", + "path" : "$.some.thing", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$.some.thing" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "some", + "index" : 2, + "path" : "$.some.thing" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "thing", + "index" : 7, + "path" : "$.some.thing" + } ] + }, { + "description" : "pseudo root dot property", + "path" : "^.some.thing", + "want" : [ { + "kind" : "TOKEN_PSEUDO_ROOT", + "value" : "^", + "index" : 0, + "path" : "^.some.thing" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "some", + "index" : 2, + "path" : "^.some.thing" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "thing", + "index" : 7, + "path" : "^.some.thing" + } ] + }, { + "description" : "root bracket property", + "path" : "$[some][thing]", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$[some][thing]" + }, { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 1, + "path" : "$[some][thing]" + }, { + "kind" : "TOKEN_BARE_PROPERTY", + "value" : "some", + "index" : 2, + "path" : "$[some][thing]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 6, + "path" : "$[some][thing]" + }, { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 7, + "path" : "$[some][thing]" + }, { + "kind" : "TOKEN_BARE_PROPERTY", + "value" : "thing", + "index" : 8, + "path" : "$[some][thing]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 13, + "path" : "$[some][thing]" + } ] + }, { + "description" : "root double quoted property", + "path" : "$[\"some\"]", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$[\"some\"]" + }, { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 1, + "path" : "$[\"some\"]" + }, { + "kind" : "TOKEN_DOUBLE_QUOTE_STRING", + "value" : "some", + "index" : 3, + "path" : "$[\"some\"]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 8, + "path" : "$[\"some\"]" + } ] + }, { + "description" : "root single quoted property", + "path" : "$['some']", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$['some']" + }, { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 1, + "path" : "$['some']" + }, { + "kind" : "TOKEN_SINGLE_QUOTE_STRING", + "value" : "some", + "index" : 3, + "path" : "$['some']" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 8, + "path" : "$['some']" + } ] + }, { + "description" : "root dot bracket property", + "path" : "$.[some][thing]", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$.[some][thing]" + }, { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 2, + "path" : "$.[some][thing]" + }, { + "kind" : "TOKEN_BARE_PROPERTY", + "value" : "some", + "index" : 3, + "path" : "$.[some][thing]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 7, + "path" : "$.[some][thing]" + }, { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 8, + "path" : "$.[some][thing]" + }, { + "kind" : "TOKEN_BARE_PROPERTY", + "value" : "thing", + "index" : 9, + "path" : "$.[some][thing]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 14, + "path" : "$.[some][thing]" + } ] + }, { + "description" : "root bracket index", + "path" : "$[1]", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$[1]" + }, { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 1, + "path" : "$[1]" + }, { + "kind" : "TOKEN_INT", + "value" : "1", + "index" : 2, + "path" : "$[1]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 3, + "path" : "$[1]" + } ] + }, { + "description" : "root dot bracket index", + "path" : "$.[1]", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$.[1]" + }, { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 2, + "path" : "$.[1]" + }, { + "kind" : "TOKEN_INT", + "value" : "1", + "index" : 3, + "path" : "$.[1]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 4, + "path" : "$.[1]" + } ] + }, { + "description" : "empty slice", + "path" : "[:]", + "want" : [ { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 0, + "path" : "[:]" + }, { + "kind" : "TOKEN_SLICE_START", + "value" : "", + "index" : 1, + "path" : "[:]" + }, { + "kind" : "TOKEN_SLICE_STOP", + "value" : "", + "index" : 2, + "path" : "[:]" + }, { + "kind" : "TOKEN_SLICE_STEP", + "value" : "", + "index" : -1, + "path" : "[:]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 2, + "path" : "[:]" + } ] + }, { + "description" : "empty slice empty step", + "path" : "[::]", + "want" : [ { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 0, + "path" : "[::]" + }, { + "kind" : "TOKEN_SLICE_START", + "value" : "", + "index" : 1, + "path" : "[::]" + }, { + "kind" : "TOKEN_SLICE_STOP", + "value" : "", + "index" : 2, + "path" : "[::]" + }, { + "kind" : "TOKEN_SLICE_STEP", + "value" : "", + "index" : 3, + "path" : "[::]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 3, + "path" : "[::]" + } ] + }, { + "description" : "slice empty stop", + "path" : "[1:]", + "want" : [ { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 0, + "path" : "[1:]" + }, { + "kind" : "TOKEN_SLICE_START", + "value" : "1", + "index" : 1, + "path" : "[1:]" + }, { + "kind" : "TOKEN_SLICE_STOP", + "value" : "", + "index" : 3, + "path" : "[1:]" + }, { + "kind" : "TOKEN_SLICE_STEP", + "value" : "", + "index" : -1, + "path" : "[1:]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 3, + "path" : "[1:]" + } ] + }, { + "description" : "slice empty start", + "path" : "[:-1]", + "want" : [ { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 0, + "path" : "[:-1]" + }, { + "kind" : "TOKEN_SLICE_START", + "value" : "", + "index" : 1, + "path" : "[:-1]" + }, { + "kind" : "TOKEN_SLICE_STOP", + "value" : "-1", + "index" : 2, + "path" : "[:-1]" + }, { + "kind" : "TOKEN_SLICE_STEP", + "value" : "", + "index" : -1, + "path" : "[:-1]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 4, + "path" : "[:-1]" + } ] + }, { + "description" : "slice start and stop", + "path" : "[1:7]", + "want" : [ { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 0, + "path" : "[1:7]" + }, { + "kind" : "TOKEN_SLICE_START", + "value" : "1", + "index" : 1, + "path" : "[1:7]" + }, { + "kind" : "TOKEN_SLICE_STOP", + "value" : "7", + "index" : 3, + "path" : "[1:7]" + }, { + "kind" : "TOKEN_SLICE_STEP", + "value" : "", + "index" : -1, + "path" : "[1:7]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 4, + "path" : "[1:7]" + } ] + }, { + "description" : "slice start, stop and step", + "path" : "[1:7:2]", + "want" : [ { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 0, + "path" : "[1:7:2]" + }, { + "kind" : "TOKEN_SLICE_START", + "value" : "1", + "index" : 1, + "path" : "[1:7:2]" + }, { + "kind" : "TOKEN_SLICE_STOP", + "value" : "7", + "index" : 3, + "path" : "[1:7:2]" + }, { + "kind" : "TOKEN_SLICE_STEP", + "value" : "2", + "index" : 5, + "path" : "[1:7:2]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 6, + "path" : "[1:7:2]" + } ] + }, { + "description" : "root dot wild", + "path" : "$.*", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$.*" + }, { + "kind" : "TOKEN_WILD", + "value" : "*", + "index" : 2, + "path" : "$.*" + } ] + }, { + "description" : "root bracket wild", + "path" : "$[*]", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$[*]" + }, { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 1, + "path" : "$[*]" + }, { + "kind" : "TOKEN_WILD", + "value" : "*", + "index" : 2, + "path" : "$[*]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 3, + "path" : "$[*]" + } ] + }, { + "description" : "root dot bracket wild", + "path" : "$.[*]", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$.[*]" + }, { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 2, + "path" : "$.[*]" + }, { + "kind" : "TOKEN_WILD", + "value" : "*", + "index" : 3, + "path" : "$.[*]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 4, + "path" : "$.[*]" + } ] + }, { + "description" : "root descend", + "path" : "$..", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$.." + }, { + "kind" : "TOKEN_DDOT", + "value" : "..", + "index" : 1, + "path" : "$.." + } ] + }, { + "description" : "root descend property", + "path" : "$..thing", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$..thing" + }, { + "kind" : "TOKEN_DDOT", + "value" : "..", + "index" : 1, + "path" : "$..thing" + }, { + "kind" : "TOKEN_BARE_PROPERTY", + "value" : "thing", + "index" : 3, + "path" : "$..thing" + } ] + }, { + "description" : "root descend dot property", + "path" : "$...thing", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$...thing" + }, { + "kind" : "TOKEN_DDOT", + "value" : "..", + "index" : 1, + "path" : "$...thing" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "thing", + "index" : 4, + "path" : "$...thing" + } ] + }, { + "description" : "root selector list of indices", + "path" : "$[1,4,5]", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$[1,4,5]" + }, { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 1, + "path" : "$[1,4,5]" + }, { + "kind" : "TOKEN_INT", + "value" : "1", + "index" : 2, + "path" : "$[1,4,5]" + }, { + "kind" : "TOKEN_COMMA", + "value" : ",", + "index" : 3, + "path" : "$[1,4,5]" + }, { + "kind" : "TOKEN_INT", + "value" : "4", + "index" : 4, + "path" : "$[1,4,5]" + }, { + "kind" : "TOKEN_COMMA", + "value" : ",", + "index" : 5, + "path" : "$[1,4,5]" + }, { + "kind" : "TOKEN_INT", + "value" : "5", + "index" : 6, + "path" : "$[1,4,5]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 7, + "path" : "$[1,4,5]" + } ] + }, { + "description" : "root selector list with a slice", + "path" : "$[1,4:9]", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$[1,4:9]" + }, { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 1, + "path" : "$[1,4:9]" + }, { + "kind" : "TOKEN_INT", + "value" : "1", + "index" : 2, + "path" : "$[1,4:9]" + }, { + "kind" : "TOKEN_COMMA", + "value" : ",", + "index" : 3, + "path" : "$[1,4:9]" + }, { + "kind" : "TOKEN_SLICE_START", + "value" : "4", + "index" : 4, + "path" : "$[1,4:9]" + }, { + "kind" : "TOKEN_SLICE_STOP", + "value" : "9", + "index" : 6, + "path" : "$[1,4:9]" + }, { + "kind" : "TOKEN_SLICE_STEP", + "value" : "", + "index" : -1, + "path" : "$[1,4:9]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 7, + "path" : "$[1,4:9]" + } ] + }, { + "description" : "root selector list of properties", + "path" : "$[some,thing]", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$[some,thing]" + }, { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 1, + "path" : "$[some,thing]" + }, { + "kind" : "TOKEN_BARE_PROPERTY", + "value" : "some", + "index" : 2, + "path" : "$[some,thing]" + }, { + "kind" : "TOKEN_COMMA", + "value" : ",", + "index" : 6, + "path" : "$[some,thing]" + }, { + "kind" : "TOKEN_BARE_PROPERTY", + "value" : "thing", + "index" : 7, + "path" : "$[some,thing]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 12, + "path" : "$[some,thing]" + } ] + }, { + "description" : "root dot filter on self dot property", + "path" : "$.[?(@.some)]", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$.[?(@.some)]" + }, { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 2, + "path" : "$.[?(@.some)]" + }, { + "kind" : "TOKEN_FILTER", + "value" : "?", + "index" : 3, + "path" : "$.[?(@.some)]" + }, { + "kind" : "TOKEN_LPAREN", + "value" : "(", + "index" : 4, + "path" : "$.[?(@.some)]" + }, { + "kind" : "TOKEN_SELF", + "value" : "@", + "index" : 5, + "path" : "$.[?(@.some)]" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "some", + "index" : 7, + "path" : "$.[?(@.some)]" + }, { + "kind" : "TOKEN_RPAREN", + "value" : ")", + "index" : 11, + "path" : "$.[?(@.some)]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 12, + "path" : "$.[?(@.some)]" + } ] + }, { + "description" : "root dot filter on root dot property", + "path" : "$.[?($.some)]", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$.[?($.some)]" + }, { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 2, + "path" : "$.[?($.some)]" + }, { + "kind" : "TOKEN_FILTER", + "value" : "?", + "index" : 3, + "path" : "$.[?($.some)]" + }, { + "kind" : "TOKEN_LPAREN", + "value" : "(", + "index" : 4, + "path" : "$.[?($.some)]" + }, { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 5, + "path" : "$.[?($.some)]" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "some", + "index" : 7, + "path" : "$.[?($.some)]" + }, { + "kind" : "TOKEN_RPAREN", + "value" : ")", + "index" : 11, + "path" : "$.[?($.some)]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 12, + "path" : "$.[?($.some)]" + } ] + }, { + "description" : "root dot filter on self index", + "path" : "$.[?(@[1])]", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$.[?(@[1])]" + }, { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 2, + "path" : "$.[?(@[1])]" + }, { + "kind" : "TOKEN_FILTER", + "value" : "?", + "index" : 3, + "path" : "$.[?(@[1])]" + }, { + "kind" : "TOKEN_LPAREN", + "value" : "(", + "index" : 4, + "path" : "$.[?(@[1])]" + }, { + "kind" : "TOKEN_SELF", + "value" : "@", + "index" : 5, + "path" : "$.[?(@[1])]" + }, { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 6, + "path" : "$.[?(@[1])]" + }, { + "kind" : "TOKEN_INT", + "value" : "1", + "index" : 7, + "path" : "$.[?(@[1])]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 8, + "path" : "$.[?(@[1])]" + }, { + "kind" : "TOKEN_RPAREN", + "value" : ")", + "index" : 9, + "path" : "$.[?(@[1])]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 10, + "path" : "$.[?(@[1])]" + } ] + }, { + "description" : "filter self dot property equality with float", + "path" : "[?(@.some == 1.1)]", + "want" : [ { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 0, + "path" : "[?(@.some == 1.1)]" + }, { + "kind" : "TOKEN_FILTER", + "value" : "?", + "index" : 1, + "path" : "[?(@.some == 1.1)]" + }, { + "kind" : "TOKEN_LPAREN", + "value" : "(", + "index" : 2, + "path" : "[?(@.some == 1.1)]" + }, { + "kind" : "TOKEN_SELF", + "value" : "@", + "index" : 3, + "path" : "[?(@.some == 1.1)]" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "some", + "index" : 5, + "path" : "[?(@.some == 1.1)]" + }, { + "kind" : "TOKEN_EQ", + "value" : "==", + "index" : 10, + "path" : "[?(@.some == 1.1)]" + }, { + "kind" : "TOKEN_FLOAT", + "value" : "1.1", + "index" : 13, + "path" : "[?(@.some == 1.1)]" + }, { + "kind" : "TOKEN_RPAREN", + "value" : ")", + "index" : 16, + "path" : "[?(@.some == 1.1)]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 17, + "path" : "[?(@.some == 1.1)]" + } ] + }, { + "description" : "filter self dot property equality with float in scientific notation", + "path" : "[?(@.some == 1.1e10)]", + "want" : [ { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 0, + "path" : "[?(@.some == 1.1e10)]" + }, { + "kind" : "TOKEN_FILTER", + "value" : "?", + "index" : 1, + "path" : "[?(@.some == 1.1e10)]" + }, { + "kind" : "TOKEN_LPAREN", + "value" : "(", + "index" : 2, + "path" : "[?(@.some == 1.1e10)]" + }, { + "kind" : "TOKEN_SELF", + "value" : "@", + "index" : 3, + "path" : "[?(@.some == 1.1e10)]" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "some", + "index" : 5, + "path" : "[?(@.some == 1.1e10)]" + }, { + "kind" : "TOKEN_EQ", + "value" : "==", + "index" : 10, + "path" : "[?(@.some == 1.1e10)]" + }, { + "kind" : "TOKEN_FLOAT", + "value" : "1.1e10", + "index" : 13, + "path" : "[?(@.some == 1.1e10)]" + }, { + "kind" : "TOKEN_RPAREN", + "value" : ")", + "index" : 19, + "path" : "[?(@.some == 1.1e10)]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 20, + "path" : "[?(@.some == 1.1e10)]" + } ] + }, { + "description" : "filter self index equality with float", + "path" : "[?(@[1] == 1.1)]", + "want" : [ { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 0, + "path" : "[?(@[1] == 1.1)]" + }, { + "kind" : "TOKEN_FILTER", + "value" : "?", + "index" : 1, + "path" : "[?(@[1] == 1.1)]" + }, { + "kind" : "TOKEN_LPAREN", + "value" : "(", + "index" : 2, + "path" : "[?(@[1] == 1.1)]" + }, { + "kind" : "TOKEN_SELF", + "value" : "@", + "index" : 3, + "path" : "[?(@[1] == 1.1)]" + }, { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 4, + "path" : "[?(@[1] == 1.1)]" + }, { + "kind" : "TOKEN_INT", + "value" : "1", + "index" : 5, + "path" : "[?(@[1] == 1.1)]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 6, + "path" : "[?(@[1] == 1.1)]" + }, { + "kind" : "TOKEN_EQ", + "value" : "==", + "index" : 8, + "path" : "[?(@[1] == 1.1)]" + }, { + "kind" : "TOKEN_FLOAT", + "value" : "1.1", + "index" : 11, + "path" : "[?(@[1] == 1.1)]" + }, { + "kind" : "TOKEN_RPAREN", + "value" : ")", + "index" : 14, + "path" : "[?(@[1] == 1.1)]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 15, + "path" : "[?(@[1] == 1.1)]" + } ] + }, { + "description" : "filter self dot property equality with int", + "path" : "[?(@.some == 1)]", + "want" : [ { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 0, + "path" : "[?(@.some == 1)]" + }, { + "kind" : "TOKEN_FILTER", + "value" : "?", + "index" : 1, + "path" : "[?(@.some == 1)]" + }, { + "kind" : "TOKEN_LPAREN", + "value" : "(", + "index" : 2, + "path" : "[?(@.some == 1)]" + }, { + "kind" : "TOKEN_SELF", + "value" : "@", + "index" : 3, + "path" : "[?(@.some == 1)]" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "some", + "index" : 5, + "path" : "[?(@.some == 1)]" + }, { + "kind" : "TOKEN_EQ", + "value" : "==", + "index" : 10, + "path" : "[?(@.some == 1)]" + }, { + "kind" : "TOKEN_INT", + "value" : "1", + "index" : 13, + "path" : "[?(@.some == 1)]" + }, { + "kind" : "TOKEN_RPAREN", + "value" : ")", + "index" : 14, + "path" : "[?(@.some == 1)]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 15, + "path" : "[?(@.some == 1)]" + } ] + }, { + "description" : "filter self dot property equality with int in scientific notation", + "path" : "[?(@.some == 1e10)]", + "want" : [ { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 0, + "path" : "[?(@.some == 1e10)]" + }, { + "kind" : "TOKEN_FILTER", + "value" : "?", + "index" : 1, + "path" : "[?(@.some == 1e10)]" + }, { + "kind" : "TOKEN_LPAREN", + "value" : "(", + "index" : 2, + "path" : "[?(@.some == 1e10)]" + }, { + "kind" : "TOKEN_SELF", + "value" : "@", + "index" : 3, + "path" : "[?(@.some == 1e10)]" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "some", + "index" : 5, + "path" : "[?(@.some == 1e10)]" + }, { + "kind" : "TOKEN_EQ", + "value" : "==", + "index" : 10, + "path" : "[?(@.some == 1e10)]" + }, { + "kind" : "TOKEN_INT", + "value" : "1e10", + "index" : 13, + "path" : "[?(@.some == 1e10)]" + }, { + "kind" : "TOKEN_RPAREN", + "value" : ")", + "index" : 17, + "path" : "[?(@.some == 1e10)]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 18, + "path" : "[?(@.some == 1e10)]" + } ] + }, { + "description" : "filter self dot property regex", + "path" : "[?(@.some =~ /foo|bar/i)]", + "want" : [ { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 0, + "path" : "[?(@.some =~ /foo|bar/i)]" + }, { + "kind" : "TOKEN_FILTER", + "value" : "?", + "index" : 1, + "path" : "[?(@.some =~ /foo|bar/i)]" + }, { + "kind" : "TOKEN_LPAREN", + "value" : "(", + "index" : 2, + "path" : "[?(@.some =~ /foo|bar/i)]" + }, { + "kind" : "TOKEN_SELF", + "value" : "@", + "index" : 3, + "path" : "[?(@.some =~ /foo|bar/i)]" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "some", + "index" : 5, + "path" : "[?(@.some =~ /foo|bar/i)]" + }, { + "kind" : "TOKEN_RE", + "value" : "=~", + "index" : 10, + "path" : "[?(@.some =~ /foo|bar/i)]" + }, { + "kind" : "TOKEN_RE_PATTERN", + "value" : "foo|bar", + "index" : 14, + "path" : "[?(@.some =~ /foo|bar/i)]" + }, { + "kind" : "TOKEN_RE_FLAGS", + "value" : "i", + "index" : 22, + "path" : "[?(@.some =~ /foo|bar/i)]" + }, { + "kind" : "TOKEN_RPAREN", + "value" : ")", + "index" : 23, + "path" : "[?(@.some =~ /foo|bar/i)]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 24, + "path" : "[?(@.some =~ /foo|bar/i)]" + } ] + }, { + "description" : "union of two paths", + "path" : "$.some | $.thing", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$.some | $.thing" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "some", + "index" : 2, + "path" : "$.some | $.thing" + }, { + "kind" : "TOKEN_UNION", + "value" : "|", + "index" : 7, + "path" : "$.some | $.thing" + }, { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 9, + "path" : "$.some | $.thing" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "thing", + "index" : 11, + "path" : "$.some | $.thing" + } ] + }, { + "description" : "union of three paths", + "path" : "$.some | $.thing | $.other", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$.some | $.thing | $.other" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "some", + "index" : 2, + "path" : "$.some | $.thing | $.other" + }, { + "kind" : "TOKEN_UNION", + "value" : "|", + "index" : 7, + "path" : "$.some | $.thing | $.other" + }, { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 9, + "path" : "$.some | $.thing | $.other" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "thing", + "index" : 11, + "path" : "$.some | $.thing | $.other" + }, { + "kind" : "TOKEN_UNION", + "value" : "|", + "index" : 17, + "path" : "$.some | $.thing | $.other" + }, { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 19, + "path" : "$.some | $.thing | $.other" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "other", + "index" : 21, + "path" : "$.some | $.thing | $.other" + } ] + }, { + "description" : "intersection two paths", + "path" : "$.some & $.thing", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$.some & $.thing" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "some", + "index" : 2, + "path" : "$.some & $.thing" + }, { + "kind" : "TOKEN_INTERSECTION", + "value" : "&", + "index" : 7, + "path" : "$.some & $.thing" + }, { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 9, + "path" : "$.some & $.thing" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "thing", + "index" : 11, + "path" : "$.some & $.thing" + } ] + }, { + "description" : "filter expression with logical and", + "path" : "[?(@.some > 1 and @.some < 5)]", + "want" : [ { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 0, + "path" : "[?(@.some > 1 and @.some < 5)]" + }, { + "kind" : "TOKEN_FILTER", + "value" : "?", + "index" : 1, + "path" : "[?(@.some > 1 and @.some < 5)]" + }, { + "kind" : "TOKEN_LPAREN", + "value" : "(", + "index" : 2, + "path" : "[?(@.some > 1 and @.some < 5)]" + }, { + "kind" : "TOKEN_SELF", + "value" : "@", + "index" : 3, + "path" : "[?(@.some > 1 and @.some < 5)]" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "some", + "index" : 5, + "path" : "[?(@.some > 1 and @.some < 5)]" + }, { + "kind" : "TOKEN_GT", + "value" : ">", + "index" : 10, + "path" : "[?(@.some > 1 and @.some < 5)]" + }, { + "kind" : "TOKEN_INT", + "value" : "1", + "index" : 12, + "path" : "[?(@.some > 1 and @.some < 5)]" + }, { + "kind" : "TOKEN_AND", + "value" : "and", + "index" : 14, + "path" : "[?(@.some > 1 and @.some < 5)]" + }, { + "kind" : "TOKEN_SELF", + "value" : "@", + "index" : 18, + "path" : "[?(@.some > 1 and @.some < 5)]" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "some", + "index" : 20, + "path" : "[?(@.some > 1 and @.some < 5)]" + }, { + "kind" : "TOKEN_LT", + "value" : "<", + "index" : 25, + "path" : "[?(@.some > 1 and @.some < 5)]" + }, { + "kind" : "TOKEN_INT", + "value" : "5", + "index" : 27, + "path" : "[?(@.some > 1 and @.some < 5)]" + }, { + "kind" : "TOKEN_RPAREN", + "value" : ")", + "index" : 28, + "path" : "[?(@.some > 1 and @.some < 5)]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 29, + "path" : "[?(@.some > 1 and @.some < 5)]" + } ] + }, { + "description" : "filter expression with logical or", + "path" : "[?(@.some == 1 or @.some == 5)]", + "want" : [ { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 0, + "path" : "[?(@.some == 1 or @.some == 5)]" + }, { + "kind" : "TOKEN_FILTER", + "value" : "?", + "index" : 1, + "path" : "[?(@.some == 1 or @.some == 5)]" + }, { + "kind" : "TOKEN_LPAREN", + "value" : "(", + "index" : 2, + "path" : "[?(@.some == 1 or @.some == 5)]" + }, { + "kind" : "TOKEN_SELF", + "value" : "@", + "index" : 3, + "path" : "[?(@.some == 1 or @.some == 5)]" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "some", + "index" : 5, + "path" : "[?(@.some == 1 or @.some == 5)]" + }, { + "kind" : "TOKEN_EQ", + "value" : "==", + "index" : 10, + "path" : "[?(@.some == 1 or @.some == 5)]" + }, { + "kind" : "TOKEN_INT", + "value" : "1", + "index" : 13, + "path" : "[?(@.some == 1 or @.some == 5)]" + }, { + "kind" : "TOKEN_OR", + "value" : "or", + "index" : 15, + "path" : "[?(@.some == 1 or @.some == 5)]" + }, { + "kind" : "TOKEN_SELF", + "value" : "@", + "index" : 18, + "path" : "[?(@.some == 1 or @.some == 5)]" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "some", + "index" : 20, + "path" : "[?(@.some == 1 or @.some == 5)]" + }, { + "kind" : "TOKEN_EQ", + "value" : "==", + "index" : 25, + "path" : "[?(@.some == 1 or @.some == 5)]" + }, { + "kind" : "TOKEN_INT", + "value" : "5", + "index" : 28, + "path" : "[?(@.some == 1 or @.some == 5)]" + }, { + "kind" : "TOKEN_RPAREN", + "value" : ")", + "index" : 29, + "path" : "[?(@.some == 1 or @.some == 5)]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 30, + "path" : "[?(@.some == 1 or @.some == 5)]" + } ] + }, { + "description" : "filter expression with logical ||", + "path" : "[?(@.some == 1 || @.some == 5)]", + "want" : [ { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 0, + "path" : "[?(@.some == 1 || @.some == 5)]" + }, { + "kind" : "TOKEN_FILTER", + "value" : "?", + "index" : 1, + "path" : "[?(@.some == 1 || @.some == 5)]" + }, { + "kind" : "TOKEN_LPAREN", + "value" : "(", + "index" : 2, + "path" : "[?(@.some == 1 || @.some == 5)]" + }, { + "kind" : "TOKEN_SELF", + "value" : "@", + "index" : 3, + "path" : "[?(@.some == 1 || @.some == 5)]" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "some", + "index" : 5, + "path" : "[?(@.some == 1 || @.some == 5)]" + }, { + "kind" : "TOKEN_EQ", + "value" : "==", + "index" : 10, + "path" : "[?(@.some == 1 || @.some == 5)]" + }, { + "kind" : "TOKEN_INT", + "value" : "1", + "index" : 13, + "path" : "[?(@.some == 1 || @.some == 5)]" + }, { + "kind" : "TOKEN_OR", + "value" : "||", + "index" : 15, + "path" : "[?(@.some == 1 || @.some == 5)]" + }, { + "kind" : "TOKEN_SELF", + "value" : "@", + "index" : 18, + "path" : "[?(@.some == 1 || @.some == 5)]" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "some", + "index" : 20, + "path" : "[?(@.some == 1 || @.some == 5)]" + }, { + "kind" : "TOKEN_EQ", + "value" : "==", + "index" : 25, + "path" : "[?(@.some == 1 || @.some == 5)]" + }, { + "kind" : "TOKEN_INT", + "value" : "5", + "index" : 28, + "path" : "[?(@.some == 1 || @.some == 5)]" + }, { + "kind" : "TOKEN_RPAREN", + "value" : ")", + "index" : 29, + "path" : "[?(@.some == 1 || @.some == 5)]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 30, + "path" : "[?(@.some == 1 || @.some == 5)]" + } ] + }, { + "description" : "filter self dot property in list literal", + "path" : "[?(@.thing in [1, '1'])]", + "want" : [ { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 0, + "path" : "[?(@.thing in [1, '1'])]" + }, { + "kind" : "TOKEN_FILTER", + "value" : "?", + "index" : 1, + "path" : "[?(@.thing in [1, '1'])]" + }, { + "kind" : "TOKEN_LPAREN", + "value" : "(", + "index" : 2, + "path" : "[?(@.thing in [1, '1'])]" + }, { + "kind" : "TOKEN_SELF", + "value" : "@", + "index" : 3, + "path" : "[?(@.thing in [1, '1'])]" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "thing", + "index" : 5, + "path" : "[?(@.thing in [1, '1'])]" + }, { + "kind" : "TOKEN_IN", + "value" : "in", + "index" : 11, + "path" : "[?(@.thing in [1, '1'])]" + }, { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 14, + "path" : "[?(@.thing in [1, '1'])]" + }, { + "kind" : "TOKEN_INT", + "value" : "1", + "index" : 15, + "path" : "[?(@.thing in [1, '1'])]" + }, { + "kind" : "TOKEN_COMMA", + "value" : ",", + "index" : 16, + "path" : "[?(@.thing in [1, '1'])]" + }, { + "kind" : "TOKEN_SINGLE_QUOTE_STRING", + "value" : "1", + "index" : 19, + "path" : "[?(@.thing in [1, '1'])]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 21, + "path" : "[?(@.thing in [1, '1'])]" + }, { + "kind" : "TOKEN_RPAREN", + "value" : ")", + "index" : 22, + "path" : "[?(@.thing in [1, '1'])]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 23, + "path" : "[?(@.thing in [1, '1'])]" + } ] + }, { + "description" : "filter expression with logical not", + "path" : "[?(@.some == 1 or not @.some < 5)]", + "want" : [ { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 0, + "path" : "[?(@.some == 1 or not @.some < 5)]" + }, { + "kind" : "TOKEN_FILTER", + "value" : "?", + "index" : 1, + "path" : "[?(@.some == 1 or not @.some < 5)]" + }, { + "kind" : "TOKEN_LPAREN", + "value" : "(", + "index" : 2, + "path" : "[?(@.some == 1 or not @.some < 5)]" + }, { + "kind" : "TOKEN_SELF", + "value" : "@", + "index" : 3, + "path" : "[?(@.some == 1 or not @.some < 5)]" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "some", + "index" : 5, + "path" : "[?(@.some == 1 or not @.some < 5)]" + }, { + "kind" : "TOKEN_EQ", + "value" : "==", + "index" : 10, + "path" : "[?(@.some == 1 or not @.some < 5)]" + }, { + "kind" : "TOKEN_INT", + "value" : "1", + "index" : 13, + "path" : "[?(@.some == 1 or not @.some < 5)]" + }, { + "kind" : "TOKEN_OR", + "value" : "or", + "index" : 15, + "path" : "[?(@.some == 1 or not @.some < 5)]" + }, { + "kind" : "TOKEN_NOT", + "value" : "not", + "index" : 18, + "path" : "[?(@.some == 1 or not @.some < 5)]" + }, { + "kind" : "TOKEN_SELF", + "value" : "@", + "index" : 22, + "path" : "[?(@.some == 1 or not @.some < 5)]" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "some", + "index" : 24, + "path" : "[?(@.some == 1 or not @.some < 5)]" + }, { + "kind" : "TOKEN_LT", + "value" : "<", + "index" : 29, + "path" : "[?(@.some == 1 or not @.some < 5)]" + }, { + "kind" : "TOKEN_INT", + "value" : "5", + "index" : 31, + "path" : "[?(@.some == 1 or not @.some < 5)]" + }, { + "kind" : "TOKEN_RPAREN", + "value" : ")", + "index" : 32, + "path" : "[?(@.some == 1 or not @.some < 5)]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 33, + "path" : "[?(@.some == 1 or not @.some < 5)]" + } ] + }, { + "description" : "filter expression with logical not using '!'", + "path" : "[?(@.some == 1 or !@.some < 5)]", + "want" : [ { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 0, + "path" : "[?(@.some == 1 or !@.some < 5)]" + }, { + "kind" : "TOKEN_FILTER", + "value" : "?", + "index" : 1, + "path" : "[?(@.some == 1 or !@.some < 5)]" + }, { + "kind" : "TOKEN_LPAREN", + "value" : "(", + "index" : 2, + "path" : "[?(@.some == 1 or !@.some < 5)]" + }, { + "kind" : "TOKEN_SELF", + "value" : "@", + "index" : 3, + "path" : "[?(@.some == 1 or !@.some < 5)]" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "some", + "index" : 5, + "path" : "[?(@.some == 1 or !@.some < 5)]" + }, { + "kind" : "TOKEN_EQ", + "value" : "==", + "index" : 10, + "path" : "[?(@.some == 1 or !@.some < 5)]" + }, { + "kind" : "TOKEN_INT", + "value" : "1", + "index" : 13, + "path" : "[?(@.some == 1 or !@.some < 5)]" + }, { + "kind" : "TOKEN_OR", + "value" : "or", + "index" : 15, + "path" : "[?(@.some == 1 or !@.some < 5)]" + }, { + "kind" : "TOKEN_NOT", + "value" : "!", + "index" : 18, + "path" : "[?(@.some == 1 or !@.some < 5)]" + }, { + "kind" : "TOKEN_SELF", + "value" : "@", + "index" : 19, + "path" : "[?(@.some == 1 or !@.some < 5)]" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "some", + "index" : 21, + "path" : "[?(@.some == 1 or !@.some < 5)]" + }, { + "kind" : "TOKEN_LT", + "value" : "<", + "index" : 26, + "path" : "[?(@.some == 1 or !@.some < 5)]" + }, { + "kind" : "TOKEN_INT", + "value" : "5", + "index" : 28, + "path" : "[?(@.some == 1 or !@.some < 5)]" + }, { + "kind" : "TOKEN_RPAREN", + "value" : ")", + "index" : 29, + "path" : "[?(@.some == 1 or !@.some < 5)]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 30, + "path" : "[?(@.some == 1 or !@.some < 5)]" + } ] + }, { + "description" : "filter true and false", + "path" : "[?(true == false)]", + "want" : [ { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 0, + "path" : "[?(true == false)]" + }, { + "kind" : "TOKEN_FILTER", + "value" : "?", + "index" : 1, + "path" : "[?(true == false)]" + }, { + "kind" : "TOKEN_LPAREN", + "value" : "(", + "index" : 2, + "path" : "[?(true == false)]" + }, { + "kind" : "TOKEN_TRUE", + "value" : "true", + "index" : 3, + "path" : "[?(true == false)]" + }, { + "kind" : "TOKEN_EQ", + "value" : "==", + "index" : 8, + "path" : "[?(true == false)]" + }, { + "kind" : "TOKEN_FALSE", + "value" : "false", + "index" : 11, + "path" : "[?(true == false)]" + }, { + "kind" : "TOKEN_RPAREN", + "value" : ")", + "index" : 16, + "path" : "[?(true == false)]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 17, + "path" : "[?(true == false)]" + } ] + }, { + "description" : "filter true and false", + "path" : "[?(nil == none && nil == null)]", + "want" : [ { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 0, + "path" : "[?(nil == none && nil == null)]" + }, { + "kind" : "TOKEN_FILTER", + "value" : "?", + "index" : 1, + "path" : "[?(nil == none && nil == null)]" + }, { + "kind" : "TOKEN_LPAREN", + "value" : "(", + "index" : 2, + "path" : "[?(nil == none && nil == null)]" + }, { + "kind" : "TOKEN_NIL", + "value" : "nil", + "index" : 3, + "path" : "[?(nil == none && nil == null)]" + }, { + "kind" : "TOKEN_EQ", + "value" : "==", + "index" : 7, + "path" : "[?(nil == none && nil == null)]" + }, { + "kind" : "TOKEN_NIL", + "value" : "none", + "index" : 10, + "path" : "[?(nil == none && nil == null)]" + }, { + "kind" : "TOKEN_AND", + "value" : "&&", + "index" : 15, + "path" : "[?(nil == none && nil == null)]" + }, { + "kind" : "TOKEN_NIL", + "value" : "nil", + "index" : 18, + "path" : "[?(nil == none && nil == null)]" + }, { + "kind" : "TOKEN_EQ", + "value" : "==", + "index" : 22, + "path" : "[?(nil == none && nil == null)]" + }, { + "kind" : "TOKEN_NIL", + "value" : "null", + "index" : 25, + "path" : "[?(nil == none && nil == null)]" + }, { + "kind" : "TOKEN_RPAREN", + "value" : ")", + "index" : 29, + "path" : "[?(nil == none && nil == null)]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 30, + "path" : "[?(nil == none && nil == null)]" + } ] + }, { + "description" : "list of quoted properties", + "path" : "$['some', 'thing']", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$['some', 'thing']" + }, { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 1, + "path" : "$['some', 'thing']" + }, { + "kind" : "TOKEN_SINGLE_QUOTE_STRING", + "value" : "some", + "index" : 3, + "path" : "$['some', 'thing']" + }, { + "kind" : "TOKEN_COMMA", + "value" : ",", + "index" : 8, + "path" : "$['some', 'thing']" + }, { + "kind" : "TOKEN_SINGLE_QUOTE_STRING", + "value" : "thing", + "index" : 11, + "path" : "$['some', 'thing']" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 17, + "path" : "$['some', 'thing']" + } ] + }, { + "description" : "call a function", + "path" : "$.some[?(length(@.thing) < 2)]", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$.some[?(length(@.thing) < 2)]" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "some", + "index" : 2, + "path" : "$.some[?(length(@.thing) < 2)]" + }, { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 6, + "path" : "$.some[?(length(@.thing) < 2)]" + }, { + "kind" : "TOKEN_FILTER", + "value" : "?", + "index" : 7, + "path" : "$.some[?(length(@.thing) < 2)]" + }, { + "kind" : "TOKEN_LPAREN", + "value" : "(", + "index" : 8, + "path" : "$.some[?(length(@.thing) < 2)]" + }, { + "kind" : "TOKEN_FUNCTION", + "value" : "length", + "index" : 9, + "path" : "$.some[?(length(@.thing) < 2)]" + }, { + "kind" : "TOKEN_SELF", + "value" : "@", + "index" : 16, + "path" : "$.some[?(length(@.thing) < 2)]" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "thing", + "index" : 18, + "path" : "$.some[?(length(@.thing) < 2)]" + }, { + "kind" : "TOKEN_RPAREN", + "value" : ")", + "index" : 23, + "path" : "$.some[?(length(@.thing) < 2)]" + }, { + "kind" : "TOKEN_LT", + "value" : "<", + "index" : 25, + "path" : "$.some[?(length(@.thing) < 2)]" + }, { + "kind" : "TOKEN_INT", + "value" : "2", + "index" : 27, + "path" : "$.some[?(length(@.thing) < 2)]" + }, { + "kind" : "TOKEN_RPAREN", + "value" : ")", + "index" : 28, + "path" : "$.some[?(length(@.thing) < 2)]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 29, + "path" : "$.some[?(length(@.thing) < 2)]" + } ] + }, { + "description" : "keys selector", + "path" : "$.thing.~", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$.thing.~" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "thing", + "index" : 2, + "path" : "$.thing.~" + }, { + "kind" : "TOKEN_KEYS", + "value" : "~", + "index" : 8, + "path" : "$.thing.~" + } ] + }, { + "description" : "keys in list selector", + "path" : "$.thing[~]", + "want" : [ { + "kind" : "TOKEN_ROOT", + "value" : "$", + "index" : 0, + "path" : "$.thing[~]" + }, { + "kind" : "TOKEN_PROPERTY", + "value" : "thing", + "index" : 2, + "path" : "$.thing[~]" + }, { + "kind" : "TOKEN_LIST_START", + "value" : "[", + "index" : 7, + "path" : "$.thing[~]" + }, { + "kind" : "TOKEN_KEYS", + "value" : "~", + "index" : 8, + "path" : "$.thing[~]" + }, { + "kind" : "TOKEN_RBRACKET", + "value" : "]", + "index" : 9, + "path" : "$.thing[~]" + } ] + }, { + "description" : "implicit root selector, name selector starts with `and`", + "path" : "anderson", + "want" : [ { + "kind" : "TOKEN_BARE_PROPERTY", + "value" : "anderson", + "index" : 0, + "path" : "anderson" + } ] + }, { + "description" : "implicit root selector, name selector starts with `or`", + "path" : "order", + "want" : [ { + "kind" : "TOKEN_BARE_PROPERTY", + "value" : "order", + "index" : 0, + "path" : "order" + } ] + }, { + "description" : "implicit root selector, name selector starts with `true`", + "path" : "trueblue", + "want" : [ { + "kind" : "TOKEN_BARE_PROPERTY", + "value" : "trueblue", + "index" : 0, + "path" : "trueblue" + } ] + }, { + "description" : "implicit root selector, name selector starts with `false`", + "path" : "falsehood", + "want" : [ { + "kind" : "TOKEN_BARE_PROPERTY", + "value" : "falsehood", + "index" : 0, + "path" : "falsehood" + } ] + }, { + "description" : "implicit root selector, name selector starts with `not`", + "path" : "nottingham", + "want" : [ { + "kind" : "TOKEN_BARE_PROPERTY", + "value" : "nottingham", + "index" : 0, + "path" : "nottingham" + } ] + }, { + "description" : "implicit root selector, name selector starts with `null`", + "path" : "nullable", + "want" : [ { + "kind" : "TOKEN_BARE_PROPERTY", + "value" : "nullable", + "index" : 0, + "path" : "nullable" + } ] + }, { + "description" : "implicit root selector, name selector starts with `none`", + "path" : "nonexpert", + "want" : [ { + "kind" : "TOKEN_BARE_PROPERTY", + "value" : "nonexpert", + "index" : 0, + "path" : "nonexpert" + } ] + }, { + "description" : "implicit root selector, name selector starts with `undefined`", + "path" : "undefinedness", + "want" : [ { + "kind" : "TOKEN_BARE_PROPERTY", + "value" : "undefinedness", + "index" : 0, + "path" : "undefinedness" + } ] + }, { + "description" : "implicit root selector, name selector starts with `missing`", + "path" : "missingly", + "want" : [ { + "kind" : "TOKEN_BARE_PROPERTY", + "value" : "missingly", + "index" : 0, + "path" : "missingly" + } ] + } ] +} \ No newline at end of file diff --git a/tests/test_lex.py b/tests/test_lex.py index 8241a04..218e17d 100644 --- a/tests/test_lex.py +++ b/tests/test_lex.py @@ -1,47 +1,13 @@ import dataclasses +import json import operator -from typing import List +from typing import List, Any import pytest +import jsonpath.token as tokmod from jsonpath import JSONPathEnvironment from jsonpath.exceptions import JSONPathSyntaxError -from jsonpath.token import TOKEN_AND -from jsonpath.token import TOKEN_COLON -from jsonpath.token import TOKEN_COMMA -from jsonpath.token import TOKEN_DDOT -from jsonpath.token import TOKEN_DOT -from jsonpath.token import TOKEN_DOUBLE_QUOTE_STRING -from jsonpath.token import TOKEN_EQ -from jsonpath.token import TOKEN_FALSE -from jsonpath.token import TOKEN_FILTER -from jsonpath.token import TOKEN_FLOAT -from jsonpath.token import TOKEN_FUNCTION -from jsonpath.token import TOKEN_GT -from jsonpath.token import TOKEN_IN -from jsonpath.token import TOKEN_INT -from jsonpath.token import TOKEN_INTERSECTION -from jsonpath.token import TOKEN_KEYS -from jsonpath.token import TOKEN_LBRACKET -from jsonpath.token import TOKEN_LPAREN -from jsonpath.token import TOKEN_LT -from jsonpath.token import TOKEN_NAME -from jsonpath.token import TOKEN_NIL -from jsonpath.token import TOKEN_NOT -from jsonpath.token import TOKEN_OR -from jsonpath.token import TOKEN_PSEUDO_ROOT -from jsonpath.token import TOKEN_RBRACKET -from jsonpath.token import TOKEN_RE -from jsonpath.token import TOKEN_RE_FLAGS -from jsonpath.token import TOKEN_RE_PATTERN -from jsonpath.token import TOKEN_ROOT -from jsonpath.token import TOKEN_RPAREN -from jsonpath.token import TOKEN_SELF -from jsonpath.token import TOKEN_SINGLE_QUOTE_STRING -from jsonpath.token import TOKEN_TRUE -from jsonpath.token import TOKEN_UNION -from jsonpath.token import TOKEN_WHITESPACE -from jsonpath.token import TOKEN_WILD from jsonpath.token import Token @@ -51,1717 +17,47 @@ class Case: path: str want: List[Token] - -TEST_CASES = [ - Case( - description="just root", - path="$", - want=[Token(kind=TOKEN_ROOT, value="$", index=0, path="$")], - ), - Case( - description="just pseudo-root", - path="^", - want=[Token(kind=TOKEN_PSEUDO_ROOT, value="^", index=0, path="^")], - ), - Case( - description="root dot property", - path="$.some.thing", - want=[ - Token(kind=TOKEN_ROOT, value="$", index=0, path="$.some.thing"), - Token(kind=TOKEN_DOT, value=".", index=1, path="$.some.thing"), - Token(kind=TOKEN_NAME, value="some", index=2, path="$.some.thing"), - Token(kind=TOKEN_DOT, value=".", index=6, path="$.some.thing"), - Token(kind=TOKEN_NAME, value="thing", index=7, path="$.some.thing"), - ], - ), - Case( - description="pseudo root dot property", - path="^.some.thing", - want=[ - Token(kind=TOKEN_PSEUDO_ROOT, value="^", index=0, path="^.some.thing"), - Token(kind=TOKEN_DOT, value=".", index=1, path="^.some.thing"), - Token(kind=TOKEN_NAME, value="some", index=2, path="^.some.thing"), - Token(kind=TOKEN_DOT, value=".", index=6, path="^.some.thing"), - Token(kind=TOKEN_NAME, value="thing", index=7, path="^.some.thing"), - ], - ), - Case( - description="root bracket property", - path="$[some][thing]", - want=[ - Token(kind=TOKEN_ROOT, value="$", index=0, path="$[some][thing]"), - Token(kind=TOKEN_LBRACKET, value="[", index=1, path="$[some][thing]"), - Token(kind=TOKEN_NAME, value="some", index=2, path="$[some][thing]"), - Token(kind=TOKEN_RBRACKET, value="]", index=6, path="$[some][thing]"), - Token(kind=TOKEN_LBRACKET, value="[", index=7, path="$[some][thing]"), - Token(kind=TOKEN_NAME, value="thing", index=8, path="$[some][thing]"), - Token(kind=TOKEN_RBRACKET, value="]", index=13, path="$[some][thing]"), - ], - ), - Case( - description="root double quoted property", - path='$["some"]', - want=[ - Token(kind=TOKEN_ROOT, value="$", index=0, path='$["some"]'), - Token(kind=TOKEN_LBRACKET, value="[", index=1, path='$["some"]'), - Token( - kind=TOKEN_DOUBLE_QUOTE_STRING, value="some", index=3, path='$["some"]' - ), - Token(kind=TOKEN_RBRACKET, value="]", index=8, path='$["some"]'), - ], - ), - Case( - description="root single quoted property", - path="$['some']", - want=[ - Token(kind=TOKEN_ROOT, value="$", index=0, path="$['some']"), - Token(kind=TOKEN_LBRACKET, value="[", index=1, path="$['some']"), - Token( - kind=TOKEN_SINGLE_QUOTE_STRING, value="some", index=3, path="$['some']" - ), - Token(kind=TOKEN_RBRACKET, value="]", index=8, path="$['some']"), - ], - ), - Case( - description="root dot bracket property", - path="$.[some][thing]", - want=[ - Token(kind=TOKEN_ROOT, value="$", index=0, path="$.[some][thing]"), - Token(kind=TOKEN_DOT, value=".", index=1, path="$.[some][thing]"), - Token(kind=TOKEN_LBRACKET, value="[", index=2, path="$.[some][thing]"), - Token(kind=TOKEN_NAME, value="some", index=3, path="$.[some][thing]"), - Token(kind=TOKEN_RBRACKET, value="]", index=7, path="$.[some][thing]"), - Token(kind=TOKEN_LBRACKET, value="[", index=8, path="$.[some][thing]"), - Token(kind=TOKEN_NAME, value="thing", index=9, path="$.[some][thing]"), - Token(kind=TOKEN_RBRACKET, value="]", index=14, path="$.[some][thing]"), - ], - ), - Case( - description="root bracket index", - path="$[1]", - want=[ - Token(kind=TOKEN_ROOT, value="$", index=0, path="$[1]"), - Token(kind=TOKEN_LBRACKET, value="[", index=1, path="$[1]"), - Token(kind=TOKEN_INT, value="1", index=2, path="$[1]"), - Token(kind=TOKEN_RBRACKET, value="]", index=3, path="$[1]"), - ], - ), - Case( - description="root dot bracket index", - path="$.[1]", - want=[ - Token(kind=TOKEN_ROOT, value="$", index=0, path="$.[1]"), - Token(kind=TOKEN_DOT, value=".", index=1, path="$.[1]"), - Token(kind=TOKEN_LBRACKET, value="[", index=2, path="$.[1]"), - Token(kind=TOKEN_INT, value="1", index=3, path="$.[1]"), - Token(kind=TOKEN_RBRACKET, value="]", index=4, path="$.[1]"), - ], - ), - Case( - description="empty slice", - path="[:]", - want=[ - Token(kind=TOKEN_LBRACKET, value="[", index=0, path="[:]"), - Token(kind=TOKEN_COLON, value=":", index=1, path="[:]"), - Token(kind=TOKEN_RBRACKET, value="]", index=2, path="[:]"), - ], - ), - Case( - description="empty slice empty step", - path="[::]", - want=[ - Token(kind=TOKEN_LBRACKET, value="[", index=0, path="[::]"), - Token(kind=TOKEN_COLON, value=":", index=1, path="[::]"), - Token(kind=TOKEN_COLON, value=":", index=2, path="[::]"), - Token(kind=TOKEN_RBRACKET, value="]", index=3, path="[::]"), - ], - ), - Case( - description="slice empty stop", - path="[1:]", - want=[ - Token(kind=TOKEN_LBRACKET, value="[", index=0, path="[1:]"), - Token(kind=TOKEN_INT, value="1", index=1, path="[1:]"), - Token(kind=TOKEN_COLON, value=":", index=2, path="[1:]"), - Token(kind=TOKEN_RBRACKET, value="]", index=3, path="[1:]"), - ], - ), - Case( - description="slice empty start", - path="[:-1]", - want=[ - Token(kind=TOKEN_LBRACKET, value="[", index=0, path="[:-1]"), - Token(kind=TOKEN_COLON, value=":", index=1, path="[:-1]"), - Token(kind=TOKEN_INT, value="-1", index=2, path="[:-1]"), - Token(kind=TOKEN_RBRACKET, value="]", index=4, path="[:-1]"), - ], - ), - Case( - description="slice start and stop", - path="[1:7]", - want=[ - Token(kind=TOKEN_LBRACKET, value="[", index=0, path="[1:7]"), - Token(kind=TOKEN_INT, value="1", index=1, path="[1:7]"), - Token(kind=TOKEN_COLON, value=":", index=2, path="[1:7]"), - Token(kind=TOKEN_INT, value="7", index=3, path="[1:7]"), - Token(kind=TOKEN_RBRACKET, value="]", index=4, path="[1:7]"), - ], - ), - Case( - description="slice start, stop and step", - path="[1:7:2]", - want=[ - Token(kind=TOKEN_LBRACKET, value="[", index=0, path="[1:7:2]"), - Token(kind=TOKEN_INT, value="1", index=1, path="[1:7:2]"), - Token(kind=TOKEN_COLON, value=":", index=2, path="[1:7:2]"), - Token(kind=TOKEN_INT, value="7", index=3, path="[1:7:2]"), - Token(kind=TOKEN_COLON, value=":", index=4, path="[1:7:2]"), - Token(kind=TOKEN_INT, value="2", index=5, path="[1:7:2]"), - Token(kind=TOKEN_RBRACKET, value="]", index=6, path="[1:7:2]"), - ], - ), - Case( - description="root dot wild", - path="$.*", - want=[ - Token(kind=TOKEN_ROOT, value="$", index=0, path="$.*"), - Token(kind=TOKEN_DOT, value=".", index=1, path="$.*"), - Token(kind=TOKEN_WILD, value="*", index=2, path="$.*"), - ], - ), - Case( - description="root bracket wild", - path="$[*]", - want=[ - Token(kind=TOKEN_ROOT, value="$", index=0, path="$[*]"), - Token(kind=TOKEN_LBRACKET, value="[", index=1, path="$[*]"), - Token(kind=TOKEN_WILD, value="*", index=2, path="$[*]"), - Token(kind=TOKEN_RBRACKET, value="]", index=3, path="$[*]"), - ], - ), - Case( - description="root dot bracket wild", - path="$.[*]", - want=[ - Token(kind=TOKEN_ROOT, value="$", index=0, path="$.[*]"), - Token(kind=TOKEN_DOT, value=".", index=1, path="$.[*]"), - Token(kind=TOKEN_LBRACKET, value="[", index=2, path="$.[*]"), - Token(kind=TOKEN_WILD, value="*", index=3, path="$.[*]"), - Token(kind=TOKEN_RBRACKET, value="]", index=4, path="$.[*]"), - ], - ), - Case( - description="root descend", - path="$..", - want=[ - Token(kind=TOKEN_ROOT, value="$", index=0, path="$.."), - Token(kind=TOKEN_DDOT, value="..", index=1, path="$.."), - ], - ), - Case( - description="root descend property", - path="$..thing", - want=[ - Token(kind=TOKEN_ROOT, value="$", index=0, path="$..thing"), - Token(kind=TOKEN_DDOT, value="..", index=1, path="$..thing"), - Token(kind=TOKEN_NAME, value="thing", index=3, path="$..thing"), - ], - ), - Case( - description="root descend dot property", - path="$...thing", - want=[ - Token(kind=TOKEN_ROOT, value="$", index=0, path="$...thing"), - Token(kind=TOKEN_DDOT, value="..", index=1, path="$...thing"), - Token(kind=TOKEN_DOT, value=".", index=3, path="$...thing"), - Token(kind=TOKEN_NAME, value="thing", index=4, path="$...thing"), - ], - ), - Case( - description="root selector list of indices", - path="$[1,4,5]", - want=[ - Token(kind=TOKEN_ROOT, value="$", index=0, path="$[1,4,5]"), - Token(kind=TOKEN_LBRACKET, value="[", index=1, path="$[1,4,5]"), - Token(kind=TOKEN_INT, value="1", index=2, path="$[1,4,5]"), - Token(kind=TOKEN_COMMA, value=",", index=3, path="$[1,4,5]"), - Token(kind=TOKEN_INT, value="4", index=4, path="$[1,4,5]"), - Token(kind=TOKEN_COMMA, value=",", index=5, path="$[1,4,5]"), - Token(kind=TOKEN_INT, value="5", index=6, path="$[1,4,5]"), - Token(kind=TOKEN_RBRACKET, value="]", index=7, path="$[1,4,5]"), - ], - ), - Case( - description="root selector list with a slice", - path="$[1,4:9]", - want=[ - Token(kind=TOKEN_ROOT, value="$", index=0, path="$[1,4:9]"), - Token(kind=TOKEN_LBRACKET, value="[", index=1, path="$[1,4:9]"), - Token(kind=TOKEN_INT, value="1", index=2, path="$[1,4:9]"), - Token(kind=TOKEN_COMMA, value=",", index=3, path="$[1,4:9]"), - Token(kind=TOKEN_INT, value="4", index=4, path="$[1,4:9]"), - Token(kind=TOKEN_COLON, value=":", index=5, path="$[1,4:9]"), - Token(kind=TOKEN_INT, value="9", index=6, path="$[1,4:9]"), - Token(kind=TOKEN_RBRACKET, value="]", index=7, path="$[1,4:9]"), - ], - ), - Case( - description="root selector list of properties", - path="$[some,thing]", - want=[ - Token(kind=TOKEN_ROOT, value="$", index=0, path="$[some,thing]"), - Token(kind=TOKEN_LBRACKET, value="[", index=1, path="$[some,thing]"), - Token(kind=TOKEN_NAME, value="some", index=2, path="$[some,thing]"), - Token(kind=TOKEN_COMMA, value=",", index=6, path="$[some,thing]"), - Token(kind=TOKEN_NAME, value="thing", index=7, path="$[some,thing]"), - Token(kind=TOKEN_RBRACKET, value="]", index=12, path="$[some,thing]"), - ], - ), - Case( - description="root dot filter on self dot property", - path="$.[?(@.some)]", - want=[ - Token(kind=TOKEN_ROOT, value="$", index=0, path="$.[?(@.some)]"), - Token(kind=TOKEN_DOT, value=".", index=1, path="$.[?(@.some)]"), - Token(kind=TOKEN_LBRACKET, value="[", index=2, path="$.[?(@.some)]"), - Token(kind=TOKEN_FILTER, value="?", index=3, path="$.[?(@.some)]"), - Token(kind=TOKEN_LPAREN, value="(", index=4, path="$.[?(@.some)]"), - Token(kind=TOKEN_SELF, value="@", index=5, path="$.[?(@.some)]"), - Token(kind=TOKEN_DOT, value=".", index=6, path="$.[?(@.some)]"), - Token(kind=TOKEN_NAME, value="some", index=7, path="$.[?(@.some)]"), - Token(kind=TOKEN_RPAREN, value=")", index=11, path="$.[?(@.some)]"), - Token(kind=TOKEN_RBRACKET, value="]", index=12, path="$.[?(@.some)]"), - ], - ), - Case( - description="root dot filter on root dot property", - path="$.[?($.some)]", - want=[ - Token(kind=TOKEN_ROOT, value="$", index=0, path="$.[?($.some)]"), - Token(kind=TOKEN_DOT, value=".", index=1, path="$.[?($.some)]"), - Token(kind=TOKEN_LBRACKET, value="[", index=2, path="$.[?($.some)]"), - Token(kind=TOKEN_FILTER, value="?", index=3, path="$.[?($.some)]"), - Token(kind=TOKEN_LPAREN, value="(", index=4, path="$.[?($.some)]"), - Token(kind=TOKEN_ROOT, value="$", index=5, path="$.[?($.some)]"), - Token(kind=TOKEN_DOT, value=".", index=6, path="$.[?($.some)]"), - Token(kind=TOKEN_NAME, value="some", index=7, path="$.[?($.some)]"), - Token(kind=TOKEN_RPAREN, value=")", index=11, path="$.[?($.some)]"), - Token(kind=TOKEN_RBRACKET, value="]", index=12, path="$.[?($.some)]"), - ], - ), - Case( - description="root dot filter on self index", - path="$.[?(@[1])]", - want=[ - Token(kind=TOKEN_ROOT, value="$", index=0, path="$.[?(@[1])]"), - Token(kind=TOKEN_DOT, value=".", index=1, path="$.[?(@[1])]"), - Token(kind=TOKEN_LBRACKET, value="[", index=2, path="$.[?(@[1])]"), - Token(kind=TOKEN_FILTER, value="?", index=3, path="$.[?(@[1])]"), - Token(kind=TOKEN_LPAREN, value="(", index=4, path="$.[?(@[1])]"), - Token(kind=TOKEN_SELF, value="@", index=5, path="$.[?(@[1])]"), - Token(kind=TOKEN_LBRACKET, value="[", index=6, path="$.[?(@[1])]"), - Token(kind=TOKEN_INT, value="1", index=7, path="$.[?(@[1])]"), - Token(kind=TOKEN_RBRACKET, value="]", index=8, path="$.[?(@[1])]"), - Token(kind=TOKEN_RPAREN, value=")", index=9, path="$.[?(@[1])]"), - Token(kind=TOKEN_RBRACKET, value="]", index=10, path="$.[?(@[1])]"), - ], - ), - Case( - description="filter self dot property equality with float", - path="[?(@.some == 1.1)]", - want=[ - Token(kind=TOKEN_LBRACKET, value="[", index=0, path="[?(@.some == 1.1)]"), - Token(kind=TOKEN_FILTER, value="?", index=1, path="[?(@.some == 1.1)]"), - Token(kind=TOKEN_LPAREN, value="(", index=2, path="[?(@.some == 1.1)]"), - Token(kind=TOKEN_SELF, value="@", index=3, path="[?(@.some == 1.1)]"), - Token(kind=TOKEN_DOT, value=".", index=4, path="[?(@.some == 1.1)]"), - Token(kind=TOKEN_NAME, value="some", index=5, path="[?(@.some == 1.1)]"), - Token(kind=TOKEN_WHITESPACE, value=" ", index=9, path="[?(@.some == 1.1)]"), - Token(kind=TOKEN_EQ, value="==", index=10, path="[?(@.some == 1.1)]"), - Token( - kind=TOKEN_WHITESPACE, value=" ", index=12, path="[?(@.some == 1.1)]" - ), - Token(kind=TOKEN_FLOAT, value="1.1", index=13, path="[?(@.some == 1.1)]"), - Token(kind=TOKEN_RPAREN, value=")", index=16, path="[?(@.some == 1.1)]"), - Token(kind=TOKEN_RBRACKET, value="]", index=17, path="[?(@.some == 1.1)]"), - ], - ), - Case( - description="filter self dot property equality float in scientific notation", - path="[?(@.some == 1.1e10)]", - want=[ - Token( - kind=TOKEN_LBRACKET, value="[", index=0, path="[?(@.some == 1.1e10)]" - ), - Token(kind=TOKEN_FILTER, value="?", index=1, path="[?(@.some == 1.1e10)]"), - Token(kind=TOKEN_LPAREN, value="(", index=2, path="[?(@.some == 1.1e10)]"), - Token(kind=TOKEN_SELF, value="@", index=3, path="[?(@.some == 1.1e10)]"), - Token(kind=TOKEN_DOT, value=".", index=4, path="[?(@.some == 1.1e10)]"), - Token(kind=TOKEN_NAME, value="some", index=5, path="[?(@.some == 1.1e10)]"), - Token( - kind=TOKEN_WHITESPACE, value=" ", index=9, path="[?(@.some == 1.1e10)]" - ), - Token(kind=TOKEN_EQ, value="==", index=10, path="[?(@.some == 1.1e10)]"), - Token( - kind=TOKEN_WHITESPACE, value=" ", index=12, path="[?(@.some == 1.1e10)]" - ), - Token( - kind=TOKEN_FLOAT, value="1.1e10", index=13, path="[?(@.some == 1.1e10)]" - ), - Token(kind=TOKEN_RPAREN, value=")", index=19, path="[?(@.some == 1.1e10)]"), - Token( - kind=TOKEN_RBRACKET, value="]", index=20, path="[?(@.some == 1.1e10)]" - ), - ], - ), - Case( - description="filter self index equality with float", - path="[?(@[1] == 1.1)]", - want=[ - Token(kind=TOKEN_LBRACKET, value="[", index=0, path="[?(@[1] == 1.1)]"), - Token(kind=TOKEN_FILTER, value="?", index=1, path="[?(@[1] == 1.1)]"), - Token(kind=TOKEN_LPAREN, value="(", index=2, path="[?(@[1] == 1.1)]"), - Token(kind=TOKEN_SELF, value="@", index=3, path="[?(@[1] == 1.1)]"), - Token(kind=TOKEN_LBRACKET, value="[", index=4, path="[?(@[1] == 1.1)]"), - Token(kind=TOKEN_INT, value="1", index=5, path="[?(@[1] == 1.1)]"), - Token(kind=TOKEN_RBRACKET, value="]", index=6, path="[?(@[1] == 1.1)]"), - Token(kind=TOKEN_WHITESPACE, value=" ", index=7, path="[?(@[1] == 1.1)]"), - Token(kind=TOKEN_EQ, value="==", index=8, path="[?(@[1] == 1.1)]"), - Token(kind=TOKEN_WHITESPACE, value=" ", index=10, path="[?(@[1] == 1.1)]"), - Token(kind=TOKEN_FLOAT, value="1.1", index=11, path="[?(@[1] == 1.1)]"), - Token(kind=TOKEN_RPAREN, value=")", index=14, path="[?(@[1] == 1.1)]"), - Token(kind=TOKEN_RBRACKET, value="]", index=15, path="[?(@[1] == 1.1)]"), - ], - ), - Case( - description="filter self dot property equality with int", - path="[?(@.some == 1)]", - want=[ - Token(kind=TOKEN_LBRACKET, value="[", index=0, path="[?(@.some == 1)]"), - Token(kind=TOKEN_FILTER, value="?", index=1, path="[?(@.some == 1)]"), - Token(kind=TOKEN_LPAREN, value="(", index=2, path="[?(@.some == 1)]"), - Token(kind=TOKEN_SELF, value="@", index=3, path="[?(@.some == 1)]"), - Token(kind=TOKEN_DOT, value=".", index=4, path="[?(@.some == 1)]"), - Token(kind=TOKEN_NAME, value="some", index=5, path="[?(@.some == 1)]"), - Token(kind=TOKEN_WHITESPACE, value=" ", index=9, path="[?(@.some == 1)]"), - Token(kind=TOKEN_EQ, value="==", index=10, path="[?(@.some == 1)]"), - Token(kind=TOKEN_WHITESPACE, value=" ", index=12, path="[?(@.some == 1)]"), - Token(kind=TOKEN_INT, value="1", index=13, path="[?(@.some == 1)]"), - Token(kind=TOKEN_RPAREN, value=")", index=14, path="[?(@.some == 1)]"), - Token(kind=TOKEN_RBRACKET, value="]", index=15, path="[?(@.some == 1)]"), - ], - ), - Case( - description="filter self dot property equality with int in scientific notation", - path="[?(@.some == 1e10)]", - want=[ - Token(kind=TOKEN_LBRACKET, value="[", index=0, path="[?(@.some == 1e10)]"), - Token(kind=TOKEN_FILTER, value="?", index=1, path="[?(@.some == 1e10)]"), - Token(kind=TOKEN_LPAREN, value="(", index=2, path="[?(@.some == 1e10)]"), - Token(kind=TOKEN_SELF, value="@", index=3, path="[?(@.some == 1e10)]"), - Token(kind=TOKEN_DOT, value=".", index=4, path="[?(@.some == 1e10)]"), - Token(kind=TOKEN_NAME, value="some", index=5, path="[?(@.some == 1e10)]"), - Token( - kind=TOKEN_WHITESPACE, value=" ", index=9, path="[?(@.some == 1e10)]" - ), - Token(kind=TOKEN_EQ, value="==", index=10, path="[?(@.some == 1e10)]"), - Token( - kind=TOKEN_WHITESPACE, value=" ", index=12, path="[?(@.some == 1e10)]" - ), - Token(kind=TOKEN_INT, value="1e10", index=13, path="[?(@.some == 1e10)]"), - Token(kind=TOKEN_RPAREN, value=")", index=17, path="[?(@.some == 1e10)]"), - Token(kind=TOKEN_RBRACKET, value="]", index=18, path="[?(@.some == 1e10)]"), - ], - ), - Case( - description="filter self dot property regex", - path="[?(@.some =~ /foo|bar/i)]", - want=[ - Token( - kind=TOKEN_LBRACKET, - value="[", - index=0, - path="[?(@.some =~ /foo|bar/i)]", - ), - Token( - kind=TOKEN_FILTER, value="?", index=1, path="[?(@.some =~ /foo|bar/i)]" - ), - Token( - kind=TOKEN_LPAREN, value="(", index=2, path="[?(@.some =~ /foo|bar/i)]" - ), - Token( - kind=TOKEN_SELF, value="@", index=3, path="[?(@.some =~ /foo|bar/i)]" - ), - Token(kind=TOKEN_DOT, value=".", index=4, path="[?(@.some =~ /foo|bar/i)]"), - Token( - kind=TOKEN_NAME, value="some", index=5, path="[?(@.some =~ /foo|bar/i)]" - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=9, - path="[?(@.some =~ /foo|bar/i)]", - ), - Token( - kind=TOKEN_RE, value="=~", index=10, path="[?(@.some =~ /foo|bar/i)]" - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=12, - path="[?(@.some =~ /foo|bar/i)]", - ), - Token( - kind=TOKEN_RE_PATTERN, - value="foo|bar", - index=14, - path="[?(@.some =~ /foo|bar/i)]", - ), - Token( - kind=TOKEN_RE_FLAGS, - value="i", - index=22, - path="[?(@.some =~ /foo|bar/i)]", - ), - Token( - kind=TOKEN_RPAREN, value=")", index=23, path="[?(@.some =~ /foo|bar/i)]" - ), - Token( - kind=TOKEN_RBRACKET, - value="]", - index=24, - path="[?(@.some =~ /foo|bar/i)]", - ), - ], - ), - Case( - description="union of two paths", - path="$.some | $.thing", - want=[ - Token(kind=TOKEN_ROOT, value="$", index=0, path="$.some | $.thing"), - Token(kind=TOKEN_DOT, value=".", index=1, path="$.some | $.thing"), - Token(kind=TOKEN_NAME, value="some", index=2, path="$.some | $.thing"), - Token(kind=TOKEN_WHITESPACE, value=" ", index=6, path="$.some | $.thing"), - Token(kind=TOKEN_UNION, value="|", index=7, path="$.some | $.thing"), - Token(kind=TOKEN_WHITESPACE, value=" ", index=8, path="$.some | $.thing"), - Token(kind=TOKEN_ROOT, value="$", index=9, path="$.some | $.thing"), - Token(kind=TOKEN_DOT, value=".", index=10, path="$.some | $.thing"), - Token(kind=TOKEN_NAME, value="thing", index=11, path="$.some | $.thing"), - ], - ), - Case( - description="union of three paths", - path="$.some | $.thing | $.other", - want=[ - Token( - kind=TOKEN_ROOT, value="$", index=0, path="$.some | $.thing | $.other" - ), - Token( - kind=TOKEN_DOT, value=".", index=1, path="$.some | $.thing | $.other" - ), - Token( - kind=TOKEN_NAME, - value="some", - index=2, - path="$.some | $.thing | $.other", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=6, - path="$.some | $.thing | $.other", - ), - Token( - kind=TOKEN_UNION, value="|", index=7, path="$.some | $.thing | $.other" - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=8, - path="$.some | $.thing | $.other", - ), - Token( - kind=TOKEN_ROOT, value="$", index=9, path="$.some | $.thing | $.other" - ), - Token( - kind=TOKEN_DOT, value=".", index=10, path="$.some | $.thing | $.other" - ), - Token( - kind=TOKEN_NAME, - value="thing", - index=11, - path="$.some | $.thing | $.other", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=16, - path="$.some | $.thing | $.other", - ), - Token( - kind=TOKEN_UNION, value="|", index=17, path="$.some | $.thing | $.other" - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=18, - path="$.some | $.thing | $.other", - ), - Token( - kind=TOKEN_ROOT, value="$", index=19, path="$.some | $.thing | $.other" - ), - Token( - kind=TOKEN_DOT, value=".", index=20, path="$.some | $.thing | $.other" - ), - Token( - kind=TOKEN_NAME, - value="other", - index=21, - path="$.some | $.thing | $.other", - ), - ], - ), - Case( - description="intersection two paths", - path="$.some & $.thing", - want=[ - Token(kind=TOKEN_ROOT, value="$", index=0, path="$.some & $.thing"), - Token(kind=TOKEN_DOT, value=".", index=1, path="$.some & $.thing"), - Token(kind=TOKEN_NAME, value="some", index=2, path="$.some & $.thing"), - Token(kind=TOKEN_WHITESPACE, value=" ", index=6, path="$.some & $.thing"), - Token(kind=TOKEN_INTERSECTION, value="&", index=7, path="$.some & $.thing"), - Token(kind=TOKEN_WHITESPACE, value=" ", index=8, path="$.some & $.thing"), - Token(kind=TOKEN_ROOT, value="$", index=9, path="$.some & $.thing"), - Token(kind=TOKEN_DOT, value=".", index=10, path="$.some & $.thing"), - Token(kind=TOKEN_NAME, value="thing", index=11, path="$.some & $.thing"), - ], - ), - Case( - description="filter expression with logical and", - path="[?(@.some > 1 and @.some < 5)]", - want=[ - Token( - kind=TOKEN_LBRACKET, - value="[", - index=0, - path="[?(@.some > 1 and @.some < 5)]", - ), - Token( - kind=TOKEN_FILTER, - value="?", - index=1, - path="[?(@.some > 1 and @.some < 5)]", - ), - Token( - kind=TOKEN_LPAREN, - value="(", - index=2, - path="[?(@.some > 1 and @.some < 5)]", - ), - Token( - kind=TOKEN_SELF, - value="@", - index=3, - path="[?(@.some > 1 and @.some < 5)]", - ), - Token( - kind=TOKEN_DOT, - value=".", - index=4, - path="[?(@.some > 1 and @.some < 5)]", - ), - Token( - kind=TOKEN_NAME, - value="some", - index=5, - path="[?(@.some > 1 and @.some < 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=9, - path="[?(@.some > 1 and @.some < 5)]", - ), - Token( - kind=TOKEN_GT, - value=">", - index=10, - path="[?(@.some > 1 and @.some < 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=11, - path="[?(@.some > 1 and @.some < 5)]", - ), - Token( - kind=TOKEN_INT, - value="1", - index=12, - path="[?(@.some > 1 and @.some < 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=13, - path="[?(@.some > 1 and @.some < 5)]", - ), - Token( - kind=TOKEN_AND, - value="and", - index=14, - path="[?(@.some > 1 and @.some < 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=17, - path="[?(@.some > 1 and @.some < 5)]", - ), - Token( - kind=TOKEN_SELF, - value="@", - index=18, - path="[?(@.some > 1 and @.some < 5)]", - ), - Token( - kind=TOKEN_DOT, - value=".", - index=19, - path="[?(@.some > 1 and @.some < 5)]", - ), - Token( - kind=TOKEN_NAME, - value="some", - index=20, - path="[?(@.some > 1 and @.some < 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=24, - path="[?(@.some > 1 and @.some < 5)]", - ), - Token( - kind=TOKEN_LT, - value="<", - index=25, - path="[?(@.some > 1 and @.some < 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=26, - path="[?(@.some > 1 and @.some < 5)]", - ), - Token( - kind=TOKEN_INT, - value="5", - index=27, - path="[?(@.some > 1 and @.some < 5)]", - ), - Token( - kind=TOKEN_RPAREN, - value=")", - index=28, - path="[?(@.some > 1 and @.some < 5)]", - ), - Token( - kind=TOKEN_RBRACKET, - value="]", - index=29, - path="[?(@.some > 1 and @.some < 5)]", - ), - ], - ), - Case( - description="filter expression with logical or", - path="[?(@.some == 1 or @.some == 5)]", - want=[ - Token( - kind=TOKEN_LBRACKET, - value="[", - index=0, - path="[?(@.some == 1 or @.some == 5)]", - ), - Token( - kind=TOKEN_FILTER, - value="?", - index=1, - path="[?(@.some == 1 or @.some == 5)]", - ), - Token( - kind=TOKEN_LPAREN, - value="(", - index=2, - path="[?(@.some == 1 or @.some == 5)]", - ), - Token( - kind=TOKEN_SELF, - value="@", - index=3, - path="[?(@.some == 1 or @.some == 5)]", - ), - Token( - kind=TOKEN_DOT, - value=".", - index=4, - path="[?(@.some == 1 or @.some == 5)]", - ), - Token( - kind=TOKEN_NAME, - value="some", - index=5, - path="[?(@.some == 1 or @.some == 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=9, - path="[?(@.some == 1 or @.some == 5)]", - ), - Token( - kind=TOKEN_EQ, - value="==", - index=10, - path="[?(@.some == 1 or @.some == 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=12, - path="[?(@.some == 1 or @.some == 5)]", - ), - Token( - kind=TOKEN_INT, - value="1", - index=13, - path="[?(@.some == 1 or @.some == 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=14, - path="[?(@.some == 1 or @.some == 5)]", - ), - Token( - kind=TOKEN_OR, - value="or", - index=15, - path="[?(@.some == 1 or @.some == 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=17, - path="[?(@.some == 1 or @.some == 5)]", - ), - Token( - kind=TOKEN_SELF, - value="@", - index=18, - path="[?(@.some == 1 or @.some == 5)]", - ), - Token( - kind=TOKEN_DOT, - value=".", - index=19, - path="[?(@.some == 1 or @.some == 5)]", - ), - Token( - kind=TOKEN_NAME, - value="some", - index=20, - path="[?(@.some == 1 or @.some == 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=24, - path="[?(@.some == 1 or @.some == 5)]", - ), - Token( - kind=TOKEN_EQ, - value="==", - index=25, - path="[?(@.some == 1 or @.some == 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=27, - path="[?(@.some == 1 or @.some == 5)]", - ), - Token( - kind=TOKEN_INT, - value="5", - index=28, - path="[?(@.some == 1 or @.some == 5)]", - ), - Token( - kind=TOKEN_RPAREN, - value=")", - index=29, - path="[?(@.some == 1 or @.some == 5)]", - ), - Token( - kind=TOKEN_RBRACKET, - value="]", - index=30, - path="[?(@.some == 1 or @.some == 5)]", - ), - ], - ), - Case( - description="filter expression with logical ||", - path="[?(@.some == 1 || @.some == 5)]", - want=[ - Token( - kind=TOKEN_LBRACKET, - value="[", - index=0, - path="[?(@.some == 1 || @.some == 5)]", - ), - Token( - kind=TOKEN_FILTER, - value="?", - index=1, - path="[?(@.some == 1 || @.some == 5)]", - ), - Token( - kind=TOKEN_LPAREN, - value="(", - index=2, - path="[?(@.some == 1 || @.some == 5)]", - ), - Token( - kind=TOKEN_SELF, - value="@", - index=3, - path="[?(@.some == 1 || @.some == 5)]", - ), - Token( - kind=TOKEN_DOT, - value=".", - index=4, - path="[?(@.some == 1 || @.some == 5)]", - ), - Token( - kind=TOKEN_NAME, - value="some", - index=5, - path="[?(@.some == 1 || @.some == 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=9, - path="[?(@.some == 1 || @.some == 5)]", - ), - Token( - kind=TOKEN_EQ, - value="==", - index=10, - path="[?(@.some == 1 || @.some == 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=12, - path="[?(@.some == 1 || @.some == 5)]", - ), - Token( - kind=TOKEN_INT, - value="1", - index=13, - path="[?(@.some == 1 || @.some == 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=14, - path="[?(@.some == 1 || @.some == 5)]", - ), - Token( - kind=TOKEN_OR, - value="||", - index=15, - path="[?(@.some == 1 || @.some == 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=17, - path="[?(@.some == 1 || @.some == 5)]", - ), - Token( - kind=TOKEN_SELF, - value="@", - index=18, - path="[?(@.some == 1 || @.some == 5)]", - ), - Token( - kind=TOKEN_DOT, - value=".", - index=19, - path="[?(@.some == 1 || @.some == 5)]", - ), - Token( - kind=TOKEN_NAME, - value="some", - index=20, - path="[?(@.some == 1 || @.some == 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=24, - path="[?(@.some == 1 || @.some == 5)]", - ), - Token( - kind=TOKEN_EQ, - value="==", - index=25, - path="[?(@.some == 1 || @.some == 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=27, - path="[?(@.some == 1 || @.some == 5)]", - ), - Token( - kind=TOKEN_INT, - value="5", - index=28, - path="[?(@.some == 1 || @.some == 5)]", - ), - Token( - kind=TOKEN_RPAREN, - value=")", - index=29, - path="[?(@.some == 1 || @.some == 5)]", - ), - Token( - kind=TOKEN_RBRACKET, - value="]", - index=30, - path="[?(@.some == 1 || @.some == 5)]", - ), - ], - ), - Case( - description="filter self dot property in list literal", - path="[?(@.thing in [1, '1'])]", - want=[ - Token( - kind=TOKEN_LBRACKET, value="[", index=0, path="[?(@.thing in [1, '1'])]" - ), - Token( - kind=TOKEN_FILTER, value="?", index=1, path="[?(@.thing in [1, '1'])]" - ), - Token( - kind=TOKEN_LPAREN, value="(", index=2, path="[?(@.thing in [1, '1'])]" - ), - Token(kind=TOKEN_SELF, value="@", index=3, path="[?(@.thing in [1, '1'])]"), - Token(kind=TOKEN_DOT, value=".", index=4, path="[?(@.thing in [1, '1'])]"), - Token( - kind=TOKEN_NAME, value="thing", index=5, path="[?(@.thing in [1, '1'])]" - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=10, - path="[?(@.thing in [1, '1'])]", - ), - Token(kind=TOKEN_IN, value="in", index=11, path="[?(@.thing in [1, '1'])]"), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=13, - path="[?(@.thing in [1, '1'])]", - ), - Token( - kind=TOKEN_LBRACKET, - value="[", - index=14, - path="[?(@.thing in [1, '1'])]", - ), - Token(kind=TOKEN_INT, value="1", index=15, path="[?(@.thing in [1, '1'])]"), - Token( - kind=TOKEN_COMMA, value=",", index=16, path="[?(@.thing in [1, '1'])]" - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=17, - path="[?(@.thing in [1, '1'])]", - ), - Token( - kind=TOKEN_SINGLE_QUOTE_STRING, - value="1", - index=19, - path="[?(@.thing in [1, '1'])]", - ), - Token( - kind=TOKEN_RBRACKET, - value="]", - index=21, - path="[?(@.thing in [1, '1'])]", - ), - Token( - kind=TOKEN_RPAREN, value=")", index=22, path="[?(@.thing in [1, '1'])]" - ), - Token( - kind=TOKEN_RBRACKET, - value="]", - index=23, - path="[?(@.thing in [1, '1'])]", - ), - ], - ), - Case( - description="filter expression with logical not", - path="[?(@.some == 1 or not @.some < 5)]", - want=[ - Token( - kind=TOKEN_LBRACKET, - value="[", - index=0, - path="[?(@.some == 1 or not @.some < 5)]", - ), - Token( - kind=TOKEN_FILTER, - value="?", - index=1, - path="[?(@.some == 1 or not @.some < 5)]", - ), - Token( - kind=TOKEN_LPAREN, - value="(", - index=2, - path="[?(@.some == 1 or not @.some < 5)]", - ), - Token( - kind=TOKEN_SELF, - value="@", - index=3, - path="[?(@.some == 1 or not @.some < 5)]", - ), - Token( - kind=TOKEN_DOT, - value=".", - index=4, - path="[?(@.some == 1 or not @.some < 5)]", - ), - Token( - kind=TOKEN_NAME, - value="some", - index=5, - path="[?(@.some == 1 or not @.some < 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=9, - path="[?(@.some == 1 or not @.some < 5)]", - ), - Token( - kind=TOKEN_EQ, - value="==", - index=10, - path="[?(@.some == 1 or not @.some < 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=12, - path="[?(@.some == 1 or not @.some < 5)]", - ), - Token( - kind=TOKEN_INT, - value="1", - index=13, - path="[?(@.some == 1 or not @.some < 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=14, - path="[?(@.some == 1 or not @.some < 5)]", - ), - Token( - kind=TOKEN_OR, - value="or", - index=15, - path="[?(@.some == 1 or not @.some < 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=17, - path="[?(@.some == 1 or not @.some < 5)]", - ), - Token( - kind=TOKEN_NOT, - value="not", - index=18, - path="[?(@.some == 1 or not @.some < 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=21, - path="[?(@.some == 1 or not @.some < 5)]", - ), - Token( - kind=TOKEN_SELF, - value="@", - index=22, - path="[?(@.some == 1 or not @.some < 5)]", - ), - Token( - kind=TOKEN_DOT, - value=".", - index=23, - path="[?(@.some == 1 or not @.some < 5)]", - ), - Token( - kind=TOKEN_NAME, - value="some", - index=24, - path="[?(@.some == 1 or not @.some < 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=28, - path="[?(@.some == 1 or not @.some < 5)]", - ), - Token( - kind=TOKEN_LT, - value="<", - index=29, - path="[?(@.some == 1 or not @.some < 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=30, - path="[?(@.some == 1 or not @.some < 5)]", - ), - Token( - kind=TOKEN_INT, - value="5", - index=31, - path="[?(@.some == 1 or not @.some < 5)]", - ), - Token( - kind=TOKEN_RPAREN, - value=")", - index=32, - path="[?(@.some == 1 or not @.some < 5)]", - ), - Token( - kind=TOKEN_RBRACKET, - value="]", - index=33, - path="[?(@.some == 1 or not @.some < 5)]", - ), - ], - ), - Case( - description="filter expression with logical not using '!'", - path="[?(@.some == 1 or !@.some < 5)]", - want=[ - Token( - kind=TOKEN_LBRACKET, - value="[", - index=0, - path="[?(@.some == 1 or !@.some < 5)]", - ), - Token( - kind=TOKEN_FILTER, - value="?", - index=1, - path="[?(@.some == 1 or !@.some < 5)]", - ), - Token( - kind=TOKEN_LPAREN, - value="(", - index=2, - path="[?(@.some == 1 or !@.some < 5)]", - ), - Token( - kind=TOKEN_SELF, - value="@", - index=3, - path="[?(@.some == 1 or !@.some < 5)]", - ), - Token( - kind=TOKEN_DOT, - value=".", - index=4, - path="[?(@.some == 1 or !@.some < 5)]", - ), - Token( - kind=TOKEN_NAME, - value="some", - index=5, - path="[?(@.some == 1 or !@.some < 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=9, - path="[?(@.some == 1 or !@.some < 5)]", - ), - Token( - kind=TOKEN_EQ, - value="==", - index=10, - path="[?(@.some == 1 or !@.some < 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=12, - path="[?(@.some == 1 or !@.some < 5)]", - ), - Token( - kind=TOKEN_INT, - value="1", - index=13, - path="[?(@.some == 1 or !@.some < 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=14, - path="[?(@.some == 1 or !@.some < 5)]", - ), - Token( - kind=TOKEN_OR, - value="or", - index=15, - path="[?(@.some == 1 or !@.some < 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=17, - path="[?(@.some == 1 or !@.some < 5)]", - ), - Token( - kind=TOKEN_NOT, - value="!", - index=18, - path="[?(@.some == 1 or !@.some < 5)]", - ), - Token( - kind=TOKEN_SELF, - value="@", - index=19, - path="[?(@.some == 1 or !@.some < 5)]", - ), - Token( - kind=TOKEN_DOT, - value=".", - index=20, - path="[?(@.some == 1 or !@.some < 5)]", - ), - Token( - kind=TOKEN_NAME, - value="some", - index=21, - path="[?(@.some == 1 or !@.some < 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=25, - path="[?(@.some == 1 or !@.some < 5)]", - ), - Token( - kind=TOKEN_LT, - value="<", - index=26, - path="[?(@.some == 1 or !@.some < 5)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=27, - path="[?(@.some == 1 or !@.some < 5)]", - ), - Token( - kind=TOKEN_INT, - value="5", - index=28, - path="[?(@.some == 1 or !@.some < 5)]", - ), - Token( - kind=TOKEN_RPAREN, - value=")", - index=29, - path="[?(@.some == 1 or !@.some < 5)]", - ), - Token( - kind=TOKEN_RBRACKET, - value="]", - index=30, - path="[?(@.some == 1 or !@.some < 5)]", - ), - ], - ), - Case( - description="filter true and false", - path="[?(true == false)]", - want=[ - Token(kind=TOKEN_LBRACKET, value="[", index=0, path="[?(true == false)]"), - Token(kind=TOKEN_FILTER, value="?", index=1, path="[?(true == false)]"), - Token(kind=TOKEN_LPAREN, value="(", index=2, path="[?(true == false)]"), - Token(kind=TOKEN_TRUE, value="true", index=3, path="[?(true == false)]"), - Token(kind=TOKEN_WHITESPACE, value=" ", index=7, path="[?(true == false)]"), - Token(kind=TOKEN_EQ, value="==", index=8, path="[?(true == false)]"), - Token( - kind=TOKEN_WHITESPACE, value=" ", index=10, path="[?(true == false)]" - ), - Token(kind=TOKEN_FALSE, value="false", index=11, path="[?(true == false)]"), - Token(kind=TOKEN_RPAREN, value=")", index=16, path="[?(true == false)]"), - Token(kind=TOKEN_RBRACKET, value="]", index=17, path="[?(true == false)]"), - ], - ), - Case( - description="filter true and false", - path="[?(nil == none && nil == null)]", - want=[ - Token( - kind=TOKEN_LBRACKET, - value="[", - index=0, - path="[?(nil == none && nil == null)]", - ), - Token( - kind=TOKEN_FILTER, - value="?", - index=1, - path="[?(nil == none && nil == null)]", - ), - Token( - kind=TOKEN_LPAREN, - value="(", - index=2, - path="[?(nil == none && nil == null)]", - ), - Token( - kind=TOKEN_NIL, - value="nil", - index=3, - path="[?(nil == none && nil == null)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=6, - path="[?(nil == none && nil == null)]", - ), - Token( - kind=TOKEN_EQ, - value="==", - index=7, - path="[?(nil == none && nil == null)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=9, - path="[?(nil == none && nil == null)]", - ), - Token( - kind=TOKEN_NIL, - value="none", - index=10, - path="[?(nil == none && nil == null)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=14, - path="[?(nil == none && nil == null)]", - ), - Token( - kind=TOKEN_AND, - value="&&", - index=15, - path="[?(nil == none && nil == null)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=17, - path="[?(nil == none && nil == null)]", - ), - Token( - kind=TOKEN_NIL, - value="nil", - index=18, - path="[?(nil == none && nil == null)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=21, - path="[?(nil == none && nil == null)]", - ), - Token( - kind=TOKEN_EQ, - value="==", - index=22, - path="[?(nil == none && nil == null)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=24, - path="[?(nil == none && nil == null)]", - ), - Token( - kind=TOKEN_NIL, - value="null", - index=25, - path="[?(nil == none && nil == null)]", - ), - Token( - kind=TOKEN_RPAREN, - value=")", - index=29, - path="[?(nil == none && nil == null)]", - ), - Token( - kind=TOKEN_RBRACKET, - value="]", - index=30, - path="[?(nil == none && nil == null)]", - ), - ], - ), - Case( - description="list of quoted properties", - path="$['some', 'thing']", - want=[ - Token(kind=TOKEN_ROOT, value="$", index=0, path="$['some', 'thing']"), - Token(kind=TOKEN_LBRACKET, value="[", index=1, path="$['some', 'thing']"), - Token( - kind=TOKEN_SINGLE_QUOTE_STRING, - value="some", - index=3, - path="$['some', 'thing']", - ), - Token(kind=TOKEN_COMMA, value=",", index=8, path="$['some', 'thing']"), - Token(kind=TOKEN_WHITESPACE, value=" ", index=9, path="$['some', 'thing']"), - Token( - kind=TOKEN_SINGLE_QUOTE_STRING, - value="thing", - index=11, - path="$['some', 'thing']", - ), - Token(kind=TOKEN_RBRACKET, value="]", index=17, path="$['some', 'thing']"), - ], - ), - Case( - description="call a function", - path="$.some[?(length(@.thing) < 2)]", - want=[ - Token( - kind=TOKEN_ROOT, - value="$", - index=0, - path="$.some[?(length(@.thing) < 2)]", - ), - Token( - kind=TOKEN_DOT, - value=".", - index=1, - path="$.some[?(length(@.thing) < 2)]", - ), - Token( - kind=TOKEN_NAME, - value="some", - index=2, - path="$.some[?(length(@.thing) < 2)]", - ), - Token( - kind=TOKEN_LBRACKET, - value="[", - index=6, - path="$.some[?(length(@.thing) < 2)]", - ), - Token( - kind=TOKEN_FILTER, - value="?", - index=7, - path="$.some[?(length(@.thing) < 2)]", - ), - Token( - kind=TOKEN_LPAREN, - value="(", - index=8, - path="$.some[?(length(@.thing) < 2)]", - ), - Token( - kind=TOKEN_FUNCTION, - value="length", - index=9, - path="$.some[?(length(@.thing) < 2)]", - ), - Token( - kind=TOKEN_LPAREN, - value="(", - index=15, - path="$.some[?(length(@.thing) < 2)]", - ), - Token( - kind=TOKEN_SELF, - value="@", - index=16, - path="$.some[?(length(@.thing) < 2)]", - ), - Token( - kind=TOKEN_DOT, - value=".", - index=17, - path="$.some[?(length(@.thing) < 2)]", - ), - Token( - kind=TOKEN_NAME, - value="thing", - index=18, - path="$.some[?(length(@.thing) < 2)]", - ), - Token( - kind=TOKEN_RPAREN, - value=")", - index=23, - path="$.some[?(length(@.thing) < 2)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=24, - path="$.some[?(length(@.thing) < 2)]", - ), - Token( - kind=TOKEN_LT, - value="<", - index=25, - path="$.some[?(length(@.thing) < 2)]", - ), - Token( - kind=TOKEN_WHITESPACE, - value=" ", - index=26, - path="$.some[?(length(@.thing) < 2)]", - ), - Token( - kind=TOKEN_INT, - value="2", - index=27, - path="$.some[?(length(@.thing) < 2)]", - ), - Token( - kind=TOKEN_RPAREN, - value=")", - index=28, - path="$.some[?(length(@.thing) < 2)]", - ), - Token( - kind=TOKEN_RBRACKET, - value="]", - index=29, - path="$.some[?(length(@.thing) < 2)]", - ), - ], - ), - Case( - description="keys selector", - path="$.thing.~", - want=[ - Token(kind=TOKEN_ROOT, value="$", index=0, path="$.thing.~"), - Token(kind=TOKEN_DOT, value=".", index=1, path="$.thing.~"), - Token(kind=TOKEN_NAME, value="thing", index=2, path="$.thing.~"), - Token(kind=TOKEN_DOT, value=".", index=7, path="$.thing.~"), - Token(kind=TOKEN_KEYS, value="~", index=8, path="$.thing.~"), - ], - ), - Case( - description="keys in list selector", - path="$.thing[~]", - want=[ - Token(kind=TOKEN_ROOT, value="$", index=0, path="$.thing[~]"), - Token(kind=TOKEN_DOT, value=".", index=1, path="$.thing[~]"), - Token(kind=TOKEN_NAME, value="thing", index=2, path="$.thing[~]"), - Token(kind=TOKEN_LBRACKET, value="[", index=7, path="$.thing[~]"), - Token(kind=TOKEN_KEYS, value="~", index=8, path="$.thing[~]"), - Token(kind=TOKEN_RBRACKET, value="]", index=9, path="$.thing[~]"), - ], - ), - Case( - description="implicit root selector, name selector starts with `and`", - path="anderson", - want=[Token(kind=TOKEN_NAME, value="anderson", index=0, path="anderson")], - ), - Case( - description="implicit root selector, name selector starts with `or`", - path="order", - want=[Token(kind=TOKEN_NAME, value="order", index=0, path="order")], - ), - Case( - description="implicit root selector, name selector starts with `true`", - path="trueblue", - want=[Token(kind=TOKEN_NAME, value="trueblue", index=0, path="trueblue")], - ), - Case( - description="implicit root selector, name selector starts with `false`", - path="falsehood", - want=[Token(kind=TOKEN_NAME, value="falsehood", index=0, path="falsehood")], - ), - Case( - description="implicit root selector, name selector starts with `not`", - path="nottingham", - want=[Token(kind=TOKEN_NAME, value="nottingham", index=0, path="nottingham")], - ), - Case( - description="implicit root selector, name selector starts with `null`", - path="nullable", - want=[Token(kind=TOKEN_NAME, value="nullable", index=0, path="nullable")], - ), - Case( - description="implicit root selector, name selector starts with `none`", - path="nonexpert", - want=[Token(kind=TOKEN_NAME, value="nonexpert", index=0, path="nonexpert")], - ), - Case( - description="implicit root selector, name selector starts with `undefined`", - path="undefinedness", - want=[ - Token(kind=TOKEN_NAME, value="undefinedness", index=0, path="undefinedness") - ], - ), - Case( - description="implicit root selector, name selector starts with `missing`", - path="missingly", - want=[Token(kind=TOKEN_NAME, value="missingly", index=0, path="missingly")], - ), -] - - @pytest.fixture() def env() -> JSONPathEnvironment: return JSONPathEnvironment() -@pytest.mark.parametrize("case", TEST_CASES, ids=operator.attrgetter("description")) +def cases() -> List[Case]: + # Deserialize tests/test_lex.json into Case objects with want as List[Token] + # Build mapping from token constant names used in JSON (e.g., "TOKEN_ROOT") + # to actual token kind values (e.g., "ROOT"). + kind_map = {name: getattr(tokmod, name) for name in dir(tokmod) if name.startswith("TOKEN_")} + # Backward-compatibility alias: some test data may use PSEUDO_ROOT to mean FAKE_ROOT + kind_map.setdefault("TOKEN_PSEUDO_ROOT", tokmod.TOKEN_FAKE_ROOT) + + def to_token(obj: dict[str, Any]) -> Token: + try: + kind_value = kind_map[obj["kind"]] + except KeyError as e: + raise KeyError(f"Unknown token kind in test_lex.json: {obj.get('kind')}\nKnown kinds: {sorted(kind_map.keys())}") from e + return Token( + kind=kind_value, + value=obj["value"], + index=obj["index"], + path=obj["path"], + ) + + with open("tests/test_lex.json", encoding="utf8") as fd: + data = json.load(fd) + + cases_list: List[Case] = [] + for case in data["tests"]: + want_tokens = [to_token(tok) for tok in case["want"]] + cases_list.append( + Case( + description=case["description"], + path=case["path"], + want=want_tokens, + ) + ) + return cases_list + +@pytest.mark.parametrize("case", cases(), ids=operator.attrgetter("description")) def test_default_lexer(env: JSONPathEnvironment, case: Case) -> None: tokens = list(env.lexer.tokenize(case.path)) assert tokens == case.want From 2c1b6319146ab7865edddf561be6898b5dc208b4 Mon Sep 17 00:00:00 2001 From: killeroonie Date: Thu, 14 Aug 2025 17:44:38 -0700 Subject: [PATCH 2/4] Fixed linter error (lines > 88), and typing error dict->Dict. --- tests/test_lex.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_lex.py b/tests/test_lex.py index 218e17d..0f2050b 100644 --- a/tests/test_lex.py +++ b/tests/test_lex.py @@ -1,7 +1,7 @@ import dataclasses import json import operator -from typing import List, Any +from typing import List, Any, Dict import pytest @@ -30,11 +30,12 @@ def cases() -> List[Case]: # Backward-compatibility alias: some test data may use PSEUDO_ROOT to mean FAKE_ROOT kind_map.setdefault("TOKEN_PSEUDO_ROOT", tokmod.TOKEN_FAKE_ROOT) - def to_token(obj: dict[str, Any]) -> Token: + def to_token(obj: Dict[str, Any]) -> Token: try: kind_value = kind_map[obj["kind"]] except KeyError as e: - raise KeyError(f"Unknown token kind in test_lex.json: {obj.get('kind')}\nKnown kinds: {sorted(kind_map.keys())}") from e + raise KeyError(f"Unknown token kind in test_lex.json: {obj.get('kind')}\nKnown kinds: " + f"{sorted(kind_map.keys())}") from e return Token( kind=kind_value, value=obj["value"], From 01bebfd142302d71cb5d913e517ce6400b14f22e Mon Sep 17 00:00:00 2001 From: killeroonie Date: Thu, 14 Aug 2025 17:44:38 -0700 Subject: [PATCH 3/4] Incorporated v2 changes to test case data. --- tests/test_lex.json | 5063 ++++++++++++++++++++++++++----------------- tests/test_lex.py | 34 +- 2 files changed, 3103 insertions(+), 1994 deletions(-) diff --git a/tests/test_lex.json b/tests/test_lex.json index 171f8e8..449e37b 100644 --- a/tests/test_lex.json +++ b/tests/test_lex.json @@ -1,1986 +1,3083 @@ { "description" : "Test cases for test_lex unit tests.", - "tests" : [ { - "description" : "just root", - "path" : "$", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$" - } ] - }, { - "description" : "just pseudo root", - "path" : "^", - "want" : [ { - "kind" : "TOKEN_PSEUDO_ROOT", - "value" : "^", - "index" : 0, - "path" : "^" - } ] - }, { - "description" : "root dot property", - "path" : "$.some.thing", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$.some.thing" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "some", - "index" : 2, - "path" : "$.some.thing" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "thing", - "index" : 7, - "path" : "$.some.thing" - } ] - }, { - "description" : "pseudo root dot property", - "path" : "^.some.thing", - "want" : [ { - "kind" : "TOKEN_PSEUDO_ROOT", - "value" : "^", - "index" : 0, - "path" : "^.some.thing" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "some", - "index" : 2, - "path" : "^.some.thing" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "thing", - "index" : 7, - "path" : "^.some.thing" - } ] - }, { - "description" : "root bracket property", - "path" : "$[some][thing]", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$[some][thing]" - }, { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 1, - "path" : "$[some][thing]" - }, { - "kind" : "TOKEN_BARE_PROPERTY", - "value" : "some", - "index" : 2, - "path" : "$[some][thing]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 6, - "path" : "$[some][thing]" - }, { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 7, - "path" : "$[some][thing]" - }, { - "kind" : "TOKEN_BARE_PROPERTY", - "value" : "thing", - "index" : 8, - "path" : "$[some][thing]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 13, - "path" : "$[some][thing]" - } ] - }, { - "description" : "root double quoted property", - "path" : "$[\"some\"]", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$[\"some\"]" - }, { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 1, - "path" : "$[\"some\"]" - }, { - "kind" : "TOKEN_DOUBLE_QUOTE_STRING", - "value" : "some", - "index" : 3, - "path" : "$[\"some\"]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 8, - "path" : "$[\"some\"]" - } ] - }, { - "description" : "root single quoted property", - "path" : "$['some']", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$['some']" - }, { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 1, - "path" : "$['some']" - }, { - "kind" : "TOKEN_SINGLE_QUOTE_STRING", - "value" : "some", - "index" : 3, - "path" : "$['some']" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 8, - "path" : "$['some']" - } ] - }, { - "description" : "root dot bracket property", - "path" : "$.[some][thing]", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$.[some][thing]" - }, { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 2, - "path" : "$.[some][thing]" - }, { - "kind" : "TOKEN_BARE_PROPERTY", - "value" : "some", - "index" : 3, - "path" : "$.[some][thing]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 7, - "path" : "$.[some][thing]" - }, { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 8, - "path" : "$.[some][thing]" - }, { - "kind" : "TOKEN_BARE_PROPERTY", - "value" : "thing", - "index" : 9, - "path" : "$.[some][thing]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 14, - "path" : "$.[some][thing]" - } ] - }, { - "description" : "root bracket index", - "path" : "$[1]", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$[1]" - }, { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 1, - "path" : "$[1]" - }, { - "kind" : "TOKEN_INT", - "value" : "1", - "index" : 2, - "path" : "$[1]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 3, - "path" : "$[1]" - } ] - }, { - "description" : "root dot bracket index", - "path" : "$.[1]", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$.[1]" - }, { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 2, - "path" : "$.[1]" - }, { - "kind" : "TOKEN_INT", - "value" : "1", - "index" : 3, - "path" : "$.[1]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 4, - "path" : "$.[1]" - } ] - }, { - "description" : "empty slice", - "path" : "[:]", - "want" : [ { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 0, - "path" : "[:]" - }, { - "kind" : "TOKEN_SLICE_START", - "value" : "", - "index" : 1, - "path" : "[:]" - }, { - "kind" : "TOKEN_SLICE_STOP", - "value" : "", - "index" : 2, - "path" : "[:]" - }, { - "kind" : "TOKEN_SLICE_STEP", - "value" : "", - "index" : -1, - "path" : "[:]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 2, - "path" : "[:]" - } ] - }, { - "description" : "empty slice empty step", - "path" : "[::]", - "want" : [ { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 0, - "path" : "[::]" - }, { - "kind" : "TOKEN_SLICE_START", - "value" : "", - "index" : 1, - "path" : "[::]" - }, { - "kind" : "TOKEN_SLICE_STOP", - "value" : "", - "index" : 2, - "path" : "[::]" - }, { - "kind" : "TOKEN_SLICE_STEP", - "value" : "", - "index" : 3, - "path" : "[::]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 3, - "path" : "[::]" - } ] - }, { - "description" : "slice empty stop", - "path" : "[1:]", - "want" : [ { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 0, - "path" : "[1:]" - }, { - "kind" : "TOKEN_SLICE_START", - "value" : "1", - "index" : 1, - "path" : "[1:]" - }, { - "kind" : "TOKEN_SLICE_STOP", - "value" : "", - "index" : 3, - "path" : "[1:]" - }, { - "kind" : "TOKEN_SLICE_STEP", - "value" : "", - "index" : -1, - "path" : "[1:]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 3, - "path" : "[1:]" - } ] - }, { - "description" : "slice empty start", - "path" : "[:-1]", - "want" : [ { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 0, - "path" : "[:-1]" - }, { - "kind" : "TOKEN_SLICE_START", - "value" : "", - "index" : 1, - "path" : "[:-1]" - }, { - "kind" : "TOKEN_SLICE_STOP", - "value" : "-1", - "index" : 2, - "path" : "[:-1]" - }, { - "kind" : "TOKEN_SLICE_STEP", - "value" : "", - "index" : -1, - "path" : "[:-1]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 4, - "path" : "[:-1]" - } ] - }, { - "description" : "slice start and stop", - "path" : "[1:7]", - "want" : [ { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 0, - "path" : "[1:7]" - }, { - "kind" : "TOKEN_SLICE_START", - "value" : "1", - "index" : 1, - "path" : "[1:7]" - }, { - "kind" : "TOKEN_SLICE_STOP", - "value" : "7", - "index" : 3, - "path" : "[1:7]" - }, { - "kind" : "TOKEN_SLICE_STEP", - "value" : "", - "index" : -1, - "path" : "[1:7]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 4, - "path" : "[1:7]" - } ] - }, { - "description" : "slice start, stop and step", - "path" : "[1:7:2]", - "want" : [ { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 0, - "path" : "[1:7:2]" - }, { - "kind" : "TOKEN_SLICE_START", - "value" : "1", - "index" : 1, - "path" : "[1:7:2]" - }, { - "kind" : "TOKEN_SLICE_STOP", - "value" : "7", - "index" : 3, - "path" : "[1:7:2]" - }, { - "kind" : "TOKEN_SLICE_STEP", - "value" : "2", - "index" : 5, - "path" : "[1:7:2]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 6, - "path" : "[1:7:2]" - } ] - }, { - "description" : "root dot wild", - "path" : "$.*", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$.*" - }, { - "kind" : "TOKEN_WILD", - "value" : "*", - "index" : 2, - "path" : "$.*" - } ] - }, { - "description" : "root bracket wild", - "path" : "$[*]", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$[*]" - }, { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 1, - "path" : "$[*]" - }, { - "kind" : "TOKEN_WILD", - "value" : "*", - "index" : 2, - "path" : "$[*]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 3, - "path" : "$[*]" - } ] - }, { - "description" : "root dot bracket wild", - "path" : "$.[*]", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$.[*]" - }, { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 2, - "path" : "$.[*]" - }, { - "kind" : "TOKEN_WILD", - "value" : "*", - "index" : 3, - "path" : "$.[*]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 4, - "path" : "$.[*]" - } ] - }, { - "description" : "root descend", - "path" : "$..", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$.." - }, { - "kind" : "TOKEN_DDOT", - "value" : "..", - "index" : 1, - "path" : "$.." - } ] - }, { - "description" : "root descend property", - "path" : "$..thing", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$..thing" - }, { - "kind" : "TOKEN_DDOT", - "value" : "..", - "index" : 1, - "path" : "$..thing" - }, { - "kind" : "TOKEN_BARE_PROPERTY", - "value" : "thing", - "index" : 3, - "path" : "$..thing" - } ] - }, { - "description" : "root descend dot property", - "path" : "$...thing", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$...thing" - }, { - "kind" : "TOKEN_DDOT", - "value" : "..", - "index" : 1, - "path" : "$...thing" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "thing", - "index" : 4, - "path" : "$...thing" - } ] - }, { - "description" : "root selector list of indices", - "path" : "$[1,4,5]", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$[1,4,5]" - }, { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 1, - "path" : "$[1,4,5]" - }, { - "kind" : "TOKEN_INT", - "value" : "1", - "index" : 2, - "path" : "$[1,4,5]" - }, { - "kind" : "TOKEN_COMMA", - "value" : ",", - "index" : 3, - "path" : "$[1,4,5]" - }, { - "kind" : "TOKEN_INT", - "value" : "4", - "index" : 4, - "path" : "$[1,4,5]" - }, { - "kind" : "TOKEN_COMMA", - "value" : ",", - "index" : 5, - "path" : "$[1,4,5]" - }, { - "kind" : "TOKEN_INT", - "value" : "5", - "index" : 6, - "path" : "$[1,4,5]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 7, - "path" : "$[1,4,5]" - } ] - }, { - "description" : "root selector list with a slice", - "path" : "$[1,4:9]", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$[1,4:9]" - }, { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 1, - "path" : "$[1,4:9]" - }, { - "kind" : "TOKEN_INT", - "value" : "1", - "index" : 2, - "path" : "$[1,4:9]" - }, { - "kind" : "TOKEN_COMMA", - "value" : ",", - "index" : 3, - "path" : "$[1,4:9]" - }, { - "kind" : "TOKEN_SLICE_START", - "value" : "4", - "index" : 4, - "path" : "$[1,4:9]" - }, { - "kind" : "TOKEN_SLICE_STOP", - "value" : "9", - "index" : 6, - "path" : "$[1,4:9]" - }, { - "kind" : "TOKEN_SLICE_STEP", - "value" : "", - "index" : -1, - "path" : "$[1,4:9]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 7, - "path" : "$[1,4:9]" - } ] - }, { - "description" : "root selector list of properties", - "path" : "$[some,thing]", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$[some,thing]" - }, { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 1, - "path" : "$[some,thing]" - }, { - "kind" : "TOKEN_BARE_PROPERTY", - "value" : "some", - "index" : 2, - "path" : "$[some,thing]" - }, { - "kind" : "TOKEN_COMMA", - "value" : ",", - "index" : 6, - "path" : "$[some,thing]" - }, { - "kind" : "TOKEN_BARE_PROPERTY", - "value" : "thing", - "index" : 7, - "path" : "$[some,thing]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 12, - "path" : "$[some,thing]" - } ] - }, { - "description" : "root dot filter on self dot property", - "path" : "$.[?(@.some)]", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$.[?(@.some)]" - }, { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 2, - "path" : "$.[?(@.some)]" - }, { - "kind" : "TOKEN_FILTER", - "value" : "?", - "index" : 3, - "path" : "$.[?(@.some)]" - }, { - "kind" : "TOKEN_LPAREN", - "value" : "(", - "index" : 4, - "path" : "$.[?(@.some)]" - }, { - "kind" : "TOKEN_SELF", - "value" : "@", - "index" : 5, - "path" : "$.[?(@.some)]" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "some", - "index" : 7, - "path" : "$.[?(@.some)]" - }, { - "kind" : "TOKEN_RPAREN", - "value" : ")", - "index" : 11, - "path" : "$.[?(@.some)]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 12, - "path" : "$.[?(@.some)]" - } ] - }, { - "description" : "root dot filter on root dot property", - "path" : "$.[?($.some)]", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$.[?($.some)]" - }, { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 2, - "path" : "$.[?($.some)]" - }, { - "kind" : "TOKEN_FILTER", - "value" : "?", - "index" : 3, - "path" : "$.[?($.some)]" - }, { - "kind" : "TOKEN_LPAREN", - "value" : "(", - "index" : 4, - "path" : "$.[?($.some)]" - }, { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 5, - "path" : "$.[?($.some)]" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "some", - "index" : 7, - "path" : "$.[?($.some)]" - }, { - "kind" : "TOKEN_RPAREN", - "value" : ")", - "index" : 11, - "path" : "$.[?($.some)]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 12, - "path" : "$.[?($.some)]" - } ] - }, { - "description" : "root dot filter on self index", - "path" : "$.[?(@[1])]", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$.[?(@[1])]" - }, { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 2, - "path" : "$.[?(@[1])]" - }, { - "kind" : "TOKEN_FILTER", - "value" : "?", - "index" : 3, - "path" : "$.[?(@[1])]" - }, { - "kind" : "TOKEN_LPAREN", - "value" : "(", - "index" : 4, - "path" : "$.[?(@[1])]" - }, { - "kind" : "TOKEN_SELF", - "value" : "@", - "index" : 5, - "path" : "$.[?(@[1])]" - }, { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 6, - "path" : "$.[?(@[1])]" - }, { - "kind" : "TOKEN_INT", - "value" : "1", - "index" : 7, - "path" : "$.[?(@[1])]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 8, - "path" : "$.[?(@[1])]" - }, { - "kind" : "TOKEN_RPAREN", - "value" : ")", - "index" : 9, - "path" : "$.[?(@[1])]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 10, - "path" : "$.[?(@[1])]" - } ] - }, { - "description" : "filter self dot property equality with float", - "path" : "[?(@.some == 1.1)]", - "want" : [ { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 0, - "path" : "[?(@.some == 1.1)]" - }, { - "kind" : "TOKEN_FILTER", - "value" : "?", - "index" : 1, - "path" : "[?(@.some == 1.1)]" - }, { - "kind" : "TOKEN_LPAREN", - "value" : "(", - "index" : 2, - "path" : "[?(@.some == 1.1)]" - }, { - "kind" : "TOKEN_SELF", - "value" : "@", - "index" : 3, - "path" : "[?(@.some == 1.1)]" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "some", - "index" : 5, - "path" : "[?(@.some == 1.1)]" - }, { - "kind" : "TOKEN_EQ", - "value" : "==", - "index" : 10, - "path" : "[?(@.some == 1.1)]" - }, { - "kind" : "TOKEN_FLOAT", - "value" : "1.1", - "index" : 13, - "path" : "[?(@.some == 1.1)]" - }, { - "kind" : "TOKEN_RPAREN", - "value" : ")", - "index" : 16, - "path" : "[?(@.some == 1.1)]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 17, - "path" : "[?(@.some == 1.1)]" - } ] - }, { - "description" : "filter self dot property equality with float in scientific notation", - "path" : "[?(@.some == 1.1e10)]", - "want" : [ { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 0, - "path" : "[?(@.some == 1.1e10)]" - }, { - "kind" : "TOKEN_FILTER", - "value" : "?", - "index" : 1, - "path" : "[?(@.some == 1.1e10)]" - }, { - "kind" : "TOKEN_LPAREN", - "value" : "(", - "index" : 2, - "path" : "[?(@.some == 1.1e10)]" - }, { - "kind" : "TOKEN_SELF", - "value" : "@", - "index" : 3, - "path" : "[?(@.some == 1.1e10)]" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "some", - "index" : 5, - "path" : "[?(@.some == 1.1e10)]" - }, { - "kind" : "TOKEN_EQ", - "value" : "==", - "index" : 10, - "path" : "[?(@.some == 1.1e10)]" - }, { - "kind" : "TOKEN_FLOAT", - "value" : "1.1e10", - "index" : 13, - "path" : "[?(@.some == 1.1e10)]" - }, { - "kind" : "TOKEN_RPAREN", - "value" : ")", - "index" : 19, - "path" : "[?(@.some == 1.1e10)]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 20, - "path" : "[?(@.some == 1.1e10)]" - } ] - }, { - "description" : "filter self index equality with float", - "path" : "[?(@[1] == 1.1)]", - "want" : [ { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 0, - "path" : "[?(@[1] == 1.1)]" - }, { - "kind" : "TOKEN_FILTER", - "value" : "?", - "index" : 1, - "path" : "[?(@[1] == 1.1)]" - }, { - "kind" : "TOKEN_LPAREN", - "value" : "(", - "index" : 2, - "path" : "[?(@[1] == 1.1)]" - }, { - "kind" : "TOKEN_SELF", - "value" : "@", - "index" : 3, - "path" : "[?(@[1] == 1.1)]" - }, { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 4, - "path" : "[?(@[1] == 1.1)]" - }, { - "kind" : "TOKEN_INT", - "value" : "1", - "index" : 5, - "path" : "[?(@[1] == 1.1)]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 6, - "path" : "[?(@[1] == 1.1)]" - }, { - "kind" : "TOKEN_EQ", - "value" : "==", - "index" : 8, - "path" : "[?(@[1] == 1.1)]" - }, { - "kind" : "TOKEN_FLOAT", - "value" : "1.1", - "index" : 11, - "path" : "[?(@[1] == 1.1)]" - }, { - "kind" : "TOKEN_RPAREN", - "value" : ")", - "index" : 14, - "path" : "[?(@[1] == 1.1)]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 15, - "path" : "[?(@[1] == 1.1)]" - } ] - }, { - "description" : "filter self dot property equality with int", - "path" : "[?(@.some == 1)]", - "want" : [ { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 0, - "path" : "[?(@.some == 1)]" - }, { - "kind" : "TOKEN_FILTER", - "value" : "?", - "index" : 1, - "path" : "[?(@.some == 1)]" - }, { - "kind" : "TOKEN_LPAREN", - "value" : "(", - "index" : 2, - "path" : "[?(@.some == 1)]" - }, { - "kind" : "TOKEN_SELF", - "value" : "@", - "index" : 3, - "path" : "[?(@.some == 1)]" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "some", - "index" : 5, - "path" : "[?(@.some == 1)]" - }, { - "kind" : "TOKEN_EQ", - "value" : "==", - "index" : 10, - "path" : "[?(@.some == 1)]" - }, { - "kind" : "TOKEN_INT", - "value" : "1", - "index" : 13, - "path" : "[?(@.some == 1)]" - }, { - "kind" : "TOKEN_RPAREN", - "value" : ")", - "index" : 14, - "path" : "[?(@.some == 1)]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 15, - "path" : "[?(@.some == 1)]" - } ] - }, { - "description" : "filter self dot property equality with int in scientific notation", - "path" : "[?(@.some == 1e10)]", - "want" : [ { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 0, - "path" : "[?(@.some == 1e10)]" - }, { - "kind" : "TOKEN_FILTER", - "value" : "?", - "index" : 1, - "path" : "[?(@.some == 1e10)]" - }, { - "kind" : "TOKEN_LPAREN", - "value" : "(", - "index" : 2, - "path" : "[?(@.some == 1e10)]" - }, { - "kind" : "TOKEN_SELF", - "value" : "@", - "index" : 3, - "path" : "[?(@.some == 1e10)]" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "some", - "index" : 5, - "path" : "[?(@.some == 1e10)]" - }, { - "kind" : "TOKEN_EQ", - "value" : "==", - "index" : 10, - "path" : "[?(@.some == 1e10)]" - }, { - "kind" : "TOKEN_INT", - "value" : "1e10", - "index" : 13, - "path" : "[?(@.some == 1e10)]" - }, { - "kind" : "TOKEN_RPAREN", - "value" : ")", - "index" : 17, - "path" : "[?(@.some == 1e10)]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 18, - "path" : "[?(@.some == 1e10)]" - } ] - }, { - "description" : "filter self dot property regex", - "path" : "[?(@.some =~ /foo|bar/i)]", - "want" : [ { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 0, - "path" : "[?(@.some =~ /foo|bar/i)]" - }, { - "kind" : "TOKEN_FILTER", - "value" : "?", - "index" : 1, - "path" : "[?(@.some =~ /foo|bar/i)]" - }, { - "kind" : "TOKEN_LPAREN", - "value" : "(", - "index" : 2, - "path" : "[?(@.some =~ /foo|bar/i)]" - }, { - "kind" : "TOKEN_SELF", - "value" : "@", - "index" : 3, - "path" : "[?(@.some =~ /foo|bar/i)]" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "some", - "index" : 5, - "path" : "[?(@.some =~ /foo|bar/i)]" - }, { - "kind" : "TOKEN_RE", - "value" : "=~", - "index" : 10, - "path" : "[?(@.some =~ /foo|bar/i)]" - }, { - "kind" : "TOKEN_RE_PATTERN", - "value" : "foo|bar", - "index" : 14, - "path" : "[?(@.some =~ /foo|bar/i)]" - }, { - "kind" : "TOKEN_RE_FLAGS", - "value" : "i", - "index" : 22, - "path" : "[?(@.some =~ /foo|bar/i)]" - }, { - "kind" : "TOKEN_RPAREN", - "value" : ")", - "index" : 23, - "path" : "[?(@.some =~ /foo|bar/i)]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 24, - "path" : "[?(@.some =~ /foo|bar/i)]" - } ] - }, { - "description" : "union of two paths", - "path" : "$.some | $.thing", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$.some | $.thing" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "some", - "index" : 2, - "path" : "$.some | $.thing" - }, { - "kind" : "TOKEN_UNION", - "value" : "|", - "index" : 7, - "path" : "$.some | $.thing" - }, { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 9, - "path" : "$.some | $.thing" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "thing", - "index" : 11, - "path" : "$.some | $.thing" - } ] - }, { - "description" : "union of three paths", - "path" : "$.some | $.thing | $.other", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$.some | $.thing | $.other" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "some", - "index" : 2, - "path" : "$.some | $.thing | $.other" - }, { - "kind" : "TOKEN_UNION", - "value" : "|", - "index" : 7, - "path" : "$.some | $.thing | $.other" - }, { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 9, - "path" : "$.some | $.thing | $.other" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "thing", - "index" : 11, - "path" : "$.some | $.thing | $.other" - }, { - "kind" : "TOKEN_UNION", - "value" : "|", - "index" : 17, - "path" : "$.some | $.thing | $.other" - }, { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 19, - "path" : "$.some | $.thing | $.other" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "other", - "index" : 21, - "path" : "$.some | $.thing | $.other" - } ] - }, { - "description" : "intersection two paths", - "path" : "$.some & $.thing", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$.some & $.thing" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "some", - "index" : 2, - "path" : "$.some & $.thing" - }, { - "kind" : "TOKEN_INTERSECTION", - "value" : "&", - "index" : 7, - "path" : "$.some & $.thing" - }, { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 9, - "path" : "$.some & $.thing" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "thing", - "index" : 11, - "path" : "$.some & $.thing" - } ] - }, { - "description" : "filter expression with logical and", - "path" : "[?(@.some > 1 and @.some < 5)]", - "want" : [ { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 0, - "path" : "[?(@.some > 1 and @.some < 5)]" - }, { - "kind" : "TOKEN_FILTER", - "value" : "?", - "index" : 1, - "path" : "[?(@.some > 1 and @.some < 5)]" - }, { - "kind" : "TOKEN_LPAREN", - "value" : "(", - "index" : 2, - "path" : "[?(@.some > 1 and @.some < 5)]" - }, { - "kind" : "TOKEN_SELF", - "value" : "@", - "index" : 3, - "path" : "[?(@.some > 1 and @.some < 5)]" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "some", - "index" : 5, - "path" : "[?(@.some > 1 and @.some < 5)]" - }, { - "kind" : "TOKEN_GT", - "value" : ">", - "index" : 10, - "path" : "[?(@.some > 1 and @.some < 5)]" - }, { - "kind" : "TOKEN_INT", - "value" : "1", - "index" : 12, - "path" : "[?(@.some > 1 and @.some < 5)]" - }, { - "kind" : "TOKEN_AND", - "value" : "and", - "index" : 14, - "path" : "[?(@.some > 1 and @.some < 5)]" - }, { - "kind" : "TOKEN_SELF", - "value" : "@", - "index" : 18, - "path" : "[?(@.some > 1 and @.some < 5)]" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "some", - "index" : 20, - "path" : "[?(@.some > 1 and @.some < 5)]" - }, { - "kind" : "TOKEN_LT", - "value" : "<", - "index" : 25, - "path" : "[?(@.some > 1 and @.some < 5)]" - }, { - "kind" : "TOKEN_INT", - "value" : "5", - "index" : 27, - "path" : "[?(@.some > 1 and @.some < 5)]" - }, { - "kind" : "TOKEN_RPAREN", - "value" : ")", - "index" : 28, - "path" : "[?(@.some > 1 and @.some < 5)]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 29, - "path" : "[?(@.some > 1 and @.some < 5)]" - } ] - }, { - "description" : "filter expression with logical or", - "path" : "[?(@.some == 1 or @.some == 5)]", - "want" : [ { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 0, - "path" : "[?(@.some == 1 or @.some == 5)]" - }, { - "kind" : "TOKEN_FILTER", - "value" : "?", - "index" : 1, - "path" : "[?(@.some == 1 or @.some == 5)]" - }, { - "kind" : "TOKEN_LPAREN", - "value" : "(", - "index" : 2, - "path" : "[?(@.some == 1 or @.some == 5)]" - }, { - "kind" : "TOKEN_SELF", - "value" : "@", - "index" : 3, - "path" : "[?(@.some == 1 or @.some == 5)]" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "some", - "index" : 5, - "path" : "[?(@.some == 1 or @.some == 5)]" - }, { - "kind" : "TOKEN_EQ", - "value" : "==", - "index" : 10, - "path" : "[?(@.some == 1 or @.some == 5)]" - }, { - "kind" : "TOKEN_INT", - "value" : "1", - "index" : 13, - "path" : "[?(@.some == 1 or @.some == 5)]" - }, { - "kind" : "TOKEN_OR", - "value" : "or", - "index" : 15, - "path" : "[?(@.some == 1 or @.some == 5)]" - }, { - "kind" : "TOKEN_SELF", - "value" : "@", - "index" : 18, - "path" : "[?(@.some == 1 or @.some == 5)]" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "some", - "index" : 20, - "path" : "[?(@.some == 1 or @.some == 5)]" - }, { - "kind" : "TOKEN_EQ", - "value" : "==", - "index" : 25, - "path" : "[?(@.some == 1 or @.some == 5)]" - }, { - "kind" : "TOKEN_INT", - "value" : "5", - "index" : 28, - "path" : "[?(@.some == 1 or @.some == 5)]" - }, { - "kind" : "TOKEN_RPAREN", - "value" : ")", - "index" : 29, - "path" : "[?(@.some == 1 or @.some == 5)]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 30, - "path" : "[?(@.some == 1 or @.some == 5)]" - } ] - }, { - "description" : "filter expression with logical ||", - "path" : "[?(@.some == 1 || @.some == 5)]", - "want" : [ { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 0, - "path" : "[?(@.some == 1 || @.some == 5)]" - }, { - "kind" : "TOKEN_FILTER", - "value" : "?", - "index" : 1, - "path" : "[?(@.some == 1 || @.some == 5)]" - }, { - "kind" : "TOKEN_LPAREN", - "value" : "(", - "index" : 2, - "path" : "[?(@.some == 1 || @.some == 5)]" - }, { - "kind" : "TOKEN_SELF", - "value" : "@", - "index" : 3, - "path" : "[?(@.some == 1 || @.some == 5)]" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "some", - "index" : 5, - "path" : "[?(@.some == 1 || @.some == 5)]" - }, { - "kind" : "TOKEN_EQ", - "value" : "==", - "index" : 10, - "path" : "[?(@.some == 1 || @.some == 5)]" - }, { - "kind" : "TOKEN_INT", - "value" : "1", - "index" : 13, - "path" : "[?(@.some == 1 || @.some == 5)]" - }, { - "kind" : "TOKEN_OR", - "value" : "||", - "index" : 15, - "path" : "[?(@.some == 1 || @.some == 5)]" - }, { - "kind" : "TOKEN_SELF", - "value" : "@", - "index" : 18, - "path" : "[?(@.some == 1 || @.some == 5)]" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "some", - "index" : 20, - "path" : "[?(@.some == 1 || @.some == 5)]" - }, { - "kind" : "TOKEN_EQ", - "value" : "==", - "index" : 25, - "path" : "[?(@.some == 1 || @.some == 5)]" - }, { - "kind" : "TOKEN_INT", - "value" : "5", - "index" : 28, - "path" : "[?(@.some == 1 || @.some == 5)]" - }, { - "kind" : "TOKEN_RPAREN", - "value" : ")", - "index" : 29, - "path" : "[?(@.some == 1 || @.some == 5)]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 30, - "path" : "[?(@.some == 1 || @.some == 5)]" - } ] - }, { - "description" : "filter self dot property in list literal", - "path" : "[?(@.thing in [1, '1'])]", - "want" : [ { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 0, - "path" : "[?(@.thing in [1, '1'])]" - }, { - "kind" : "TOKEN_FILTER", - "value" : "?", - "index" : 1, - "path" : "[?(@.thing in [1, '1'])]" - }, { - "kind" : "TOKEN_LPAREN", - "value" : "(", - "index" : 2, - "path" : "[?(@.thing in [1, '1'])]" - }, { - "kind" : "TOKEN_SELF", - "value" : "@", - "index" : 3, - "path" : "[?(@.thing in [1, '1'])]" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "thing", - "index" : 5, - "path" : "[?(@.thing in [1, '1'])]" - }, { - "kind" : "TOKEN_IN", - "value" : "in", - "index" : 11, - "path" : "[?(@.thing in [1, '1'])]" - }, { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 14, - "path" : "[?(@.thing in [1, '1'])]" - }, { - "kind" : "TOKEN_INT", - "value" : "1", - "index" : 15, - "path" : "[?(@.thing in [1, '1'])]" - }, { - "kind" : "TOKEN_COMMA", - "value" : ",", - "index" : 16, - "path" : "[?(@.thing in [1, '1'])]" - }, { - "kind" : "TOKEN_SINGLE_QUOTE_STRING", - "value" : "1", - "index" : 19, - "path" : "[?(@.thing in [1, '1'])]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 21, - "path" : "[?(@.thing in [1, '1'])]" - }, { - "kind" : "TOKEN_RPAREN", - "value" : ")", - "index" : 22, - "path" : "[?(@.thing in [1, '1'])]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 23, - "path" : "[?(@.thing in [1, '1'])]" - } ] - }, { - "description" : "filter expression with logical not", - "path" : "[?(@.some == 1 or not @.some < 5)]", - "want" : [ { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 0, - "path" : "[?(@.some == 1 or not @.some < 5)]" - }, { - "kind" : "TOKEN_FILTER", - "value" : "?", - "index" : 1, - "path" : "[?(@.some == 1 or not @.some < 5)]" - }, { - "kind" : "TOKEN_LPAREN", - "value" : "(", - "index" : 2, - "path" : "[?(@.some == 1 or not @.some < 5)]" - }, { - "kind" : "TOKEN_SELF", - "value" : "@", - "index" : 3, - "path" : "[?(@.some == 1 or not @.some < 5)]" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "some", - "index" : 5, - "path" : "[?(@.some == 1 or not @.some < 5)]" - }, { - "kind" : "TOKEN_EQ", - "value" : "==", - "index" : 10, - "path" : "[?(@.some == 1 or not @.some < 5)]" - }, { - "kind" : "TOKEN_INT", - "value" : "1", - "index" : 13, - "path" : "[?(@.some == 1 or not @.some < 5)]" - }, { - "kind" : "TOKEN_OR", - "value" : "or", - "index" : 15, - "path" : "[?(@.some == 1 or not @.some < 5)]" - }, { - "kind" : "TOKEN_NOT", - "value" : "not", - "index" : 18, - "path" : "[?(@.some == 1 or not @.some < 5)]" - }, { - "kind" : "TOKEN_SELF", - "value" : "@", - "index" : 22, - "path" : "[?(@.some == 1 or not @.some < 5)]" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "some", - "index" : 24, - "path" : "[?(@.some == 1 or not @.some < 5)]" - }, { - "kind" : "TOKEN_LT", - "value" : "<", - "index" : 29, - "path" : "[?(@.some == 1 or not @.some < 5)]" - }, { - "kind" : "TOKEN_INT", - "value" : "5", - "index" : 31, - "path" : "[?(@.some == 1 or not @.some < 5)]" - }, { - "kind" : "TOKEN_RPAREN", - "value" : ")", - "index" : 32, - "path" : "[?(@.some == 1 or not @.some < 5)]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 33, - "path" : "[?(@.some == 1 or not @.some < 5)]" - } ] - }, { - "description" : "filter expression with logical not using '!'", - "path" : "[?(@.some == 1 or !@.some < 5)]", - "want" : [ { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 0, - "path" : "[?(@.some == 1 or !@.some < 5)]" - }, { - "kind" : "TOKEN_FILTER", - "value" : "?", - "index" : 1, - "path" : "[?(@.some == 1 or !@.some < 5)]" - }, { - "kind" : "TOKEN_LPAREN", - "value" : "(", - "index" : 2, - "path" : "[?(@.some == 1 or !@.some < 5)]" - }, { - "kind" : "TOKEN_SELF", - "value" : "@", - "index" : 3, - "path" : "[?(@.some == 1 or !@.some < 5)]" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "some", - "index" : 5, - "path" : "[?(@.some == 1 or !@.some < 5)]" - }, { - "kind" : "TOKEN_EQ", - "value" : "==", - "index" : 10, - "path" : "[?(@.some == 1 or !@.some < 5)]" - }, { - "kind" : "TOKEN_INT", - "value" : "1", - "index" : 13, - "path" : "[?(@.some == 1 or !@.some < 5)]" - }, { - "kind" : "TOKEN_OR", - "value" : "or", - "index" : 15, - "path" : "[?(@.some == 1 or !@.some < 5)]" - }, { - "kind" : "TOKEN_NOT", - "value" : "!", - "index" : 18, - "path" : "[?(@.some == 1 or !@.some < 5)]" - }, { - "kind" : "TOKEN_SELF", - "value" : "@", - "index" : 19, - "path" : "[?(@.some == 1 or !@.some < 5)]" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "some", - "index" : 21, - "path" : "[?(@.some == 1 or !@.some < 5)]" - }, { - "kind" : "TOKEN_LT", - "value" : "<", - "index" : 26, - "path" : "[?(@.some == 1 or !@.some < 5)]" - }, { - "kind" : "TOKEN_INT", - "value" : "5", - "index" : 28, - "path" : "[?(@.some == 1 or !@.some < 5)]" - }, { - "kind" : "TOKEN_RPAREN", - "value" : ")", - "index" : 29, - "path" : "[?(@.some == 1 or !@.some < 5)]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 30, - "path" : "[?(@.some == 1 or !@.some < 5)]" - } ] - }, { - "description" : "filter true and false", - "path" : "[?(true == false)]", - "want" : [ { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 0, - "path" : "[?(true == false)]" - }, { - "kind" : "TOKEN_FILTER", - "value" : "?", - "index" : 1, - "path" : "[?(true == false)]" - }, { - "kind" : "TOKEN_LPAREN", - "value" : "(", - "index" : 2, - "path" : "[?(true == false)]" - }, { - "kind" : "TOKEN_TRUE", - "value" : "true", - "index" : 3, - "path" : "[?(true == false)]" - }, { - "kind" : "TOKEN_EQ", - "value" : "==", - "index" : 8, - "path" : "[?(true == false)]" - }, { - "kind" : "TOKEN_FALSE", - "value" : "false", - "index" : 11, - "path" : "[?(true == false)]" - }, { - "kind" : "TOKEN_RPAREN", - "value" : ")", - "index" : 16, - "path" : "[?(true == false)]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 17, - "path" : "[?(true == false)]" - } ] - }, { - "description" : "filter true and false", - "path" : "[?(nil == none && nil == null)]", - "want" : [ { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 0, - "path" : "[?(nil == none && nil == null)]" - }, { - "kind" : "TOKEN_FILTER", - "value" : "?", - "index" : 1, - "path" : "[?(nil == none && nil == null)]" - }, { - "kind" : "TOKEN_LPAREN", - "value" : "(", - "index" : 2, - "path" : "[?(nil == none && nil == null)]" - }, { - "kind" : "TOKEN_NIL", - "value" : "nil", - "index" : 3, - "path" : "[?(nil == none && nil == null)]" - }, { - "kind" : "TOKEN_EQ", - "value" : "==", - "index" : 7, - "path" : "[?(nil == none && nil == null)]" - }, { - "kind" : "TOKEN_NIL", - "value" : "none", - "index" : 10, - "path" : "[?(nil == none && nil == null)]" - }, { - "kind" : "TOKEN_AND", - "value" : "&&", - "index" : 15, - "path" : "[?(nil == none && nil == null)]" - }, { - "kind" : "TOKEN_NIL", - "value" : "nil", - "index" : 18, - "path" : "[?(nil == none && nil == null)]" - }, { - "kind" : "TOKEN_EQ", - "value" : "==", - "index" : 22, - "path" : "[?(nil == none && nil == null)]" - }, { - "kind" : "TOKEN_NIL", - "value" : "null", - "index" : 25, - "path" : "[?(nil == none && nil == null)]" - }, { - "kind" : "TOKEN_RPAREN", - "value" : ")", - "index" : 29, - "path" : "[?(nil == none && nil == null)]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 30, - "path" : "[?(nil == none && nil == null)]" - } ] - }, { - "description" : "list of quoted properties", - "path" : "$['some', 'thing']", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$['some', 'thing']" - }, { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 1, - "path" : "$['some', 'thing']" - }, { - "kind" : "TOKEN_SINGLE_QUOTE_STRING", - "value" : "some", - "index" : 3, - "path" : "$['some', 'thing']" - }, { - "kind" : "TOKEN_COMMA", - "value" : ",", - "index" : 8, - "path" : "$['some', 'thing']" - }, { - "kind" : "TOKEN_SINGLE_QUOTE_STRING", - "value" : "thing", - "index" : 11, - "path" : "$['some', 'thing']" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 17, - "path" : "$['some', 'thing']" - } ] - }, { - "description" : "call a function", - "path" : "$.some[?(length(@.thing) < 2)]", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$.some[?(length(@.thing) < 2)]" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "some", - "index" : 2, - "path" : "$.some[?(length(@.thing) < 2)]" - }, { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 6, - "path" : "$.some[?(length(@.thing) < 2)]" - }, { - "kind" : "TOKEN_FILTER", - "value" : "?", - "index" : 7, - "path" : "$.some[?(length(@.thing) < 2)]" - }, { - "kind" : "TOKEN_LPAREN", - "value" : "(", - "index" : 8, - "path" : "$.some[?(length(@.thing) < 2)]" - }, { - "kind" : "TOKEN_FUNCTION", - "value" : "length", - "index" : 9, - "path" : "$.some[?(length(@.thing) < 2)]" - }, { - "kind" : "TOKEN_SELF", - "value" : "@", - "index" : 16, - "path" : "$.some[?(length(@.thing) < 2)]" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "thing", - "index" : 18, - "path" : "$.some[?(length(@.thing) < 2)]" - }, { - "kind" : "TOKEN_RPAREN", - "value" : ")", - "index" : 23, - "path" : "$.some[?(length(@.thing) < 2)]" - }, { - "kind" : "TOKEN_LT", - "value" : "<", - "index" : 25, - "path" : "$.some[?(length(@.thing) < 2)]" - }, { - "kind" : "TOKEN_INT", - "value" : "2", - "index" : 27, - "path" : "$.some[?(length(@.thing) < 2)]" - }, { - "kind" : "TOKEN_RPAREN", - "value" : ")", - "index" : 28, - "path" : "$.some[?(length(@.thing) < 2)]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 29, - "path" : "$.some[?(length(@.thing) < 2)]" - } ] - }, { - "description" : "keys selector", - "path" : "$.thing.~", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$.thing.~" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "thing", - "index" : 2, - "path" : "$.thing.~" - }, { - "kind" : "TOKEN_KEYS", - "value" : "~", - "index" : 8, - "path" : "$.thing.~" - } ] - }, { - "description" : "keys in list selector", - "path" : "$.thing[~]", - "want" : [ { - "kind" : "TOKEN_ROOT", - "value" : "$", - "index" : 0, - "path" : "$.thing[~]" - }, { - "kind" : "TOKEN_PROPERTY", - "value" : "thing", - "index" : 2, - "path" : "$.thing[~]" - }, { - "kind" : "TOKEN_LIST_START", - "value" : "[", - "index" : 7, - "path" : "$.thing[~]" - }, { - "kind" : "TOKEN_KEYS", - "value" : "~", - "index" : 8, - "path" : "$.thing[~]" - }, { - "kind" : "TOKEN_RBRACKET", - "value" : "]", - "index" : 9, - "path" : "$.thing[~]" - } ] - }, { - "description" : "implicit root selector, name selector starts with `and`", - "path" : "anderson", - "want" : [ { - "kind" : "TOKEN_BARE_PROPERTY", - "value" : "anderson", - "index" : 0, - "path" : "anderson" - } ] - }, { - "description" : "implicit root selector, name selector starts with `or`", - "path" : "order", - "want" : [ { - "kind" : "TOKEN_BARE_PROPERTY", - "value" : "order", - "index" : 0, - "path" : "order" - } ] - }, { - "description" : "implicit root selector, name selector starts with `true`", - "path" : "trueblue", - "want" : [ { - "kind" : "TOKEN_BARE_PROPERTY", - "value" : "trueblue", - "index" : 0, - "path" : "trueblue" - } ] - }, { - "description" : "implicit root selector, name selector starts with `false`", - "path" : "falsehood", - "want" : [ { - "kind" : "TOKEN_BARE_PROPERTY", - "value" : "falsehood", - "index" : 0, - "path" : "falsehood" - } ] - }, { - "description" : "implicit root selector, name selector starts with `not`", - "path" : "nottingham", - "want" : [ { - "kind" : "TOKEN_BARE_PROPERTY", - "value" : "nottingham", - "index" : 0, - "path" : "nottingham" - } ] - }, { - "description" : "implicit root selector, name selector starts with `null`", - "path" : "nullable", - "want" : [ { - "kind" : "TOKEN_BARE_PROPERTY", - "value" : "nullable", - "index" : 0, - "path" : "nullable" - } ] - }, { - "description" : "implicit root selector, name selector starts with `none`", - "path" : "nonexpert", - "want" : [ { - "kind" : "TOKEN_BARE_PROPERTY", - "value" : "nonexpert", - "index" : 0, - "path" : "nonexpert" - } ] - }, { - "description" : "implicit root selector, name selector starts with `undefined`", - "path" : "undefinedness", - "want" : [ { - "kind" : "TOKEN_BARE_PROPERTY", - "value" : "undefinedness", - "index" : 0, - "path" : "undefinedness" - } ] - }, { - "description" : "implicit root selector, name selector starts with `missing`", - "path" : "missingly", - "want" : [ { - "kind" : "TOKEN_BARE_PROPERTY", - "value" : "missingly", - "index" : 0, - "path" : "missingly" - } ] - } ] + "tests": [ + { + "description": "just root", + "path": "$", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$" + } + ] + }, + { + "description": "just pseudo-root", + "path": "^", + "want": [ + { + "kind": "TOKEN_PSEUDO_ROOT", + "value": "^", + "index": 0, + "path": "^" + } + ] + }, + { + "description": "root dot property", + "path": "$.some.thing", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$.some.thing" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 1, + "path": "$.some.thing" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 2, + "path": "$.some.thing" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 6, + "path": "$.some.thing" + }, + { + "kind": "TOKEN_NAME", + "value": "thing", + "index": 7, + "path": "$.some.thing" + } + ] + }, + { + "description": "pseudo root dot property", + "path": "^.some.thing", + "want": [ + { + "kind": "TOKEN_PSEUDO_ROOT", + "value": "^", + "index": 0, + "path": "^.some.thing" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 1, + "path": "^.some.thing" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 2, + "path": "^.some.thing" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 6, + "path": "^.some.thing" + }, + { + "kind": "TOKEN_NAME", + "value": "thing", + "index": 7, + "path": "^.some.thing" + } + ] + }, + { + "description": "root bracket property", + "path": "$[some][thing]", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$[some][thing]" + }, + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 1, + "path": "$[some][thing]" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 2, + "path": "$[some][thing]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 6, + "path": "$[some][thing]" + }, + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 7, + "path": "$[some][thing]" + }, + { + "kind": "TOKEN_NAME", + "value": "thing", + "index": 8, + "path": "$[some][thing]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 13, + "path": "$[some][thing]" + } + ] + }, + { + "description": "root double quoted property", + "path": "$[\"some\"]", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$[\"some\"]" + }, + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 1, + "path": "$[\"some\"]" + }, + { + "kind": "TOKEN_DOUBLE_QUOTE_STRING", + "value": "some", + "index": 3, + "path": "$[\"some\"]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 8, + "path": "$[\"some\"]" + } + ] + }, + { + "description": "root single quoted property", + "path": "$['some']", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$['some']" + }, + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 1, + "path": "$['some']" + }, + { + "kind": "TOKEN_SINGLE_QUOTE_STRING", + "value": "some", + "index": 3, + "path": "$['some']" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 8, + "path": "$['some']" + } + ] + }, + { + "description": "root dot bracket property", + "path": "$.[some][thing]", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$.[some][thing]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 1, + "path": "$.[some][thing]" + }, + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 2, + "path": "$.[some][thing]" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 3, + "path": "$.[some][thing]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 7, + "path": "$.[some][thing]" + }, + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 8, + "path": "$.[some][thing]" + }, + { + "kind": "TOKEN_NAME", + "value": "thing", + "index": 9, + "path": "$.[some][thing]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 14, + "path": "$.[some][thing]" + } + ] + }, + { + "description": "root bracket index", + "path": "$[1]", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$[1]" + }, + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 1, + "path": "$[1]" + }, + { + "kind": "TOKEN_INT", + "value": "1", + "index": 2, + "path": "$[1]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 3, + "path": "$[1]" + } + ] + }, + { + "description": "root dot bracket index", + "path": "$.[1]", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$.[1]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 1, + "path": "$.[1]" + }, + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 2, + "path": "$.[1]" + }, + { + "kind": "TOKEN_INT", + "value": "1", + "index": 3, + "path": "$.[1]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 4, + "path": "$.[1]" + } + ] + }, + { + "description": "empty slice", + "path": "[:]", + "want": [ + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 0, + "path": "[:]" + }, + { + "kind": "TOKEN_COLON", + "value": ":", + "index": 1, + "path": "[:]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 2, + "path": "[:]" + } + ] + }, + { + "description": "empty slice empty step", + "path": "[::]", + "want": [ + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 0, + "path": "[::]" + }, + { + "kind": "TOKEN_COLON", + "value": ":", + "index": 1, + "path": "[::]" + }, + { + "kind": "TOKEN_COLON", + "value": ":", + "index": 2, + "path": "[::]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 3, + "path": "[::]" + } + ] + }, + { + "description": "slice empty stop", + "path": "[1:]", + "want": [ + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 0, + "path": "[1:]" + }, + { + "kind": "TOKEN_INT", + "value": "1", + "index": 1, + "path": "[1:]" + }, + { + "kind": "TOKEN_COLON", + "value": ":", + "index": 2, + "path": "[1:]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 3, + "path": "[1:]" + } + ] + }, + { + "description": "slice empty start", + "path": "[:-1]", + "want": [ + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 0, + "path": "[:-1]" + }, + { + "kind": "TOKEN_COLON", + "value": ":", + "index": 1, + "path": "[:-1]" + }, + { + "kind": "TOKEN_INT", + "value": "-1", + "index": 2, + "path": "[:-1]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 4, + "path": "[:-1]" + } + ] + }, + { + "description": "slice start and stop", + "path": "[1:7]", + "want": [ + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 0, + "path": "[1:7]" + }, + { + "kind": "TOKEN_INT", + "value": "1", + "index": 1, + "path": "[1:7]" + }, + { + "kind": "TOKEN_COLON", + "value": ":", + "index": 2, + "path": "[1:7]" + }, + { + "kind": "TOKEN_INT", + "value": "7", + "index": 3, + "path": "[1:7]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 4, + "path": "[1:7]" + } + ] + }, + { + "description": "slice start, stop and step", + "path": "[1:7:2]", + "want": [ + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 0, + "path": "[1:7:2]" + }, + { + "kind": "TOKEN_INT", + "value": "1", + "index": 1, + "path": "[1:7:2]" + }, + { + "kind": "TOKEN_COLON", + "value": ":", + "index": 2, + "path": "[1:7:2]" + }, + { + "kind": "TOKEN_INT", + "value": "7", + "index": 3, + "path": "[1:7:2]" + }, + { + "kind": "TOKEN_COLON", + "value": ":", + "index": 4, + "path": "[1:7:2]" + }, + { + "kind": "TOKEN_INT", + "value": "2", + "index": 5, + "path": "[1:7:2]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 6, + "path": "[1:7:2]" + } + ] + }, + { + "description": "root dot wild", + "path": "$.*", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$.*" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 1, + "path": "$.*" + }, + { + "kind": "TOKEN_WILD", + "value": "*", + "index": 2, + "path": "$.*" + } + ] + }, + { + "description": "root bracket wild", + "path": "$[*]", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$[*]" + }, + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 1, + "path": "$[*]" + }, + { + "kind": "TOKEN_WILD", + "value": "*", + "index": 2, + "path": "$[*]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 3, + "path": "$[*]" + } + ] + }, + { + "description": "root dot bracket wild", + "path": "$.[*]", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$.[*]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 1, + "path": "$.[*]" + }, + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 2, + "path": "$.[*]" + }, + { + "kind": "TOKEN_WILD", + "value": "*", + "index": 3, + "path": "$.[*]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 4, + "path": "$.[*]" + } + ] + }, + { + "description": "root descend", + "path": "$..", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$.." + }, + { + "kind": "TOKEN_DDOT", + "value": "..", + "index": 1, + "path": "$.." + } + ] + }, + { + "description": "root descend property", + "path": "$..thing", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$..thing" + }, + { + "kind": "TOKEN_DDOT", + "value": "..", + "index": 1, + "path": "$..thing" + }, + { + "kind": "TOKEN_NAME", + "value": "thing", + "index": 3, + "path": "$..thing" + } + ] + }, + { + "description": "root descend dot property", + "path": "$...thing", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$...thing" + }, + { + "kind": "TOKEN_DDOT", + "value": "..", + "index": 1, + "path": "$...thing" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 3, + "path": "$...thing" + }, + { + "kind": "TOKEN_NAME", + "value": "thing", + "index": 4, + "path": "$...thing" + } + ] + }, + { + "description": "root selector list of indices", + "path": "$[1,4,5]", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$[1,4,5]" + }, + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 1, + "path": "$[1,4,5]" + }, + { + "kind": "TOKEN_INT", + "value": "1", + "index": 2, + "path": "$[1,4,5]" + }, + { + "kind": "TOKEN_COMMA", + "value": ",", + "index": 3, + "path": "$[1,4,5]" + }, + { + "kind": "TOKEN_INT", + "value": "4", + "index": 4, + "path": "$[1,4,5]" + }, + { + "kind": "TOKEN_COMMA", + "value": ",", + "index": 5, + "path": "$[1,4,5]" + }, + { + "kind": "TOKEN_INT", + "value": "5", + "index": 6, + "path": "$[1,4,5]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 7, + "path": "$[1,4,5]" + } + ] + }, + { + "description": "root selector list with a slice", + "path": "$[1,4:9]", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$[1,4:9]" + }, + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 1, + "path": "$[1,4:9]" + }, + { + "kind": "TOKEN_INT", + "value": "1", + "index": 2, + "path": "$[1,4:9]" + }, + { + "kind": "TOKEN_COMMA", + "value": ",", + "index": 3, + "path": "$[1,4:9]" + }, + { + "kind": "TOKEN_INT", + "value": "4", + "index": 4, + "path": "$[1,4:9]" + }, + { + "kind": "TOKEN_COLON", + "value": ":", + "index": 5, + "path": "$[1,4:9]" + }, + { + "kind": "TOKEN_INT", + "value": "9", + "index": 6, + "path": "$[1,4:9]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 7, + "path": "$[1,4:9]" + } + ] + }, + { + "description": "root selector list of properties", + "path": "$[some,thing]", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$[some,thing]" + }, + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 1, + "path": "$[some,thing]" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 2, + "path": "$[some,thing]" + }, + { + "kind": "TOKEN_COMMA", + "value": ",", + "index": 6, + "path": "$[some,thing]" + }, + { + "kind": "TOKEN_NAME", + "value": "thing", + "index": 7, + "path": "$[some,thing]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 12, + "path": "$[some,thing]" + } + ] + }, + { + "description": "root dot filter on self dot property", + "path": "$.[?(@.some)]", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$.[?(@.some)]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 1, + "path": "$.[?(@.some)]" + }, + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 2, + "path": "$.[?(@.some)]" + }, + { + "kind": "TOKEN_FILTER", + "value": "?", + "index": 3, + "path": "$.[?(@.some)]" + }, + { + "kind": "TOKEN_LPAREN", + "value": "(", + "index": 4, + "path": "$.[?(@.some)]" + }, + { + "kind": "TOKEN_SELF", + "value": "@", + "index": 5, + "path": "$.[?(@.some)]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 6, + "path": "$.[?(@.some)]" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 7, + "path": "$.[?(@.some)]" + }, + { + "kind": "TOKEN_RPAREN", + "value": ")", + "index": 11, + "path": "$.[?(@.some)]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 12, + "path": "$.[?(@.some)]" + } + ] + }, + { + "description": "root dot filter on root dot property", + "path": "$.[?($.some)]", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$.[?($.some)]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 1, + "path": "$.[?($.some)]" + }, + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 2, + "path": "$.[?($.some)]" + }, + { + "kind": "TOKEN_FILTER", + "value": "?", + "index": 3, + "path": "$.[?($.some)]" + }, + { + "kind": "TOKEN_LPAREN", + "value": "(", + "index": 4, + "path": "$.[?($.some)]" + }, + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 5, + "path": "$.[?($.some)]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 6, + "path": "$.[?($.some)]" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 7, + "path": "$.[?($.some)]" + }, + { + "kind": "TOKEN_RPAREN", + "value": ")", + "index": 11, + "path": "$.[?($.some)]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 12, + "path": "$.[?($.some)]" + } + ] + }, + { + "description": "root dot filter on self index", + "path": "$.[?(@[1])]", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$.[?(@[1])]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 1, + "path": "$.[?(@[1])]" + }, + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 2, + "path": "$.[?(@[1])]" + }, + { + "kind": "TOKEN_FILTER", + "value": "?", + "index": 3, + "path": "$.[?(@[1])]" + }, + { + "kind": "TOKEN_LPAREN", + "value": "(", + "index": 4, + "path": "$.[?(@[1])]" + }, + { + "kind": "TOKEN_SELF", + "value": "@", + "index": 5, + "path": "$.[?(@[1])]" + }, + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 6, + "path": "$.[?(@[1])]" + }, + { + "kind": "TOKEN_INT", + "value": "1", + "index": 7, + "path": "$.[?(@[1])]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 8, + "path": "$.[?(@[1])]" + }, + { + "kind": "TOKEN_RPAREN", + "value": ")", + "index": 9, + "path": "$.[?(@[1])]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 10, + "path": "$.[?(@[1])]" + } + ] + }, + { + "description": "filter self dot property equality with float", + "path": "[?(@.some == 1.1)]", + "want": [ + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 0, + "path": "[?(@.some == 1.1)]" + }, + { + "kind": "TOKEN_FILTER", + "value": "?", + "index": 1, + "path": "[?(@.some == 1.1)]" + }, + { + "kind": "TOKEN_LPAREN", + "value": "(", + "index": 2, + "path": "[?(@.some == 1.1)]" + }, + { + "kind": "TOKEN_SELF", + "value": "@", + "index": 3, + "path": "[?(@.some == 1.1)]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 4, + "path": "[?(@.some == 1.1)]" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 5, + "path": "[?(@.some == 1.1)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 9, + "path": "[?(@.some == 1.1)]" + }, + { + "kind": "TOKEN_EQ", + "value": "==", + "index": 10, + "path": "[?(@.some == 1.1)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 12, + "path": "[?(@.some == 1.1)]" + }, + { + "kind": "TOKEN_FLOAT", + "value": "1.1", + "index": 13, + "path": "[?(@.some == 1.1)]" + }, + { + "kind": "TOKEN_RPAREN", + "value": ")", + "index": 16, + "path": "[?(@.some == 1.1)]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 17, + "path": "[?(@.some == 1.1)]" + } + ] + }, + { + "description": "filter self dot property equality float in scientific notation", + "path": "[?(@.some == 1.1e10)]", + "want": [ + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 0, + "path": "[?(@.some == 1.1e10)]" + }, + { + "kind": "TOKEN_FILTER", + "value": "?", + "index": 1, + "path": "[?(@.some == 1.1e10)]" + }, + { + "kind": "TOKEN_LPAREN", + "value": "(", + "index": 2, + "path": "[?(@.some == 1.1e10)]" + }, + { + "kind": "TOKEN_SELF", + "value": "@", + "index": 3, + "path": "[?(@.some == 1.1e10)]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 4, + "path": "[?(@.some == 1.1e10)]" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 5, + "path": "[?(@.some == 1.1e10)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 9, + "path": "[?(@.some == 1.1e10)]" + }, + { + "kind": "TOKEN_EQ", + "value": "==", + "index": 10, + "path": "[?(@.some == 1.1e10)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 12, + "path": "[?(@.some == 1.1e10)]" + }, + { + "kind": "TOKEN_FLOAT", + "value": "1.1e10", + "index": 13, + "path": "[?(@.some == 1.1e10)]" + }, + { + "kind": "TOKEN_RPAREN", + "value": ")", + "index": 19, + "path": "[?(@.some == 1.1e10)]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 20, + "path": "[?(@.some == 1.1e10)]" + } + ] + }, + { + "description": "filter self index equality with float", + "path": "[?(@[1] == 1.1)]", + "want": [ + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 0, + "path": "[?(@[1] == 1.1)]" + }, + { + "kind": "TOKEN_FILTER", + "value": "?", + "index": 1, + "path": "[?(@[1] == 1.1)]" + }, + { + "kind": "TOKEN_LPAREN", + "value": "(", + "index": 2, + "path": "[?(@[1] == 1.1)]" + }, + { + "kind": "TOKEN_SELF", + "value": "@", + "index": 3, + "path": "[?(@[1] == 1.1)]" + }, + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 4, + "path": "[?(@[1] == 1.1)]" + }, + { + "kind": "TOKEN_INT", + "value": "1", + "index": 5, + "path": "[?(@[1] == 1.1)]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 6, + "path": "[?(@[1] == 1.1)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 7, + "path": "[?(@[1] == 1.1)]" + }, + { + "kind": "TOKEN_EQ", + "value": "==", + "index": 8, + "path": "[?(@[1] == 1.1)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 10, + "path": "[?(@[1] == 1.1)]" + }, + { + "kind": "TOKEN_FLOAT", + "value": "1.1", + "index": 11, + "path": "[?(@[1] == 1.1)]" + }, + { + "kind": "TOKEN_RPAREN", + "value": ")", + "index": 14, + "path": "[?(@[1] == 1.1)]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 15, + "path": "[?(@[1] == 1.1)]" + } + ] + }, + { + "description": "filter self dot property equality with int", + "path": "[?(@.some == 1)]", + "want": [ + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 0, + "path": "[?(@.some == 1)]" + }, + { + "kind": "TOKEN_FILTER", + "value": "?", + "index": 1, + "path": "[?(@.some == 1)]" + }, + { + "kind": "TOKEN_LPAREN", + "value": "(", + "index": 2, + "path": "[?(@.some == 1)]" + }, + { + "kind": "TOKEN_SELF", + "value": "@", + "index": 3, + "path": "[?(@.some == 1)]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 4, + "path": "[?(@.some == 1)]" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 5, + "path": "[?(@.some == 1)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 9, + "path": "[?(@.some == 1)]" + }, + { + "kind": "TOKEN_EQ", + "value": "==", + "index": 10, + "path": "[?(@.some == 1)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 12, + "path": "[?(@.some == 1)]" + }, + { + "kind": "TOKEN_INT", + "value": "1", + "index": 13, + "path": "[?(@.some == 1)]" + }, + { + "kind": "TOKEN_RPAREN", + "value": ")", + "index": 14, + "path": "[?(@.some == 1)]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 15, + "path": "[?(@.some == 1)]" + } + ] + }, + { + "description": "filter self dot property equality with int in scientific notation", + "path": "[?(@.some == 1e10)]", + "want": [ + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 0, + "path": "[?(@.some == 1e10)]" + }, + { + "kind": "TOKEN_FILTER", + "value": "?", + "index": 1, + "path": "[?(@.some == 1e10)]" + }, + { + "kind": "TOKEN_LPAREN", + "value": "(", + "index": 2, + "path": "[?(@.some == 1e10)]" + }, + { + "kind": "TOKEN_SELF", + "value": "@", + "index": 3, + "path": "[?(@.some == 1e10)]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 4, + "path": "[?(@.some == 1e10)]" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 5, + "path": "[?(@.some == 1e10)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 9, + "path": "[?(@.some == 1e10)]" + }, + { + "kind": "TOKEN_EQ", + "value": "==", + "index": 10, + "path": "[?(@.some == 1e10)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 12, + "path": "[?(@.some == 1e10)]" + }, + { + "kind": "TOKEN_INT", + "value": "1e10", + "index": 13, + "path": "[?(@.some == 1e10)]" + }, + { + "kind": "TOKEN_RPAREN", + "value": ")", + "index": 17, + "path": "[?(@.some == 1e10)]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 18, + "path": "[?(@.some == 1e10)]" + } + ] + }, + { + "description": "filter self dot property regex", + "path": "[?(@.some =~ /foo|bar/i)]", + "want": [ + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 0, + "path": "[?(@.some =~ /foo|bar/i)]" + }, + { + "kind": "TOKEN_FILTER", + "value": "?", + "index": 1, + "path": "[?(@.some =~ /foo|bar/i)]" + }, + { + "kind": "TOKEN_LPAREN", + "value": "(", + "index": 2, + "path": "[?(@.some =~ /foo|bar/i)]" + }, + { + "kind": "TOKEN_SELF", + "value": "@", + "index": 3, + "path": "[?(@.some =~ /foo|bar/i)]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 4, + "path": "[?(@.some =~ /foo|bar/i)]" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 5, + "path": "[?(@.some =~ /foo|bar/i)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 9, + "path": "[?(@.some =~ /foo|bar/i)]" + }, + { + "kind": "TOKEN_RE", + "value": "=~", + "index": 10, + "path": "[?(@.some =~ /foo|bar/i)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 12, + "path": "[?(@.some =~ /foo|bar/i)]" + }, + { + "kind": "TOKEN_RE_PATTERN", + "value": "foo|bar", + "index": 14, + "path": "[?(@.some =~ /foo|bar/i)]" + }, + { + "kind": "TOKEN_RE_FLAGS", + "value": "i", + "index": 22, + "path": "[?(@.some =~ /foo|bar/i)]" + }, + { + "kind": "TOKEN_RPAREN", + "value": ")", + "index": 23, + "path": "[?(@.some =~ /foo|bar/i)]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 24, + "path": "[?(@.some =~ /foo|bar/i)]" + } + ] + }, + { + "description": "union of two paths", + "path": "$.some | $.thing", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$.some | $.thing" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 1, + "path": "$.some | $.thing" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 2, + "path": "$.some | $.thing" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 6, + "path": "$.some | $.thing" + }, + { + "kind": "TOKEN_UNION", + "value": "|", + "index": 7, + "path": "$.some | $.thing" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 8, + "path": "$.some | $.thing" + }, + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 9, + "path": "$.some | $.thing" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 10, + "path": "$.some | $.thing" + }, + { + "kind": "TOKEN_NAME", + "value": "thing", + "index": 11, + "path": "$.some | $.thing" + } + ] + }, + { + "description": "union of three paths", + "path": "$.some | $.thing | $.other", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$.some | $.thing | $.other" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 1, + "path": "$.some | $.thing | $.other" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 2, + "path": "$.some | $.thing | $.other" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 6, + "path": "$.some | $.thing | $.other" + }, + { + "kind": "TOKEN_UNION", + "value": "|", + "index": 7, + "path": "$.some | $.thing | $.other" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 8, + "path": "$.some | $.thing | $.other" + }, + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 9, + "path": "$.some | $.thing | $.other" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 10, + "path": "$.some | $.thing | $.other" + }, + { + "kind": "TOKEN_NAME", + "value": "thing", + "index": 11, + "path": "$.some | $.thing | $.other" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 16, + "path": "$.some | $.thing | $.other" + }, + { + "kind": "TOKEN_UNION", + "value": "|", + "index": 17, + "path": "$.some | $.thing | $.other" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 18, + "path": "$.some | $.thing | $.other" + }, + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 19, + "path": "$.some | $.thing | $.other" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 20, + "path": "$.some | $.thing | $.other" + }, + { + "kind": "TOKEN_NAME", + "value": "other", + "index": 21, + "path": "$.some | $.thing | $.other" + } + ] + }, + { + "description": "intersection two paths", + "path": "$.some & $.thing", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$.some & $.thing" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 1, + "path": "$.some & $.thing" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 2, + "path": "$.some & $.thing" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 6, + "path": "$.some & $.thing" + }, + { + "kind": "TOKEN_INTERSECTION", + "value": "&", + "index": 7, + "path": "$.some & $.thing" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 8, + "path": "$.some & $.thing" + }, + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 9, + "path": "$.some & $.thing" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 10, + "path": "$.some & $.thing" + }, + { + "kind": "TOKEN_NAME", + "value": "thing", + "index": 11, + "path": "$.some & $.thing" + } + ] + }, + { + "description": "filter expression with logical and", + "path": "[?(@.some > 1 and @.some < 5)]", + "want": [ + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 0, + "path": "[?(@.some > 1 and @.some < 5)]" + }, + { + "kind": "TOKEN_FILTER", + "value": "?", + "index": 1, + "path": "[?(@.some > 1 and @.some < 5)]" + }, + { + "kind": "TOKEN_LPAREN", + "value": "(", + "index": 2, + "path": "[?(@.some > 1 and @.some < 5)]" + }, + { + "kind": "TOKEN_SELF", + "value": "@", + "index": 3, + "path": "[?(@.some > 1 and @.some < 5)]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 4, + "path": "[?(@.some > 1 and @.some < 5)]" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 5, + "path": "[?(@.some > 1 and @.some < 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 9, + "path": "[?(@.some > 1 and @.some < 5)]" + }, + { + "kind": "TOKEN_GT", + "value": ">", + "index": 10, + "path": "[?(@.some > 1 and @.some < 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 11, + "path": "[?(@.some > 1 and @.some < 5)]" + }, + { + "kind": "TOKEN_INT", + "value": "1", + "index": 12, + "path": "[?(@.some > 1 and @.some < 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 13, + "path": "[?(@.some > 1 and @.some < 5)]" + }, + { + "kind": "TOKEN_AND", + "value": "and", + "index": 14, + "path": "[?(@.some > 1 and @.some < 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 17, + "path": "[?(@.some > 1 and @.some < 5)]" + }, + { + "kind": "TOKEN_SELF", + "value": "@", + "index": 18, + "path": "[?(@.some > 1 and @.some < 5)]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 19, + "path": "[?(@.some > 1 and @.some < 5)]" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 20, + "path": "[?(@.some > 1 and @.some < 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 24, + "path": "[?(@.some > 1 and @.some < 5)]" + }, + { + "kind": "TOKEN_LT", + "value": "<", + "index": 25, + "path": "[?(@.some > 1 and @.some < 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 26, + "path": "[?(@.some > 1 and @.some < 5)]" + }, + { + "kind": "TOKEN_INT", + "value": "5", + "index": 27, + "path": "[?(@.some > 1 and @.some < 5)]" + }, + { + "kind": "TOKEN_RPAREN", + "value": ")", + "index": 28, + "path": "[?(@.some > 1 and @.some < 5)]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 29, + "path": "[?(@.some > 1 and @.some < 5)]" + } + ] + }, + { + "description": "filter expression with logical or", + "path": "[?(@.some == 1 or @.some == 5)]", + "want": [ + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 0, + "path": "[?(@.some == 1 or @.some == 5)]" + }, + { + "kind": "TOKEN_FILTER", + "value": "?", + "index": 1, + "path": "[?(@.some == 1 or @.some == 5)]" + }, + { + "kind": "TOKEN_LPAREN", + "value": "(", + "index": 2, + "path": "[?(@.some == 1 or @.some == 5)]" + }, + { + "kind": "TOKEN_SELF", + "value": "@", + "index": 3, + "path": "[?(@.some == 1 or @.some == 5)]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 4, + "path": "[?(@.some == 1 or @.some == 5)]" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 5, + "path": "[?(@.some == 1 or @.some == 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 9, + "path": "[?(@.some == 1 or @.some == 5)]" + }, + { + "kind": "TOKEN_EQ", + "value": "==", + "index": 10, + "path": "[?(@.some == 1 or @.some == 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 12, + "path": "[?(@.some == 1 or @.some == 5)]" + }, + { + "kind": "TOKEN_INT", + "value": "1", + "index": 13, + "path": "[?(@.some == 1 or @.some == 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 14, + "path": "[?(@.some == 1 or @.some == 5)]" + }, + { + "kind": "TOKEN_OR", + "value": "or", + "index": 15, + "path": "[?(@.some == 1 or @.some == 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 17, + "path": "[?(@.some == 1 or @.some == 5)]" + }, + { + "kind": "TOKEN_SELF", + "value": "@", + "index": 18, + "path": "[?(@.some == 1 or @.some == 5)]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 19, + "path": "[?(@.some == 1 or @.some == 5)]" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 20, + "path": "[?(@.some == 1 or @.some == 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 24, + "path": "[?(@.some == 1 or @.some == 5)]" + }, + { + "kind": "TOKEN_EQ", + "value": "==", + "index": 25, + "path": "[?(@.some == 1 or @.some == 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 27, + "path": "[?(@.some == 1 or @.some == 5)]" + }, + { + "kind": "TOKEN_INT", + "value": "5", + "index": 28, + "path": "[?(@.some == 1 or @.some == 5)]" + }, + { + "kind": "TOKEN_RPAREN", + "value": ")", + "index": 29, + "path": "[?(@.some == 1 or @.some == 5)]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 30, + "path": "[?(@.some == 1 or @.some == 5)]" + } + ] + }, + { + "description": "filter expression with logical ||", + "path": "[?(@.some == 1 || @.some == 5)]", + "want": [ + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 0, + "path": "[?(@.some == 1 || @.some == 5)]" + }, + { + "kind": "TOKEN_FILTER", + "value": "?", + "index": 1, + "path": "[?(@.some == 1 || @.some == 5)]" + }, + { + "kind": "TOKEN_LPAREN", + "value": "(", + "index": 2, + "path": "[?(@.some == 1 || @.some == 5)]" + }, + { + "kind": "TOKEN_SELF", + "value": "@", + "index": 3, + "path": "[?(@.some == 1 || @.some == 5)]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 4, + "path": "[?(@.some == 1 || @.some == 5)]" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 5, + "path": "[?(@.some == 1 || @.some == 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 9, + "path": "[?(@.some == 1 || @.some == 5)]" + }, + { + "kind": "TOKEN_EQ", + "value": "==", + "index": 10, + "path": "[?(@.some == 1 || @.some == 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 12, + "path": "[?(@.some == 1 || @.some == 5)]" + }, + { + "kind": "TOKEN_INT", + "value": "1", + "index": 13, + "path": "[?(@.some == 1 || @.some == 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 14, + "path": "[?(@.some == 1 || @.some == 5)]" + }, + { + "kind": "TOKEN_OR", + "value": "||", + "index": 15, + "path": "[?(@.some == 1 || @.some == 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 17, + "path": "[?(@.some == 1 || @.some == 5)]" + }, + { + "kind": "TOKEN_SELF", + "value": "@", + "index": 18, + "path": "[?(@.some == 1 || @.some == 5)]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 19, + "path": "[?(@.some == 1 || @.some == 5)]" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 20, + "path": "[?(@.some == 1 || @.some == 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 24, + "path": "[?(@.some == 1 || @.some == 5)]" + }, + { + "kind": "TOKEN_EQ", + "value": "==", + "index": 25, + "path": "[?(@.some == 1 || @.some == 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 27, + "path": "[?(@.some == 1 || @.some == 5)]" + }, + { + "kind": "TOKEN_INT", + "value": "5", + "index": 28, + "path": "[?(@.some == 1 || @.some == 5)]" + }, + { + "kind": "TOKEN_RPAREN", + "value": ")", + "index": 29, + "path": "[?(@.some == 1 || @.some == 5)]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 30, + "path": "[?(@.some == 1 || @.some == 5)]" + } + ] + }, + { + "description": "filter self dot property in list literal", + "path": "[?(@.thing in [1, '1'])]", + "want": [ + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 0, + "path": "[?(@.thing in [1, '1'])]" + }, + { + "kind": "TOKEN_FILTER", + "value": "?", + "index": 1, + "path": "[?(@.thing in [1, '1'])]" + }, + { + "kind": "TOKEN_LPAREN", + "value": "(", + "index": 2, + "path": "[?(@.thing in [1, '1'])]" + }, + { + "kind": "TOKEN_SELF", + "value": "@", + "index": 3, + "path": "[?(@.thing in [1, '1'])]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 4, + "path": "[?(@.thing in [1, '1'])]" + }, + { + "kind": "TOKEN_NAME", + "value": "thing", + "index": 5, + "path": "[?(@.thing in [1, '1'])]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 10, + "path": "[?(@.thing in [1, '1'])]" + }, + { + "kind": "TOKEN_IN", + "value": "in", + "index": 11, + "path": "[?(@.thing in [1, '1'])]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 13, + "path": "[?(@.thing in [1, '1'])]" + }, + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 14, + "path": "[?(@.thing in [1, '1'])]" + }, + { + "kind": "TOKEN_INT", + "value": "1", + "index": 15, + "path": "[?(@.thing in [1, '1'])]" + }, + { + "kind": "TOKEN_COMMA", + "value": ",", + "index": 16, + "path": "[?(@.thing in [1, '1'])]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 17, + "path": "[?(@.thing in [1, '1'])]" + }, + { + "kind": "TOKEN_SINGLE_QUOTE_STRING", + "value": "1", + "index": 19, + "path": "[?(@.thing in [1, '1'])]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 21, + "path": "[?(@.thing in [1, '1'])]" + }, + { + "kind": "TOKEN_RPAREN", + "value": ")", + "index": 22, + "path": "[?(@.thing in [1, '1'])]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 23, + "path": "[?(@.thing in [1, '1'])]" + } + ] + }, + { + "description": "filter expression with logical not", + "path": "[?(@.some == 1 or not @.some < 5)]", + "want": [ + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 0, + "path": "[?(@.some == 1 or not @.some < 5)]" + }, + { + "kind": "TOKEN_FILTER", + "value": "?", + "index": 1, + "path": "[?(@.some == 1 or not @.some < 5)]" + }, + { + "kind": "TOKEN_LPAREN", + "value": "(", + "index": 2, + "path": "[?(@.some == 1 or not @.some < 5)]" + }, + { + "kind": "TOKEN_SELF", + "value": "@", + "index": 3, + "path": "[?(@.some == 1 or not @.some < 5)]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 4, + "path": "[?(@.some == 1 or not @.some < 5)]" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 5, + "path": "[?(@.some == 1 or not @.some < 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 9, + "path": "[?(@.some == 1 or not @.some < 5)]" + }, + { + "kind": "TOKEN_EQ", + "value": "==", + "index": 10, + "path": "[?(@.some == 1 or not @.some < 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 12, + "path": "[?(@.some == 1 or not @.some < 5)]" + }, + { + "kind": "TOKEN_INT", + "value": "1", + "index": 13, + "path": "[?(@.some == 1 or not @.some < 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 14, + "path": "[?(@.some == 1 or not @.some < 5)]" + }, + { + "kind": "TOKEN_OR", + "value": "or", + "index": 15, + "path": "[?(@.some == 1 or not @.some < 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 17, + "path": "[?(@.some == 1 or not @.some < 5)]" + }, + { + "kind": "TOKEN_NOT", + "value": "not", + "index": 18, + "path": "[?(@.some == 1 or not @.some < 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 21, + "path": "[?(@.some == 1 or not @.some < 5)]" + }, + { + "kind": "TOKEN_SELF", + "value": "@", + "index": 22, + "path": "[?(@.some == 1 or not @.some < 5)]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 23, + "path": "[?(@.some == 1 or not @.some < 5)]" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 24, + "path": "[?(@.some == 1 or not @.some < 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 28, + "path": "[?(@.some == 1 or not @.some < 5)]" + }, + { + "kind": "TOKEN_LT", + "value": "<", + "index": 29, + "path": "[?(@.some == 1 or not @.some < 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 30, + "path": "[?(@.some == 1 or not @.some < 5)]" + }, + { + "kind": "TOKEN_INT", + "value": "5", + "index": 31, + "path": "[?(@.some == 1 or not @.some < 5)]" + }, + { + "kind": "TOKEN_RPAREN", + "value": ")", + "index": 32, + "path": "[?(@.some == 1 or not @.some < 5)]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 33, + "path": "[?(@.some == 1 or not @.some < 5)]" + } + ] + }, + { + "description": "filter expression with logical not using '!'", + "path": "[?(@.some == 1 or !@.some < 5)]", + "want": [ + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 0, + "path": "[?(@.some == 1 or !@.some < 5)]" + }, + { + "kind": "TOKEN_FILTER", + "value": "?", + "index": 1, + "path": "[?(@.some == 1 or !@.some < 5)]" + }, + { + "kind": "TOKEN_LPAREN", + "value": "(", + "index": 2, + "path": "[?(@.some == 1 or !@.some < 5)]" + }, + { + "kind": "TOKEN_SELF", + "value": "@", + "index": 3, + "path": "[?(@.some == 1 or !@.some < 5)]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 4, + "path": "[?(@.some == 1 or !@.some < 5)]" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 5, + "path": "[?(@.some == 1 or !@.some < 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 9, + "path": "[?(@.some == 1 or !@.some < 5)]" + }, + { + "kind": "TOKEN_EQ", + "value": "==", + "index": 10, + "path": "[?(@.some == 1 or !@.some < 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 12, + "path": "[?(@.some == 1 or !@.some < 5)]" + }, + { + "kind": "TOKEN_INT", + "value": "1", + "index": 13, + "path": "[?(@.some == 1 or !@.some < 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 14, + "path": "[?(@.some == 1 or !@.some < 5)]" + }, + { + "kind": "TOKEN_OR", + "value": "or", + "index": 15, + "path": "[?(@.some == 1 or !@.some < 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 17, + "path": "[?(@.some == 1 or !@.some < 5)]" + }, + { + "kind": "TOKEN_NOT", + "value": "!", + "index": 18, + "path": "[?(@.some == 1 or !@.some < 5)]" + }, + { + "kind": "TOKEN_SELF", + "value": "@", + "index": 19, + "path": "[?(@.some == 1 or !@.some < 5)]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 20, + "path": "[?(@.some == 1 or !@.some < 5)]" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 21, + "path": "[?(@.some == 1 or !@.some < 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 25, + "path": "[?(@.some == 1 or !@.some < 5)]" + }, + { + "kind": "TOKEN_LT", + "value": "<", + "index": 26, + "path": "[?(@.some == 1 or !@.some < 5)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 27, + "path": "[?(@.some == 1 or !@.some < 5)]" + }, + { + "kind": "TOKEN_INT", + "value": "5", + "index": 28, + "path": "[?(@.some == 1 or !@.some < 5)]" + }, + { + "kind": "TOKEN_RPAREN", + "value": ")", + "index": 29, + "path": "[?(@.some == 1 or !@.some < 5)]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 30, + "path": "[?(@.some == 1 or !@.some < 5)]" + } + ] + }, + { + "description": "filter true and false", + "path": "[?(true == false)]", + "want": [ + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 0, + "path": "[?(true == false)]" + }, + { + "kind": "TOKEN_FILTER", + "value": "?", + "index": 1, + "path": "[?(true == false)]" + }, + { + "kind": "TOKEN_LPAREN", + "value": "(", + "index": 2, + "path": "[?(true == false)]" + }, + { + "kind": "TOKEN_TRUE", + "value": "true", + "index": 3, + "path": "[?(true == false)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 7, + "path": "[?(true == false)]" + }, + { + "kind": "TOKEN_EQ", + "value": "==", + "index": 8, + "path": "[?(true == false)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 10, + "path": "[?(true == false)]" + }, + { + "kind": "TOKEN_FALSE", + "value": "false", + "index": 11, + "path": "[?(true == false)]" + }, + { + "kind": "TOKEN_RPAREN", + "value": ")", + "index": 16, + "path": "[?(true == false)]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 17, + "path": "[?(true == false)]" + } + ] + }, + { + "description": "filter true and false", + "path": "[?(nil == none && nil == null)]", + "want": [ + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 0, + "path": "[?(nil == none && nil == null)]" + }, + { + "kind": "TOKEN_FILTER", + "value": "?", + "index": 1, + "path": "[?(nil == none && nil == null)]" + }, + { + "kind": "TOKEN_LPAREN", + "value": "(", + "index": 2, + "path": "[?(nil == none && nil == null)]" + }, + { + "kind": "TOKEN_NIL", + "value": "nil", + "index": 3, + "path": "[?(nil == none && nil == null)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 6, + "path": "[?(nil == none && nil == null)]" + }, + { + "kind": "TOKEN_EQ", + "value": "==", + "index": 7, + "path": "[?(nil == none && nil == null)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 9, + "path": "[?(nil == none && nil == null)]" + }, + { + "kind": "TOKEN_NIL", + "value": "none", + "index": 10, + "path": "[?(nil == none && nil == null)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 14, + "path": "[?(nil == none && nil == null)]" + }, + { + "kind": "TOKEN_AND", + "value": "&&", + "index": 15, + "path": "[?(nil == none && nil == null)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 17, + "path": "[?(nil == none && nil == null)]" + }, + { + "kind": "TOKEN_NIL", + "value": "nil", + "index": 18, + "path": "[?(nil == none && nil == null)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 21, + "path": "[?(nil == none && nil == null)]" + }, + { + "kind": "TOKEN_EQ", + "value": "==", + "index": 22, + "path": "[?(nil == none && nil == null)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 24, + "path": "[?(nil == none && nil == null)]" + }, + { + "kind": "TOKEN_NIL", + "value": "null", + "index": 25, + "path": "[?(nil == none && nil == null)]" + }, + { + "kind": "TOKEN_RPAREN", + "value": ")", + "index": 29, + "path": "[?(nil == none && nil == null)]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 30, + "path": "[?(nil == none && nil == null)]" + } + ] + }, + { + "description": "list of quoted properties", + "path": "$['some', 'thing']", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$['some', 'thing']" + }, + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 1, + "path": "$['some', 'thing']" + }, + { + "kind": "TOKEN_SINGLE_QUOTE_STRING", + "value": "some", + "index": 3, + "path": "$['some', 'thing']" + }, + { + "kind": "TOKEN_COMMA", + "value": ",", + "index": 8, + "path": "$['some', 'thing']" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 9, + "path": "$['some', 'thing']" + }, + { + "kind": "TOKEN_SINGLE_QUOTE_STRING", + "value": "thing", + "index": 11, + "path": "$['some', 'thing']" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 17, + "path": "$['some', 'thing']" + } + ] + }, + { + "description": "call a function", + "path": "$.some[?(length(@.thing) < 2)]", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$.some[?(length(@.thing) < 2)]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 1, + "path": "$.some[?(length(@.thing) < 2)]" + }, + { + "kind": "TOKEN_NAME", + "value": "some", + "index": 2, + "path": "$.some[?(length(@.thing) < 2)]" + }, + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 6, + "path": "$.some[?(length(@.thing) < 2)]" + }, + { + "kind": "TOKEN_FILTER", + "value": "?", + "index": 7, + "path": "$.some[?(length(@.thing) < 2)]" + }, + { + "kind": "TOKEN_LPAREN", + "value": "(", + "index": 8, + "path": "$.some[?(length(@.thing) < 2)]" + }, + { + "kind": "TOKEN_FUNCTION", + "value": "length", + "index": 9, + "path": "$.some[?(length(@.thing) < 2)]" + }, + { + "kind": "TOKEN_LPAREN", + "value": "(", + "index": 15, + "path": "$.some[?(length(@.thing) < 2)]" + }, + { + "kind": "TOKEN_SELF", + "value": "@", + "index": 16, + "path": "$.some[?(length(@.thing) < 2)]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 17, + "path": "$.some[?(length(@.thing) < 2)]" + }, + { + "kind": "TOKEN_NAME", + "value": "thing", + "index": 18, + "path": "$.some[?(length(@.thing) < 2)]" + }, + { + "kind": "TOKEN_RPAREN", + "value": ")", + "index": 23, + "path": "$.some[?(length(@.thing) < 2)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 24, + "path": "$.some[?(length(@.thing) < 2)]" + }, + { + "kind": "TOKEN_LT", + "value": "<", + "index": 25, + "path": "$.some[?(length(@.thing) < 2)]" + }, + { + "kind": "TOKEN_WHITESPACE", + "value": " ", + "index": 26, + "path": "$.some[?(length(@.thing) < 2)]" + }, + { + "kind": "TOKEN_INT", + "value": "2", + "index": 27, + "path": "$.some[?(length(@.thing) < 2)]" + }, + { + "kind": "TOKEN_RPAREN", + "value": ")", + "index": 28, + "path": "$.some[?(length(@.thing) < 2)]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 29, + "path": "$.some[?(length(@.thing) < 2)]" + } + ] + }, + { + "description": "keys selector", + "path": "$.thing.~", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$.thing.~" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 1, + "path": "$.thing.~" + }, + { + "kind": "TOKEN_NAME", + "value": "thing", + "index": 2, + "path": "$.thing.~" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 7, + "path": "$.thing.~" + }, + { + "kind": "TOKEN_KEYS", + "value": "~", + "index": 8, + "path": "$.thing.~" + } + ] + }, + { + "description": "keys in list selector", + "path": "$.thing[~]", + "want": [ + { + "kind": "TOKEN_ROOT", + "value": "$", + "index": 0, + "path": "$.thing[~]" + }, + { + "kind": "TOKEN_DOT", + "value": ".", + "index": 1, + "path": "$.thing[~]" + }, + { + "kind": "TOKEN_NAME", + "value": "thing", + "index": 2, + "path": "$.thing[~]" + }, + { + "kind": "TOKEN_LBRACKET", + "value": "[", + "index": 7, + "path": "$.thing[~]" + }, + { + "kind": "TOKEN_KEYS", + "value": "~", + "index": 8, + "path": "$.thing[~]" + }, + { + "kind": "TOKEN_RBRACKET", + "value": "]", + "index": 9, + "path": "$.thing[~]" + } + ] + }, + { + "description": "implicit root selector, name selector starts with `and`", + "path": "anderson", + "want": [ + { + "kind": "TOKEN_NAME", + "value": "anderson", + "index": 0, + "path": "anderson" + } + ] + }, + { + "description": "implicit root selector, name selector starts with `or`", + "path": "order", + "want": [ + { + "kind": "TOKEN_NAME", + "value": "order", + "index": 0, + "path": "order" + } + ] + }, + { + "description": "implicit root selector, name selector starts with `true`", + "path": "trueblue", + "want": [ + { + "kind": "TOKEN_NAME", + "value": "trueblue", + "index": 0, + "path": "trueblue" + } + ] + }, + { + "description": "implicit root selector, name selector starts with `false`", + "path": "falsehood", + "want": [ + { + "kind": "TOKEN_NAME", + "value": "falsehood", + "index": 0, + "path": "falsehood" + } + ] + }, + { + "description": "implicit root selector, name selector starts with `not`", + "path": "nottingham", + "want": [ + { + "kind": "TOKEN_NAME", + "value": "nottingham", + "index": 0, + "path": "nottingham" + } + ] + }, + { + "description": "implicit root selector, name selector starts with `null`", + "path": "nullable", + "want": [ + { + "kind": "TOKEN_NAME", + "value": "nullable", + "index": 0, + "path": "nullable" + } + ] + }, + { + "description": "implicit root selector, name selector starts with `none`", + "path": "nonexpert", + "want": [ + { + "kind": "TOKEN_NAME", + "value": "nonexpert", + "index": 0, + "path": "nonexpert" + } + ] + }, + { + "description": "implicit root selector, name selector starts with `undefined`", + "path": "undefinedness", + "want": [ + { + "kind": "TOKEN_NAME", + "value": "undefinedness", + "index": 0, + "path": "undefinedness" + } + ] + }, + { + "description": "implicit root selector, name selector starts with `missing`", + "path": "missingly", + "want": [ + { + "kind": "TOKEN_NAME", + "value": "missingly", + "index": 0, + "path": "missingly" + } + ] + } + ] } \ No newline at end of file diff --git a/tests/test_lex.py b/tests/test_lex.py index 0f2050b..b465d57 100644 --- a/tests/test_lex.py +++ b/tests/test_lex.py @@ -1,7 +1,9 @@ import dataclasses import json import operator -from typing import List, Any, Dict +from typing import Any +from typing import Dict +from typing import List import pytest @@ -10,12 +12,15 @@ from jsonpath.exceptions import JSONPathSyntaxError from jsonpath.token import Token +DATA_FILE = "tests/test_lex.json" + @dataclasses.dataclass class Case: description: str path: str - want: List[Token] + want: List[tokmod.Token] + @pytest.fixture() def env() -> JSONPathEnvironment: @@ -26,26 +31,32 @@ def cases() -> List[Case]: # Deserialize tests/test_lex.json into Case objects with want as List[Token] # Build mapping from token constant names used in JSON (e.g., "TOKEN_ROOT") # to actual token kind values (e.g., "ROOT"). - kind_map = {name: getattr(tokmod, name) for name in dir(tokmod) if name.startswith("TOKEN_")} - # Backward-compatibility alias: some test data may use PSEUDO_ROOT to mean FAKE_ROOT - kind_map.setdefault("TOKEN_PSEUDO_ROOT", tokmod.TOKEN_FAKE_ROOT) - + kind_map = { + name: getattr(tokmod, name) for name in dir(tokmod) if name.startswith("TOKEN_") + } + # Backward-compatibility alias: some test data may use PSEUDO_ROOT + # to mean FAKE_ROOT + # kind_map.setdefault("TOKEN_PSEUDO_ROOT", tokmod.TOKEN_FAKE_ROOT) + def to_token(obj: Dict[str, Any]) -> Token: try: kind_value = kind_map[obj["kind"]] except KeyError as e: - raise KeyError(f"Unknown token kind in test_lex.json: {obj.get('kind')}\nKnown kinds: " - f"{sorted(kind_map.keys())}") from e + raise KeyError( + f"Unknown token kind in test_lex.json: {obj.get('kind')}\n" + f"Known kinds: " + f"{sorted(kind_map.keys())}" + ) from e return Token( kind=kind_value, value=obj["value"], index=obj["index"], path=obj["path"], ) - - with open("tests/test_lex.json", encoding="utf8") as fd: + + with open(DATA_FILE, encoding="utf8") as fd: data = json.load(fd) - + cases_list: List[Case] = [] for case in data["tests"]: want_tokens = [to_token(tok) for tok in case["want"]] @@ -58,6 +69,7 @@ def to_token(obj: Dict[str, Any]) -> Token: ) return cases_list + @pytest.mark.parametrize("case", cases(), ids=operator.attrgetter("description")) def test_default_lexer(env: JSONPathEnvironment, case: Case) -> None: tokens = list(env.lexer.tokenize(case.path)) From e433f8cdb4c543211134d7851ed89d36b4d729fc Mon Sep 17 00:00:00 2001 From: killeroonie Date: Wed, 27 Aug 2025 13:05:51 -0700 Subject: [PATCH 4/4] Simplified loading of json file. --- tests/test_lex.py | 77 ++++++++--------------------------------------- 1 file changed, 13 insertions(+), 64 deletions(-) diff --git a/tests/test_lex.py b/tests/test_lex.py index b465d57..43cdbcf 100644 --- a/tests/test_lex.py +++ b/tests/test_lex.py @@ -1,81 +1,30 @@ -import dataclasses import json import operator from typing import Any from typing import Dict -from typing import List import pytest -import jsonpath.token as tokmod -from jsonpath import JSONPathEnvironment +from jsonpath import DEFAULT_ENV from jsonpath.exceptions import JSONPathSyntaxError from jsonpath.token import Token -DATA_FILE = "tests/test_lex.json" - - -@dataclasses.dataclass -class Case: +with open("tests/test_lex.json", encoding="UTF-8") as fd: + """Loads the test case data. Each test case is: description: str path: str - want: List[tokmod.Token] - - -@pytest.fixture() -def env() -> JSONPathEnvironment: - return JSONPathEnvironment() - - -def cases() -> List[Case]: - # Deserialize tests/test_lex.json into Case objects with want as List[Token] - # Build mapping from token constant names used in JSON (e.g., "TOKEN_ROOT") - # to actual token kind values (e.g., "ROOT"). - kind_map = { - name: getattr(tokmod, name) for name in dir(tokmod) if name.startswith("TOKEN_") - } - # Backward-compatibility alias: some test data may use PSEUDO_ROOT - # to mean FAKE_ROOT - # kind_map.setdefault("TOKEN_PSEUDO_ROOT", tokmod.TOKEN_FAKE_ROOT) - - def to_token(obj: Dict[str, Any]) -> Token: - try: - kind_value = kind_map[obj["kind"]] - except KeyError as e: - raise KeyError( - f"Unknown token kind in test_lex.json: {obj.get('kind')}\n" - f"Known kinds: " - f"{sorted(kind_map.keys())}" - ) from e - return Token( - kind=kind_value, - value=obj["value"], - index=obj["index"], - path=obj["path"], - ) - - with open(DATA_FILE, encoding="utf8") as fd: - data = json.load(fd) - - cases_list: List[Case] = [] - for case in data["tests"]: - want_tokens = [to_token(tok) for tok in case["want"]] - cases_list.append( - Case( - description=case["description"], - path=case["path"], - want=want_tokens, - ) - ) - return cases_list + want: List[Token] + """ + CASES = json.load(fd)["tests"] -@pytest.mark.parametrize("case", cases(), ids=operator.attrgetter("description")) -def test_default_lexer(env: JSONPathEnvironment, case: Case) -> None: - tokens = list(env.lexer.tokenize(case.path)) - assert tokens == case.want +@pytest.mark.parametrize("case", CASES, ids=operator.itemgetter("description")) +def test_default_lexer(case: Dict[str, Any]) -> None: + tokens = list(DEFAULT_ENV.lexer.tokenize(case["path"])) + want = [Token(**token) for token in case["want"]] + assert tokens == want -def test_illegal_token(env: JSONPathEnvironment) -> None: +def test_illegal_token() -> None: with pytest.raises(JSONPathSyntaxError): - list(env.lexer.tokenize("%")) + list(DEFAULT_ENV.lexer.tokenize("%"))