examples/usercmodule: Add example of a native C class.
This shows how ports can add their own custom types/classes. It is part of the unix coverage build, so we can use it for tests too. Signed-off-by: Laurens Valk <laurens@pybricks.com>
This commit is contained in:
committed by
Damien George
parent
1d27c7d423
commit
a67989aa20
20
tests/misc/cexample_class.py
Normal file
20
tests/misc/cexample_class.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# test custom native class
|
||||
|
||||
try:
|
||||
import cexample
|
||||
import time
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
t = cexample.Timer()
|
||||
|
||||
print(t)
|
||||
print(t.time() <= 1)
|
||||
|
||||
time.sleep_ms(100)
|
||||
|
||||
elapsed = t.time()
|
||||
|
||||
if not (99 <= elapsed <= 110):
|
||||
print("Elapsed time should be approx. 100ms but it is", elapsed)
|
||||
Reference in New Issue
Block a user