Finish adding tests

This commit is contained in:
Sam Mohr 2024-11-02 21:58:25 -07:00
parent 71b1fdebc4
commit de124ecc3e
No known key found for this signature in database
GPG key ID: EA41D161A3C1BC99
13 changed files with 196 additions and 38 deletions

View file

@ -96,10 +96,7 @@ SpaceAfter(
"",
),
@50-74 Apply(
@50-53 Var {
module_name: "",
ident: "try",
},
@50-53 Try,
[
@54-57 Var {
module_name: "",

View file

@ -0,0 +1,2 @@
"123"
|> try Str.toU64

View file

@ -0,0 +1,32 @@
SpaceAfter(
BinOps(
[
(
@0-5 SpaceAfter(
Str(
PlainLine(
"123",
),
),
[
Newline,
],
),
@17-19 Pizza,
),
],
@20-33 Apply(
@20-23 Try,
[
@24-33 Var {
module_name: "Str",
ident: "toU64",
},
],
Space,
),
),
[
Newline,
],
)

View file

@ -0,0 +1,2 @@
"123"
|> try Str.toU64

View file

@ -0,0 +1 @@
Str.toU64 "123" |> try

View file

@ -0,0 +1,27 @@
SpaceAfter(
BinOps(
[
(
@0-15 Apply(
@0-9 Var {
module_name: "Str",
ident: "toU64",
},
[
@10-15 Str(
PlainLine(
"123",
),
),
],
Space,
),
@15-17 Pizza,
),
],
@18-21 Try,
),
[
Newline,
],
)

View file

@ -0,0 +1 @@
Str.toU64 "123"|> try

View file

@ -0,0 +1 @@
try Str.toU64 "123"

View file

@ -0,0 +1,20 @@
SpaceAfter(
Apply(
@0-3 Try,
[
@5-14 Var {
module_name: "Str",
ident: "toU64",
},
@16-21 Str(
PlainLine(
"123",
),
),
],
Space,
),
[
Newline,
],
)

View file

@ -0,0 +1 @@
try Str.toU64 "123"

View file

@ -6071,6 +6071,41 @@ mod test_fmt {
);
}
#[test]
fn format_try() {
expr_formats_same(indoc!(
r#"
_ = crash
_ = crash ""
crash "" ""
"#
));
expr_formats_to(
indoc!(
r#"
_ = crash
_ = crash ""
_ = crash "" ""
try
foo
(\_ -> crash "")
"#
),
indoc!(
r#"
_ = crash
_ = crash ""
_ = crash "" ""
try
foo
(\_ -> crash "")
"#
),
);
}
#[test]
fn issue_6197() {
expr_formats_to(

View file

@ -495,6 +495,9 @@ mod test_snapshots {
pass/tag_pattern.expr,
pass/ten_times_eleven.expr,
pass/three_arg_closure.expr,
pass/try_function_after_pipe.expr,
pass/try_pipe_suffix.expr,
pass/try_plain_prefix.expr,
pass/tuple_access_after_ident.expr,
pass/tuple_access_after_record.expr,
pass/tuple_accessor_function.expr,