roc/test/str/platform/Helper.roc
Luke Boswell cd6a5900c6
fix multi-module platform exposes and add str platform tests
Fix a bug where platforms exposing multiple modules would fail at runtime
with "nested value not found" errors when modules call each other's methods.

Root cause: compileAndSerializeModulesForEmbedding was passing module names
in the wrong order (exposed_modules.items vs sorted_modules), and wasn't
passing type module names when compiling sibling platform modules.

Changes:
- src/cli/main.zig: Pass sorted_modules as type module names when compiling
  platform modules, platform main, and app modules
- src/eval/interpreter.zig: Improve error messages for nested_value_not_found
- src/canonicalize/Can.zig: Add trace output for nested_value_not_found

Test infrastructure:
- Add SimpleTestSpec and simple_list variant to platform_config.zig
- Add 8 str platform tests covering direct calls, transitive calls, and
  diamond dependency patterns
- Update test_runner.zig to handle simple_list
- Add test_runner invocations for int and str platforms to build.zig
- Make CLI tests run sequentially to avoid cache race conditions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 17:10:56 +11:00

23 lines
749 B
Text

# Helper module - imports Core and Utils (diamond dependency pattern)
# Diamond: Helper→Core→Utils and Helper→Utils
import Core
import Utils
Helper := [].{
# Simple method that does NOT call other modules
simple : Str -> Str
simple = |s| "simple: ${s}"
# This function calls Core.wrap internally (transitive call)
wrap_fancy : Str -> Str
wrap_fancy = |s| Core.wrap("fancy: ${s}")
# This function calls Core.prefix internally (transitive call)
prefix_fancy : Str -> Str
prefix_fancy = |s| Core.prefix("fancy: ${s}")
# Uses both Core and Utils - exercises diamond dependency
# Helper→Core→Utils AND Helper→Utils
wrap_quoted : Str -> Str
wrap_quoted = |s| Core.wrap(Utils.quote(s))
}