I am working on horrible code.
while (x)
{
if (check1)
{
if (check2)
{
if (check3)
{
function();
}
else
{
error3();
}
}
else
{
error2();
}
}
else
{
error1();
}
}
I'd like it to look like this
while (x)
{
if (!check1)
{
error1();
continue;
}
if (!check2)
{
error2();
continue;
}
if (!check3)
{
error3();
continue;
}
function();
}
But... This is 'time tested code' that is in many products..... ... and horrible to work with, and will encourage errors in the future.
I need a way to prove that when I change the code to my implementation, the resulting code is equivalent.
Right now when I compile the two versions of code I get different binary files.
Questions:
Is there a way to encourage the compiler to get the same output for both implementations so that I can show management that they're the same?
Is there a different way to demonstrate that the implementations are equivalent?
Aucun commentaire:
Enregistrer un commentaire