Option to sort truthTable

This commit is contained in:
Martin Berg Alstad
2024-06-16 00:12:52 +02:00
parent 32d5089b44
commit b9998ce7bf
2 changed files with 112 additions and 12 deletions

View File

@ -62,3 +62,23 @@ GET {{url}}/simplify/{{expression}}?simplify=false
expression("A & B | C")
%}
GET {{url}}/simplify/table/{{expression}}
### GET with table sorted by true first
< {%
import {expression} from "./common";
expression("A & B | C")
%}
GET {{url}}/simplify/table/{{expression}}?sort=TRUE_FIRST
> {%
client.test("Response body is sorted by true first", () => {
const table = response.body.truthTable;
const results = table.truthMatrix.map(arr => arr[arr.length - 1])
const expected = results.slice() // Creates a copy of the array
expected.sort((a, b) => b - a)
for (let i = 0; i < results.length; i++) {
client.assert(results[i] === expected[i], "Response body is not sorted by true first")
}
});
%}