summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-01-13 16:37:18 +0100
committerLaurenz <laurmaedje@gmail.com>2021-01-13 16:37:18 +0100
commit1cd687b681224a6a190fea5d542b92f147f9abf0 (patch)
tree471c106ceee8384f91aa0304fa21148493663177 /src
parent274e008e2c775d9c8c888767a6baeaff9e99de9d (diff)
Move escaping tests to integration and extend them 🚚
Diffstat (limited to 'src')
-rw-r--r--src/parse/tests.rs17
-rw-r--r--src/parse/tokens.rs15
2 files changed, 8 insertions, 24 deletions
diff --git a/src/parse/tests.rs b/src/parse/tests.rs
index f8b9dcbb..9a0a4ce6 100644
--- a/src/parse/tests.rs
+++ b/src/parse/tests.rs
@@ -252,23 +252,6 @@ fn test_parse_raw() {
}
#[test]
-fn test_parse_escape_sequences() {
- // Basic, mostly tested in tokenizer.
- t!(r"\[" Text("["));
- t!(r"\u{1F3D5}" nodes: [S(0..9, Text("🏕"))], spans: true);
-
- // Bad value.
- t!(r"\u{FFFFFF}"
- nodes: [Text(r"\u{FFFFFF}")],
- errors: [S(0..10, "invalid unicode escape sequence")]);
-
- // No closing brace.
- t!(r"\u{41*"
- nodes: [Text("A"), Strong],
- errors: [S(5..5, "expected closing brace")]);
-}
-
-#[test]
fn test_parse_groups() {
// Test paren group.
t!("{({1) + 3}"
diff --git a/src/parse/tokens.rs b/src/parse/tokens.rs
index 7741d27f..85fc4978 100644
--- a/src/parse/tokens.rs
+++ b/src/parse/tokens.rs
@@ -179,7 +179,7 @@ impl<'s> Tokens<'s> {
// Parenthesis.
'[' | ']' | '{' | '}' => true,
// Markup.
- '*' | '_' | '#' | '~' | '`' => true,
+ '*' | '_' | '#' | '~' | '`' | '$' => true,
// Escaping.
'\\' => true,
_ => false,
@@ -279,7 +279,7 @@ impl<'s> Tokens<'s> {
// Parenthesis.
'[' | ']' | '{' | '}' |
// Markup.
- '*' | '_' | '~' | '#' | '`' => {
+ '*' | '_' | '#' | '~' | '`' | '$' => {
let start = self.s.index();
self.s.eat_assert(c);
Token::Text(&self.s.eaten_from(start))
@@ -447,19 +447,19 @@ mod tests {
use Token::{Ident, *};
use TokenMode::{Code, Markup};
- fn Raw(text: &str, backticks: usize, terminated: bool) -> Token {
+ const fn Raw(text: &str, backticks: usize, terminated: bool) -> Token {
Token::Raw(TokenRaw { text, backticks, terminated })
}
- fn Math(formula: &str, inline: bool, terminated: bool) -> Token {
+ const fn Math(formula: &str, inline: bool, terminated: bool) -> Token {
Token::Math(TokenMath { formula, inline, terminated })
}
- fn UnicodeEscape(sequence: &str, terminated: bool) -> Token {
+ const fn UnicodeEscape(sequence: &str, terminated: bool) -> Token {
Token::UnicodeEscape(TokenUnicodeEscape { sequence, terminated })
}
- fn Str(string: &str, terminated: bool) -> Token {
+ const fn Str(string: &str, terminated: bool) -> Token {
Token::Str(TokenStr { string, terminated })
}
@@ -505,7 +505,7 @@ mod tests {
('/', None, "//", LineComment("")),
('/', None, "/**/", BlockComment("")),
('/', Some(Markup), "*", Star),
- ('/', Some(Markup), "_", Underscore),
+ ('/', Some(Markup), "$ $", Math(" ", true, true)),
('/', Some(Markup), r"\\", Text(r"\")),
('/', Some(Markup), "#let", Let),
('/', Some(Code), "(", LeftParen),
@@ -740,6 +740,7 @@ mod tests {
t!(Markup: r"\#" => Text("#"));
t!(Markup: r"\~" => Text("~"));
t!(Markup: r"\`" => Text("`"));
+ t!(Markup: r"\$" => Text("$"));
// Test unescapable symbols.
t!(Markup[" /"]: r"\a" => Text(r"\"), Text("a"));