Skip to content

Commit 76eb58f

Browse files
committed
Fix tests
1 parent 60cf537 commit 76eb58f

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

scrapscript.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2341,17 +2341,28 @@ def test_parse_record_with_trailing_comma_raises_parse_error(self) -> None:
23412341
def test_parse_symbol_returns_symbol(self) -> None:
23422342
self.assertEqual(parse([SymbolToken("abc")]), Symbol("abc"))
23432343

2344-
# def test_parse_guard(self) -> None:
2345-
# self.assertEqual(
2346-
# parse(tokenize("| x guard y -> x")),
2347-
# MatchFunction([MatchCase(Guard(Var("x"), Var("y")), Var("x"))]),
2348-
# )
2349-
2350-
# def test_parse_guard_exp(self) -> None:
2351-
# self.assertEqual(
2352-
# parse(tokenize("| x guard x==1 -> x")),
2353-
# MatchFunction([MatchCase(Guard(Var("x"), Binop(BinopKind.EQUAL, Var("x"), Int(1))), Var("x"))]),
2354-
# )
2344+
def test_parse_guard(self) -> None:
2345+
self.assertEqual(
2346+
parse(tokenize("| x guard y -> x")),
2347+
MatchFunction([MatchCase(Var("x"), Var("y"), Var("x"))]),
2348+
)
2349+
2350+
def test_parse_guard_exp(self) -> None:
2351+
self.assertEqual(
2352+
parse(tokenize("| x guard x==1 -> x")),
2353+
MatchFunction([MatchCase(Var("x"), Binop(BinopKind.EQUAL, Var("x"), Int(1)), Var("x"))]),
2354+
)
2355+
2356+
def test_parse_multiple_guards(self) -> None:
2357+
self.assertEqual(
2358+
parse(tokenize("| x guard y -> x | a guard b -> 1")),
2359+
MatchFunction(
2360+
[
2361+
MatchCase(Var("x"), Var("y"), Var("x")),
2362+
MatchCase(Var("a"), Var("b"), Int(1)),
2363+
]
2364+
),
2365+
)
23552366

23562367

23572368
class MatchTests(unittest.TestCase):

0 commit comments

Comments
 (0)