AlexeyDmitriev / JHelper

GNU Lesser General Public License v3.0
119 stars 31 forks source link

Having function instead of class causes tests to be invalid #109

Closed mehranagh20 closed 5 years ago

mehranagh20 commented 5 years ago

I've changed the task, submission and template files so I can have a function instead of class.

It compiles and works but because of global static arrays and variables which are initialized to 0 for the first test but later for other tests they are changed and affected by previous tests result of tests changes.

How can I have a fresh start for each test and avoid having classes?

mehranagh20 commented 5 years ago

@AlexeyDmitriev Do you have any solution for this problem? :)

AlexeyDmitriev commented 5 years ago

@mehranagh20 Sorry for late answer.

I do not have solution for this except using local variables (and pass them to other functions and/or capture them by lambdas). Note, that static and global variables still will not work even with classes (but you may use fields). You may find relevant discussion/design consideration in #97

AlexeyDmitriev commented 5 years ago

Please let me know if you have other questions/comments on that

mehranagh20 commented 5 years ago

@AlexeyDmitriev Thanks for your response. Do you think is it somehow possible to re-execute the code for each test?

AlexeyDmitriev commented 5 years ago

I'm not sure I understand the question.