Skip to content

Commit

Permalink
Merge pull request #708 from gregsdennis/logic/functional
Browse files Browse the repository at this point in the history
Logic/functional
  • Loading branch information
gregsdennis committed Apr 18, 2024
2 parents a19875d + 282a9e1 commit f9e9cab
Show file tree
Hide file tree
Showing 58 changed files with 2,083 additions and 80 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>Json.Schema.Benchmark</RootNamespace>
<RootNamespace>Json.Benchmarks</RootNamespace>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand All @@ -19,10 +19,17 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\JsonLogic\JsonLogic.csproj" />
<ProjectReference Include="..\JsonSchema\JsonSchema.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="Files\more-tests.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Files\tests.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="SimplePropsSchema.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
128 changes: 128 additions & 0 deletions Benchmarks/Files/more-tests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
[
"# This file is my own analysis of the behavior of the online runner for some weird cases. The idea is to align this implementation with that.",
[ {}, {}, {} ],
[ {"+": [1, {}]}, {}, null ],
[ {"+": 3}, {}, 3 ],
[ {"-": [1, {}]}, {}, null ],
[ {"*": [1, {}]}, {}, null ],
[ {"/": [1, {}]}, {}, null ],
[ {"/": [1, 0]}, {}, null ],
[ {"%": [1, {}]}, {}, null ],
[ {"%": [1, 0]}, {}, null ],
[ {"all": [[2, 1], true]}, {}, true ],
[ {"all": [[2, 1], false]}, {}, false ],
[ {"all": [[2, 1], "string"]}, {}, true ],
[ {"all": [[2, 0], "string"]}, {}, true ],
[ {"all": [[false, false], true]}, {}, true ],
[ {"all": [[], true]}, {}, false ],
[ {"all": ["string", true]}, {}, false ],
[ {"some": [[2, 1], true]}, {}, true ],
[ {"some": [[2, 1], false]}, {}, false ],
[ {"some": [[2, 1], "string"]}, {}, true ],
[ {"some": [[2, 0], "string"]}, {}, true ],
[ {"some": [[false, false], true]}, {}, true ],
[ {"some": [[], true]}, {}, false ],
[ {"some": ["string", true]}, {}, false ],
[ {"none": [[2, 1], true]}, {}, false ],
[ {"none": [[2, 1], false]}, {}, true ],
[ {"none": [[2, 1], "string"]}, {}, false ],
[ {"none": [[2, 0], "string"]}, {}, false ],
[ {"none": [[false, false], true]}, {}, false ],
[ {"none": [[], true]}, {}, true ],
[ {"none": ["string", true]}, {}, true ],
[ {"<" : ["abc", "123"]}, {}, false ],
[ {"<" : ["abc", 123]}, {}, false ],
[ {"<" : ["456", 123]}, {}, false ],
[ {"<" : ["abc", []]}, {}, false ],
[ {"<" : ["abc", ["123"]]}, {}, false ],
[ {"<" : ["abc", [123]]}, {}, false ],
[ {"<" : [false, 123]}, {}, true ],
[ {">" : ["abc", "123"]}, {}, true ],
[ {">" : ["abc", 123]}, {}, false ],
[ {">" : ["456", 123]}, {}, true ],
[ {">" : ["abc", []]}, {}, true ],
[ {">" : ["abc", ["123"]]}, {}, true ],
[ {">" : ["abc", [123]]}, {}, true ],
[ {"<" : ["123", "456", "789"]}, {}, true ],
[ {"<" : ["123", 456, "789"]}, {}, true ],
[ {"<" : ["123a", 456, "789"]}, {}, false ],
[ {"<" : ["", "4", 5]}, {}, true ],
[ {"cat" : ["abc", [123,456]]}, {}, "abc123,456" ],
[ {"in" : [123, "abcd"]}, {}, false ],
[ {"in" : ["bcd", 123]}, {}, false ],
[ {"in" : ["2", 123]}, {}, false ],
[ {"in" : [2, 123]}, {}, false ],
[ {"in" : ["bcd", [123, "bcd"]]}, {}, true ],
[ {"in" : ["bcd", [123, "bcde"]]}, {}, false ],
[ {"in" : [[123, "bcde"], "bcd"]}, {}, false ],
[ {"in" : [null, "bcd"]}, {}, false ],
[ {"in" : ["bcd", null]}, {}, false ],
[ {"log": 3}, {}, 3 ],
[ {"max": ["abc"]}, {}, null ],
[ {"max": [3, 4, 5, "abc"]}, {}, null ],
[ {"min": ["abc"]}, {}, null ],
[ {"min": [3, 4, 5, "abc"]}, {}, null ],
[ {"missing": "var1" }, {"var2": true}, ["var1"] ],
[ {"missing": "var1" }, {"var1": null}, ["var1"] ],
[ {"missing": "var1" }, {"var1": ""}, ["var1"] ],
[ {"missing": "var1" }, {"var1": "a"}, [] ],
[ {"missing": "var1" }, {"var1": false}, [] ],
[ {"missing_some":[1, "b"]}, {"a": "b"}, ["b"] ],
[ {"missing_some":[1, 123]}, {"a": "b"}, [123] ],
[ {"missing_some":["foo", false]}, {"a": "b"}, [false] ],
[ {"substr": ["jsonlogic", "4"]}, {}, "logic" ],
[ {"substr": ["jsonlogic", "abc"]}, {}, "jsonlogic" ],
[ {"substr": ["jsonlogic", true]}, {}, "sonlogic" ],
[ {"substr": ["jsonlogic", 4.4]}, {}, "logic" ],
[ {"substr": ["jsonlogic", -4.4]}, {}, "ogic" ],
[ {"substr": ["jsonlogic", -4.6]}, {}, "ogic" ],
[ {"substr": ["jsonlogic", -4.6, 2]}, {}, "og" ],
[ {"substr": ["jsonlogic", -4.6, 2.7]}, {}, "og" ],
[ {"substr": [123456789, 4.4]}, {}, "56789" ],
[ {"substr": [null, 4.4]}, {}, "" ],
[ {"substr": [null, 2]}, {}, "ll" ],
[ {"substr": [false, 4.4]}, {}, "e" ],
[ {"substr": [["jsonlogic"], 4.4]}, {}, "logic" ],
[ {"substr": [["jsonlogic", "test"], 4.4]}, {}, "logic,test" ],
[ {"reduce":[
[1,2,3,4,5],
{"+":[{"var":"current"}, {"var":"accumulator"}]},
"10"
]}, {}, 25 ],
[ {"reduce":[
[1,2,3,4,5],
{"+":[{"var":"current"}, {"var":"accumulator"}]},
"abc"
]}, {}, null ],
[ {"reduce":[
[1,2,"abc",4,5],
{"+":[{"var":"current"}, {"var":"accumulator"}]},
10
]}, {}, null ],
[ {"reduce":[
[1,2,3,4,5],
{"+":[5, {"var":"accumulator"}]},
10
]}, {}, 35 ],
[ {"reduce":[
[1,2,3,4,5],
{"+":["abc", {"var":"accumulator"}]},
10
]}, {}, null ],
[ {"reduce":[
5,
{"+":["abc", {"var":"accumulator"}]},
10
]}, {}, 10 ],
[ {"reduce":[
5,
{"+":[{"var":"current"}, {"var":"accumulator"}]},
10
]}, {}, 10 ],
[ {"reduce":[
[1,2,3,4,5],
{"+":[{"var":"current"}, 5]},
10
]}, {}, 10 ],
"EOF"
]

0 comments on commit f9e9cab

Please sign in to comment.