remove the lowering tests because they are annoying to maintain and

don't add anything over lalrpop-test really
This commit is contained in:
Niko Matsakis 2015-10-25 07:04:53 -04:00
parent 63c9c2efc9
commit 1fa3bc6832
2 changed files with 0 additions and 70 deletions

View File

@ -12,9 +12,6 @@ use grammar::parse_tree::{InternToken, NonterminalString, TerminalString};
use grammar::repr as r;
use util::{map, Map};
#[cfg(test)]
mod test;
pub fn lower(grammar: pt::Grammar, types: r::Types) -> NormResult<r::Grammar> {
let state = LowerState::new(types, &grammar);
state.lower(grammar)

View File

@ -1,67 +0,0 @@
use grammar::repr::{Grammar, Production};
use normalize::normalize_without_validating;
use parser;
use test_util::expect_debug;
fn flat_productions(grammar: &Grammar) -> Vec<Production> {
let mut productions: Vec<_> =
grammar.nonterminals.values()
.flat_map(|data| data.productions.iter().cloned())
.collect();
// sort by the action fn index just to get a consistent ordering
productions.sort_by(|k1, k2| {
Ord::cmp(&k1.action, &k2.action)
});
productions
}
#[test]
fn test_comma() {
let grammar = parser::parse_grammar(r#"
grammar;
extern { enum Tok { "," => .., "Id" => .. } }
Comma<E>: Vec<E> =
<v:(<E> ",")*> <e:E?> =>
v.into_iter().chain(e.into_iter()).collect();
Ids = Comma<"Id">;
"#).unwrap();
let actual = normalize_without_validating(grammar).unwrap();
expect_debug(flat_productions(&actual),
r#"[
Ids = Comma<"Id"> => ActionFn(0);,
Comma<"Id"> = (<"Id"> ",")*, "Id"? => ActionFn(1);,
"Id"? = "Id" => ActionFn(2);,
"Id"? = => ActionFn(3);,
(<"Id"> ",")* = => ActionFn(4);,
(<"Id"> ",") = "Id", "," => ActionFn(6);,
(<"Id"> ",")* = (<"Id"> ",")*, "Id", "," => ActionFn(7);
]"#);
expect_debug(&actual.action_fn_defns,
r#"[
fn _(__0: Vec<Tok>) -> Vec<Tok> { (__0) },
fn _(v: ::std::vec::Vec<Tok>, e: ::std::option::Option<Tok>) -> Vec<Tok> { v.into_iter().chain(e.into_iter()).collect() },
fn _(__0: Tok) -> ::std::option::Option<Tok> { Some(__0) },
fn _() -> ::std::option::Option<Tok> { None },
fn _() -> ::std::vec::Vec<Tok> { vec![] },
fn _(v: ::std::vec::Vec<Tok>, e: Tok) -> ::std::vec::Vec<Tok> { { let mut v = v; v.push(e); v } },
fn _(__0: Tok, _: Tok) -> Tok { (__0) },
fn _(..) { ActionFn(5)((<"Id"> ",")*, ActionFn(6)("Id", ",")) }
]"#);
}
#[test]
fn test_intern_token() {
let grammar = parser::parse_grammar(r#"
grammar;
extern { }
A = ",";
"#).unwrap();
normalize_without_validating(grammar).unwrap();
}