Skip to content
docs
Arxo ↗

Exercise 6. A test on silence and a test on dispute

For LLMs2 sections

An exercise for the tests page. The page’s test checks the happy path: registry and accreditation grant access. A test checking only TRUE_ONLY will miss a norm that fires always.

Setup. Write two tests for the same package. The first: with one registry fact, access is not established, computation took place, and the access norm was not applied. The second: registry, accreditation, and a “not admitted” case record yield BOTH, with the norm applied.

Hint. Besides truth_status and evaluation_status, a test holds the applied(<norm name>) expectation, and it can be negated.

Below is the solution. Try it yourself first.

The same package as on the tests page:

Arxo Law
language "law.core" version "0.2";
package tutorial.archive.tested version "0.1.1";
namespace "urn:law:tutorial:archive:tested";
entity Person;
relation in_researcher_registry(p: Person) kind institutional;
relation accredited(p: Person) kind institutional;
relation may_enter_rare_room(p: Person) kind institutional;
rule RareRoomAccess strict {
for p: Person;
when in_researcher_registry(p) and accredited(p);
then may_enter_rare_room(p);
}

First test. Three expectations, the third the point here: NEITHER could also come from a norm that fired but whose conclusion was overridden. The “not applied” expectation cuts that off:

Arxo Law
test "только реестр — допуск не установлен, норма не применялась" {
given {
context {
decision_time @2026-03-01T09:00:00+05:00;
knowledge_time @2026-03-01T09:00:00+05:00;
legal_time @2026-03-01;
timezone "Asia/Almaty";
}
assert in_researcher_registry(entity_ref("urn:tutorial:ivanova")) {
id "assert-reg";
origin case_input;
}
}
evaluate truth(may_enter_rare_room(entity_ref("urn:tutorial:ivanova")));
expect truth_status == NEITHER;
expect evaluation_status == COMPUTED;
expect not applied(RareRoomAccess);
}

The test name reads: “Registry only — access not established, the norm not applied.”

Second test. The negative record is fed by the same assert with the word not before the literal. The norm fired, and its conclusion stands next to the record. The compiler does not accept the positive applied(...) observation inside the page package, so this test is shown as text and executed from the file:

Arxo Law
test "норма и запись дела спорят — BOTH при применённой норме" {
given {
context {
decision_time @2026-03-01T09:00:00+05:00;
knowledge_time @2026-03-01T09:00:00+05:00;
legal_time @2026-03-01;
timezone "Asia/Almaty";
}
assert in_researcher_registry(entity_ref("urn:tutorial:ivanova")) {
id "assert-reg";
origin case_input;
}
assert accredited(entity_ref("urn:tutorial:ivanova")) {
id "assert-acc";
origin case_input;
}
assert not may_enter_rare_room(entity_ref("urn:tutorial:ivanova")) {
id "assert-refused";
origin case_input;
}
}
evaluate truth(may_enter_rare_room(entity_ref("urn:tutorial:ivanova")));
expect truth_status == BOTH;
expect applied(RareRoomAccess);
}

The test name reads: “The norm and the case record argue — BOTH with the norm applied.”

Both tests lie in the ready-made test file and are executed on this page’s program:

Terminal
B=engines/lawc/target/gate/law-cli
$B lower docs/tutorials/36-exercise-writing-tests.en.law.md > /tmp/ex36.lawir.json
$B test docs/tutorials/tests/36-exercise-tests.lawtest --lawtest --program /tmp/ex36.lawir.json

What the exercise teaches. A NEITHER test without not applied does not tell “the norm did not fire” from “the norm fired but the conclusion is not established”. A pair of tests, positive and negative, with an application expectation is the minimum for every norm, needed on every later track page.

Documentation for Arxo. Writings — blog.arxo.io.

Anonymous visit counts on stats.arxo.io, no cookies.