예제 #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
예제 #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
예제 #3
0
 def runner():
     # Run in JS
     code = HasEventsJS.JSCODE
     for c in cls.mro()[1:]:
         if c is event.HasEvents:
             break
         code += create_js_hasevents_class(
             c, c.__name__, c.__bases__[0].__name__ + '.prototype')
     for c in extra_classes:
         code += create_js_hasevents_class(c, c.__name__)
     code += create_js_hasevents_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
     code = reduce_code(code)
     jsresult = evaljs(code)
     jsresult = jsresult.replace('[ ',
                                 '[').replace(' ]',
                                              ']').replace('\n  ', ' ')
     jsresult = jsresult.replace('"', "'").split('!!!!')[-1]
     print('js:', jsresult)
     # Run in Python
     pyresult = reprs(func(cls))
     pyresult = pyresult.replace('"',
                                 "'").replace("\\'",
                                              "'").split('!!!!')[-1]
     print('py:', pyresult)
     #
     assert pyresult.lower() == reference
     assert jsresult.lower() == reference
예제 #4
0
 def runner():
     # Run in JS
     code = HasEventsJS.JSCODE
     for c in extra_classes:
         code += create_js_hasevents_class(c, c.__name__)
     this_classes = []
     for c in cls.mro():
         if c is event.HasEvents:
             break
         this_classes.append(c)
     for c in reversed(this_classes):
         code += create_js_hasevents_class(
             c, c.__name__, c.__bases__[0].__name__ + '.prototype')
     code += py2js(func, 'test', inline_stdlib=False, docstrings=False)
     code += 'console.log(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, print_result=False)  # allow using file
     jsresult = jsresult.replace('[ ',
                                 '[').replace(' ]',
                                              ']').replace('\n  ', ' ')
     jsresult = jsresult.replace('"', "'").split('!!!!')[-1]
     print('js:', jsresult)
     # Run in Python
     pyresult = reprs(func(cls))
     pyresult = pyresult.replace('"',
                                 "'").replace("\\'",
                                              "'").split('!!!!')[-1]
     print('py:', pyresult)
     #
     assert pyresult.lower() == reference
     assert jsresult.lower() == reference
예제 #5
0
 def runner():
     # Run in JS
     code = HasEventsJS.JSCODE
     for c in extra_classes:
         code += create_js_hasevents_class(c, c.__name__)
     this_classes = []
     for c in cls.mro():
         if c is event.HasEvents:
             break
         this_classes.append(c)
     for c in reversed(this_classes):
         code += create_js_hasevents_class(c, c.__name__, c.__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
     code = reduce_code(code)
     jsresult = evaljs(code)
     jsresult = jsresult.replace('[ ', '[').replace(' ]', ']').replace('\n  ', ' ')
     jsresult = jsresult.replace('"', "'").split('!!!!')[-1]
     print('js:', jsresult)
     # Run in Python
     pyresult = reprs(func(cls))
     pyresult = pyresult.replace('"', "'").replace("\\'", "'").split('!!!!')[-1]
     print('py:', pyresult)
     #
     assert pyresult.lower() == reference
     assert jsresult.lower() == reference