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