Skip to content

Commit

Permalink
Add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jseyfried committed Mar 14, 2017
1 parent 839c286 commit 85e02bd
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
1 change: 1 addition & 0 deletions src/test/compile-fail/macro-with-seps-err-msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
6 changes: 3 additions & 3 deletions src/test/run-pass-fulldeps/proc-macro/attr-args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
5 changes: 5 additions & 0 deletions src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 4 additions & 3 deletions src/test/run-pass-fulldeps/proc-macro/derive-b.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 85e02bd

Please sign in to comment.