提交 24ef9052 编写于 作者: G Geoffry Song

Remove FakeExtCtxt from qquote tests.

Instead create an ExtCtxt structure.
上级 ea892dc7
......@@ -15,38 +15,25 @@
extern crate syntax;
use syntax::ast;
use syntax::codemap;
use syntax::codemap::{self, DUMMY_SP};
use syntax::parse;
use syntax::print::pprust;
trait FakeExtCtxt {
fn call_site(&self) -> codemap::Span;
fn cfg(&self) -> ast::CrateConfig;
fn ident_of(&self, st: &str) -> ast::Ident;
fn name_of(&self, st: &str) -> ast::Name;
fn parse_sess(&self) -> &parse::ParseSess;
}
impl FakeExtCtxt for parse::ParseSess {
fn call_site(&self) -> codemap::Span {
codemap::Span {
lo: codemap::BytePos(0),
hi: codemap::BytePos(0),
expn_id: codemap::NO_EXPANSION,
}
}
fn cfg(&self) -> ast::CrateConfig { Vec::new() }
fn ident_of(&self, st: &str) -> ast::Ident {
parse::token::str_to_ident(st)
}
fn name_of(&self, st: &str) -> ast::Name {
parse::token::intern(st)
}
fn parse_sess(&self) -> &parse::ParseSess { self }
}
fn main() {
let cx = parse::new_parse_sess();
let ps = syntax::parse::new_parse_sess();
let mut cx = syntax::ext::base::ExtCtxt::new(
&ps, vec![],
syntax::ext::expand::ExpansionConfig::default("qquote".to_string()));
cx.bt_push(syntax::codemap::ExpnInfo {
call_site: DUMMY_SP,
callee: syntax::codemap::NameAndSpan {
name: "".to_string(),
format: syntax::codemap::MacroBang,
allow_internal_unstable: false,
span: None,
}
});
let cx = &mut cx;
assert_eq!(pprust::expr_to_string(&*quote_expr!(&cx, 23)), "23");
......
......@@ -17,38 +17,25 @@
extern crate syntax;
use syntax::ast;
use syntax::codemap;
use syntax::codemap::{self, DUMMY_SP};
use syntax::parse;
use syntax::print::pprust;
trait FakeExtCtxt {
fn call_site(&self) -> codemap::Span;
fn cfg(&self) -> ast::CrateConfig;
fn ident_of(&self, st: &str) -> ast::Ident;
fn name_of(&self, st: &str) -> ast::Name;
fn parse_sess(&self) -> &parse::ParseSess;
}
impl FakeExtCtxt for parse::ParseSess {
fn call_site(&self) -> codemap::Span {
codemap::Span {
lo: codemap::BytePos(0),
hi: codemap::BytePos(0),
expn_id: codemap::NO_EXPANSION,
}
}
fn cfg(&self) -> ast::CrateConfig { Vec::new() }
fn ident_of(&self, st: &str) -> ast::Ident {
parse::token::str_to_ident(st)
}
fn name_of(&self, st: &str) -> ast::Name {
parse::token::intern(st)
}
fn parse_sess(&self) -> &parse::ParseSess { self }
}
fn main() {
let cx = parse::new_parse_sess();
let ps = syntax::parse::new_parse_sess();
let mut cx = syntax::ext::base::ExtCtxt::new(
&ps, vec![],
syntax::ext::expand::ExpansionConfig::default("qquote".to_string()));
cx.bt_push(syntax::codemap::ExpnInfo {
call_site: DUMMY_SP,
callee: syntax::codemap::NameAndSpan {
name: "".to_string(),
format: syntax::codemap::MacroBang,
allow_internal_unstable: false,
span: None,
}
});
let cx = &mut cx;
assert_eq!(pprust::expr_to_string(&*quote_expr!(&cx, 23)), "23");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册