Many weeks ago I had an issue which turned out to be masked by having portray_text(true)
in effect. That is no longer the case. Just now I started writing more unit tests, all was well until I added two more that failed. Once again, the error message is totally baffling, here is the failure output.
ERROR: /home/sean/Documents/code/prolog/the-f-word-project/src/ast/ast.plt:165:
test defun_arglist_simple_var_no_value: wrong answer (compared using ==)
ERROR: Expected: [defun((0,1,0),tk((7,1,7),"foo"),[tk((12,1,12),"xyz")],[])]
ERROR: Got: [defun((0,1,0),tk((7,1,7),"foo"),[tk((12,1,12),"xyx")],[])]
ERROR: /home/sean/Documents/code/prolog/the-f-word-project/src/ast/ast.plt:171:
test defun_arglist_multi_simple: wrong answer (compared using ==)
ERROR: Expected: [defun((0,1,0),tk((7,1,7),"foo"),[tk((12,1,12),"xyz"),tk((16,1,16),"n1"),tk((19,1,19),"count/int")],[])]
ERROR: Got: [defun((0,1,0),tk((7,1,7),"foo"),[tk((12,1,12),"xyx"),tk((16,1,16),"n1"),tk((19,1,19),"count/int")],[])]
Here is the test code. The failures are the last two, I created them by cutting and pasting the previous test, extending it, then cutting and pasting it again. Why should these fail even if the test output looks correct?
:- begin_tests(defun_syntax_errors).
:- use_module(myapp(helpers)).
test(defun_no_function_name,
[throws(ast(syntax((0,1,0), defun_function_name((7,1,7)))))]) :-
rawast("(defun ())", _Ast).
test(defun_no_arglist,
[throws(ast(syntax((0,1,0), expected_paren_open((10,1,10)))))]) :-
rawast("(defun foo)", _Ast).
test(defun_arglist_empty,
[true(Ast == [defun((0,1,0), tk((7,1,7),"foo"), [], [])])]) :-
rawast("(defun foo ())", Ast).
test(defun_arglist_simple_var_no_value,
[true(Ast == [defun((0,1,0), tk((7,1,7),"foo"),
[tk((12,1,12), "xyz")],
[])])]) :-
rawast("(defun foo (xyx))", Ast).
test(defun_arglist_multi_simple,
[true(Ast ==
[defun((0, 1, 0), tk((7, 1, 7), "foo"),
[tk((12, 1, 12), "xyz"),
tk((16, 1, 16), "n1"),
tk((19, 1, 19), "count/int")],
[])]
)]) :-
rawast("(defun foo (xyx n1 count/int))", Ast).
:- end_tests(defun_syntax_errors).
This time I am completely baffled as I KNOW I have consistent string representation going on whereas before I had allowed some character-code/string inconsistencies to slip in but that has been ruled out at the tokenisation level with tests…which pass!