Add tests.
This commit is contained in:
parent
839c2860cc
commit
85e02bdbfc
@ -20,6 +20,7 @@ extern crate derive_b;
|
||||
#[C] //~ ERROR: The attribute `C` is currently unknown to the compiler
|
||||
#[B(D)]
|
||||
#[B(E = "foo")]
|
||||
#[B arbitrary tokens] //~ expected one of `(` or `=`, found `arbitrary`
|
||||
struct B;
|
||||
|
||||
fn main() {}
|
||||
|
@ -14,4 +14,5 @@ fn main() {
|
||||
globnar::brotz!(); //~ ERROR non-ident macro paths are experimental
|
||||
::foo!(); //~ ERROR non-ident macro paths are experimental
|
||||
foo::<T>!(); //~ ERROR type parameters are not allowed on macros
|
||||
#[derive(foo::Bar)] struct T; //~ ERROR non-ident macro paths are experimental
|
||||
}
|
||||
|
@ -19,6 +19,6 @@ use attr_args::attr_with_args;
|
||||
#[attr_with_args(text = "Hello, world!")]
|
||||
fn foo() {}
|
||||
|
||||
fn main() {
|
||||
assert_eq!(foo(), "Hello, world!");
|
||||
}
|
||||
#[::attr_args::identity
|
||||
fn main() { assert_eq!(foo(), "Hello, world!"); }]
|
||||
struct Dummy;
|
||||
|
@ -30,3 +30,8 @@ pub fn attr_with_args(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
fn foo() -> &'static str { "Hello, world!" }
|
||||
"#.parse().unwrap()
|
||||
}
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn identity(attr_args: TokenStream, _: TokenStream) -> TokenStream {
|
||||
attr_args
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ use proc_macro::TokenStream;
|
||||
#[proc_macro_derive(B, attributes(B, C))]
|
||||
pub fn derive(input: TokenStream) -> TokenStream {
|
||||
let input = input.to_string();
|
||||
assert!(input.contains("#[B]"));
|
||||
assert!(input.contains("#[B arbitrary tokens]"));
|
||||
assert!(input.contains("struct B {"));
|
||||
assert!(input.contains("#[C]"));
|
||||
"".parse().unwrap()
|
||||
|
@ -11,11 +11,12 @@
|
||||
// aux-build:derive-b.rs
|
||||
// ignore-stage1
|
||||
|
||||
#[macro_use]
|
||||
#![feature(proc_macro)]
|
||||
|
||||
extern crate derive_b;
|
||||
|
||||
#[derive(Debug, PartialEq, B, Eq, Copy, Clone)]
|
||||
#[B]
|
||||
#[derive(Debug, PartialEq, derive_b::B, Eq, Copy, Clone)]
|
||||
#[cfg_attr(all(), B arbitrary tokens)]
|
||||
struct B {
|
||||
#[C]
|
||||
a: u64
|
||||
|
Loading…
x
Reference in New Issue
Block a user