コード例 #1
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(),
        ])
コード例 #2
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'),
        ])
コード例 #3
0
ファイル: test_sd.py プロジェクト: scottx611x/napkin
    def test_call_with_return(self):
        c = sd.Context()

        foo = c.object('foo')
        bar = c.object('bar')
        with foo:
            bar.func().ret('val')

        self.check(c, [
            sd_action.Call(foo, bar, 'func', sd.Params()),
            sd_action.Return(sd.Params(('val',))),
        ])
コード例 #4
0
ファイル: test_sd.py プロジェクト: scottx611x/napkin
    def test_return_from_outside_func_without_calling_any(self):
        c = sd.Context()

        foo = c.object('foo')
        bar = c.object('bar')
        with foo:
            with bar.func():
                c.ret()

        self.check(c, [
            sd_action.Call(foo, bar, 'func', sd.Params()),
            sd_action.Return(sd.Params()),
        ])
コード例 #5
0
ファイル: test_sd.py プロジェクト: scottx611x/napkin
    def test_simple(self):
        c = sd.Context()

        foo = c.object('foo')
        bar = c.object('bar')
        with foo:
            bar.func()
            c.destroy(bar)

        self.check(c, [
            sd_action.Call(foo, bar, 'func', sd.Params()),
            sd_action.ImplicitReturn(),
            sd_action.Call(foo, bar, '<<destroy>>', sd.Params(), flags='d'),
            sd_action.ImplicitReturn(),
        ])
コード例 #6
0
ファイル: test_sd.py プロジェクト: scottx611x/napkin
    def test_call_twice(self):
        c = sd.Context()

        foo = c.object('foo')
        bar = c.object('bar')
        with foo:
            bar.func()
            bar.func2()

        self.check(c, [
            sd_action.Call(foo, bar, 'func', sd.Params()),
            sd_action.ImplicitReturn(),
            sd_action.Call(foo, bar, 'func2', sd.Params()),
            sd_action.ImplicitReturn(),
        ])
コード例 #7
0
ファイル: test_sd.py プロジェクト: scottx611x/napkin
    def test_call_with_return(self):
        c = sd.Context()

        foo = c.object('foo')
        bar = c.object('bar')
        baz = c.object('baz')
        with foo:
            with bar.func():
                baz.func2().ret()

        self.check(c, [
            sd_action.Call(foo, bar, 'func', sd.Params()),
            sd_action.Call(bar, baz, 'func2', sd.Params()),
            sd_action.Return(sd.Params()),
            sd_action.ImplicitReturn(),
        ])
コード例 #8
0
ファイル: test_sd.py プロジェクト: scottx611x/napkin
    def test_call_others_in_constructor(self):
        c = sd.Context()

        foo = c.object('foo')
        bar = c.object('bar')
        baz = c.object('baz')
        with foo:
            with c.create(bar):
                baz.func()

        self.check(c, [
            sd_action.Call(foo, bar, '<<create>>', sd.Params(), flags='c'),
            sd_action.Call(bar, baz, 'func', sd.Params()),
            sd_action.ImplicitReturn(),
            sd_action.ImplicitReturn(),
        ])
コード例 #9
0
ファイル: test_sd.py プロジェクト: scottx611x/napkin
    def test_non_default_method(self):
        c = sd.Context()

        foo = c.object('foo')
        bar = c.object('bar')
        with foo:
            c.create(bar.new())

        self.check(c, [
            sd_action.Call(foo, bar, 'new', sd.Params(), flags='c'),
            sd_action.ImplicitReturn(),
        ])
コード例 #10
0
ファイル: test_sd.py プロジェクト: scottx611x/napkin
    def test_simple(self):
        c = sd.Context()

        foo = c.object('foo')
        bar = c.object('bar')
        with foo:
            c.create(bar)

        self.check(c, [
            sd_action.Call(foo, bar, '<<create>>', sd.Params(), flags='c'),
            sd_action.ImplicitReturn(),
        ])
コード例 #11
0
ファイル: test_sd.py プロジェクト: scottx611x/napkin
    def test_do_nothing_in_outside_func(self):
        c = sd.Context()

        foo = c.object('foo')
        bar = c.object('bar')
        with foo:
            with bar.func():
                pass

        self.check(c, [
            sd_action.Call(foo, bar, 'func', sd.Params()),
            sd_action.ImplicitReturn(),
        ])
コード例 #12
0
ファイル: test_sd.py プロジェクト: scottx611x/napkin
    def test_constructor_params(self):
        c = sd.Context()

        foo = c.object('foo')
        bar = c.object('bar')
        with foo:
            c.create(bar.new('a', name='bar'))

        self.check(c, [
            sd_action.Call(foo, bar, 'new',
                           params=sd.Params(('a',), dict(name='bar')),
                           flags='c'),
            sd_action.ImplicitReturn(),
        ])
コード例 #13
0
ファイル: test_sd.py プロジェクト: SokobanRyu/napkin
    def test_call_specific(self):
        c = sd.Context()

        foo = c.object('foo')
        bar = c.object('bar')
        baz = c.object('baz')
        with foo:
            bar.func().note('callee side note')
            baz.func().note(caller='caller side note',
                            callee='callee side note')
            baz.func2().note('note').ret('val')

        self.check(c, [
            sd_action.Call(foo, bar, 'func', sd.Params(),
                           notes=['callee side note', None]),
            sd_action.ImplicitReturn(),
            sd_action.Call(foo, baz, 'func', sd.Params(),
                           notes=['callee side note', 'caller side note']),
            sd_action.ImplicitReturn(),
            sd_action.Call(foo, baz, 'func2', sd.Params(),
                           notes=['note', None]),
            sd_action.Return(sd.Params(('val',))),
        ])
コード例 #14
0
ファイル: test_sd.py プロジェクト: scottx611x/napkin
    def test_over_object_implicit(self):
        c = sd.Context()

        foo = c.object('foo')
        bar = c.object('bar')
        with foo:
            c.note('blah')
            bar.func()

        self.check(c, [
            sd_action.Note('blah', obj=foo),
            sd_action.Call(foo, bar, 'func', sd.Params()),
            sd_action.ImplicitReturn(),
        ])
コード例 #15
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'),
        ])
コード例 #16
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'),
        ])
コード例 #17
0
ファイル: test_sd.py プロジェクト: scottx611x/napkin
 def test_empty(self):
     assert "" == str(sd.Params(tuple(), dict()))
コード例 #18
0
ファイル: test_sd.py プロジェクト: scottx611x/napkin
 def test_args(self):
     assert "abc, def" == str(sd.Params(('abc', 'def'), dict()))
コード例 #19
0
ファイル: test_sd.py プロジェクト: scottx611x/napkin
 def test_args_kargs(self):
     assert "abc, foo=1" == str(sd.Params(('abc',),
                                          dict(foo=1)))