tabs are not emitted literally

This commit is contained in:
ConnorSkees 2020-04-26 19:02:43 -04:00
parent f4f4fe2e03
commit d53b44aafe
3 changed files with 11 additions and 15 deletions

View File

@ -140,13 +140,6 @@ pub(crate) fn peek_escape<I: Iterator<Item = Token>>(
value = toks.peek_forward(1).unwrap().kind as u32; 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(); let c = std::char::from_u32(value).unwrap();
if is_name(c) { if is_name(c) {
Ok(c.to_string()) Ok(c.to_string())

View File

@ -143,13 +143,6 @@ fn escape<I: Iterator<Item = Token>>(
value = toks.next().unwrap().kind as u32; 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(); let c = std::char::from_u32(value).unwrap();
if (identifier_start && is_name_start(c) && !c.is_digit(10)) if (identifier_start && is_name_start(c) && !c.is_digit(10))
|| (!identifier_start && is_name(c)) || (!identifier_start && is_name(c))

View File

@ -51,7 +51,7 @@ test!(
test!( test!(
escape_tabs, escape_tabs,
"a {\n color: \\ x \\9x;\n}\n", "a {\n color: \\ x \\9x;\n}\n",
"a {\n color: \\\tx \\\tx;\n}\n" "a {\n color: \\9 x \\9 x;\n}\n"
); );
test!( test!(
escape_interpolation_start, escape_interpolation_start,
@ -158,3 +158,13 @@ test!(
unquoted_escape_minus_unquoted, unquoted_escape_minus_unquoted,
"a {\n color: \\a - foo;\n}\n" "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"
);