-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_auto.pro
More file actions
78 lines (62 loc) · 1.7 KB
/
Copy pathtest_auto.pro
File metadata and controls
78 lines (62 loc) · 1.7 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
:- use_module(library(pprint),[
print_term/2
]).
% -------------------- what is tested
:- import(file("html_cphe.pro"),[
cphe_ast/2
, cphe_string/2
]).
/*
% Broken due to different loading mechanism (load.pro vs load0.pro).
:- import(file("sketch_application.pro"),[
start_http_server/0
, check_web_app/0
]).
:- import(file("enterprise/library/sql.pro"),[
sql_ddl_create_table/2
]).
*/
% -------------------- the tests
test(A) :- clause(run(A), _).
run(html_cphe_attribute) :-
Exp = p(a=b, "T", c=d, b("U", "V")),
cphe_ast(Exp, Ast),
pretty(Exp), nl,
pretty(Ast), nl,
actual_expected(
Ast,
elem(p,[attr(a,b),attr(c,d)],[text("T"),elem(b,[],[text("U"),text("V")])])
).
run(html_cphe_string) :-
Exp = a(href="foo.png", "The image"),
cphe_string(Exp, Str),
pretty(Exp), nl,
write(Str), nl.
run(html_cphe_string_empty_tag) :-
Exp = img(src="foo.png", alt="bar"),
cphe_string(Exp, Str),
pretty(Exp), nl,
write(Str), nl.
run(html_cphe_document) :-
Exp = ['!doctype'(html), html(head(title("Title")), body(p("Paragraph")))],
cphe_string(Exp, Str),
pretty(Exp), nl,
write(Str), nl.
run(check_web_app) :-
check_web_app.
run(sql_ddl_create_table) :-
forall(sql_ddl_create_table(_, Sql), (
write(Sql), nl
)).
check_web_app :-
writeln("broken").
sql_ddl_create_table(_, _) :-
writeln("broken").
% -------------------- helper
actual_expected(Act, Exp) :- Act == Exp, !.
actual_expected(Act, Exp) :-
write("------------------------------ assertion failure"), nl,
write("actual : "), pretty(Act), nl,
write("expected : "), pretty(Exp), nl,
fail.
pretty(A) :- print_term(A, []).