jsonlogic-hs-0.1.0.0: test/community/val.json
[
"Test Specification for val",
{
"description": "Fetches a value",
"rule": { "val": "hello" },
"data": { "hello" : 0 },
"result": 0
},
{
"description": "Fetches a nested value",
"rule": { "val": ["hello", "world"] },
"data": { "hello" : { "world": 1 } },
"result": 1
},
{
"description": "Fetches a value from an empty key",
"rule": { "val": "" },
"data": { "" : 1 },
"result": 1
},
{
"description": "Fetches a value from a nested empty key",
"rule": { "val": ["", ""] },
"data": { "" : { "": 2 } },
"result": 2
},
{
"description": "Fetches a value from an array",
"rule": { "val": [1] },
"data": [1, 2],
"result": 2
},
{
"description": "Fetches a value from an array in an object",
"rule": { "val": ["arr", 1] },
"data": { "arr": [1, 2] },
"result": 2
},
{
"description": "Fetches a value from a doubly nested empty key",
"rule": { "val": ["", "", ""] },
"data": { "" : { "": { "": 3 } } },
"result": 3
},
{
"description": "Fetches a value from a key that is purely a dot",
"rule": { "val": "." },
"data": { "." : 20 },
"result": 20
},
{
"description": "Fetching a value from null returns null",
"rule": { "val": "hello" },
"data": { "hello" : null },
"result": null
},
{
"description": "Fetching a value from a null fetched value returns null",
"rule": { "val": ["hello", "world"] },
"data": { "hello" : null },
"result": null
},
{
"description": "Fetches the entire context",
"rule": { "val": [] },
"data": { "": 21 },
"result": { "": 21 }
},
{
"description": "Fetches the entire context for a nested key",
"rule": { "val": "" },
"data": { "": { "": 22 } },
"result": { "": 22 }
},
{
"description": "Using val in a map",
"rule": { "map": [[1,2,3], { "+": [{ "val": [] }, 1] }] },
"data": null,
"result": [2,3,4]
}
]