summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2020-04-28 09:13:49 -0500
committerJeff Epler <jepler@gmail.com>2020-09-06 09:53:16 -0500
commit20c2dd0c0853f3f1f6a5fa23887f08ec5cf77818 (patch)
treed35a27568356cc03ac25769daa404ddde21f7de9 /tests
parent5d17d6402d57a74e20ea332da6a31be65ec0e2ca (diff)
core: add int.bit_length() when MICROPY_CYPTHON_COMPAT is enabled
This method of integer objects is needed for a port of python3's decimal.py module. MICROPY_CPYTHON_COMPAT is enabled by CIRCUITPY_FULL_BUILD.
Diffstat (limited to 'tests')
-rw-r--r--tests/basics/bit_length.py4
-rw-r--r--tests/basics/builtin_help.py.exp4
2 files changed, 6 insertions, 2 deletions
diff --git a/tests/basics/bit_length.py b/tests/basics/bit_length.py
new file mode 100644
index 000000000..5eb33f604
--- /dev/null
+++ b/tests/basics/bit_length.py
@@ -0,0 +1,4 @@
+for i in range(129):
+ j = (1 << i)
+ print(i, (j-1).bit_length(), (j).bit_length(), (j+1).bit_length())
+ print(i, (-j-1).bit_length(), (-j).bit_length(), (-j+1).bit_length())
diff --git a/tests/basics/builtin_help.py.exp b/tests/basics/builtin_help.py.exp
index ed8a7d74b..89350a6c7 100644
--- a/tests/basics/builtin_help.py.exp
+++ b/tests/basics/builtin_help.py.exp
@@ -1,14 +1,14 @@
########
object <function> is of type function
object <class 'int'> is of type type
+ bit_length -- <function>
from_bytes -- <classmethod>
to_bytes -- <function>
object 1 is of type int
+ bit_length -- <function>
from_bytes -- <classmethod>
to_bytes -- <function>
object <module 'micropython'> is of type module
__name__ -- micropython
- const -- <function>
- opt_level -- <function>
########
done