chroma_solstice/libs/narrator/test/runtime/visits.lua
Your Name 03532d29e4 Vendor libs/hump, sfxrlua, json4lua, narrator as real files
These were committed as empty submodule gitlinks with no .gitmodules,
so the folders were never populated and the game could not load
(require of libs/hump/timer, libs/sfxrlua/sfxr, narrator.narrator).
Checked out each at its pinned commit and vendored the files, matching
the existing bundled-libs convention. Removed the junk libs/libs/ tree.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-11 11:37:09 -04:00

65 lines
No EOL
1.6 KiB
Lua

local narrator, describe, it, assert = ...
local content = [[
A root text
+ Go to knot -> knot
=== knot
+ Go to stitch -> stitch
= stitch
+ Go to label -> label
- (label) Some text
+ (choice) Go to root -> _._
]]
local book = narrator.parse_content(content)
local story = narrator.init_story(book)
story:begin()
local function visits()
local visits = {
root = story:get_visits(''),
knot = story:get_visits('knot'),
stitch = story:get_visits('knot.stitch'),
label = story:get_visits('knot.stitch.label'),
choice = story:get_visits('knot.stitch.choice')
}
return visits
end
local places = { 'root', 'knot', 'stitch', 'label' }
for cycle = 1, 3 do
describe('Visits with cycle ' .. cycle .. '.', function()
story:continue()
for place_index = 1, #places do
local place = places[place_index]
it('Visit the ' .. place .. '.', function()
story:continue()
local place = place
local divert = story.choices[1].divert
local expected_root = cycle
local expected_knot = place_index > 1 and cycle or cycle - 1
local expected_stitch = place_index > 2 and cycle or cycle - 1
local expected_label = place_index > 3 and cycle or cycle - 1
local expected_choice = place_index > 4 and cycle or cycle - 1
local visits = visits()
assert.equal(visits.root, expected_root)
assert.equal(visits.knot, expected_knot)
assert.equal(visits.stitch, expected_stitch)
assert.equal(visits.label, expected_label)
assert.equal(visits.choice, expected_choice)
story:choose(1)
end)
end
end)
end