Skip to content

[mypyc] Move glue method test cases into a dedicated file #13937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
237 changes: 0 additions & 237 deletions mypyc/test-data/irbuild-basic.test
Original file line number Diff line number Diff line change
Expand Up @@ -2228,243 +2228,6 @@ L0:
r1 = CPyTagged_Multiply(4, r0)
return r1

[case testPropertyDerivedGen]
from typing import Callable
class BaseProperty:
@property
def value(self) -> object:
return self._incrementer

@property
def bad_value(self) -> object:
return self._incrementer

@property
def next(self) -> BaseProperty:
return BaseProperty(self._incrementer + 1)

def __init__(self, value: int) -> None:
self._incrementer = value

class DerivedProperty(BaseProperty):
@property
def value(self) -> int:
return self._incrementer

@property
def bad_value(self) -> object:
return self._incrementer

@property
def next(self) -> DerivedProperty:
return DerivedProperty(self._incr_func, self._incr_func(self.value))

def __init__(self, incr_func: Callable[[int], int], value: int) -> None:
BaseProperty.__init__(self, value)
self._incr_func = incr_func


class AgainProperty(DerivedProperty):
@property
def next(self) -> AgainProperty:
return AgainProperty(self._incr_func, self._incr_func(self._incr_func(self.value)))

@property
def bad_value(self) -> int:
return self._incrementer
[out]
def BaseProperty.value(self):
self :: __main__.BaseProperty
r0 :: int
r1 :: object
L0:
r0 = self._incrementer
r1 = box(int, r0)
return r1
def BaseProperty.bad_value(self):
self :: __main__.BaseProperty
r0 :: int
r1 :: object
L0:
r0 = self._incrementer
r1 = box(int, r0)
return r1
def BaseProperty.next(self):
self :: __main__.BaseProperty
r0, r1 :: int
r2 :: __main__.BaseProperty
L0:
r0 = borrow self._incrementer
r1 = CPyTagged_Add(r0, 2)
keep_alive self
r2 = BaseProperty(r1)
return r2
def BaseProperty.__init__(self, value):
self :: __main__.BaseProperty
value :: int
L0:
self._incrementer = value
return 1
def DerivedProperty.value(self):
self :: __main__.DerivedProperty
r0 :: int
L0:
r0 = self._incrementer
return r0
def DerivedProperty.value__BaseProperty_glue(__mypyc_self__):
__mypyc_self__ :: __main__.DerivedProperty
r0 :: int
r1 :: object
L0:
r0 = __mypyc_self__.value
r1 = box(int, r0)
return r1
def DerivedProperty.bad_value(self):
self :: __main__.DerivedProperty
r0 :: int
r1 :: object
L0:
r0 = self._incrementer
r1 = box(int, r0)
return r1
def DerivedProperty.next(self):
self :: __main__.DerivedProperty
r0 :: object
r1 :: int
r2, r3, r4 :: object
r5 :: int
r6 :: __main__.DerivedProperty
L0:
r0 = self._incr_func
r1 = self.value
r2 = self._incr_func
r3 = box(int, r1)
r4 = PyObject_CallFunctionObjArgs(r2, r3, 0)
r5 = unbox(int, r4)
r6 = DerivedProperty(r0, r5)
return r6
def DerivedProperty.next__BaseProperty_glue(__mypyc_self__):
__mypyc_self__, r0 :: __main__.DerivedProperty
L0:
r0 = __mypyc_self__.next
return r0
def DerivedProperty.__init__(self, incr_func, value):
self :: __main__.DerivedProperty
incr_func :: object
value :: int
r0 :: None
L0:
r0 = BaseProperty.__init__(self, value)
self._incr_func = incr_func
return 1
def AgainProperty.next(self):
self :: __main__.AgainProperty
r0 :: object
r1 :: int
r2, r3, r4 :: object
r5 :: int
r6, r7, r8 :: object
r9 :: int
r10 :: __main__.AgainProperty
L0:
r0 = self._incr_func
r1 = self.value
r2 = self._incr_func
r3 = box(int, r1)
r4 = PyObject_CallFunctionObjArgs(r2, r3, 0)
r5 = unbox(int, r4)
r6 = self._incr_func
r7 = box(int, r5)
r8 = PyObject_CallFunctionObjArgs(r6, r7, 0)
r9 = unbox(int, r8)
r10 = AgainProperty(r0, r9)
return r10
def AgainProperty.next__DerivedProperty_glue(__mypyc_self__):
__mypyc_self__, r0 :: __main__.AgainProperty
L0:
r0 = __mypyc_self__.next
return r0
def AgainProperty.next__BaseProperty_glue(__mypyc_self__):
__mypyc_self__, r0 :: __main__.AgainProperty
L0:
r0 = __mypyc_self__.next
return r0
def AgainProperty.bad_value(self):
self :: __main__.AgainProperty
r0 :: int
L0:
r0 = self._incrementer
return r0
def AgainProperty.bad_value__DerivedProperty_glue(__mypyc_self__):
__mypyc_self__ :: __main__.AgainProperty
r0 :: int
r1 :: object
L0:
r0 = __mypyc_self__.bad_value
r1 = box(int, r0)
return r1
def AgainProperty.bad_value__BaseProperty_glue(__mypyc_self__):
__mypyc_self__ :: __main__.AgainProperty
r0 :: int
r1 :: object
L0:
r0 = __mypyc_self__.bad_value
r1 = box(int, r0)
return r1

