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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
// Copyright 2017 the authors. See the 'Copyright and license' section of the
// README.md file at the top-level directory of this repository.
//
// Licensed under the Apache License, Version 2.0 (the LICENSE file). This file
// may not be copied, modified, or distributed except according to those terms.
//! Types of various sizes for testing `ObjectAlloc`s.
//!
//! This module defines a number of types ranging in size from 1 through 2^13 = 8192 bytes. The
//! sizes used include all powers of two, all midpoints between successive powers of two (that is,
//! `x + x/2` where `x` is a power of two), and at least one prime in between any two even sizes.
//! Each type is named `ByteN` where `N` is the type's size in bytes.
/// Invoke a macro on multiple sets of arguments.
///
/// `call_macro!` invokes the macro `m` on 0 or more sets of arguments. Each set of arguments must
/// be surrounded in parentheses.
///
/// # Examples
///
/// ```rust
/// # #[macro_use] extern crate object_alloc_test;
/// # fn main() {
/// call_macro!(println, ("Once upon a midnight dreary, while I pondered, weak and weary,"),
/// ("Over many a quaint and curious volume of forgotten lore—"),
/// ("While I nodded, nearly napping, suddenly there came a tapping,"),
/// ("As of some one gently rapping, rapping at my chamber door."),
/// ("\"'Tis some visiter,\" I muttered, \"tapping at my chamber door—"),
/// (" Only this and nothing more."));
/// # }
/// ```
}
)
}
call_macro!;
// TODO: Document the pattern of matching particular types to avoid defining anything for them.
/// Call a macro once for each type defined in the `types` module.
///
/// `call_for_all_types_prefix` is useful for defining something (usually test functions) once for
/// each type defined in the `test` module. The first argument, `fn`, is the name of a macro to
/// invoke. This macro will be invoked once for each type with its first argument being a
/// constructed identifier and the second argument being the type. For example,
/// `call_for_all_types_prefix!(foo, bar)` expands to:
///
/// ```rust,ignore
/// foo!(bar_0001_byte, $crate::types::Byte1);
/// foo!(bar_0002_byte, $crate::types::Byte2);
/// foo!(bar_0003_byte, $crate::types::Byte3);
/// // ...etc
/// ```
///
/// An arbitrary number of optional arguments may also be supplied; these will be
/// passed as additional trailing arguments in the invocation of the macro. For example,
/// `call_for_all_types_prefix!(foo, bar, baz, blah)` expands to:
///
/// ```rust,ignore
/// foo!(bar_0001_byte, $crate::types::Byte1, baz, blah);
/// foo!(bar_0002_byte, $crate::types::Byte2, baz, blah);
/// foo!(bar_0003_byte, $crate::types::Byte3, baz, blah);
/// // ...etc
/// ```
///
/// # Examples
///
/// ```rust
/// # #![feature(plugin)]
/// # #![plugin(interpolate_idents)]
/// # #[macro_use] extern crate object_alloc_test;
/// # fn main() {
/// macro_rules! make_default_test {
/// ($name:ident, $type:ty) => (
/// fn $name() {
/// <$type>::default();
/// }
/// )
/// }
///
/// call_for_all_types_prefix!(make_default_test, default_test);
/// # }
/// ```