Пример #1
0
def test_compare_is_global_mod():
    TEST_PAIRS = (
        # True
        ("", True),
        ("-0", True),
        ("-15", True),
        ("-35", True),
        ("+0", True),
        ("+1", True),
        ("+15", True),
        ("+35", True),
        # False
        ("d5", False),
        ("dF", False),
        ("d100", False),
        ("(", False),
        (")", False),
        ("-L", False),
        ("-2L", False),
        ("-2l", False),
        ("-H", False),
        ("-3H", False),
        ("-3h", False),
        ("0", False),
        ("1", False),
        ("10", False),
    )
    table = DiceTable()
    for stream_token, answer in TEST_PAIRS:
        assert table.compare(StackToken.global_mod, stream_token) == answer
Пример #2
0
def test_compare_single_char():
    TEST_PAIRS = (
        ('(', '('),
        (')', ')'),
    )
    table = DiceTable()
    for token_string, stream_token in TEST_PAIRS:
        assert table.compare(token_string, stream_token)
Пример #3
0
def test_compare_match_none():
    # These should never match
    STARTS = (
        StackToken.start,
        StackToken.die_type,
        StackToken.drop_mod,
    )
    POSSIBLE_MATCHES = (
        "d6",
        "(",
        "-H",
        "-12",
        "+15",
    )
    table = DiceTable()
    for token_string, stream_token in product(STARTS, POSSIBLE_MATCHES):
        assert not table.compare(token_string, stream_token)