This repository has been archived by the owner on Sep 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathtest_marelle.pl
61 lines (52 loc) · 1.59 KB
/
test_marelle.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
%
% test_marelle.pl
% marelle
%
% Unit tests for Marelle.
%
:- begin_tests(marelle).
:- include('marelle').
test(sh) :-
sh(echo),
\+ sh('test 1 -eq 0').
test(isdir) :-
isdir('.'),
\+ isdir('7e1b960e8ccf8ed248d05f1803791da7'),
sh('touch /tmp/7e1b960e8ccf8ed248d05f1803791da7'),
\+ isdir('/tmp/7e1b960e8ccf8ed248d05f1803791da7'),
sh('mkdir -p /tmp/2739b22b11ee348c6eda77b57c577485'),
isdir('/tmp/2739b22b11ee348c6eda77b57c577485').
test(isfile) :-
isfile('marelle.pl'),
\+ isfile('.'),
sh('mkdir -p /tmp/2739b22b11ee348c6eda77b57c577485'),
\+ isfile('/tmp/2739b22b11ee348c6eda77b57c577485'),
sh('touch /tmp/7e1b960e8ccf8ed248d05f1803791da7'),
isfile('/tmp/7e1b960e8ccf8ed248d05f1803791da7').
test(sformat) :-
sformat('', [], ''),
sformat('Ohai', [], 'Ohai'),
sformat('~a says hello', ['Bob'], 'Bob says hello'),
sformat('Hello ~a', ['Bob'], 'Hello Bob'),
sformat('~a, ~a, ~a', ['Once', 'twice', 'three times'],
'Once, twice, three times'),
\+ catch(
sformat('~a and ~a', [romeo], _),
'wrong number of arguments in interpolation',
fail
).
test(symlink) :-
Dest = '/tmp/03435f97a0b2cef0780c9f2327e7e668',
Link = '/tmp/03435f97a0b2cef0780c9f2327e7e668-link',
sh(['touch ', Dest]),
sh(['rm -f ', Link]),
\+ is_symlinked(Dest, Link),
symlink(Dest, Link),
is_symlinked(Dest, Link).
test(join) :-
join([], ''),
join([''], ''),
join(['one'], 'one'),
join(['one', ' two'], 'one two'),
join(['one', ' two', ' and three'], 'one two and three').
:- end_tests(marelle).