Exemple #1
0
def test_recursive_link(beeper, beeper_class, clock):
    if beeper_class == MultichannelBeeper:
        # TODO: This gets rather nasty with component property; fix!
        raise pytest.xfail(
            'INTERNALERROR> RuntimeError: maximum recursion depth exceeded')
    with beeper.extra_behavior('link function'):
        beeper.volume = link(beeper.volume)
        with pytest.raises(RuntimeError):
            beeper.volume.get()
        assert str(beeper.volume) in ('<RuntimeError while getting value>',
                                      '<RecursionError while getting value>')
Exemple #2
0
def test_set_to_expression_with_linked_property(beeper, clock):
    with beeper.extra_behavior('link function'):
        beeper.volume = link(beeper.pitch)
        beeper.pitch += Progress(clock, 2) * 20
        assert beeper.volume == 440
        assert beeper.pitch == 440
        clock.advance_sync(1)
        assert beeper.volume == 450
        assert beeper.pitch == 450
        clock.advance_sync(1)
        assert beeper.volume == 460
        assert beeper.pitch == 460
Exemple #3
0
def test_link_dump_function(beeper, beeper_class, clock, check_dump):
    # The dump is different for normal properties and for components
    with beeper.extra_behavior('link function'):
        beeper.volume = link(beeper.pitch) + 4
        if beeper_class == MultichannelBeeper:
            check_dump(beeper.volume, """
                <test beeper>.volume (volumes[0]) value <444.0>:
                  <test beeper>.volumes value <444.0, 0.0, 0.0>:
                    Concat <444.0, 0.0, 0.0>:
                      + <444.0>:
                        linked <test beeper>.pitch (pitches[0]) <440.0>:
                          <test beeper>.pitches value <440.0, 440.0, 440.0>:
                            Constant <440.0, 440.0, 440.0>
                        Constant <4.0>
                      Constant <0.0, 0.0>
            """)
        else:
            check_dump(beeper.volume, """
                <test beeper>.volume value <444.0>:
                  + <444.0>:
                    linked <test beeper>.pitch <440.0>:
                      Constant <440.0>
                    Constant <4.0>
            """)
Exemple #4
0
def test_link_function_idempotent(beeper, clock):
    with beeper.extra_behavior('link function'):
        linked = link(beeper.volume)
        assert linked is link(linked)