Test suite for lib-core.crafting v0.1.0. Covers:
1. define_recipe + list_recipes round-trip; shallow-copy isolation
(mutating the returned list does not affect the registry).
2. define_recipe missing id → Loud-Error.
3. define_recipe duplicate id → Loud-Error.
4. define_recipe empty inputs → Loud-Error.
5. get_recipe known/unknown.
6. is_known propagates ctx-identity to recipe.is_known(ctx).
7. can_craft happy-path → ok=true.
8. can_craft missing inputs → error='missing_inputs' +
missing-array with {template, needed, have}.
9. craft happy-path: consumes 2, crafts 1, container has only output.
10. craft unknown recipe → ok=false, error='unknown_recipe',
container untouched.
11. craft is_known=false → ok=false, error='unknown_recipe',
container untouched.
12. count-form: 2-of-3 reports missing={template, needed=3, have=2}.
Uses engine.test.assert with string.find for pattern matching
loud-error messages (engine.test has no assert_match helper).
Per-test isolation via crafting._test_clear_all; composition templates
are defined once at module-scope (composition has no clear-all hook).
Depends on lib-core.crafting 0.1.0, lib-core.inventory-list 0.1.0,
lib-core.composition 0.3.0 (all three direct, per non-transitive
engine resolver).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
12 lines
263 B
Markdown
12 lines
263 B
Markdown
# lib-core.crafting-test
|
|
|
|
Test suite for `lib-core.crafting` v0.1.0.
|
|
|
|
**12 assertions.**
|
|
|
|
**Run:**
|
|
```bash
|
|
SPOREL_LIBS_DIR=~/Projects/Sporel/sporel-libs SPOREL_CI=1 SPOREL_LOG_STDERR=1 \
|
|
./build/Sporel.exe --test-libs=lib-core.crafting-test 2>&1 | tail -30
|
|
```
|