Forums Register Login

Assertions Doubts

+Pie Number of slices to send: Send
All these quotes are taken from Dan site, in true/false pattern.
But I want to know what it is and how can we identify by seeing the code that assert has been used as to check control flow invairant/postcondition/precondition/class variant/internal variant


The assert statement is being used to check a control-flow invariant to verify that the control flow never reaches a point in the program.




The assert statement is being used to check a class invariant--something that must be true about each instance of the class




The assert statement is being used to check an internal invariant--something that the programmer assumes to be true at a particular point in the program




The assert statements are being used to check a precondition--something that must be true when the method is invoked.





The assert statement is being used to check a postcondition--something that must be true when the method completes successfully.



can anyone explain the above thing with coding? Whether assertion can be used to check control flow invariant, postcondition and precondition (all the three condition I don't know)

pls explain
[ December 15, 2006: Message edited by: Micheal John ]
+Pie Number of slices to send: Send
Can you post the complete question?
+Pie Number of slices to send: Send
I have understood the precondition/postcondition and control flow invariant.

But still to check class variant and internal variant is not clear:

For Class Variant


For Internal Variant


My Understanding :Control Flow Invariant Example is: if assert statement is used in the default area of the switch or else in if/else construct.

Precondition Example: assert statement will be the first statement of the method, which means while invoking this method itself some thing needs to true..

Postcondition Example: the assert statement will be at the end of the method, which means while returning some thing that needs to true.

Need more clarification on checking on class variant and internal variant..
It runs on an internal combustion engine. This ad does not:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 910 times.
Similar Threads
Assertions Doubt
Assertions
questions about assert
SCJP exam Query....Assertions....
Q about assertion
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 19, 2024 00:05:21.