1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/examples/call_v_from_python/test.py

12 lines
369 B
Python
Raw Normal View History

from ctypes import *
import math, os
so_file="./test.so"
if os.name=="nt":
so_file="./test.dll"
lib = CDLL(so_file)
assert lib.square(10) == 100, "Cannot validate V square()."
lib.sqrt_of_sum_of_squares.restype = c_double
assert lib.sqrt_of_sum_of_squares(c_double(1.1), c_double(2.2)) == math.sqrt(1.1*1.1 + 2.2*2.2), "Cannot validate V sqrt_of_sum_of_squares()."