Skip to content

Add VisuStructCore tests and CI workflow - #8

Merged
code4teaching merged 2 commits into
mainfrom
core-tests-and-ci
Oct 18, 2026
Merged

code4teaching merged 2 commits into
mainfrom
core-tests-and-ci

Conversation

@code4teaching

@code4teaching code4teaching commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

Requested by Holger · project thread

Before: VisuStructCore had one test (decoding a tiny XML snippet) and nothing ran it automatically.

After: swift test runs on every pull request and every push to main (macOS runner), and checks the simulator, the code generators and the XML codec against the example diagrams in VisuStruct-Dateien.

What the tests cover:

  • Every .visustruct example loads, survives save + reload unchanged, and produces non-empty Java, Python and JavaScript.
  • Simulation of Collatz, Fibonacci and NumberEven (with input) gives the expected output; plus for/do-until loops, switch with default, &&/||/!=, rejected input and division by zero.
  • The Java class export for Collatz and Fibonacci matches the shipped .java files; Python/JS output for Collatz has the expected loop and print lines.

Fixes found along the way:

  • sanitizedJavaClassName: a title starting with a digit ("2 Summe") produced 2_Summe, which is not a valid Java class name; it now yields _2_Summe.
  • The existing XML codec test fed plain text, but the format stores text as ;-separated code points, so it had been failing silently (it never ran before). It now uses the encoded form.

How: shared helpers in TestSupport.swift locate VisuStruct-Dateien via #filePath and drive the simulation engine to completion, feeding inputs.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ

Tests cover loading, round-tripping and code generation for every example
diagram in VisuStruct-Dateien, simulation of the Collatz, Fibonacci and
NumberEven examples plus loops, switch, conditions and errors, and the
Java class export against the shipped .java files.

Also fixes sanitizedJavaClassName returning a name that starts with a
digit ("2 Summe" -> "2_Summe"), which is not a valid Java class name.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
@code4teaching code4teaching self-assigned this Oct 18, 2026
The test fed plain text, but .visustruct/.strk store text as
semicolon-separated code points, so it decoded to empty strings.
It had never run before CI existed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
@code4teaching
code4teaching marked this pull request as ready for review October 18, 2026 21:50
@code4teaching
code4teaching merged commit 3f9a3e2 into main Oct 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants