roc/test/fx/inspect_custom_test.roc
2025-12-02 01:31:17 -05:00

25 lines
556 B
Text

app [main!] { pf: platform "./platform/main.roc" }
import pf.Stdout
# Define an opaque type with a custom to_inspect method
Color := [Red, Green, Blue].{
to_inspect : Color -> Str
to_inspect = |color| match color {
Red => "Color::Red"
Green => "Color::Green"
Blue => "Color::Blue"
}
}
main! = || {
red : Color
red = Red
# Test inspect with custom to_inspect method
result = inspect red
Stdout.line!(result)
# Compare with what the default would be
Stdout.line!("Expected: Color::Red")
}