Skip to content

Commit 3ca5e2f

Browse files
committed
fix tests: fix all invalid tests
1 parent fc896a5 commit 3ca5e2f

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

src/lib.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,21 @@ macro_rules! volatile_type {
9494
///
9595
/// ```rust
9696
/// use volatile_table::volatile;
97+
///
98+
/// static mut SOME_VAR: usize = 0;
9799
///
98100
/// // 1. Default (Read-Write, usize, from raw pointer)
99101
/// let p = volatile!(&raw mut SOME_VAR);
100102
///
101103
/// // 2. Custom Type and Access (Read-Only, u32)
102-
/// let p = volatile!(ro <u32> : &raw mut SOME_VAR);
104+
/// let p = volatile!(ro <usize> : &raw mut SOME_VAR);
103105
///
104106
/// // 3. From a literal address (common in embedded)
105107
/// // This uses the @from_usize flag
106108
/// let p = volatile!(@from_usize rw <u32> : 0x4000_1000);
107109
///
108110
/// // 4. Shorthand for typed RW
109-
/// let p = volatile!(<u8> : &raw mut SOME_VAR);
111+
/// let p = volatile!(<usize> : &raw mut SOME_VAR);
110112
/// ```
111113
///
112114
/// # Internal flags:
@@ -120,7 +122,7 @@ macro_rules! volatile {
120122
[ $(@from_usize)? @ignore_from_usize $tt:ident : $($a:tt)+ ] => {
121123
<$crate::volatile_type!($tt)>::from_ptr($($a)*)
122124
};
123-
[ $(@from_usize)? @ignore_from_usize $ty:ty : $($a:tt)+ ] => {
125+
[ $(@from_usize)? @ignore_from_usize <$ty:ty> : $($a:tt)+ ] => {
124126
<$crate::volatile_type!(<$ty>)>::from_ptr($($a)*)
125127
};
126128
[ $(@from_usize)? @ignore_from_usize $($a:tt)+ ] => {
@@ -148,7 +150,7 @@ macro_rules! volatile {
148150
[ $tt:ident : $($a:tt)+ ] => {
149151
<$crate::volatile_type!($tt)>::from_ptr($($a)*)
150152
};
151-
[ $ty:ty : $($a:tt)+ ] => {
153+
[ <$ty:ty> : $($a:tt)+ ] => {
152154
<$crate::volatile_type!(<$ty>)>::from_ptr($($a)*)
153155
};
154156
[ $($a:tt)+ ] => {
@@ -178,16 +180,18 @@ macro_rules! volatile {
178180
///
179181
/// ### Simple Register Definition
180182
/// ```rust
183+
/// use volatile_table::volatile_table;
181184
/// volatile_table! {
182185
/// /// System clock control
183186
/// pub rw <u32> CLK_CTRL = 0x4000_0000;
184187
/// /// Status register (read-only)
185-
/// ro STATUS = 0x4000_0004;
188+
/// ro <u32> STATUS = 0x4000_0004;
186189
/// }
187190
/// ```
188191
///
189192
/// ### Advanced Memory Map (e.g., UART Driver)
190193
/// ```rust
194+
/// use volatile_table::volatile_table;
191195
/// volatile_table! {
192196
/// map [pub rw <u32> UART_BASE = 0xC810_04C0]: {
193197
/// wo <u32> TX_FIFO += 0x00;

tests/volatile_macro.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11

2-
#[cfg(test)]
32
#[test]
43
fn test_volatile_macro() {
54
use volatile_table::volatile;

tests/volatile_table_macro.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11

2-
#[cfg(test)]
32
#[test]
43
fn test_volatile_table_macro() {
54
use volatile_table::volatile_table;

0 commit comments

Comments
 (0)