Eiffel has a feature Design by Contract. According to this, for any routine, there is a check that assertions such as require
and ensure
must be true. However, I haven't been able to find out how to enforce the rule through command line that if the assertions are false, there must be an error/exception thrown by the compiler or during run time.
For example, if this is the root class,
class
APPLICATION
inherit
ARGUMENTS
create
make
feature {NONE}
object: TEST1
make
-- Run application.
do
create object
object.function(-1)
print(object.value)
end
end
and this is the TEST1
class
class
TEST1
feature
value: INTEGER
-- value for testing
function(val: INTEGER)
-- Assign
require
val>0
do
value:=val
ensure
value>0
end
end
The program compiles and executes without any error, even though both the assertions are violated.
I am compiling using
ec application.e
However, Eiffel Studio does report a violation of contract.
So, how can one enforce this through command line? Is there a particular flag to use?