[jsinterp] Support alternative function definition form

This commit is contained in:
Yen Chi Hsuan 2015-11-10 12:54:02 +08:00
parent b25f753397
commit ff29bf81f8
2 changed files with 5 additions and 2 deletions

View file

@ -19,6 +19,9 @@ class TestJSInterpreter(unittest.TestCase):
jsi = JSInterpreter('function x3(){return 42;}')
self.assertEqual(jsi.call_function('x3'), 42)
jsi = JSInterpreter('var x5 = function(){return 42;}')
self.assertEqual(jsi.call_function('x5'), 42)
def test_calc(self):
jsi = JSInterpreter('function x4(a){return 2*a+1;}')
self.assertEqual(jsi.call_function('x4', 3), 7)