This is great, but code becomes more cluttered and violates separation of concerns. Is there anyway to move pre- and post-conditions to the end of a file where all tests can be collected, then somehow inject the code into the functions, perhaps via macro? Think of it like decorators. For example:
importcontrafuncfn1(x:int):int=x-1funcfn2(x:int):int=x-1# Bottom of filecontrafn1:# Like block-label syntaxpreconditionsx>1,x<20postconditionsresult>0contrafn2:preconditionsx>1,x<20postconditionsresult>0
And this would run exactly as if you had written the following:
This is great, but code becomes more cluttered and violates separation of concerns. Is there anyway to move pre- and post-conditions to the end of a file where all tests can be collected, then somehow inject the code into the functions, perhaps via macro? Think of it like decorators. For example:
And this would run exactly as if you had written the following:
I am new to Nim, so I don't know if the above syntax or similar is possible via a module import.
Cheers~