# Path: bl/ugen.py
# N = _Nothing()
# 
# R = Random
# 
# def Random(*c):
#     return _sample(random.choice, c)
# 
# def RandomPhrase(phrases=(), length=None):
#     if length is not None:
#         for phrase in phrases:
#             if len(phrase) != length:
#                 raise ValueError('Phrase %s is not of specified length: %s' %
#                                 (phrase, length))
#     return _randomPhraseGen(phrases).next
# 
# RP = RandomPhrase
# 
# def RandomWalk(sounds, startIndex=None):
#     return _randomWalk(sounds, startIndex).next
# 
# RW = RandomWalk
# 
# def Weight(*weights):
#     ws = _weighted(*weights)
#     return R(*ws)
# 
# W = Weight
# 
# C = Cycle
# 
# def Cycle(*c):
#     return _sample(c=c)
# 
# O = Oscillate
# 
# def Oscillate(*c):
#     c = list(c) + list(reversed(c[1:-1]))
#     return _sample(c=c)


import random
from twisted.trial.unittest import TestCase
from bl.ugen import (N, R, Random, RandomPhrase, RP, RandomWalk, RW, Weight, W,
                     C, Cycle, O, Oscillate)




class UGensTestCase(TestCase):

    def setUp(self):
        random.seed(0)

    def test_N(self):
        self.assertEqual(N(), None)
        self.failIf(N)
        self.failIf(bool(N))
        self.assertEqual(repr(N), 'N')
        self.assertEqual(str(N), 'N')

    def test_Cycle(self):
        self.assertIdentical(C, Cycle)
        c = C(1, 2, 3, 4, 5)
        results = [c() for i in range(10)]
        self.assertEqual(results, [1, 2, 3, 4, 5, 1, 2, 3, 4, 5])

    def test_Oscillate(self):
        self.assertIdentical(O, Oscillate)

# Path: bl/ugen.py
# N = _Nothing()
# 
# R = Random
# 
# def Random(*c):
#     return _sample(random.choice, c)
# 
# def RandomPhrase(phrases=(), length=None):
#     if length is not None:
#         for phrase in phrases:
#             if len(phrase) != length:
#                 raise ValueError('Phrase %s is not of specified length: %s' %
#                                 (phrase, length))
#     return _randomPhraseGen(phrases).next
# 
# RP = RandomPhrase
# 
# def RandomWalk(sounds, startIndex=None):
#     return _randomWalk(sounds, startIndex).next
# 
# RW = RandomWalk
# 
# def Weight(*weights):
#     ws = _weighted(*weights)
#     return R(*ws)
# 
# W = Weight
# 
# C = Cycle
# 
# def Cycle(*c):
#     return _sample(c=c)
# 
# O = Oscillate
# 
# def Oscillate(*c):
#     c = list(c) + list(reversed(c[1:-1]))
#     return _sample(c=c)


# Path: bl/tests/test_ugen.py
import random
from twisted.trial.unittest import TestCase
from bl.ugen import (N, R, Random, RandomPhrase, RP, RandomWalk, RW, Weight, W,
                     C, Cycle, O, Oscillate)





class UGensTestCase(TestCase):

    def setUp(self):
        random.seed(0)

    def test_N(self):
        self.assertEqual(N(), None)
        self.failIf(N)
        self.failIf(bool(N))
        self.assertEqual(repr(N), 'N')
        self.assertEqual(str(N), 'N')

    def test_Cycle(self):
        self.assertIdentical(C, Cycle)
        c = C(1, 2, 3, 4, 5)
        results = [c() for i in range(10)]
        self.assertEqual(results, [1, 2, 3, 4, 5, 1, 2, 3, 4, 5])

    def test_Oscillate(self):
        self.assertIdentical(O, Oscillate)

        o = O(1, 2, 3, 4, 5)