Inconsistent expectations of integers

Would it make more sense if the expected output format of integers stay consistent?


“Evaluating” stage expects integer as integer

[tester::#LV1] Running tests for Stage #LV1 (Evaluating Expressions - Literals: 
[tester::#LV1] [test-1] [test.lox] 27
[tester::#LV1] [test-1] Expected line #1 on stdout to be "27", got "27.0"

“Parsing” stage expects integer as float

[tester::#HT8] Running tests for Stage #HT8 (Parsing Expressions - Equality operators)
[tester::#HT8] [test-3] [test.lox] 47 == 16
[tester::#HT8] [test-3] Expected line #1 on stdout to be "(== 47.0 16.0)", got "(== 47 16)"

Main stage expects integer as float

[tester::#PQ5] Running tests for Stage #PQ5 (Scanning: Reserved words)
[tester::#PQ5] [test-4] [test.lox] var result = (a + b) > 7 && "Success" != "Failure" or x >= 5
[tester::#PQ5] [test-4] Expected line #10 on stdout to be "NUMBER 7 7.0", got "NUMBER 7 7"

Yep, we found this weird too but didn’t want to deviate from the book too much.

I do see why these are different in the book though - in the first case we’re looking for the representation of a “value”, in the latter two we’re looking for the representation of a “token”.

If we fix this, I think we’ll want to do it in a way that accepts either representation.

1 Like

Got it!

My bad, didn’t get to that part in the book until after having finished the stage.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.