mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
Update tests to use $(...) interpolation
This commit is contained in:
parent
25be487977
commit
163bde0c41
3 changed files with 55 additions and 18 deletions
|
@ -158,9 +158,20 @@ mod test_parse {
|
|||
|
||||
// INTERPOLATION
|
||||
|
||||
#[test]
|
||||
fn escaped_interpolation() {
|
||||
assert_segments(r#""Hi, \$(name)!""#, |arena| {
|
||||
bumpalo::vec![in arena;
|
||||
Plaintext("Hi, "),
|
||||
EscapedChar(EscapedChar::Dollar),
|
||||
Plaintext("(name)!"),
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn string_with_interpolation_in_middle() {
|
||||
assert_segments(r#""Hi, \(name)!""#, |arena| {
|
||||
assert_segments(r#""Hi, $(name)!""#, |arena| {
|
||||
let expr = arena.alloc(Var {
|
||||
module_name: "",
|
||||
ident: "name",
|
||||
|
@ -176,7 +187,7 @@ mod test_parse {
|
|||
|
||||
#[test]
|
||||
fn string_with_interpolation_in_front() {
|
||||
assert_segments(r#""\(name), hi!""#, |arena| {
|
||||
assert_segments(r#""$(name), hi!""#, |arena| {
|
||||
let expr = arena.alloc(Var {
|
||||
module_name: "",
|
||||
ident: "name",
|
||||
|
@ -191,7 +202,7 @@ mod test_parse {
|
|||
|
||||
#[test]
|
||||
fn string_with_interpolation_in_back() {
|
||||
assert_segments(r#""Hello \(name)""#, |arena| {
|
||||
assert_segments(r#""Hello $(name)""#, |arena| {
|
||||
let expr = arena.alloc(Var {
|
||||
module_name: "",
|
||||
ident: "name",
|
||||
|
@ -206,7 +217,7 @@ mod test_parse {
|
|||
|
||||
#[test]
|
||||
fn string_with_multiple_interpolations() {
|
||||
assert_segments(r#""Hi, \(name)! How is \(project) going?""#, |arena| {
|
||||
assert_segments(r#""Hi, $(name)! How is $(project) going?""#, |arena| {
|
||||
let expr1 = arena.alloc(Var {
|
||||
module_name: "",
|
||||
ident: "name",
|
||||
|
@ -227,6 +238,32 @@ mod test_parse {
|
|||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn string_with_non_interpolation_dollar_signs() {
|
||||
assert_segments(
|
||||
r#""$a Hi, $(name)! $b How is $(project) going? $c""#,
|
||||
|arena| {
|
||||
let expr1 = arena.alloc(Var {
|
||||
module_name: "",
|
||||
ident: "name",
|
||||
});
|
||||
|
||||
let expr2 = arena.alloc(Var {
|
||||
module_name: "",
|
||||
ident: "project",
|
||||
});
|
||||
|
||||
bumpalo::vec![in arena;
|
||||
Plaintext("$a Hi, "),
|
||||
Interpolated(Loc::new(10, 14, expr1)),
|
||||
Plaintext("! $b How is "),
|
||||
Interpolated(Loc::new(29, 36, expr2)),
|
||||
Plaintext(" going? $c")
|
||||
]
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_source_file() {
|
||||
assert_parsing_fails("", SyntaxError::Eof(Region::zero()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue