

def test_bound_methods(self):

    class MyClass14():

        def __init__(self):
            self.a = 1

        def add2(self):
            self.a += 2

    class MyClass15(MyClass14):

        def add3(self):
            self.a += 3
    code = (py2js(MyClass14) + py2js(MyClass15))
    assert (evaljs((code + 'var m = new MyClass14(); m.add2(); m.add2(); m.a')) == '5')
    assert (evaljs((code + 'var m = new MyClass14(); var f = m.add2; f(); f(); m.a')) == '5')
    assert (evaljs((code + 'var m = new MyClass15(); var f = m.add3; f(); f(); m.a')) == '7')
    assert (evaljs((code + 'var m = new MyClass15(); var f2 = m.add2, f3 = m.add3; f2(); f3(); m.a')) == '6')

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