Question about Prog2.tests.daily.AstTests::testASTDivision

it seem that there is some extra commas in the expected output, in my case I’m ignoring the empty parameter is that a mistake?? or I have forgot something :sweat_smile:

for example

current :    Block[Binary_=[Var_m,Binary_+[Var_m,Const_1]]]    and
expected: Block[Binary_=[Var_m,Binary_+[Var_m,Const_1]],]


current : <...ary_=[Var_m,Const_0][While[Binary_>=[Var_x,Var_y],Block[Binary_=[Var_m,Binary_+[Var_m,Const_1]]]Binary_=[Var_x,Binar...>

You should not print a comma after the last statement in a block.
But you need commas in between every statement of a block.

1 Like

I know, but for example in this case :sweat_smile:


there is a a comma at the end and by the way this is not AST from my implementation but the error message that im recieving from the test

org.junit.ComparisonFailure: expected:<...ary_=[Var_m,Const_0][,While[Binary_>=[Var_x,Var_y],Block[Binary_=[Var_m,Binary_+[Var_m,Const_1]],]Binary_=[Var_x,Binar...> but was:<...ary_=[Var_m,Const_0][While[Binary_>=[Var_x,Var_y],Block[Binary_=[Var_m,Binary_+[Var_m,Const_1]]]Binary_=[Var_x,Binar...>

or Expected is my result and current is what it supposed to look like ?

Have you written own tests (with blocks) to see whether it works in your custom test cases?

From the context, I would guess that this is only an extract from a larger string and JUnit is nice and only shows you the important part instead of the whole large string.

Expected is what is expected to be the result (and not what is produced).

it’s written that this is the expected form Block[Binary_=[Var_m,Binary_+[Var_m,Const_1]],] :neutral_face: with an extra comma at the end of a Block, and I’m pretty sure I’m considering not putting a comma at the end.

so according to you there is an extra part after the ‘,’ :sweat_smile:
well JUnit in this case wasn’t that much helpful but the inverse …

well JUnit in this case wasn’t that much helpful but the inverse …

Unfortunately, yes, and it makes it quite hard for us to understand the error message as well.
However, I actually think you might be missing a comma where there should be one (not the other way round).

Either way, it would be a good idea to write your own tests for this so you can see what’s actually going on.

1 Like