Files
hakorune/apps/tests/phase246ex_atoi_mini.hako
nyash-codex 463a6240fb chore(test): Improve phase246ex_atoi_mini test format
- Change from string return ("PASS"/"FAIL") to numeric RC (0=success, 1=fail)
- Add print("result = N") for stdout verification
- Update comments to reflect new test format

This makes test results verifiable via both stdout AND return code,
avoiding future confusion about RC interpretation.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-11 17:24:32 +09:00

36 lines
847 B
Plaintext

// Phase 246-EX: Minimal _atoi test
// Tests NumberAccumulation pattern: result = result * 10 + digit_pos
// Prints "result = N" to stdout, returns 0 on success (42), 1 on failure.
static box Phase246ExAtoiMini {
main() {
local s = "42"
local len = 2
local result = me.atoi(s, len)
// Expected: 42
print("result = " + result)
if result == 42 {
return 0
} else {
return 1
}
}
method atoi(s, len) {
local result = 0
local digits = "0123456789"
local i = 0
loop(i < len) {
local ch = s.substring(i, i + 1)
local digit_pos = digits.indexOf(ch)
if digit_pos < 0 { break }
result = result * 10 + digit_pos
i = i + 1
}
return result
}
}