def test_function1(self):
        "test function definition and running"
        self.trytext("""
def fcn(x, scale=2):
    'test function'
    out = sqrt(x)
    if scale > 1:
        out = out * scale
    endif
    return out
enddef
""")
        self.trytext("a = fcn(4, scale=9)")
        self.isValue("a", 18)
        self.NoExceptionRaised()

        self.trytext("a = fcn(9, scale=0)")
        self.isValue("a", 3)
        self.NoExceptionRaised()

        out, err = self.trytext("print(fcn)")
        self.NoExceptionRaised()
        out = out.split('\n')
        self.assert_(out[0].startswith('<Procedure fcn(x, scale='))
        self.assert_('test func' in out[1])

        out, err = self.trytext("a = fcn()")
        self.ExceptionRaised()
        errtype, errmsg = err[0].get_error()

        errlines = errmsg.split('\n')

        self.assertTrue(errtype == 'TypeError')

        out, err = self.trytext("a = fcn(x, bogus=3)")
        self.ExceptionRaised()
        errtype, errmsg = err[0].get_error()
        errmsgs = errmsg.split('\n')
        self.assertTrue(errtype == 'NameError')
dataset/ETHPy150Open xraypy/xraylarch/tests/test_funccalls.py/TestEval.test_function1/original