Esempio n. 1
0
 def runner():
     # Run in JS
     code = js_rename(HasSignalsJS.JSCODE, 'HasSignalsJS', 'HasSignals')
     for c in cls.mro()[1:]:
         if c is HasSignals:
             break
         code += create_js_signals_class(c, c.__name__, c.__bases__[0].__name__+'.prototype')
     for c in extra_classes:
         code += create_js_signals_class(c, c.__name__)
     code += create_js_signals_class(cls, cls.__name__, cls.__bases__[0].__name__+'.prototype')
     code += py2js(func, 'test', inline_stdlib=False)
     code += 'test(%s);' % cls.__name__
     nargs, function_deps, method_deps = get_std_info(code)
     code = get_partial_std_lib(function_deps, method_deps, []) + code
     jsresult = evaljs(code)
     jsresult = jsresult.replace('[ ', '[').replace(' ]', ']')
     jsresult = jsresult.replace('"', "'")
     print('js:', jsresult)
     # Run in Python
     pyresult = str(func(cls))
     pyresult = pyresult.replace('"', "'")
     print('py:', pyresult)
     #
     assert pyresult.lower() == reference
     assert jsresult.lower() == reference
Esempio n. 2
0
 def runner():
     # Run in JS
     code = js_rename(HasSignalsJS.JSCODE, 'HasSignalsJS', 'HasSignals')
     for c in cls.mro()[1:]:
         if c is HasSignals:
             break
         code += create_js_signals_class(c, c.__name__, c.__bases__[0].__name__+'.prototype')
     for c in extra_classes:
         code += create_js_signals_class(c, c.__name__)
     code += create_js_signals_class(cls, cls.__name__, cls.__bases__[0].__name__+'.prototype')
     code += py2js(func, 'test', inline_stdlib=False)
     code += 'test(%s);' % cls.__name__
     nargs, function_deps, method_deps = get_std_info(code)
     code = get_partial_std_lib(function_deps, method_deps, []) + code
     jsresult = evaljs(code)
     jsresult = jsresult.replace('[ ', '[').replace(' ]', ']')
     jsresult = jsresult.replace('"', "'")
     print('js:', jsresult)
     # Run in Python
     pyresult = str(func(cls))
     pyresult = pyresult.replace('"', "'")
     print('py:', pyresult)
     #
     assert pyresult.lower() == reference
     assert jsresult.lower() == reference