Esempio n. 1
0
    def test_inside_top_level_two_sections(self):
        c = sd.Context()

        foo = c.object('foo')
        bar = c.object('bar')
        baz = c.object('baz')

        with c.alt():
            with c.choice('ok'):
                with foo:
                    bar.func()
            with c.choice('else'):
                with foo:
                    baz.func()

        self.check(c, [
            sd_action.FragBegin('alt'),
            sd_action.FragBegin('choice', 'ok'),
            sd_action.Call(foo, bar, 'func', sd.Params()),
            sd_action.ImplicitReturn(),
            sd_action.FragEnd('choice'),
            sd_action.FragBegin('choice', 'else'),
            sd_action.Call(foo, baz, 'func', sd.Params()),
            sd_action.ImplicitReturn(),
            sd_action.FragEnd('choice'),
            sd_action.FragEnd('alt'),
        ])
Esempio n. 2
0
    def test_inside_func_call_twice(self):
        c = sd.Context()

        foo = c.object('foo')
        bar = c.object('bar')
        baz = c.object('baz')

        with foo:
            with bar.func():
                with c.opt():
                    baz.func()
                with c.opt():
                    baz.func()

        self.check(c, [
            sd_action.Call(foo, bar, 'func', sd.Params()),
            sd_action.FragBegin('opt'),
            sd_action.Call(bar, baz, 'func', sd.Params()),
            sd_action.ImplicitReturn(),
            sd_action.FragEnd('opt'),
            sd_action.FragBegin('opt'),
            sd_action.Call(bar, baz, 'func', sd.Params()),
            sd_action.ImplicitReturn(),
            sd_action.FragEnd('opt'),
            sd_action.ImplicitReturn(),
        ])
Esempio n. 3
0
    def test_top_level(self):
        c = sd.Context()

        foo = c.object('foo')
        bar = c.object('bar')

        with c.group():
            with foo:
                bar.func()

        self.check(c, [
            sd_action.FragBegin('group'),
            sd_action.Call(foo, bar, 'func', sd.Params()),
            sd_action.ImplicitReturn(),
            sd_action.FragEnd('group'),
        ])
Esempio n. 4
0
    def test_with_condition(self):
        c = sd.Context()

        foo = c.object('foo')
        bar = c.object('bar')

        with c.opt('condition'):
            with foo:
                bar.func()

        self.check(c, [
            sd_action.FragBegin('opt', 'condition'),
            sd_action.Call(foo, bar, 'func', sd.Params()),
            sd_action.ImplicitReturn(),
            sd_action.FragEnd('opt'),
        ])