program main fn parse_bool(text: string) -> (result bool i32) call std.string.parse_bool_result : (result bool i32) var text : string fn bool_score(text: string) -> i32 local let value : unit call parse_bool : (result bool i32) var text : string if : i32 std.result.is_ok : bool var value : (result bool i32) if : i32 std.result.unwrap_ok : bool var value : (result bool i32) int 1 : i32 int 0 : i32 std.result.unwrap_err : i32 var value : (result bool i32) fn main() -> i32 local let value : unit call parse_bool : (result bool i32) string "true" : string if : i32 std.result.is_ok : bool var value : (result bool i32) if : i32 std.result.unwrap_ok : bool var value : (result bool i32) int 0 : i32 int 1 : i32 std.result.unwrap_err : i32 var value : (result bool i32) test "parse bool true ok" local let value : unit call parse_bool : (result bool i32) string "true" : string if : bool std.result.is_ok : bool var value : (result bool i32) std.result.unwrap_ok : bool var value : (result bool i32) bool false : bool test "parse bool false ok" local let value : unit call parse_bool : (result bool i32) string "false" : string if : bool std.result.is_ok : bool var value : (result bool i32) if : bool std.result.unwrap_ok : bool var value : (result bool i32) bool false : bool bool true : bool bool false : bool test "parse bool uppercase err" local let value : unit call parse_bool : (result bool i32) string "TRUE" : string if : bool std.result.is_err : bool var value : (result bool i32) binary = : bool std.result.unwrap_err : i32 var value : (result bool i32) int 1 : i32 bool false : bool test "parse bool empty err" local let value : unit call parse_bool : (result bool i32) string "" : string if : bool std.result.is_err : bool var value : (result bool i32) binary = : bool std.result.unwrap_err : i32 var value : (result bool i32) int 1 : i32 bool false : bool test "parse bool whitespace err" local let value : unit call parse_bool : (result bool i32) string " true" : string if : bool std.result.is_err : bool var value : (result bool i32) binary = : bool std.result.unwrap_err : i32 var value : (result bool i32) int 1 : i32 bool false : bool test "parse bool helper flow" binary = : bool binary + : i32 call bool_score : i32 string "true" : string call bool_score : i32 string "false" : string int 1 : i32