From d53b44aafe85d3aced7af82eee11f7f52a1ea74e Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sun, 26 Apr 2020 19:02:43 -0400 Subject: [PATCH] tabs are not emitted literally --- src/utils/peek_until.rs | 7 ------- src/utils/strings.rs | 7 ------- tests/str-escape.rs | 12 +++++++++++- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/utils/peek_until.rs b/src/utils/peek_until.rs index 935d083..eaedc76 100644 --- a/src/utils/peek_until.rs +++ b/src/utils/peek_until.rs @@ -140,13 +140,6 @@ pub(crate) fn peek_escape>( value = toks.peek_forward(1).unwrap().kind as u32; } - // tabs are emitted literally - // TODO: figure out where this check is done - // in the source dart - if value == 0x9 { - return Ok("\\\t".to_string()); - } - let c = std::char::from_u32(value).unwrap(); if is_name(c) { Ok(c.to_string()) diff --git a/src/utils/strings.rs b/src/utils/strings.rs index 2e8a788..82dc692 100644 --- a/src/utils/strings.rs +++ b/src/utils/strings.rs @@ -143,13 +143,6 @@ fn escape>( value = toks.next().unwrap().kind as u32; } - // tabs are emitted literally - // TODO: figure out where this check is done - // in the source dart - if value == 0x9 { - return Ok("\\\t".to_string()); - } - let c = std::char::from_u32(value).unwrap(); if (identifier_start && is_name_start(c) && !c.is_digit(10)) || (!identifier_start && is_name(c)) diff --git a/tests/str-escape.rs b/tests/str-escape.rs index 168fd28..5875cf2 100644 --- a/tests/str-escape.rs +++ b/tests/str-escape.rs @@ -51,7 +51,7 @@ test!( test!( escape_tabs, "a {\n color: \\ x \\9x;\n}\n", - "a {\n color: \\\tx \\\tx;\n}\n" + "a {\n color: \\9 x \\9 x;\n}\n" ); test!( escape_interpolation_start, @@ -158,3 +158,13 @@ test!( unquoted_escape_minus_unquoted, "a {\n color: \\a - foo;\n}\n" ); +test!( + quoted_escaped_tab, + "a {\n color: \"\\9\";\n}\n", + "a {\n color: \"\t\";\n}\n" +); +test!( + unquoted_escaped_tab, + "a {\n color: \\9;\n}\n", + "a {\n color: \\9 ;\n}\n" +);