#NEWLINE# def test_py2js_on_function( ) : #NEWLINE# #INDENT# def foo( ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# jscode = py2js ( foo ) #NEWLINE# assert jscode . startswith ( 'var foo' ) #NEWLINE# assert jscode . pycode . startswith ( 'def foo' ) #NEWLINE# jscode = py2js ( foo , 'bar' ) #NEWLINE# assert jscode . pycode . startswith ( 'def foo' ) #NEWLINE# assert ( 'foo' not in jscode ) #NEWLINE# assert jscode . startswith ( 'var bar' ) #NEWLINE# assert ( 'bar = function ' in jscode ) #NEWLINE# jscode = py2js ( foo , 'bar.bla' ) #NEWLINE# assert jscode . pycode . startswith ( 'def foo' ) #NEWLINE# assert ( 'foo' not in jscode ) #NEWLINE# assert ( not ( 'var bar.bla' in jscode ) ) #NEWLINE# assert ( 'bar.bla = function ' in jscode ) #NEWLINE# stub1 = ( lambda x : x ) #NEWLINE# stub2 = ( lambda x = None : stub1 ) #NEWLINE# @ stub1 #NEWLINE# @ stub1 #NEWLINE# def foo1( ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# @ stub2 ( ) #NEWLINE# def foo2( ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# @ py2js #NEWLINE# def foo3( ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# @ py2js ( indent = 1 ) #NEWLINE# def foo4( ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# assert callable ( foo2 ) #NEWLINE# assert callable ( foo2 ) #NEWLINE# assert py2js ( foo1 ) . pycode . startswith ( 'def foo' ) #NEWLINE# assert py2js ( foo2 ) . pycode . startswith ( 'def foo' ) #NEWLINE# assert foo3 . startswith ( 'var foo3' ) #NEWLINE# assert foo4 . startswith ( '    var foo4' )