The state of the TestConsole
.
Accesses a TestConsole
instance in the environment and clears the input
buffer.
Accesses a TestConsole
instance in the environment and clears the output
buffer.
Accesses a TestConsole
instance in the environment and runs the
specified effect with the TestConsole
set to debug mode, so that
console output is rendered to standard output in addition to being
written to the output buffer.
Accesses a TestConsole
instance in the environment and writes the
specified sequence of strings to the input buffer.
Constructs a new Test
object that implements the TestConsole
interface.
Constructs a new Test
object that implements the TestConsole
interface. This can be useful for mixing in with implementations of other
interfaces.
Accesses a TestConsole
instance in the environment and returns the
contents of the output buffer.
Accesses a TestConsole
instance in the environment and returns the
contents of the error buffer.
Accesses a TestConsole
instance in the environment and saves the
console state in an effect which, when run, will restore the
TestConsole
to the saved state.
Accesses a TestConsole
instance in the environment and runs the
specified effect with the TestConsole
set to silent mode, so that
console output is only written to the output buffer and not rendered to
standard output.
TestConsole
provides a testable interface for programs interacting with the console by modeling input and output as reading from and writing to input and output buffers maintained byTestConsole
and backed by aRef
.All calls to
putStr
andputStrLn
using theTestConsole
will write the string to the output buffer and all calls togetStrLn
will take a string from the input buffer. To facilitate debugging, by default output will also be rendered to standard output. You can enable or disable this for a scope usingdebug
,silent
, or the corresponding test aspects.TestConsole
has several methods to access and manipulate the content of these buffers includingfeedLines
to feed strings to the input buffer that will then be returned by calls togetStrLn
,output
to get the content of the output buffer from calls toputStr
andputStrLn
, andclearInput
andclearOutput
to clear the respective buffers.Together, these functions make it easy to test programs interacting with the console.