aboutsummaryrefslogtreecommitdiff
path: root/c/tests
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-03-24 16:32:24 -0500
committerJoel Martin <github@martintribe.org>2014-03-24 16:32:24 -0500
commit3169070063b2cb877200117ebb384269d73bcb93 (patch)
tree23de3db1ea5c37afd21a45b6ed7771f56a08c0c4 /c/tests
downloadmal-3169070063b2cb877200117ebb384269d73bcb93.tar.gz
mal-3169070063b2cb877200117ebb384269d73bcb93.zip
Current state of mal for Clojure West lighting talk.
Diffstat (limited to 'c/tests')
-rw-r--r--c/tests/step9_interop.mal23
1 files changed, 23 insertions, 0 deletions
diff --git a/c/tests/step9_interop.mal b/c/tests/step9_interop.mal
new file mode 100644
index 0000000..657e3e7
--- /dev/null
+++ b/c/tests/step9_interop.mal
@@ -0,0 +1,23 @@
+
+;; Testing FFI of "strlen"
+(. nil "int32" "strlen" "string" "abcde")
+;=>5
+(. nil "int32" "strlen" "string" "")
+;=>0
+
+;; Testing FFI of "strcmp"
+
+(. nil "int32" "strcmp" "string" "abc" "string" "abcA")
+;=>-65
+(. nil "int32" "strcmp" "string" "abcA" "string" "abc")
+;=>65
+(. nil "int32" "strcmp" "string" "abc" "string" "abc")
+;=>0
+
+
+;; Testing FFI of "pow" (libm.so)
+
+(. "libm.so" "double" "pow" "double" 2.0 "double" 3.0)
+;=>8.000000
+(. "libm.so" "double" "pow" "double" 3.0 "double" 2.0)
+;=>9.000000