1#![feature(let_chains)]
2pub mod expect;
5#[cfg(feature = "expect-tokens")]
6pub mod expect_tokens;
7mod patchwork;
8mod runtime;
9mod str_lit_kind;
10
11#[cfg(test)]
12mod tests;
13
14#[cfg(feature = "expect-tokens")]
15#[cfg(test)]
16mod expect_tokens_tests;
17
18#[macro_export]
19macro_rules! expect {
20 ($actual:literal) => {
21 {
22 static COUNTER: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
23 let index = COUNTER.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
24 $crate::expect::Expect {
25 file_position: $crate::expect::FilePosition {
26 file: file!(),
27 line: line!(),
28 column: column!(),
29 },
30 raw_actual: stringify!($actual),
31 expected: [],
32 raw_expected: [],
33 assertion_index: index,
34 }
35 .assert_eq($actual)
36 }
37 };
38 ($actual:expr) => {
39 {
40 static COUNTER: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
41 let index = COUNTER.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
42 $crate::expect::Expect {
43 file_position: $crate::expect::FilePosition {
44 file: file!(),
45 line: line!(),
46 column: column!(),
47 },
48 raw_actual: stringify!($actual),
49 expected: [],
50 raw_expected: [],
51 assertion_index: index,
52 }
53 .assert_debug_eq($actual)
54 }
55 };
56 ($actual:literal, $($expected:literal),*) => {
57 {
58 static COUNTER: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
59 let index = COUNTER.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
60 $crate::expect::Expect {
61 file_position: $crate::expect::FilePosition {
62 file: file!(),
63 line: line!(),
64 column: column!(),
65 },
66 raw_actual: stringify!($actual),
67 expected: [$($expected),*],
68 raw_expected: [$(stringify!($expected)),*],
69 assertion_index: index,
70 }
71 .assert_eq($actual)
72 }
73 };
74 ($actual:expr, $($expected:literal),*) => {
75 {
76 static COUNTER: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
77 let index = COUNTER.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
78 $crate::expect::Expect {
79 file_position: $crate::expect::FilePosition {
80 file: file!(),
81 line: line!(),
82 column: column!(),
83 },
84 raw_actual: stringify!($actual),
85 expected: [$($expected),*],
86 raw_expected: [$(stringify!($expected)),*],
87 assertion_index: index,
88 }
89 .assert_debug_eq($actual)
90 }
91 };
92}
93
94#[cfg(feature = "expect-tokens")]
95#[macro_export]
96macro_rules! expect_tokens {
97 ($actual:expr) => {
98 {
99 static COUNTER: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
100 let index = COUNTER.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
101 $crate::expect::Expect {
102 file_position: $crate::expect::FilePosition {
103 file: file!(),
104 line: line!(),
105 column: column!(),
106 },
107 raw_actual: stringify!($actual),
108 expected: [],
109 raw_expected: [],
110 assertion_index: index,
111 }
112 .assert_eq(&$crate::expect_tokens::ExpectTokens::convert($actual))
113 }
114 };
115 ($actual:expr, $($expected:literal),*) => {
116 {
117 static COUNTER: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
118 let index = COUNTER.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
119 $crate::expect::Expect {
120 file_position: $crate::expect::FilePosition {
121 file: file!(),
122 line: line!(),
123 column: column!(),
124 },
125 raw_actual: stringify!($actual),
126 expected: [$($expected),*],
127 raw_expected: [$(stringify!($expected)),*],
128 assertion_index: index,
129 }
130 .assert_eq(&$crate::expect_tokens::ExpectTokens::convert($actual))
131 }
132 };
133}