Ejemplo n.º 1
0
def test_bc_primBytecodeAt_with_instvars():
    #   ^ self at: 1
    py.test.skip("Broken, fix me")
    w_fakeclass = mockclass(1, name='fakeclass', varsized=True)
    w_fakeinst = w_fakeclass.as_class_get_shadow().new(1)
    w_fakeinst.store(0, wrap_char("a"))  # static slot 0: instance variable
    w_fakeinst.store(1, wrap_char("b"))  # varying slot 1

    def test():
        assert utility.unwrap_char(
            interpret_bc([112, 118, 192, 124],
                         fakeliterals(),
                         receiver=w_fakeinst)) == "b"

    run_with_faked_methods([[w_fakeclass, primitives.AT, 1, "at:"]], test)
Ejemplo n.º 2
0
def test_bc_primBytecodeAt_with_instvars():
    #   ^ self at: 1
    py.test.skip("Broken, fix me")
    w_fakeclass = mockclass(1, name='fakeclass', varsized=True)
    w_fakeinst = w_fakeclass.as_class_get_shadow().new(1)
    w_fakeinst.store(0, wrap_char("a")) # static slot 0: instance variable
    w_fakeinst.store(1, wrap_char("b")) # varying slot 1
    def test():
        assert utility.unwrap_char(interpret_bc(
            [112, 118, 192, 124],
            fakeliterals(),
            receiver=w_fakeinst)) == "b"
    run_with_faked_methods(
        [[w_fakeclass, primitives.AT, 1, "at:"]],
        test)
Ejemplo n.º 3
0
def func(interp, w_obj, n0):
    n0 = assert_valid_index(n0, w_obj)
    # XXX I am not sure this is correct, but it un-breaks translation:
    # make sure that getbyte is only performed on W_BytesObjects
    if not isinstance(w_obj, model.W_BytesObject):
        raise PrimitiveFailedError
    return utility.wrap_char(w_obj.getchar(n0))
Ejemplo n.º 4
0
 def test():
     assert utility.unwrap_char(
         interpret_bc([0x70, 0x76, 0x20, 0xc1, 0x7c],
                      fakeliterals(wrap_char("b")),
                      receiver=w_fakeinst)) == "b"
     assert utility.unwrap_char(w_fakeinst.fetch(0)) == "a"
     assert utility.unwrap_char(w_fakeinst.fetch(1)) == "b"
Ejemplo n.º 5
0
def func(interp, w_obj, n0):
    n0 = assert_valid_index(n0, w_obj)
    # XXX I am not sure this is correct, but it un-breaks translation:
    # make sure that getbyte is only performed on W_BytesObjects
    if not isinstance(w_obj, model.W_BytesObject):
        raise PrimitiveFailedError
    return utility.wrap_char(w_obj.getchar(n0))
Ejemplo n.º 6
0
def wrap(x):
    if isinstance(x, int): return utility.wrap_int(x)
    if isinstance(x, float): return utility.wrap_float(x)
    if isinstance(x, model.W_Object): return x
    if isinstance(x, str) and len(x) == 1: return utility.wrap_char(x)
    if isinstance(x, str): return utility.wrap_string(x)
    raise NotImplementedError
Ejemplo n.º 7
0
 def test():
     assert utility.unwrap_char(interpret_bc(
         [0x70, 0x76, 0x20, 0xc1, 0x7c],
         fakeliterals(wrap_char("b")),
         receiver=w_fakeinst)) == "b"
     assert utility.unwrap_char(w_fakeinst.fetch(0)) == "a"
     assert utility.unwrap_char(w_fakeinst.fetch(1)) == "b"
Ejemplo n.º 8
0
def test_bc_primBytecodeAtPut_with_instvars():
    #   ^ self at: 1 put: #b
    py.test.skip("Broken, fix me")
    w_fakeclass = mockclass(1, name='fakeclass', varsized=True)
    w_fakeinst = w_fakeclass.as_class_get_shadow().new(1)
    w_fakeinst.store(0, wrap_char("a")) # static slot 0: instance variable
    w_fakeinst.store(1, wrap_char("a")) # varying slot 1
    def test():
        assert utility.unwrap_char(interpret_bc(
            [0x70, 0x76, 0x20, 0xc1, 0x7c],
            fakeliterals(wrap_char("b")),
            receiver=w_fakeinst)) == "b"
        assert utility.unwrap_char(w_fakeinst.fetch(0)) == "a"
        assert utility.unwrap_char(w_fakeinst.fetch(1)) == "b"
    run_with_faked_methods(
        [[w_fakeclass, primitives.AT_PUT, 2, "at:put:"]],
        test)
Ejemplo n.º 9
0
def test_bc_primBytecodeAtPut_with_instvars():
    #   ^ self at: 1 put: #b
    py.test.skip("Broken, fix me")
    w_fakeclass = mockclass(1, name='fakeclass', varsized=True)
    w_fakeinst = w_fakeclass.as_class_get_shadow().new(1)
    w_fakeinst.store(0, wrap_char("a"))  # static slot 0: instance variable
    w_fakeinst.store(1, wrap_char("a"))  # varying slot 1

    def test():
        assert utility.unwrap_char(
            interpret_bc([0x70, 0x76, 0x20, 0xc1, 0x7c],
                         fakeliterals(wrap_char("b")),
                         receiver=w_fakeinst)) == "b"
        assert utility.unwrap_char(w_fakeinst.fetch(0)) == "a"
        assert utility.unwrap_char(w_fakeinst.fetch(1)) == "b"

    run_with_faked_methods([[w_fakeclass, primitives.AT_PUT, 2, "at:put:"]],
                           test)
Ejemplo n.º 10
0
 def test():
     assert interpret_bc([32, 118, 33, 193, 124],
                         fakeliterals("a",
                                      wrap_char("b"))) == wrap_char("b")
Ejemplo n.º 11
0
 def test():
     assert interpret_bc(
         [ 32, 118, 33, 193, 124 ],
         fakeliterals("a", wrap_char("b"))) == wrap_char("b")