Does PureUnit work with modules?

Just starting out? Need help? Post your questions and find answers here.
User avatar
Erich
User
User
Posts: 49
Joined: Thu Sep 30, 2010 9:21 pm

Does PureUnit work with modules?

Post by Erich »

I always get an error "Can't define a procedure inside another procedure" when I want to test a procedure from a module. :(
"I have never let my schooling interfere with my education." - Mark Twain
freak
PureBasic Team
PureBasic Team
Posts: 5941
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Does PureUnit work with modules?

Post by freak »

I must say I did not test this yet, but it should work as long as you keep the test procedures outside of the module (in the main scope). The test procedure should be able to call module code without problems.

Do you have some example code to show your problem?
quidquid Latine dictum sit altum videtur
Little John
Addict
Addict
Posts: 4789
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Does PureUnit work with modules?

Post by Little John »

freak wrote:I must say I did not test this yet, but it should work as long as you keep the test procedures outside of the module (in the main scope).
I have written several programs for testing modules with PureUnit in this way, and they all work fine.
User avatar
Erich
User
User
Posts: 49
Joined: Thu Sep 30, 2010 9:21 pm

Re: Does PureUnit work with modules?

Post by Erich »

Yes, indeed it works! Sorry, my mistake. Freak pointed me in the right direction.

Instead of this:

Code: Select all

XIncludeFile "module_unittest1.pb"
ProcedureUnitStartup start_test()
I wrote that somewhere in a larger test suite:

Code: Select all

ProcedureUnitStartup start_test()
XIncludeFile "module_unittest1.pb"
which explains the error message. The include has to be outside the test procedure.
"I have never let my schooling interfere with my education." - Mark Twain
Little John
Addict
Addict
Posts: 4789
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Does PureUnit work with modules?

Post by Little John »

Erich wrote:The include has to be outside the test procedure.
Yes.
Including one or more procedures in another procedure will never work with PB,
regardless of whether the included procedures are inside a module or not.
Post Reply