[case testPropertyTraitSubclassing]
from mypy_extensions import trait
@trait
class SubclassedTrait:
@property
def this(self) -> SubclassedTrait:
return self

@property
def boxed(self) -> object:
return 3

class DerivingObject(SubclassedTrait):
@property
def this(self) -> DerivingObject:
return self

@property
def boxed(self) -> int:
return 5
[out]
def SubclassedTrait.this(self):
self :: __main__.SubclassedTrait
L0:
return self
def SubclassedTrait.boxed(self):
self :: __main__.SubclassedTrait
r0 :: object
L0:
r0 = object 3
return r0
def DerivingObject.this(self):
self :: __main__.DerivingObject
L0:
return self
def DerivingObject.this__SubclassedTrait_glue(__mypyc_self__):
__mypyc_self__, r0 :: __main__.DerivingObject
L0:
r0 = __mypyc_self__.this
return r0
def DerivingObject.boxed(self):
self :: __main__.DerivingObject
L0:
return 10
def DerivingObject.boxed__SubclassedTrait_glue(__mypyc_self__):
__mypyc_self__ :: __main__.DerivingObject
r0 :: int
r1 :: object
L0:
r0 = __mypyc_self__.boxed
r1 = box(int, r0)
return r1

[case testNativeIndex]
from typing import List
class A:
Expand Down
88 changes: 0 additions & 88 deletions mypyc/test-data/irbuild-classes.test
Original file line number Diff line number Diff line change
Expand Up @@ -181,94 +181,6 @@ L0:
o.x = r1; r2 = is_error
return o

[case testSubclassSpecialize2]
class A:
def foo(self, x: int) -> object:
return str(x)
class B(A):
def foo(self, x: object) -> object:
return x
class C(B):
def foo(self, x: object) -> int:
return id(x)

def use_a(x: A, y: int) -> object:
return x.foo(y)

def use_b(x: B, y: object) -> object:
return x.foo(y)

def use_c(x: C, y: object) -> int:
return x.foo(y)
[out]
def A.foo(self, x):
self :: __main__.A
x :: int
r0 :: str
L0:
r0 = CPyTagged_Str(x)
return r0
def B.foo(self, x):
self :: __main__.B
x :: object
L0:
return x
def B.foo__A_glue(self, x):
self :: __main__.B
x :: int
r0, r1 :: object
L0:
r0 = box(int, x)
r1 = B.foo(self, r0)
return r1
def C.foo(self, x):
self :: __main__.C
x :: object
r0 :: int
L0:
r0 = CPyTagged_Id(x)
return r0
def C.foo__B_glue(self, x):
self :: __main__.C
x :: object
r0 :: int
r1 :: object
L0:
r0 = C.foo(self, x)
r1 = box(int, r0)
return r1
def C.foo__A_glue(self, x):
self :: __main__.C
x :: int
r0 :: object
r1 :: int
r2 :: object
L0:
r0 = box(int, x)
r1 = C.foo(self, r0)
r2 = box(int, r1)
return r2
def use_a(x, y):
x :: __main__.A
y :: int
r0 :: object
L0:
r0 = x.foo(y)
return r0
def use_b(x, y):
x :: __main__.B
y, r0 :: object
L0:
r0 = x.foo(y)
return r0
def use_c(x, y):
x :: __main__.C
y :: object
r0 :: int
L0:
r0 = x.foo(y)
return r0

[case testSubclass_toplevel]
from typing import TypeVar, Generic
from mypy_extensions import trait
Expand Down
Loading