diff options
| author | Damien George <damien@micropython.org> | 2023-05-25 10:57:08 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2023-06-01 13:01:07 +1000 |
| commit | 48ffd6596e7a4c185a81be233b46d3c99a83a7ac (patch) | |
| tree | 3a15993f388746d0125b875c621a8508b5c8b731 /tests | |
| parent | 3ae78e803b69c4f1fd5dfe7eb732de7075f12e6c (diff) | |
py: Change MP_UNARY_OP_INT to MP_UNARY_OP_INT_MAYBE.
To be consistent with MP_UNARY_OP_INT_FLOAT and MP_UNARY_OP_INT_COMPLEX,
and allow int() to first check if a type supports __int__ before trying
other things (as per CPython).
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/basics/int_big1.py | 3 | ||||
| -rw-r--r-- | tests/basics/special_methods_intbig.py | 8 |
2 files changed, 11 insertions, 0 deletions
diff --git a/tests/basics/int_big1.py b/tests/basics/int_big1.py index 5b35e3db4..ea48372b2 100644 --- a/tests/basics/int_big1.py +++ b/tests/basics/int_big1.py @@ -10,6 +10,9 @@ print(y) print('%#X' % (x - x)) # print prefix print('{:#,}'.format(x)) # print with commas +# construction +print(int(x)) + # addition print(x + 1) print(x + y) diff --git a/tests/basics/special_methods_intbig.py b/tests/basics/special_methods_intbig.py new file mode 100644 index 000000000..653422f21 --- /dev/null +++ b/tests/basics/special_methods_intbig.py @@ -0,0 +1,8 @@ +# Test class special methods, that use a bigint. + +class A: + def __int__(self): + return 1 << 100 + + +print(int(A())) |
