]> git.proxmox.com Git - rustc.git/blobdiff - src/test/run-pass-fulldeps/qquote.rs
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / src / test / run-pass-fulldeps / qquote.rs
index ba713bb98f8547a71e8728b08fe14f78ccc9a8e0..edaa88452c4854ecc53bd57671907b4200ccc9eb 100644 (file)
@@ -63,4 +63,41 @@ fn main() {
 
     let attr = quote_attr!(cx, #![cfg(foo = "bar")]);
     check!(attribute_to_string, attr, quote_attr!(cx, $attr); r#"#![cfg(foo = "bar")]"#);
+
+    // quote_arg!
+
+    let arg = quote_arg!(cx, foo: i32);
+    check!(arg_to_string, arg, quote_arg!(cx, $arg); "foo: i32");
+
+    let function = quote_item!(cx, fn f($arg) { }).unwrap();
+    check!(item_to_string, function; "fn f(foo: i32) { }");
+
+    let args = vec![arg, quote_arg!(cx, bar: u32)];
+    let args = &args[..];
+    let function = quote_item!(cx, fn f($args) { }).unwrap();
+    check!(item_to_string, function; "fn f(foo: i32, bar: u32) { }");
+
+    // quote_block!
+
+    let block = quote_block!(cx, { $stmt let y = 40u32; });
+    check!(block_to_string, block, *quote_block!(cx, $block); "{ let x = 20u16; let y = 40u32; }");
+
+    let function = quote_item!(cx, fn f() $block).unwrap();
+    check!(item_to_string, function; "fn f() { let x = 20u16; let y = 40u32; }");
+
+    // quote_path!
+
+    let path = quote_path!(cx, ::syntax::ptr::P<MetaItem>);
+    check!(path_to_string, path, quote_path!(cx, $path); "::syntax::ptr::P<MetaItem>");
+
+    let ty = quote_ty!(cx, $path);
+    check!(ty_to_string, ty; "::syntax::ptr::P<MetaItem>");
+
+    // quote_meta_item!
+
+    let meta = quote_meta_item!(cx, cfg(foo = "bar"));
+    check!(meta_item_to_string, meta, *quote_meta_item!(cx, $meta); r#"cfg(foo = "bar")"#);
+
+    let attr = quote_attr!(cx, #![$meta]);
+    check!(attribute_to_string, attr; r#"#![cfg(foo = "bar")]"#);
 }