Forum > Translations

Translation of: Include assertion code (id 155)

(1/3) > >>

nikel:
In translation file there's a line "Include assertion code". I looked up several dictionaries for the word assertion and I found some things like:

* notice
* action of approval the process for sanction
* insistence

Could somoone tell me what is this?

Xor-el:
assert could mean to confirm or to verify.

nikel:
Thank you for your answer, I'm using something like confirmation.

wp:
I think it means, in other words, "include code related to the procedure Assert()" - see https://www.freepascal.org/docs-html/rtl/system/assert.html

howardpc:
Assertion is probably used here in a technical programming sense.
"Assert()" is a built-in FPC function (the idea is borrowed from C-type languages) that is used in the debugging phase only.
e.g.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Assert(Assigned(myObject),'the reference to myObject is Nil');
This simple idea enables you to sprinkle sanity checks all over your code to test essential conditions that you may assume hold true, but perhaps, for reasons you have overlooked, do not in fact hold true, and so trash your whole scheme. If the condition you "assert" to be true is not in fact true, then an exception is raised, and the message you wrote in the Assert procedure is shown.

The benefit of using "Assert()" in your code is that by a simple command-line switch (-Sa) the inclusion of all assertion code can be enabled. Otherwise, no assertion code is included, even though you do not manually change any lines in your units that call Assert.

So in the debug phase of project development you can run with all assertion checks enabled by activating a single command-line parameter.
In the production phase you omit assertion code generation, and your executable is thereby smaller and faster, once you have eliminated any bugs the assertions have shown up.

Navigation

[0] Message Index

[#] Next page

Go to full version