@@ -0,0 +1,2532 @@
+# -*- coding: utf-8 -%0A#%0A# This file is part of flower. See the NOTICE for more information.%0A%0Afrom __future__ import absolute_import%0A%0Aimport time%0Afrom py.test import skip%0A%0Afrom offset import makechan, go, gosched, run, maintask%0A%0ASHOW_STRANGE = False%0A%0A%0Aimport six%0Afrom six.moves import xrange%0A%0Adef dprint(txt):%0A    if SHOW_STRANGE:%0A        print(txt)%0A%0Aclass Test_Stackless:%0A%0A    def test_simple(self):%0A        rlist = %5B%5D%0A%0A        def f():%0A            rlist.append('f')%0A%0A        def g():%0A            rlist.append('g')%0A            gosched()%0A%0A        @maintask%0A        def main():%0A            rlist.append('m')%0A            cg = go(g)%0A            cf = go(f)%0A            gosched()%0A            rlist.append('m')%0A%0A        run()%0A%0A        assert rlist == 'm g f m'.split()%0A%0A    def test_run(self):%0A        output = %5B%5D%0A        def print_(*args):%0A            output.append(args)%0A%0A        def f(i):%0A            print_(i)%0A%0A        go(f, 1)%0A        go(f, 2)%0A        run()%0A%0A        assert output == %5B(1,), (2,)%5D%0A%0A%0A    # tests inspired from simple core.com examples%0A%0A    def test_construction(self):%0A        output = %5B%5D%0A        def print_(*args):%0A            output.append(args)%0A%0A        def aCallable(value):%0A            print_(%22aCallable:%22, value)%0A%0A        go(aCallable, 'Inline using setup')%0A%0A        run()%0A        assert output == %5B(%22aCallable:%22, 'Inline using setup')%5D%0A%0A%0A        del output%5B:%5D%0A        go(aCallable, 'Inline using ()')%0A%0A        run()%0A        assert output == %5B(%22aCallable:%22, 'Inline using ()')%5D%0A%0A    def test_run(self):%0A        output = %5B%5D%0A        def print_(*args):%0A            output.append(args)%0A%0A        def f(i):%0A            print_(i)%0A%0A        @maintask%0A        def main():%0A            go(f, 1)%0A            go(f, 2)%0A%0A        run()%0A%0A        assert output == %5B(1,), (2,)%5D%0A%0A    def test_schedule(self):%0A        output = %5B%5D%0A        def print_(*args):%0A            output.append(args)%0A%0A        def f(i):%0A            print_(i)%0A%0A        go(f, 1)%0A        go(f, 2)%0A        gosched()%0A%0A        assert output == %5B(1,), (2,)%5D%0A%0A%0A    def test_cooperative(self):%0A        output = %5B%5D%0A        def print_(*args):%0A            output.append(args)%0A%0A        def Loop(i):%0A            for x in range(3):%0A                gosched()%0A                print_(%22schedule%22, i)%0A%0A        @maintask%0A        def main():%0A            go(Loop, 1)%0A            go(Loop, 2)%0A        run()%0A%0A        assert output == %5B('schedule', 1), ('schedule', 2),%0A                          ('schedule', 1), ('schedule', 2),%0A                          ('schedule', 1), ('schedule', 2),%5D%0A

add tests for the scheduler