def test_simple_builtin(): from pypy.translator.js.modules.dom import document def test_document_call(): return document.getElementById("some_id") fn = compile_function(test_document_call, []) assert check_source_contains(fn, "= document") assert check_source_contains(fn, "\.getElementById")
def test_basicexternal_element(): def be_fun(): b = B() b.a = a b.a.some_code("aa") fun = compile_function(be_fun, []) assert check_source_contains(fun, "\.some_code")
def test_callback(): def callback(a): return str(a) def callback_stuff(): SomeNodeInstance.some_callback = callback fn = compile_function(callback_stuff, []) assert check_source_contains(fn, "\.some_callback = callback")
def test_set_timeout(): from pypy.translator.js.modules.dom import setTimeout def to_timeout(): pass def s_timeout_call(): setTimeout(to_timeout, 300) c = compile_function(s_timeout_call, []) assert check_source_contains(c, "setTimeout \( 'to_timeout\(\)',300 \)")
def test_simple_proxy(): try: oldproxy = commproxy.USE_MOCHIKIT commproxy.USE_MOCHIKIT = True def simple_proxy(): retval = SomeProxyInstance.some_method() fn = compile_function(simple_proxy, []) assert check_source_contains(fn, "loadJSONDoc\('some_method'") finally: commproxy.USE_MOCHIKIT = oldproxy
def test_prebuild_basicexternal(): def tt_fun(): ee.bb() fun = compile_function(tt_fun, []) assert check_source_contains(fun, "EE = ee")
def test_decorator(): def dec_fun(): a.some_code("aa") fun = compile_function(dec_fun, []) assert check_source_contains(fun, "\.some_code")
def test_prebuilt_basicexternal(): def tt_fun(): ee.bb() fun = compile_function(tt_fun, []) assert check_source_contains(fun, "EE = ee")