Пример #1
0
def test_ldc():
    value = 5.0
    constants = ConstantPool()
    constant = constants.create_double(value)

    assert_incrementing_instruction(
        instruction=constant_instruction('ldc', constant),
        constants=constants,
        expected=[Push(Double.create_instance(value))])
Пример #2
0
def test_printable_constants():
    # Ensure we can successfully repr valid constants without crashing.
    pool = ConstantPool()
    repr(pool.create_utf8('HelloWorld'))
    repr(pool.create_class('HelloWorld'))
    repr(pool.create_double(1))
    repr(pool.create_float(1))
    repr(pool.create_integer(1))
    repr(pool.create_long(1))
    repr(pool.create_name_and_type('HelloWorld', 'I'))
    repr(pool.create_field_ref('HelloWorld', 'test', 'I'))
    repr(pool.create_method_ref('HelloWorld', 'test', 'I)V'))
    repr(pool.create_interface_method_ref('HelloWorld', 'test', 'I)V'))
    repr(pool.create_string('HelloWorld'))
Пример #3
0
def test_printable_constants():
    # Ensure we can successfully repr valid constants without crashing.
    pool = ConstantPool()
    repr(pool.create_utf8('HelloWorld'))
    repr(pool.create_class('HelloWorld'))
    repr(pool.create_double(1))
    repr(pool.create_float(1))
    repr(pool.create_integer(1))
    repr(pool.create_long(1))
    repr(pool.create_name_and_type('HelloWorld', 'I'))
    repr(pool.create_field_ref('HelloWorld', 'test', 'I'))
    repr(pool.create_method_ref('HelloWorld', 'test', 'I)V'))
    repr(pool.create_interface_method_ref(
        'HelloWorld',
        'test',
        'I)V'
    ))
    repr(pool.create_string('HelloWorld'))