Conflict between tests

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Conflict between tests

Zamar
I've run into an issue with the sub command while running the StackTest.vm and BasicTest.vm files

StackTest.vm compares successfully if I use "M = D - M" but fails on BasicTest.vm whereas BasicTest.vm compares successfully if I use "M = M - D" but fails on StackTest.vm

Which is the correct one?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Conflict between tests

ybakos
Those are two very different operations! Each are correct in their respective contexts when they pass their tests.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Conflict between tests

cadet1620
Administrator
In reply to this post by Zamar
Zamar wrote
I've run into an issue with the sub command while running the StackTest.vm and BasicTest.vm files

StackTest.vm compares successfully if I use "M = D - M" but fails on BasicTest.vm whereas BasicTest.vm compares successfully if I use "M = M - D" but fails on StackTest.vm

Which is the correct one?
If you haven't already, look at the .vm files for the two tests.

The version of 'sub' that works in StackTest is probably the correct one for several reasons:
  1) You thought about what 'sub' had to do and wrote the code to do what it needed to do.
  2) BasicTest assumes that the VM commands tested in the StackArithmetic tests are working correctly, and adds more VM commands to be tested. It is far more likely that a problem with the additional VM commands is causing the failure than a problem with the 'sub' commands it uses.
  3) A = B-A is a "reverse subtraction". This is a rarely used construction and whenever I see it in other people's code when I'm debugging I look at it very suspiciously. I find that in the vast majority of cases the actual usage is A= -(A-B), and in that case the code is easier to understand if it's written that way.

--Mark
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Conflict between tests

Zamar
I found the problem, there was a typo and my translator wasn't translating the neg routine.

Thanks for the help and clarifying the subtraction!
Loading...