Beispiel #1
0
def test_the_result_of_an_addition_can_narrate_where_it_comes_from():
    three = Value(3, BingoSource('cup of tea'))
    eight = Value(8, BingoSource('garden gate'))

    eleven = three + eight
    assert eleven.value == 11
    assert eleven.narrate() == '''11. from: 3 + 8
Beispiel #2
0
def test_value_can_have_an_object_source():
    bingo_four = Value(4, BingoSource('knock at the door'))
    assert bingo_four.narrate() == '4. from: the bingo number, knock at the door'
Beispiel #3
0
def test_value_can_tell_us_about_where_it_comes_from():
    assert Value(3, 'bob').narrate() == '3. from: bob'
Beispiel #4
0
def test_value_can_tell_us_about_itself():
    assert Value(2).narrate() == '2. i am what i am.'
def test_subtraction():
    assert (Value(15) - Value(7)).value == 8
def test_addition():
    assert (Value(3) + Value(-8)).value == -5
def test_division():
    assert (Value(5) / Value(2)).value == 2.5
def test_multiplication():
    assert (Value(5) * Value(3)).value == 15