jsonlogic-hs-0.1.0.0: test/community/control/and.json
[
"Basic Checks",
{
"description": "Two true values should be true",
"rule": { "and": [true, true] },
"data": null,
"result": true
},
{
"description": "false and true should be false",
"rule": { "and": [false, true] },
"data": null,
"result": false
},
{
"description": "true and false should be false",
"rule": { "and": [true, false] },
"data": null,
"result": false
},
{
"description": "Two false values should be false",
"rule": { "and": [false, false] },
"data": null,
"result": false
},
{
"description": "All true values should be true",
"rule": { "and": [true, true, true] },
"data": null,
"result": true
},
{
"description": "Any false value should be false",
"rule": { "and": [true, true, false] },
"data": null,
"result": false
},
{
"description": "And with a single false value should be false",
"rule": { "and": [false] },
"data": null,
"result": false
},
{
"description": "When all values are truthy, the last truthy value should be returned",
"rule": { "and": [1, 2, 3] },
"data": null,
"result": 3
},
{
"description": "When all values are truthy, the last truthy value should be returned (2)",
"rule": { "and": [true, 1, {}] },
"data": null,
"result": {}
},
{
"description": "And with a single falsey value should be return the falsy value",
"rule": { "and": [[]] },
"data": null,
"result": []
},
{
"description": "And with a single falsey value should be return the falsy value (2)",
"rule": { "and": [0] },
"data": null,
"result": 0
},
{
"description": "And with a single falsey value should be return the falsy value (3)",
"rule": { "and": [""] },
"data": null,
"result": ""
},
{
"description": "And with a single true value should be true",
"rule": { "and": [true] },
"data": null,
"result": true
},
{
"description": "And with 2 truthy values should return the last truthy value",
"rule": { "and": [1, 3] },
"data": null,
"result": 3
},
{
"description": "And with a truthy value and a false value should return the false value",
"rule": { "and": [3, false] },
"data": null,
"result": false
},
{
"description": "And with a truthy value and a false value should return the false value (2)",
"rule": { "and": [false, 3] },
"data": null,
"result": false
},
{
"description": "Empty array is falsy, so it is returned",
"rule": { "and": [[], true] },
"data": null,
"result": []
},
{
"description": "0 is falsy, so it is returned",
"rule": { "and": [0, true] },
"data": null,
"result": 0
},
{
"description": "Empty string is falsy, so it is returned",
"rule": { "and": ["", true] },
"data": null,
"result": ""
},
{
"description": "0 as a string is truthy, so the last truthy value is returned",
"rule": { "and": ["0", true] },
"data": null,
"result": true
},
{
"description": "And with no arguments should return false",
"rule": { "and": [] },
"data": null,
"result": false
},
"Valid Arguments Checks",
{
"description": "And with non-array arguments should throw",
"rule": { "and": true },
"data": null,
"error": { "type": "Invalid Arguments" }
},
"Short Circuiting Checks",
{
"description": "And will not interpret the second argument if the first is false",
"rule": { "and": [false, { "throw": "Not Lazy" }] },
"data": null,
"result": false
},
{
"description": "And will not interpret the second argument if the first is falsy",
"rule": { "and": [0, { "throw": "Not Lazy" }] },
"data": null,
"result": 0
},
{
"description": "And will not interpret the nth argument if any value before it is false",
"rule": { "and": [true, 1, 2, 3, 4, [], { "throw": "Not Lazy" }] },
"data": null,
"result": []
}
]