Interpret bounded Truthtrance fact questions
Verify and publish checkpoint container / container (push) Successful in 10m38s
Verify and publish checkpoint container / container (push) Successful in 10m38s
This commit is contained in:
1 parent
88c0ab1547
commit
8ae275f598
16 files changed
+431
-31
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { parseFreeformFactV1 } from '../game/truthtrance-freeform-facts';
|
||||
import { TRUTH_CARD_NAMES } from '../game/truthtrance-card-names';
|
||||
|
||||
void test('freeform v1 compiles exact current personal spice comparisons', () => {
|
||||
assert.deepEqual(parseFreeformFactV1('Do you have at least 5 spice?'), {kind:'spice', compare:'gte', value:5});
|
||||
assert.deepEqual(parseFreeformFactV1(' DO YOU HAVE EXACTLY 0 SPICE '), {kind:'spice', compare:'eq', value:0});
|
||||
assert.deepEqual(parseFreeformFactV1('do you have at most 7 spice'), {kind:'spice', compare:'lte', value:7});
|
||||
assert.deepEqual(parseFreeformFactV1('Do\tyou have at\tleast 0002 spice?'), {kind:'spice', compare:'gte', value:2});
|
||||
assert.equal(parseFreeformFactV1('Do you have exactly 9007199254740992 spice?'), null);
|
||||
});
|
||||
|
||||
void test('freeform v1 resolves only exact printed card names regardless of case', () => {
|
||||
for (const name of TRUTH_CARD_NAMES) {
|
||||
assert.deepEqual(parseFreeformFactV1(`do you have a ${name.toUpperCase()}?`), {kind:'hand', name});
|
||||
}
|
||||
assert.deepEqual(parseFreeformFactV1('Do you have an Artillery Strike?'), {kind:'hand', name:'Artillery Strike'});
|
||||
assert.equal(parseFreeformFactV1('Do you have a shield card?'), null);
|
||||
assert.equal(parseFreeformFactV1('Do you have a secret weapon?'), null);
|
||||
});
|
||||
|
||||
void test('freeform v1 declines ambiguous, compound, negative and future wording', () => {
|
||||
for (const phrase of [
|
||||
'', 'Do you have 5 spice?', 'Do you have more than 5 spice?',
|
||||
'Do you have at least -1 spice?', 'Do you have at least 2.5 spice?',
|
||||
'Do you have at least 5 spice and a Shield?',
|
||||
'Do you not have a Shield?', 'Do you have a Shield or a Snooper?',
|
||||
'Do you have a Shield this turn?', 'Will you have at least 5 spice?',
|
||||
'Do you have a Shield??', 'Do you have a Shield? Please answer.',
|
||||
'Do you have at least 5 spice?\nOr a Shield?',
|
||||
'Do you have a Shield?'.padEnd(501, ' '),
|
||||
]) assert.equal(parseFreeformFactV1(phrase), null, phrase);
|
||||
});
|
||||
Reference in new issue
Block a user