-
Notifications
You must be signed in to change notification settings - Fork 0
/
minitest.sty
62 lines (50 loc) · 1.4 KB
/
minitest.sty
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
% I don't really like l3test I guess. No token list comparison.
% actually that's somewhat "trivial" to fix
% also should learn l3build system some day...
\ProvidesExplPackage{minitest}{2022/07/03}{0.0.0}{Test}
\cs_new_protected:Npn \testname:n {\str_set:Nn \__testname}
\let \testname \testname:n
\str_set:Nn \__testname {}
\cs_new_protected:Npn \testfail:nn
#1 %message
#2 %extra code to be executed e.g. additional \pretty:n calls
{
\pretty:x
{Test~\__testname,~line~\the\inputlineno :~#1}
#2
\errmessage {#1}
}
\cs_new_protected:Npn \testfail:n #1 {\testfail:nn {#1} {}}
\cs_new_protected:Npn \testfail: {\testfail:n {Error}}
\cs_new_protected:Npn \assertequal:nn #1 #2 {
\tl_if_eq:nnF {#1} {#2} {
\testfail:nn {Token~lists~not~equal!} {
\pretty:x {The~token~lists~are:}
\pretty:n {#1}
\pretty:n {#2}
}
}
}
\cs_new_protected:Npn \assertequal_str:nn #1 #2 {
\str_if_eq:nnF {#1} {#2} {
\testfail:nn {Strings~not~equal!} {
\pretty:x {The~input~token~lists~are:}
\pretty:n {#1}
\pretty:n {#2}
}
}
}
\cs_new_protected:Npn \assertmeaning:NN #1 #2 {
\tl_if_single_token:nF {#1} { \testfail:n {{#1}~not~single~token!} }
\tl_if_single_token:nF {#2} { \testfail:n {{#2}~not~single~token!} }
\token_if_eq_meaning:NNF #1 #2 {
\testfail:nn {Meaning~not~equal!} {
\pretty:x {The~input~tokens~are:}
\pretty:n {#1}
\pretty:n {#2}
}
}
}
\AtEndDocument{\pretty:n
{All~tests~passed!}
}