Skip to content

Commit 446e210

Browse files
committed
tentatively exporting isMNull
1 parent 6b7bd39 commit 446e210

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Foreign/Matlab/Array.hsc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ module Foreign.Matlab.Array (
3232
mxArrayGetList, mxArraySetList,
3333
mxArrayGetAll, mxArraySetAll, mxArrayGetFirst,
3434
fromListIO, cellFromListsIO,
35+
isMNull,
3536

3637
-- * Struct access
3738
-- |Structs in Matlab are always arrays, and so can be accessed using most array accessors.

test/Test/Engine.hs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ runEngineTests host = do
2525
addpath eng testPath
2626
runLocalMatFun eng
2727
cosOfPi eng
28+
testIsMNull eng
2829
testGetFirst eng
2930
testAbstractValueUse eng
3031
testTypedAbstractValueUse eng
@@ -53,6 +54,22 @@ cosBody eng cosFun x = do
5354
y <- mxScalarGet y
5455
print (y :: MDouble)
5556

57+
testIsMNull :: Engine -> IO ()
58+
testIsMNull eng = do
59+
putStrLn $ "\n-- testIsMNull --"
60+
xa <- createMXScalar (1.0 :: MDouble)
61+
let xaRes = assert (isMNull xa == False) xa
62+
xaResEi <- mxArrayGetFirst xaRes
63+
putStrLn $ " xaResEi is Right: " <> (show $ isRight xaResEi)
64+
xae :: MXArray MChar <- createMXArray []
65+
freeMXArray xae
66+
mxLen <- mxArrayLength xae
67+
putStrLn $ "length is " <> (show mxLen)
68+
-- This is a bit surprising, but ok
69+
let xaeRes = assert (isMNull xae == False) xae
70+
xaeResEi <- mxArrayGetFirst xaeRes
71+
putStrLn $ " xaeResEi is Right: " <> (show $ isRight xaeResEi)
72+
5673
testGetFirst :: Engine -> IO ()
5774
testGetFirst eng = do
5875
putStrLn $ "\n-- testGetFirst --"

0 commit comments

Comments
 (0)