InvariantsCore
This file defines the core interface for defining invariants.
abstract
type
AbstractInvariant
end
function
title
end
description
(
::
AbstractInvariant
)
=
nothing
function
satisfies
end
function
errormessage
(
inv
::
AbstractInvariant
,
msg
)
buf
=
IOBuffer
(
)
errormessage
(
IOContext
(
buf
,
:
color
=>
true
,
:
displaysize
=>
(
88
,
500
)
)
,
inv
,
msg
)
return
String
(
take!
(
buf
)
)
end
function
errormessage
(
io
::
IO
,
inv
::
AbstractInvariant
,
msg
)
println
(
io
)
showdescription
(
io
,
inv
)
println
(
io
,
msg
)
end
function
showdescription
(
io
,
inv
)
desc
=
description
(
inv
)
isnothing
(
desc
)
||
print
(
io
,
description
(
inv
)
)
end
function
showtitle
(
io
,
inv
)
print
(
io
,
title
(
inv
)
)
end