~:
    [ utf8Test i [utf8 "xαβ"]
        [ prompt 0, utf8 "x" <> end <> output 0 (utf8 "x")
          <> prompt 1 <> utf8 "α" <> end <> output 1 (utf8 "α")
          <> prompt 2 <> utf8 "β" <> end <> output 2 (utf8 "β")
          <> prompt 3
        ]
    , "bad encoding (separate)" ~:
        utf8Test i [utf8 "α", raw [149], utf8 "x", raw [206]]
        [ prompt 0, utf8 "α" <> end <> output 0 (utf8 "α") <> prompt 1
        , err <> end <> output 1 err <> prompt 2
        , utf8 "x" <> end <> output 2 (utf8 "x") <> prompt 3
        , whenLegacy (err <> end <> output 3 err <> prompt 4)
        ]
    , "bad encoding (together)" ~:
        utf8Test i [utf8 "α" <> raw [149] <> utf8 "x" <> raw [206]]
        [ prompt 0, utf8 "α" <> end <> output 0 (utf8 "α")
        <> prompt 1 <> err <> end <> output 1 err
        <> prompt 2 <> utf8 "x" <> end <> output 2 (utf8 "x")
        <> prompt 3 <> whenLegacy (err <> end <> output 3 err <> prompt 4)
        ]
    , utf8Test i [raw [206]] -- incomplete
        [ prompt 0, whenLegacy (utf8 "?" <> end <> output 0 (utf8 "?"))
        <> whenLegacy (prompt 1)
        ]
    ]

setCharInput :: Invocation -> Invocation
setCharInput i = i { progArgs 
inputChar :: Invocation -> Test
inputChar i = "getInputChar" ~:
    [ utf8Test i [utf8 "xαβ"]
        [ prompt 0, utf8 "x" <> end <> output 0 (utf8 "x")
          <> prompt 1 <> utf8 "α" <> end <> output 1 (utf8 "α")
          <> prompt 2 <> utf8 "β" <> end <> output 2 (utf8 "β")
          <> prompt 3
        ]
    , "bad encoding (separate)" ~:
        utf8Test i [utf8 "α", raw [149], utf8 "x", raw [206]]
        [ prompt 0, utf8 "α" <> end <> output 0 (utf8 "α") <> prompt 1
        , err <> end <> output 1 err <> prompt 2
        , utf8 "x" <> end <> output 2 (utf8 "x") <> prompt 3
        , whenLegacy (err <> end <> output 3 err <> prompt 4)
        ]
    , "bad encoding (together)" ~:
        utf8Test i [utf8 "α" <> raw [149] <> utf8 "x" <> raw [206]]
        [ prompt 0, utf8 "α" <> end <> output 0 (utf8 "α")
        <> prompt 1 <> err <> end <> output 1 err
        <> prompt 2 <> utf8 "x" <> end <> output 2 (utf8 "x")
        <> prompt 3 <> whenLegacy (err <> end <> output 3 err <> prompt 4)
        ]
    , utf8Test i [raw [206]] -- incomplete
        [ prompt 0, whenLegacy (utf8 "?" <> end <> output 0 (utf8 "?"))
        <> whenLegacy (prompt 1)
        ]
    ]
inputChar i = "getInputChar" ~:
    [ utf8Test i [utf8 "xαβ"]
        [ prompt 0, utf8 "x" <> end <> output 0 (utf8 "x")
          <> prompt 1 <> utf8 "α" <> end <> output 1 (utf8 "α")
          <> prompt 2 <> utf8 "β" <> end <> output 2 (utf8 "β")
          <> prompt 3
        ]
    , "bad encoding (separate)" ~:
        utf8Test i [utf8 "α", raw [149], utf8 "x", raw [206]]
        [ prompt 0, utf8 "α" <> end <> output 0 (utf8 "α") <> prompt 1
        , err <> end <> output 1 err <> prompt 2
        , utf8 "x" <> end <> output 2 (utf8 "x") <> prompt 3
        , whenLegacy (err <> end <> output 3 err <> prompt 4)
        ]
    , "bad encoding (together)" ~:
        utf8Test i [utf8 "α" <> raw [149] <> utf8 "x" <> raw [206]]
        [ prompt 0, utf8 "α" <> end <> output 0 (utf8 "α")
        <> prompt 1 <> err <> end <> output 1 err
        <> prompt 2 <> utf8 "x" <> end <> output 2 (utf8 "x")
        <> prompt 3 <> whenLegacy (err <> end <> output 3 err <> prompt 4)
        ]
    , utf8Test i [raw [206]] -- incomplete
        [ prompt 0, whenLegacy (utf8 "?" <> end <> output 0 (utf8 "?"))
        <> whenLegacy (prompt 1)
        ]
    ]