Esempio n. 1
0
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")
Esempio n. 2
0
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")
Esempio n. 3
0
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")
Esempio n. 4
0
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")
Esempio n. 5
0
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")
Esempio n. 6
0
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")
Esempio n. 7
0
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 \)")
Esempio n. 8
0
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
Esempio n. 9
0
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
Esempio n. 10
0
def test_prebuild_basicexternal():
    def tt_fun():
        ee.bb()
    
    fun = compile_function(tt_fun, [])
    assert check_source_contains(fun, "EE = ee")
Esempio n. 11
0
def test_decorator():
    def dec_fun():
        a.some_code("aa")
    
    fun = compile_function(dec_fun, [])
    assert check_source_contains(fun, "\.some_code")
Esempio n. 12
0
def test_prebuilt_basicexternal():
    def tt_fun():
        ee.bb()

    fun = compile_function(tt_fun, [])
    assert check_source_contains(fun, "EE = ee")
Esempio n. 13
0
def test_decorator():
    def dec_fun():
        a.some_code("aa")

    fun = compile_function(dec_fun, [])
    assert check_source_contains(fun, "\.some_code")