program main
  fn parse_u64(text: string) -> (result u64 i32)
    call std.string.parse_u64_result
      var text
  fn parsed_text(text: string) -> string
    call std.num.u64_to_string
      std.result.unwrap_ok
        call parse_u64
          var text
  fn main() -> i32
    local let value: (result u64 i32)
      call parse_u64
        string "42"
    if
      std.result.is_ok
        var value
      if
        binary =
          call std.num.u64_to_string
            std.result.unwrap_ok
              var value
          string "42"
        int 0
        int 1
      std.result.unwrap_err
        var value
  test "parse u64 zero ok"
    binary =
      call parsed_text
        string "0"
      string "0"
  test "parse u64 high ok"
    binary =
      call parsed_text
        string "18446744073709551615"
      string "18446744073709551615"
  test "parse u64 empty err"
    local let value: (result u64 i32)
      call parse_u64
        string ""
    if
      std.result.is_err
        var value
      binary =
        std.result.unwrap_err
          var value
        int 1
      bool false
  test "parse u64 plus err"
    local let value: (result u64 i32)
      call parse_u64
        string "+1"
    if
      std.result.is_err
        var value
      binary =
        std.result.unwrap_err
          var value
        int 1
      bool false
  test "parse u64 negative err"
    local let value: (result u64 i32)
      call parse_u64
        string "-1"
    if
      std.result.is_err
        var value
      binary =
        std.result.unwrap_err
          var value
        int 1
      bool false
  test "parse u64 above range err"
    local let value: (result u64 i32)
      call parse_u64
        string "18446744073709551616"
    if
      std.result.is_err
        var value
      binary =
        std.result.unwrap_err
          var value
        int 1
      bool false
