program main
  fn parse_i64(text: string) -> (result i64 i32)
    call std.string.parse_i64_result
      var text
  fn parsed_text(text: string) -> string
    call std.num.i64_to_string
      std.result.unwrap_ok
        call parse_i64
          var text
  fn main() -> i32
    local let value: (result i64 i32)
      call parse_i64
        string "-7"
    if
      std.result.is_ok
        var value
      if
        binary =
          call std.num.i64_to_string
            std.result.unwrap_ok
              var value
          string "-7"
        int 0
        int 1
      std.result.unwrap_err
        var value
  test "parse i64 zero ok"
    binary =
      call parsed_text
        string "0"
      string "0"
  test "parse i64 negative ok"
    binary =
      call parsed_text
        string "-7"
      string "-7"
  test "parse i64 low ok"
    binary =
      call parsed_text
        string "-9223372036854775808"
      string "-9223372036854775808"
  test "parse i64 high ok"
    binary =
      call parsed_text
        string "9223372036854775807"
      string "9223372036854775807"
  test "parse i64 empty err"
    local let value: (result i64 i32)
      call parse_i64
        string ""
    if
      std.result.is_err
        var value
      binary =
        std.result.unwrap_err
          var value
        int 1
      bool false
  test "parse i64 plus err"
    local let value: (result i64 i32)
      call parse_i64
        string "+1"
    if
      std.result.is_err
        var value
      binary =
        std.result.unwrap_err
          var value
        int 1
      bool false
  test "parse i64 above range err"
    local let value: (result i64 i32)
      call parse_i64
        string "9223372036854775808"
    if
      std.result.is_err
        var value
      binary =
        std.result.unwrap_err
          var value
        int 1
      bool false
