Beispiel #1
0
 def test_match_basic_bool(self):
     match = pattern((bool, lambda i: False))
     result = match(True)
     assert not result
Beispiel #2
0
 def test_match_basic_float(self):
     match = pattern((float, lambda i: i + 1))
     result = match(0.0)
     assert result == 1.0
Beispiel #3
0
 def test_match_basic_int(self):
     match = pattern((int, lambda i: i + 1))
     result = match(0)
     assert result == 1
Beispiel #4
0
 def test_match_basic_str(self):
     match = pattern((str, lambda i: "goodbye"))
     result = match("Hello World")
     assert result == "goodbye"
Beispiel #5
0
 def test_does_not_match_pattern(self):
     match = pattern((int, lambda i: i + 1))
     result = match("Hello World")
     assert result is None
Beispiel #6
0
 def test_no_patterns_pattern(self):
     match = pattern()
     result = match("Hello World")
     assert result is None