From 0ec6824eeb3869ead9212c93ed18e8160551abfc Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sun, 19 Jul 2015 14:20:59 -0400 Subject: [PATCH] fix escape test --- lalrpop/src/tok/mod.rs | 2 +- lalrpop/src/tok/test.rs | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lalrpop/src/tok/mod.rs b/lalrpop/src/tok/mod.rs index d8b7e87..6189743 100644 --- a/lalrpop/src/tok/mod.rs +++ b/lalrpop/src/tok/mod.rs @@ -198,7 +198,7 @@ impl<'input> Tokenizer<'input> { Some(idx1) => { self.bump(); // consume the '`' let text: &'input str = &self.text[idx0+1..idx1]; // do not include the `` in the str - Ok((idx0, Escape(text), idx1)) + Ok((idx0, Escape(text), idx1+1)) } None => { Err(UnterminatedEscape(idx0)) diff --git a/lalrpop/src/tok/test.rs b/lalrpop/src/tok/test.rs index 4864ce4..9892093 100644 --- a/lalrpop/src/tok/test.rs +++ b/lalrpop/src/tok/test.rs @@ -66,16 +66,18 @@ fn code_forgot_comma() { #[test] fn various_kinds_of_ids() { - test("foo>", vec![ - ("~~~ ", MacroId("foo")), - (" ~ ", LessThan), - (" ~ ", MacroId("T")), - (" ~ ", LessThan), - (" ~~ ", Lifetime("'a")), - (" ~ ", Comma), - (" ~ ", Id("U")), - (" ~ ", GreaterThan), - (" ~", GreaterThan), + test("foo>", vec![ + ("~~~ ", MacroId("foo")), + (" ~ ", LessThan), + (" ~ ", MacroId("T")), + (" ~ ", LessThan), + (" ~~ ", Lifetime("'a")), + (" ~ ", Comma), + (" ~ ", Id("U")), + (" ~ ", Comma), + (" ~~~~~~ ", Escape("Z*{}")), + (" ~ ", GreaterThan), + (" ~", GreaterThan), ]); }