Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for invalid and uncommon filter literal values #89

Merged
merged 2 commits into from
Aug 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 162 additions & 3 deletions tests/filter.json
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,14 @@
},
{
"name": "equals number, zero and negative zero",
"selector" : "$[[email protected]==0]",
"document" : [{"a": -0, "d": "e"}, {"a":0.1, "d": "f"}, {"a":"0", "d": "g"}],
"result": [
{"a": -0, "d": "e"}
]
},
{
"name": "equals number, negative zero and zero",
"selector" : "$[[email protected]==-0]",
"document" : [{"a": 0, "d": "e"}, {"a":0.1, "d": "f"}, {"a":"0", "d": "g"}],
"result": [
Expand All @@ -813,6 +821,14 @@
{"a": 100, "d": "e"}
]
},
{
"name": "equals number, exponent upper e",
"selector" : "$[[email protected]==1E2]",
gregsdennis marked this conversation as resolved.
Show resolved Hide resolved
"document" : [{"a": 100, "d": "e"}, {"a":100.1, "d": "f"}, {"a":"100", "d": "g"}],
"result": [
{"a": 100, "d": "e"}
]
},
{
"name": "equals number, positive exponent",
"selector" : "$[[email protected]==1e+2]",
Expand All @@ -829,6 +845,46 @@
{"a": 0.01, "d": "e"}
]
},
{
"name": "equals number, exponent 0",
"selector" : "$[[email protected]==1e0]",
"document" : [{"a": 1, "d": "e"}, {"a":2, "d": "f"}, {"a":"1", "d": "g"}],
"result": [
{"a": 1, "d": "e"}
]
},
{
"name": "equals number, exponent -0",
"selector" : "$[[email protected]==1e-0]",
"document" : [{"a": 1, "d": "e"}, {"a":2, "d": "f"}, {"a":"1", "d": "g"}],
"result": [
{"a": 1, "d": "e"}
]
},
{
"name": "equals number, exponent +0",
"selector" : "$[[email protected]==1e+0]",
"document" : [{"a": 1, "d": "e"}, {"a":2, "d": "f"}, {"a":"1", "d": "g"}],
"result": [
{"a": 1, "d": "e"}
]
},
{
"name": "equals number, exponent leading -0",
"selector" : "$[[email protected]==1e-02]",
"document" : [{"a": 0.01, "d": "e"}, {"a":0.02, "d": "f"}, {"a":"0.01", "d": "g"}],
"result": [
{"a": 0.01, "d": "e"}
]
},
{
"name": "equals number, exponent +00",
"selector" : "$[[email protected]==1e+00]",
Marcono1234 marked this conversation as resolved.
Show resolved Hide resolved
"document" : [{"a": 1, "d": "e"}, {"a":2, "d": "f"}, {"a":"1", "d": "g"}],
"result": [
{"a": 1, "d": "e"}
]
},
{
"name": "equals number, decimal fraction",
"selector" : "$[[email protected]==1.1]",
Expand All @@ -838,9 +894,12 @@
]
},
{
"name": "equals number, decimal fraction, no fractional digit",
"selector" : "$[[email protected]==1.]",
"invalid_selector": true
"name": "equals number, decimal fraction, trailing 0",
"selector" : "$[[email protected]==1.10]",
"document" : [{"a": 1.1, "d": "e"}, {"a":1.0, "d": "f"}, {"a":"1.1", "d": "g"}],
"result": [
{"a": 1.1, "d": "e"}
]
},
{
"name": "equals number, decimal fraction, exponent",
Expand All @@ -866,6 +925,91 @@
{"a": 0.011, "d": "e"}
]
},
{
"name": "equals number, invalid plus",
"selector" : "$[[email protected]==+1]",
"invalid_selector": true
},
{
"name": "equals number, invalid minus space",
"selector" : "$[[email protected]==- 1]",
"invalid_selector": true
},
{
"name": "equals number, invalid double minus",
"selector" : "$[[email protected]==--1]",
gregsdennis marked this conversation as resolved.
Show resolved Hide resolved
"invalid_selector": true
},
{
"name": "equals number, invalid no int digit",
"selector" : "$[[email protected]==.1]",
"invalid_selector": true
},
{
"name": "equals number, invalid minus no int digit",
"selector" : "$[[email protected]==-.1]",
"invalid_selector": true
},
{
"name": "equals number, invalid 00",
"selector" : "$[[email protected]==00]",
"invalid_selector": true
},
{
"name": "equals number, invalid leading 0",
"selector" : "$[[email protected]==01]",
"invalid_selector": true
},
{
"name": "equals number, invalid no fractional digit",
"selector" : "$[[email protected]==1.]",
"invalid_selector": true
},
{
"name": "equals number, invalid middle minus",
"selector" : "$[[email protected]==1.-1]",
"invalid_selector": true
},
{
"name": "equals number, invalid no fractional digit e",
"selector" : "$[[email protected]==1.e1]",
"invalid_selector": true
},
{
"name": "equals number, invalid no e digit",
"selector" : "$[[email protected]==1e]",
"invalid_selector": true
},
{
"name": "equals number, invalid no e digit minus",
"selector" : "$[[email protected]==1e-]",
"invalid_selector": true
},
{
"name": "equals number, invalid double e",
"selector" : "$[[email protected]==1eE1]",
"invalid_selector": true
},
{
"name": "equals number, invalid e digit double minus",
"selector" : "$[[email protected]==1e--1]",
"invalid_selector": true
},
{
"name": "equals number, invalid e digit plus minus",
"selector" : "$[[email protected]==1e+-1]",
"invalid_selector": true
},
{
"name": "equals number, invalid e decimal",
"selector" : "$[[email protected]==1e2.3]",
"invalid_selector": true
},
{
"name": "equals number, invalid multi e",
"selector" : "$[[email protected]==1e2e3]",
"invalid_selector": true
},
{
"name": "equals, special nothing",
"selector" : "$.values[?length(@.a) == value($..c)]",
Expand Down Expand Up @@ -1037,6 +1181,21 @@
"name": "or, left hand literal must be compared",
"selector" : "$[?false || true == false]",
"invalid_selector": true
},
{
"name": "true, incorrectly capitalized",
"selector" : "$[?@==True]",
"invalid_selector": true
},
{
"name": "false, incorrectly capitalized",
"selector" : "$[?@==False]",
"invalid_selector": true
},
{
"name": "null, incorrectly capitalized",
"selector" : "$[?@==Null]",
"invalid_selector": true
}
]
}
Loading