diff --git a/src/test/run-pass-fulldeps/auxiliary/cond_noprelude_plugin.rs b/src/test/run-pass-fulldeps/auxiliary/cond_noprelude_plugin.rs deleted file mode 100644 index 664bb9da89a..00000000000 --- a/src/test/run-pass-fulldeps/auxiliary/cond_noprelude_plugin.rs +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_parens)] -#![feature(plugin)] -#![feature(plugin_registrar)] -#![feature(rustc_private)] -#![plugin(proc_macro_plugin)] - -extern crate rustc_plugin; -extern crate proc_macro_tokens; -extern crate syntax; - -use proc_macro_tokens::build::ident_eq; - -use syntax::ast::Ident; -use syntax::ext::base::{ExtCtxt, MacResult}; -use syntax::ext::proc_macro_shim::build_block_emitter; -use syntax::tokenstream::{TokenTree, TokenStream}; -use syntax::codemap::Span; - -use rustc_plugin::Registry; - -#[plugin_registrar] -pub fn plugin_registrar(reg: &mut Registry) { - reg.register_macro("cond", cond); -} - -fn cond<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box { - let output = cond_rec(TokenStream::from_tts(tts.clone().to_owned())); - build_block_emitter(cx, sp, output) -} - -fn cond_rec(input: TokenStream) -> TokenStream { - if input.is_empty() { - return qquote!(); - } - - let next = input.slice(0..1); - let rest = input.slice_from(1..); - - let clause : TokenStream = match next.maybe_delimited() { - Some(ts) => ts, - _ => panic!("Invalid input"), - }; - - // clause is ([test]) [rhs] - if clause.len() < 2 { panic!("Invalid macro usage in cond: {:?}", clause) } - - let test: TokenStream = clause.slice(0..1); - let rhs: TokenStream = clause.slice_from(1..); - - if ident_eq(&test[0], Ident::from_str("else")) || rest.is_empty() { - qquote!({unquote(rhs)}) - } else { - qquote!({if unquote(test) { unquote(rhs) } else { cond!(unquote(rest)) } }) - } -} diff --git a/src/test/run-pass-fulldeps/auxiliary/cond_prelude_plugin.rs b/src/test/run-pass-fulldeps/auxiliary/cond_prelude_plugin.rs deleted file mode 100644 index 6a2d159a4bd..00000000000 --- a/src/test/run-pass-fulldeps/auxiliary/cond_prelude_plugin.rs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_parens)] -#![feature(plugin)] -#![feature(plugin_registrar)] -#![feature(rustc_private)] -#![plugin(proc_macro_plugin)] - -extern crate rustc_plugin; -extern crate proc_macro_tokens; -extern crate syntax; - -use syntax::ext::proc_macro_shim::prelude::*; -use proc_macro_tokens::prelude::*; - -use rustc_plugin::Registry; - -#[plugin_registrar] -pub fn plugin_registrar(reg: &mut Registry) { - reg.register_macro("cond", cond); -} - -fn cond<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box { - let output = cond_rec(TokenStream::from_tts(tts.clone().to_owned())); - build_block_emitter(cx, sp, output) -} - -fn cond_rec(input: TokenStream) -> TokenStream { - if input.is_empty() { - return qquote!(); - } - - let next = input.slice(0..1); - let rest = input.slice_from(1..); - - let clause : TokenStream = match next.maybe_delimited() { - Some(ts) => ts, - _ => panic!("Invalid input"), - }; - - // clause is ([test]) [rhs] - if clause.len() < 2 { panic!("Invalid macro usage in cond: {:?}", clause) } - - let test: TokenStream = clause.slice(0..1); - let rhs: TokenStream = clause.slice_from(1..); - - if ident_eq(&test[0], Ident::from_str("else")) || rest.is_empty() { - qquote!({unquote(rhs)}) - } else { - qquote!({if unquote(test) { unquote(rhs) } else { cond!(unquote(rest)) } }) - } -} diff --git a/src/test/run-pass-fulldeps/macro-quote-noprelude.rs b/src/test/run-pass-fulldeps/macro-quote-noprelude.rs deleted file mode 100644 index 4184ca7be37..00000000000 --- a/src/test/run-pass-fulldeps/macro-quote-noprelude.rs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:cond_noprelude_plugin.rs -// ignore-stage1 - -#![feature(plugin)] -#![feature(rustc_private)] -#![plugin(cond_noprelude_plugin)] - -fn fact(n : i64) -> i64 { - if n == 0 { - 1 - } else { - n * fact(n - 1) - } -} - -fn fact_cond(n : i64) -> i64 { - cond!( - ((n == 0) 1) - (else (n * fact_cond(n-1))) - ) -} - -fn fib(n : i64) -> i64 { - if n == 0 || n == 1 { - 1 - } else { - fib(n-1) + fib(n-2) - } -} - -fn fib_cond(n : i64) -> i64 { - cond!( - ((n == 0) 1) - ((n == 1) 1) - (else (fib_cond(n-1) + fib_cond(n-2))) - ) -} - -fn main() { - assert_eq!(fact(3), fact_cond(3)); - assert_eq!(fact(5), fact_cond(5)); - assert_eq!(fib(5), fib_cond(5)); - assert_eq!(fib(8), fib_cond(8)); -} diff --git a/src/test/run-pass-fulldeps/macro-quote-prelude.rs b/src/test/run-pass-fulldeps/macro-quote-prelude.rs deleted file mode 100644 index 5b703a5bc26..00000000000 --- a/src/test/run-pass-fulldeps/macro-quote-prelude.rs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:cond_prelude_plugin.rs -// ignore-stage1 - -#![feature(plugin)] -#![feature(rustc_private)] -#![plugin(cond_prelude_plugin)] - -fn fact(n : i64) -> i64 { - if n == 0 { - 1 - } else { - n * fact(n - 1) - } -} - -fn fact_cond(n : i64) -> i64 { - cond!( - ((n == 0) 1) - (else (n * fact_cond(n-1))) - ) -} - -fn fib(n : i64) -> i64 { - if n == 0 || n == 1 { - 1 - } else { - fib(n-1) + fib(n-2) - } -} - -fn fib_cond(n : i64) -> i64 { - cond!( - ((n == 0) 1) - ((n == 1) 1) - (else (fib_cond(n-1) + fib_cond(n-2))) - ) -} - -fn main() { - assert_eq!(fact(3), fact_cond(3)); - assert_eq!(fact(5), fact_cond(5)); - assert_eq!(fib(5), fib_cond(5)); - assert_eq!(fib(8), fib_cond(8)); -}