示例#1
0
def test_dice_plus_operators():
    result = dicebot.roll_inner("1d1 + 100")
    assert result[1] == 101
    result = dicebot.roll_inner("1d1 - 100")
    assert result[1] == -99
    result = dicebot.roll_inner("1d1 * 100")
    assert result[1] == 100
    result = dicebot.roll_inner("1d1 / 100")
    assert result[1] == 0.01
    result = dicebot.roll_inner("100d1 / 10")
    assert result[1] == 10
    result = dicebot.roll_inner("100d1 / 10")
    assert result[1] == 10
示例#2
0
def test_parenthesis():
    result = dicebot.roll_inner("(1 + 2) * 3")
    assert result == ([], 9)
示例#3
0
def test_division():
    result = dicebot.roll_inner("8 / 4")
    assert result[1] == 2
    result = dicebot.roll_inner("10 / 4")
    assert result[1] == 2.5
示例#4
0
def test_adding_dice():
    result = dicebot.roll_inner("1d1 + 1d1")
    assert result == ([[1], [1]], 2)
示例#5
0
def test_subtraction():
    result = dicebot.roll_inner("1 - 1")
    assert result[1] == 0
示例#6
0
def test_multiplication():
    result = dicebot.roll_inner("2 * 3")
    assert result[1] == 6
示例#7
0
def test_addition():
    result = dicebot.roll_inner("1 + 1")
    assert result[1] == 2
    result = dicebot.roll_inner("1 + 1 + 2")
    assert result[1] == 4
示例#8
0
def test_0ds():
    result = dicebot.roll_inner("0d1")
    assert result == ([[]], 0)
示例#9
0
def test_bogus_function():
    with pytest.raises(Exception):
        dicebot.roll_inner("3q1")
示例#10
0
def test_nds():
    result = dicebot.roll_inner("3d1")
    assert result == ([[1, 1, 1]], 3)
    result = dicebot.roll_inner("3D1")
    assert result == ([[1, 1, 1]], 3)
示例#11
0
def test_empty():
    with pytest.raises(TypeError):
        dicebot.roll_inner()