initial: actor-test v0.1.0 — 8 assertions
Phase-A.5 test-lib for lib-core.actor. Covers create-validation (missing/zero movement_speed loud-errors + valid spec), position (initial x/y), move ((0,0) no-op + additive delta), movement_speed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
24
LICENSE
Normal file
24
LICENSE
Normal file
@@ -0,0 +1,24 @@
|
||||
Copyright (c) 2026 Calic. All rights reserved.
|
||||
|
||||
This software is part of the Sporel platform — **Tier 1 (Official /
|
||||
Proprietary)** content per the Three-Tier Licensing Model documented in
|
||||
`meta/docs/archive/design/vision.md §Licensing Model` (current source;
|
||||
migration to `meta/docs/architecture/licensing-model.md` pending).
|
||||
|
||||
⚠ **WIP — Legal review required before public launch.** The terms below
|
||||
reflect design intent only; the formalized license framework will be
|
||||
finalized through legal counsel before the first public release. Until
|
||||
then, this notice serves as a placeholder defending the platform owner's
|
||||
rights against unintentional re-licensing.
|
||||
|
||||
No license is granted to copy, modify, distribute, sublicense, or otherwise
|
||||
use this software in any form without prior written permission from the
|
||||
copyright holder.
|
||||
|
||||
References:
|
||||
- Tier 1 (this file): all rights reserved, proprietary, sold/distributed
|
||||
via official channels (Steam, etc.)
|
||||
- Tier 2 (Semi-Commercial Co-Development): bilateral contracts, revenue-
|
||||
share — see vision.md §Licensing Model
|
||||
- Tier 3 (Community Content): CC BY-NC-SA 4.0 + asymmetric CLA — applies
|
||||
to community-uploaded libs/modules/assets, not this repo
|
||||
27
README.md
Normal file
27
README.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# lib-core.actor-test
|
||||
|
||||
Test-lib for `lib-core.actor` v0.1.0. Follows the P.2.4 Test-Module-
|
||||
Pattern: exports `run_tests(ctx)` invoked by the engine's `--test-libs`
|
||||
runner; uses `engine.test.*` for TAP-style output.
|
||||
|
||||
**Version:** 0.1.0
|
||||
**Lib-ID:** lib-core.actor-test
|
||||
**Role:** test
|
||||
**Requires:** lib-core.actor v0.1.0, lib-core.composition v0.1.0
|
||||
**Tags:** test, actor
|
||||
|
||||
## Coverage (8 assertions)
|
||||
|
||||
| Group | Count | What |
|
||||
|---|---|---|
|
||||
| `create` validation | 3 | missing-movement_speed error, zero-movement_speed error, valid-spec returns handle |
|
||||
| `position` | 2 | initial x, initial y |
|
||||
| `move` | 2 | (0,0) is no-op, additive delta updates position |
|
||||
| `movement_speed` | 1 | reads override value |
|
||||
|
||||
## Run
|
||||
|
||||
```bash
|
||||
~/Projects/Sporel/sporel-engine/build/sporel \
|
||||
--test-libs=lib-core.actor-test
|
||||
```
|
||||
85
init.lua
Normal file
85
init.lua
Normal file
@@ -0,0 +1,85 @@
|
||||
-- lib-core.actor-test — Phase A.5
|
||||
-- 8 assertions: 3 create-validation + 2 position + 2 move + 1 movement_speed.
|
||||
-- Pattern follows P.2.4 Test-Module-Pattern; TAP output via engine.test.*
|
||||
|
||||
local actor = require("lib-core.actor")
|
||||
local composition = require("lib-core.composition")
|
||||
local T = engine.test
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.run_tests(ctx)
|
||||
-- Caller-side: define a template once. Actor doesn't auto-define.
|
||||
composition.define_template{
|
||||
id = "test_actor",
|
||||
properties = {
|
||||
position = {x = 0, y = 0},
|
||||
movement_speed = 100,
|
||||
},
|
||||
tags = {"renderable"},
|
||||
}
|
||||
|
||||
-- ----------------------------------------------------------------
|
||||
-- create-validation (3)
|
||||
-- ----------------------------------------------------------------
|
||||
|
||||
-- Loud-error on missing movement_speed
|
||||
local ok_missing_ms = pcall(actor.create, {
|
||||
template = "test_actor",
|
||||
properties = { position = {x = 0, y = 0} },
|
||||
})
|
||||
T.assert(not ok_missing_ms,
|
||||
"actor.create loud-errors when properties.movement_speed missing")
|
||||
|
||||
-- Loud-error on non-positive movement_speed
|
||||
local ok_zero_ms = pcall(actor.create, {
|
||||
template = "test_actor",
|
||||
properties = { position = {x = 0, y = 0}, movement_speed = 0 },
|
||||
})
|
||||
T.assert(not ok_zero_ms,
|
||||
"actor.create loud-errors when movement_speed is 0")
|
||||
|
||||
-- Happy path: valid spec returns a handle
|
||||
local a1 = actor.create{
|
||||
template = "test_actor",
|
||||
properties = {
|
||||
position = {x = 100, y = 200},
|
||||
movement_speed = 150,
|
||||
},
|
||||
}
|
||||
T.assert(a1 ~= nil, "actor.create returns non-nil handle on valid spec")
|
||||
|
||||
-- ----------------------------------------------------------------
|
||||
-- position (2)
|
||||
-- ----------------------------------------------------------------
|
||||
|
||||
-- position returns initial values
|
||||
local x, y = actor.position(a1)
|
||||
T.equals(x, 100, "actor.position returns initial x")
|
||||
T.equals(y, 200, "actor.position returns initial y")
|
||||
|
||||
-- ----------------------------------------------------------------
|
||||
-- move (2)
|
||||
-- ----------------------------------------------------------------
|
||||
|
||||
-- move(0, 0) is no-op
|
||||
actor.move(a1, 0, 0)
|
||||
local x0, y0 = actor.position(a1)
|
||||
T.assert(x0 == 100 and y0 == 200,
|
||||
"actor.move(0,0) preserves position")
|
||||
|
||||
-- move(dx, dy) updates position additively
|
||||
actor.move(a1, 50, -25)
|
||||
local x1, y1 = actor.position(a1)
|
||||
T.assert(x1 == 150 and y1 == 175,
|
||||
"actor.move(50,-25) shifts position to (150, 175)")
|
||||
|
||||
-- ----------------------------------------------------------------
|
||||
-- movement_speed (1)
|
||||
-- ----------------------------------------------------------------
|
||||
|
||||
T.equals(actor.movement_speed(a1), 150,
|
||||
"actor.movement_speed returns the override value (150)")
|
||||
end
|
||||
|
||||
return M
|
||||
6
manifest.core
Normal file
6
manifest.core
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"id": "lib-core.actor-test.core",
|
||||
"kind": "lib",
|
||||
"version": "0.1.0",
|
||||
"license": "Proprietary"
|
||||
}
|
||||
10
manifest.lib
Normal file
10
manifest.lib
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"id": "lib-core.actor-test",
|
||||
"role": "test",
|
||||
"version": "0.1.0",
|
||||
"api_min": "0.1",
|
||||
"deps": [
|
||||
{"id": "lib-core.actor", "version": "0.1.0"},
|
||||
{"id": "lib-core.composition", "version": "0.1.0"}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user