Skip to content

Commit

Permalink
Add test samples for Nickel extended patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
yannham committed Jun 5, 2024
1 parent d7c045a commit be73d73
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
29 changes: 28 additions & 1 deletion topiary-cli/tests/samples/expected/nickel.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,34 @@
}
} => null,
_ => null,
}
},

# Extended pattern formatting
match {
{ foo, bar } if foo == 'Hello
&& bar == 'Goodbye =>
"multi"
++ "line"
++ "result",
{ foo, bar } if foo == 'Hello
&& bar == 'Goodbye => "single line result",
{ x, y, ..rest }
or { x }
or { y } => null,
{
foo = [
x,
_,
z,
..rest
],
bar = [
1,
2,
_
]
} => null,
},
],

# Nickel standard library as of af0d5ee
Expand Down
27 changes: 26 additions & 1 deletion topiary-cli/tests/samples/input/nickel.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,32 @@
}
} => null,
_ => null,
}
},

# Extended pattern formatting
match {
{foo, bar}
if
foo == 'Hello &&
bar == 'Goodbye
=>
"multi"
++ "line"
++ "result",

{foo, bar}
if
foo == 'Hello &&
bar == 'Goodbye
=> "single line result",

{x, y, ..rest} or {x} or
{y} => null,

{foo = [x, _,
z, ..rest], bar = [1,
2, _]} => null,
},
],

# Nickel standard library as of af0d5ee
Expand Down

0 comments on commit be73d73

Please sign in to comment.