Exemplo n.º 1
0
def test_term_dice_with_flag_and_operator_invalid():
    token = term()
    with pytest.raises(ParseException):
        token.parseString("1d6!keeper+5")
    with pytest.raises(ParseException):
        token.parseString("1d6a!keep+5")
    with pytest.raises(ParseException):
        token.parseString("1d6!advant+5")
Exemplo n.º 2
0
def test_term_dice_only():
    parse_result = term().parseString("1d6")
    tokens = parse_result.asList()
    assert len(tokens) == 1

    actual = tokens.pop()
    expected = Dice(rolls=1, sides=6)
    assert actual == expected
Exemplo n.º 3
0
def test_term_dice_with_flag_and_operator_invalid():
    token = term()
    with pytest.raises(ParseException):
        token.parseString("1d6!keeper+5")
    with pytest.raises(ParseException):
        token.parseString("1d6a!keep+5")
    with pytest.raises(ParseException):
        token.parseString("1d6!advant+5")
Exemplo n.º 4
0
 def test_term_dice_with_flag_and_operator_invalid(self):
     token = term()
     with self.assertRaises(ParseException):
         actual = token.parseString("1d6!keeper+5")
     with self.assertRaises(ParseException):
         actual = token.parseString("1d6a!keep+5")
     with self.assertRaises(ParseException):
         actual = token.parseString("1d6!advant+5")
Exemplo n.º 5
0
def test_term_dice_only():
    parse_result = term().parseString("1d6")
    tokens = parse_result.asList()
    assert len(tokens) == 1

    actual = tokens.pop()
    expected = Dice(rolls=1, sides=6)
    assert actual == expected
Exemplo n.º 6
0
def test_term_dice_only_invalid():
    token = term()
    with pytest.raises(ParseException):
        token.parseString("1d1.2")
    with pytest.raises(ParseException):
        token.parseString("1d-6")
    with pytest.raises(ParseException):
        token.parseString("1t6")
Exemplo n.º 7
0
 def test_term_dice_only_invalid(self):
     token = term()
     with self.assertRaises(ParseException):
         actual = token.parseString("1d1.2")
     with self.assertRaises(ParseException):
         actual = token.parseString("1d-6")
     with self.assertRaises(ParseException):
         actual = token.parseString("1t6")
Exemplo n.º 8
0
def test_term_dice_only_invalid():
    token = term()
    with pytest.raises(ParseException):
        token.parseString("1d1.2")
    with pytest.raises(ParseException):
        token.parseString("1d-6")
    with pytest.raises(ParseException):
        token.parseString("1t6")
Exemplo n.º 9
0
 def test_term_dice_only_uppercase(self):
     token = term()
     actual = token.parseString("1D6")
     pprint(actual.asList())
     self.assertEqual(len(actual), 3)
     #NOTE:  this is the same as in test_term_dice_only as CaselessLiteral will
     # return the case of the defined matchString, not the search string passed
     # into parse.   -ZR
     self.assertEqual(actual.asList(), [1, 'd', 6])
Exemplo n.º 10
0
def test_term_dice_with_flag_and_operator():
    parse_result = term().parseString("1d6!keep+5")
    tokens = parse_result.asList()
    assert len(tokens) == 1

    actual = tokens.pop()
    expected = [[Dice(rolls=1, sides=6), "!keep"], "+", 5]
    assert len(actual) == 3
    assert actual == expected
Exemplo n.º 11
0
def test_term_dice_with_flag():
    parse_result = term().parseString("1d6!keep")
    tokens = parse_result.asList()
    assert len(tokens) == 1

    actual = tokens.pop()
    expected = [Dice(rolls=1, sides=6), "!keep"]
    assert len(actual) == 2
    assert actual == expected
Exemplo n.º 12
0
def test_term_dice_with_flag_and_operator():
    parse_result = term().parseString("1d6!keep+5")
    tokens = parse_result.asList()
    assert len(tokens) == 1

    actual = tokens.pop()
    expected = [[Dice(rolls=1, sides=6), "!keep"], "+", 5]
    assert len(actual) == 3
    assert actual == expected
Exemplo n.º 13
0
def test_term_dice_with_flag():
    parse_result = term().parseString("1d6!keep")
    tokens = parse_result.asList()
    assert len(tokens) == 1

    actual = tokens.pop()
    expected = [Dice(rolls=1, sides=6), "!keep"]
    assert len(actual) == 2
    assert actual == expected
Exemplo n.º 14
0
def test_term_dice_only_uppercase():
    # NOTE:  this is the same as in test_term_dice_only as CaselessLiteral will
    # return the case of the defined matchString, not the search string passed
    # into parse.   -ZR
    parse_result = term().parseString("1D6")
    tokens = parse_result.asList()
    assert len(tokens) == 1

    actual = tokens.pop()
    expected = Dice(rolls=1, sides=6)
    assert actual == expected
Exemplo n.º 15
0
def test_term_dice_only_uppercase():
    #NOTE:  this is the same as in test_term_dice_only as CaselessLiteral will
    # return the case of the defined matchString, not the search string passed
    # into parse.   -ZR
    parse_result = term().parseString("1D6")
    tokens = parse_result.asList()
    assert len(tokens) == 1

    actual = tokens.pop()
    expected = Dice(rolls=1, sides=6)
    assert actual == expected
Exemplo n.º 16
0
 def test_term_dice_only(self):
     token = term()
     actual = token.parseString("1d6")
     pprint(actual.asList())
     self.assertEqual(len(actual), 3)
     self.assertEqual(actual.asList(), [1, 'd', 6])
Exemplo n.º 17
0
 def test_term_dice_with_flag(self):
     token = term()
     actual = token.parseString("1d6!keep")
     pprint(actual.asList())
     self.assertEqual(len(actual), 4)
     self.assertEqual(actual.asList(), [1, 'd', 6, '!keep'])
Exemplo n.º 18
0
 def test_term_dice_with_operator(self):
     token = term()
     actual = token.parseString("1d6+5")
     pprint(actual.asList())
     self.assertEqual(len(actual), 5)
     self.assertEqual(actual.asList(), [1, 'd', 6, '+', 5])
Exemplo n.º 19
0
 def test_term_dice_with_flag_and_operator_uppercase(self):
     token = term()
     actual = token.parseString("1D6!KEEP+5")
     pprint(actual.asList())
     self.assertEqual(len(actual), 6)
     self.assertEqual(actual.asList(), [1, 'd', 6, '!keep', '+', 5])