Files
Dune/tests/truthtrance-freeform-v4.test.ts
T
Quintine 4f990db52e
Verify and publish checkpoint container / container (push) Canceled after 0s
Expand Basic Semuta and Truthtrance rules
2026-10-29 05:57:46 +11:00

30 lines
1.7 KiB
TypeScript

import assert from 'node:assert/strict';
import test from 'node:test';
import { parseFreeformFactV3 } from '../game/truthtrance-freeform-facts-v3';
import { parseFreeformFactV4 } from '../game/truthtrance-freeform-facts-v4';
void test('v4 parses exact negative named cards and primary hand categories', () => {
const cases = [
['Do you have no Shield?', {kind:'handCount', name:'Shield', compare:'eq', value:0}],
['DO YOU NOT HAVE A SHIELD IN YOUR HAND?', {kind:'handCount', name:'Shield', compare:'eq', value:0}],
['Do you have no poison weapons?', {kind:'handInventory', category:'poisonWeapon', compare:'eq', value:0}],
['Do you not have any projectile defenses in your hand?', {kind:'handInventory', category:'projectileDefense', compare:'eq', value:0}],
['Do you have no cards in your hand?', {kind:'handInventory', category:'all', compare:'eq', value:0}],
['Do you not have a worthless card?', {kind:'handInventory', category:'worthless', compare:'eq', value:0}],
] as const;
for (const [text, expected] of cases) {
assert.equal(parseFreeformFactV3(text), null, text);
assert.deepEqual(parseFreeformFactV4(text), expected, text);
}
});
void test('v4 rejects ambiguous, future, malformed and compound language', () => {
for (const text of [
'Do you have no special cards?', 'Do you not have a weapons?', 'Do you have no constructor?',
'Do you have no Shield or Snooper?', 'Will you have no Shield?',
'Do you have no Shield this turn?', 'Do you have no Shield??',
'Do you have no Shield?\nPlease answer.', 'Do you have no Shield?'.padEnd(501, ' '),
'Do you have at most 0 poison weapons?',
]) assert.equal(parseFreeformFactV4(text), null, text);
});