micropython: add micropython component

This commit is contained in:
KY-zhang-X
2022-09-29 12:10:37 +08:00
parent 1514f1cb9b
commit dd76146324
2679 changed files with 354110 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
This directory doesn't contain real tests, but code snippets to detect
various interpreter features, which can't be/inconvenient to detecte by
other means. Scripts here are executed by run-tests.py at the beginning of
testsuite to decide what other test groups to run/exclude.

View File

@@ -0,0 +1,6 @@
# check if async/await keywords are supported
async def foo():
await 1
print("async")

View File

@@ -0,0 +1,5 @@
try:
bytearray
print("bytearray")
except NameError:
print("no")

View File

@@ -0,0 +1,6 @@
try:
import usys as sys
except ImportError:
import sys
print(sys.byteorder)

View File

@@ -0,0 +1,5 @@
try:
complex
print("complex")
except NameError:
print("no")

View File

@@ -0,0 +1,2 @@
x = const(1)
print(x)

View File

@@ -0,0 +1,5 @@
try:
extra_coverage
print("coverage")
except NameError:
print("no")

View File

@@ -0,0 +1,13 @@
# detect how many bits of precision the floating point implementation has
try:
float
except NameError:
print(0)
else:
if float("1.0000001") == float("1.0"):
print(30)
elif float("1e300") == float("inf"):
print(32)
else:
print(64)

View File

@@ -0,0 +1 @@
64

View File

@@ -0,0 +1,3 @@
# check whether f-strings (PEP-498) are supported
a = 1
print(f"a={a}")

View File

@@ -0,0 +1 @@
a=1

View File

@@ -0,0 +1,2 @@
# Check whether arbitrary-precision integers (MPZ) are supported
print(1000000000000000000000000000000000000000000000)

View File

@@ -0,0 +1 @@
1000000000000000000000000000000000000000000000

View File

@@ -0,0 +1,8 @@
# this test for the availability of native emitter
@micropython.native
def f():
pass
f()
print("native")

View File

@@ -0,0 +1,3 @@
# Check for emacs keys in REPL
t = +11
t == 2

View File

@@ -0,0 +1,7 @@
MicroPython \.\+ version
Use \.\+
>>> # Check for emacs keys in REPL
>>> t = \.\+
>>> t == 2
True
>>>

View File

@@ -0,0 +1,4 @@
# just check if ctrl+w is supported, because it makes sure that
# both MICROPY_REPL_EMACS_WORDS_MOVE and MICROPY_REPL_EXTRA_WORDS_MOVE are enabled.
t = 1231
t == 1

View File

@@ -0,0 +1,7 @@
MicroPython \.\+ version
Use \.\+
>>> # Check for emacs keys in REPL
>>> t = \.\+
>>> t == 2
True
>>>

View File

@@ -0,0 +1,9 @@
class Foo:
def __radd__(self, other):
pass
try:
5 + Foo()
except TypeError:
print("TypeError")

View File

@@ -0,0 +1,2 @@
# check if set literal syntax is supported
print({1})

View File

@@ -0,0 +1,5 @@
try:
slice
print("slice")
except NameError:
print("no")

View File

@@ -0,0 +1,6 @@
try:
import uio
print("uio")
except ImportError:
print("no")