

def test_bound_funcs_in_methods(self):

    class MyClass16():

        def foo1(self):
            self.a = 3
            f = (lambda i: self.a)
            return f()

        def foo2(self):
            self.a = 3

            def bar():
                return self.a
            return bar()

        def foo3(self):
            self.a = 3

            def bar(self):
                return self.a
            return bar()
    code = py2js(MyClass16)
    assert (evaljs((code + 'var m = new MyClass16(); m.foo1()')) == '3')
    assert (evaljs((code + 'var m = new MyClass16(); m.foo2()')) == '3')
    assert (evaljs((code + 'var m = new MyClass16(); try {m.foo3();} catch (err) {"ok"}')) == 'ok')

dataset/ETHPy150Open zoofIO/flexx/flexx/pyscript/tests/test_parser2.py TestClasses.test_bound_funcs_in_methods/original