qemu-arm: Add tests for freezing viper and asm_thumb code.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
0a2895b099
commit
414b59d39c
29
ports/qemu-arm/test-frzmpy/frozen_asm.py
Normal file
29
ports/qemu-arm/test-frzmpy/frozen_asm.py
Normal file
@ -0,0 +1,29 @@
|
||||
# Test freezing inline-asm code.
|
||||
|
||||
import micropython
|
||||
|
||||
|
||||
@micropython.asm_thumb
|
||||
def asm_add(r0, r1):
|
||||
add(r0, r0, r1)
|
||||
|
||||
|
||||
@micropython.asm_thumb
|
||||
def asm_add1(r0) -> object:
|
||||
lsl(r0, r0, 1)
|
||||
add(r0, r0, 3)
|
||||
|
||||
|
||||
@micropython.asm_thumb
|
||||
def asm_cast_bool(r0) -> bool:
|
||||
pass
|
||||
|
||||
|
||||
@micropython.asm_thumb
|
||||
def asm_shift_int(r0) -> int:
|
||||
lsl(r0, r0, 29)
|
||||
|
||||
|
||||
@micropython.asm_thumb
|
||||
def asm_shift_uint(r0) -> uint:
|
||||
lsl(r0, r0, 29)
|
8
ports/qemu-arm/test-frzmpy/frozen_viper.py
Normal file
8
ports/qemu-arm/test-frzmpy/frozen_viper.py
Normal file
@ -0,0 +1,8 @@
|
||||
# Test freezing viper code.
|
||||
|
||||
import micropython
|
||||
|
||||
|
||||
@micropython.viper
|
||||
def viper_add(x, y):
|
||||
print(x + y)
|
7
tests/qemu-arm/asm_test.py
Normal file
7
tests/qemu-arm/asm_test.py
Normal file
@ -0,0 +1,7 @@
|
||||
import frozen_asm
|
||||
|
||||
print(frozen_asm.asm_add(1, 2))
|
||||
print(frozen_asm.asm_add1(3))
|
||||
print(frozen_asm.asm_cast_bool(0), frozen_asm.asm_cast_bool(3))
|
||||
print(frozen_asm.asm_shift_int(4))
|
||||
print(frozen_asm.asm_shift_uint(4))
|
5
tests/qemu-arm/asm_test.py.exp
Normal file
5
tests/qemu-arm/asm_test.py.exp
Normal file
@ -0,0 +1,5 @@
|
||||
3
|
||||
4
|
||||
False True
|
||||
-2147483648
|
||||
2147483648
|
3
tests/qemu-arm/viper_test.py
Normal file
3
tests/qemu-arm/viper_test.py
Normal file
@ -0,0 +1,3 @@
|
||||
import frozen_viper
|
||||
|
||||
frozen_viper.viper_add(1, 2)
|
1
tests/qemu-arm/viper_test.py.exp
Normal file
1
tests/qemu-arm/viper_test.py.exp
Normal file
@ -0,0 +1 @@
|
||||
3
|
Loading…
Reference in New Issue
Block a user