micropython: add micropython component
This commit is contained in:
12
components/language/micropython/tests/jni/README
Normal file
12
components/language/micropython/tests/jni/README
Normal file
@@ -0,0 +1,12 @@
|
||||
Running "jni" module tests (as well as just using this module) requires
|
||||
being able to load libjvm.so, which requires path to it set via
|
||||
LD_LIBRARY_PATH environment variable. This path is not set automatically
|
||||
and there is no easy way to guess it, because there can be installed
|
||||
different implementations of JVM, for one implementation, there can be
|
||||
different versions, and single version may include different variants
|
||||
of JVM.
|
||||
|
||||
For example, for OpenJDK 7 on x86_64, following may work:
|
||||
|
||||
LD_LIBRARY_PATH=/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server ./run-tests.py jni/*.py
|
||||
|
16
components/language/micropython/tests/jni/list.py
Normal file
16
components/language/micropython/tests/jni/list.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import jni
|
||||
|
||||
try:
|
||||
ArrayList = jni.cls("java/util/ArrayList")
|
||||
except:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
l = ArrayList()
|
||||
print(l)
|
||||
l.add("one")
|
||||
l.add("two")
|
||||
|
||||
print(l.toString())
|
||||
print(l)
|
||||
print(l[0], l[1])
|
4
components/language/micropython/tests/jni/list.py.exp
Normal file
4
components/language/micropython/tests/jni/list.py.exp
Normal file
@@ -0,0 +1,4 @@
|
||||
[]
|
||||
[one, two]
|
||||
[one, two]
|
||||
one two
|
16
components/language/micropython/tests/jni/object.py
Normal file
16
components/language/micropython/tests/jni/object.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import jni
|
||||
|
||||
try:
|
||||
Integer = jni.cls("java/lang/Integer")
|
||||
except:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
# Create object
|
||||
i = Integer(42)
|
||||
print(i)
|
||||
# Call object method
|
||||
print(i.hashCode())
|
||||
# Pass object to another method
|
||||
System = jni.cls("java/lang/System")
|
||||
System.out.println(i)
|
3
components/language/micropython/tests/jni/object.py.exp
Normal file
3
components/language/micropython/tests/jni/object.py.exp
Normal file
@@ -0,0 +1,3 @@
|
||||
42
|
||||
42
|
||||
42
|
9
components/language/micropython/tests/jni/system_out.py
Normal file
9
components/language/micropython/tests/jni/system_out.py
Normal file
@@ -0,0 +1,9 @@
|
||||
try:
|
||||
import jni
|
||||
|
||||
System = jni.cls("java/lang/System")
|
||||
except:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
System.out.println("Hello, Java!")
|
@@ -0,0 +1 @@
|
||||
Hello, Java!
|
Reference in New Issue
Block a user