mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
fix parse tests
This commit is contained in:
parent
61fc05dace
commit
e7bbfe96db
2 changed files with 6 additions and 5 deletions
|
@ -377,12 +377,13 @@ fn chomp_private_tag(buffer: &[u8], row: Row, col: Col) -> Result<&str, BadIdent
|
||||||
|
|
||||||
match chomp_uppercase_part(&buffer[1..]) {
|
match chomp_uppercase_part(&buffer[1..]) {
|
||||||
Ok(name) => {
|
Ok(name) => {
|
||||||
let chomped = 1 + name.len();
|
let width = 1 + name.len();
|
||||||
|
|
||||||
if let Ok(('.', _)) = char::from_utf8_slice_start(&buffer[chomped..]) {
|
if let Ok(('.', _)) = char::from_utf8_slice_start(&buffer[width..]) {
|
||||||
Err(BadIdent::BadPrivateTag(row, col + chomped as u16))
|
Err(BadIdent::BadPrivateTag(row, col + width as u16))
|
||||||
} else {
|
} else {
|
||||||
Ok(name)
|
let value = unsafe { std::str::from_utf8_unchecked(&buffer[..width]) };
|
||||||
|
Ok(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_) => Err(BadIdent::BadPrivateTag(row, col + 1)),
|
Err(_) => Err(BadIdent::BadPrivateTag(row, col + 1)),
|
||||||
|
|
|
@ -1005,7 +1005,7 @@ mod test_parse {
|
||||||
use roc_parse::ident::BadIdent;
|
use roc_parse::ident::BadIdent;
|
||||||
|
|
||||||
let arena = Bump::new();
|
let arena = Bump::new();
|
||||||
let expected = Expr::MalformedIdent("@One.Two.Whee", BadIdent::QualifiedTag(0, 13));
|
let expected = Expr::MalformedIdent("@One.Two.Whee", BadIdent::BadPrivateTag(0, 4));
|
||||||
let actual = parse_expr_with(&arena, "@One.Two.Whee");
|
let actual = parse_expr_with(&arena, "@One.Two.Whee");
|
||||||
|
|
||||||
assert_eq!(Ok(expected), actual);
|
assert_eq!(Ok(expected), actual);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue