~chris.foo/lolram/main

« back to all changes in this revision

Viewing changes to src/py3/lolram/coroutines_test.py

  • Committer: Christopher Foo
  • Date: 2012-11-14 03:50:50 UTC
  • Revision ID: chris.foo@gmail.com-20121114035050-pa1dtyww8m42tfos
Removes contents except for README notice.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#    Copyright © 2011-2012 Christopher Foo <chris.foo@gmail.com>
2
 
#
3
 
#    This file is part of Lolram.
4
 
#
5
 
#    Lolram is free software: you can redistribute it and/or modify
6
 
#    it under the terms of the GNU General Public License as published by
7
 
#    the Free Software Foundation, either version 3 of the License, or
8
 
#    (at your option) any later version.
9
 
#
10
 
#    Lolram is distributed in the hope that it will be useful,
11
 
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
#    GNU General Public License for more details.
14
 
#
15
 
#    You should have received a copy of the GNU General Public License
16
 
#    along with Lolram.  If not, see <http://www.gnu.org/licenses/>.
17
 
#
18
 
 
19
 
import lolram.coroutines
20
 
import unittest
21
 
 
22
 
 
23
 
def my_undec_coroutine():
24
 
    while True:
25
 
        (yield)
26
 
 
27
 
 
28
 
@lolram.coroutines.coroutine
29
 
def my_coroutine():
30
 
    while True:
31
 
        (yield)
32
 
 
33
 
 
34
 
class TestCoroutine(unittest.TestCase):
35
 
    def test_failure(self):
36
 
        '''It should not automatically start the coroutine'''
37
 
 
38
 
        c = my_undec_coroutine()
39
 
 
40
 
        def f():
41
 
            c.send('asdf')
42
 
 
43
 
        self.assertRaises(TypeError, f)
44
 
 
45
 
    def test_coroutine(self):
46
 
        '''It should automatically start the coroutine'''
47
 
 
48
 
        c = my_coroutine()
49
 
        c.send('asdf')
50
 
 
51
 
if __name__ == "__main__":
52
 
    #import sys;sys.argv = ['', 'Test.testName']
53
 
    unittest.main()