-
Notifications
You must be signed in to change notification settings - Fork 2
/
tests.pl
62 lines (55 loc) · 1.94 KB
/
tests.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
:- module(tests, [test_all/0]).
:- use_module(syntax, [s//1]).
:- use_module(data).
test_all :-
setup_call_cleanup(
data:init_db,
(
findall(Tc, tests:test_case(Tc), TestCases),
test_all_parse(TestCases, [])
),
data:close_db
).
test_all_parse([], Failures) :-
nl,
show_failures(Failures).
test_all_parse([Input | Inputs], Failures) :-
phrase(s(_Syntax), Input),
!,
write('.'),
test_all_parse(Inputs, Failures).
test_all_parse([Input | Inputs], Failures) :-
write('f'),
test_all_parse(Inputs, [Input | Failures]).
show_failures([Failure | Failures]) :-
format('Test Failed: ~k does not parse.', [Failure]), nl,
data:learn_unknown_words(Failure),
show_failures(Failures).
show_failures([]) :- nl.
test_case([max,revealed,to,everyone,the,amazing,fact,that,birds,fly]).
test_case([the,dog,slept]).
test_case([max,said,birds,fly]).
test_case([i,walked,past,the,car]).
test_case([i,passed,the,car]).
test_case([max,looked,very,silly]).
test_case([mary,looked,up,the,tower]). % TODO: ensure this parses two ways.
test_case([joe,threw,out,the,trash]).
test_case([joe,threw,the,trash,out]).
test_case([it,is,both,very,warm,and,quite,dry]).
test_case([john,drank,both,coffee,and,tea]).
test_case([i,both,ate,and,slept,in,the,tower]).
test_case([i,saw,him,after,he,left]).
test_case([the,discussion,was,surprising,after,he,left]).
test_case([the,discussion,after,he,left,was,surprising]).
test_case([after,he,left,the,discussion,was,surprising]).
test_case([quickly,he,chased,it,into,the,garden]).
test_case([he,quickly,chased,it,into,the,garden]).
test_case([he,chased,it,quickly,into,the,garden]).
test_case([he,chased,it,into,the,garden,quickly]).
test_case([jesus,wept]).
test_case([john,wanted,to,leave]).
test_case([john,seemed,very,old]).
test_case([john,seemed,very,old,in,his,own,way]).
test_case([i,woke,up]).
test_case([i,walked,past,the,car]).
test_case([quickly,he,ate]).