-
Notifications
You must be signed in to change notification settings - Fork 588
/
tests.rs
78 lines (74 loc) · 2.04 KB
/
tests.rs
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 super::*;
use pretty_assertions::assert_eq;
macro_rules! gen_tests {(
$(
$test_name:ident:
stringify! {
#[$function:ident $(($($attrs:tt)*))?]
$($input:tt)*
} == $output:expr;
)*
) => (
$(
#[test]
fn $test_name()
{
let input: TokenStream =
stringify!($($input)*)
.parse()
.expect("Syntax error in test");
let output: TokenStream =
$output
.parse()
.expect("Syntax error in test");
let attrs: TokenStream =
stringify!($($($attrs)*)?)
.parse()
.expect("Syntax error in test");
let ret = $function(attrs, input).to_string();
eprintln!("{}", ret);
assert_eq!(ret, output.to_string());
}
)*
)}
gen_tests! {
identity_for_no_unsafe:
stringify! {
#[compiler_test(derive_test)]
#[cold]
fn foo(config: crate::Config) {
// Do tests
}
} == stringify! {
#[cfg(test)]
mod foo {
use super::*;
#[allow(unused)]
fn foo(config: crate::Config) {
// Do tests
}
#[cfg(feature = "singlepass")]
mod singlepass {
use super::*;
#[test_log::test]
#[cold]
#[cfg(feature = "universal")]
fn universal() {
foo(crate::Config::new(
crate::Engine::Universal,
crate::Compiler::Singlepass
))
}
#[test_log::test]
#[cold]
#[cfg(feature = "dylib")]
fn dylib() {
foo(crate::Config::new(
crate::Engine::Dylib,
crate::Compiler::Singlepass
))
}
}
}
};
}