program main
  fn stdin_result() -> (result string i32)
    call std.io.read_stdin_result : (result string i32)
  fn stdin_text_or_empty(value: (result string i32)) -> string
    match : string
      subject
        var value : (result string i32)
      arm ok text
        var text : string
      arm err code
        string "" : string
  fn stdin_len_or_code(value: (result string i32)) -> i32
    match : i32
      subject
        var value : (result string i32)
      arm ok text
        call std.string.len : i32
          var text : string
      arm err code
        var code : i32
  fn stdin_ok_len() -> i32
    call std.string.len : i32
      unwrap_ok : string
        call stdin_result : (result string i32)
  fn main() -> i32
    local let value : unit
      call stdin_result : (result string i32)
    if : i32
      is_ok : bool
        var value : (result string i32)
      call std.string.len : i32
        unwrap_ok : string
          var value : (result string i32)
      int 1 : i32
  test "stdin result test runner returns ok"
    is_ok : bool
      call stdin_result : (result string i32)
  test "stdin result payload length matches match"
    local let value : unit
      call stdin_result : (result string i32)
    binary = : bool
      call std.string.len : i32
        unwrap_ok : string
          var value : (result string i32)
      call stdin_len_or_code : i32
        var value : (result string i32)
  test "stdin result match observes ok payload"
    local let value : unit
      call stdin_result : (result string i32)
    binary = : bool
      call std.string.len : i32
        call stdin_text_or_empty : string
          var value : (result string i32)
      call stdin_len_or_code : i32
        var value : (result string i32)
