Esempio n. 1
0
def test_inlining_second_call_simple():
    assert compile_base(INLINING_TEST_PROGRAM.format('self.external_call("Hello")'), trim=2) == [
        OpcodePushStatic(2),
        internal_call('File.__constructor__')
    ]
Esempio n. 2
0
def test_inlining_internal_call():
    compile_base(INLINING_TEST_PROGRAM.format('Console.print(n1)'), trim=2)
Esempio n. 3
0
def test_inlining_binary_op_mixed():
    assert compile_base(INLINING_TEST_PROGRAM.format('self.add(2, n1)'), trim=2) == [
        OpcodePushLocal(1),
        OpcodePushStatic(2),
        internal_call('number.__addition__')
    ]
Esempio n. 4
0
def test_inlining_binary_op_variables():
    assert compile_base(INLINING_TEST_PROGRAM.format('self.add(n1, n2)'), trim=2) == [
        OpcodePushLocal(2),
        OpcodePushLocal(1),
        internal_call('number.__addition__')
    ]
Esempio n. 5
0
def test_inlining_binary_op_constants():
    assert compile_base(INLINING_TEST_PROGRAM.format('self.add(1, 2)'), trim=2) == [
        OpcodePushStatic(2),
        OpcodePushStatic(3),
        internal_call('number.__addition__')
    ]
Esempio n. 6
0
def test_self_dereference_in_static_function():
    with pytest.raises(SelfInStaticMethod):
        compile_base(SELF_USE_IN_STATIC_METHOD.format('self.n1'))
Esempio n. 7
0
def test_direct_self_use_in_static_function():
    with pytest.raises(SelfInStaticMethod):
        compile_base(SELF_USE_IN_STATIC_METHOD.format('return self'))

    with pytest.raises(SelfInStaticMethod):
        compile_base(SELF_USE_IN_STATIC_METHOD.format('Console.print(self)'))