Permalink
Browse files

add the beginnings of a test suite

  • Loading branch information...
0xdaf committed Jun 13, 2011
1 parent 5067605 commit 381992f3aa07278e5a479992c3445609086593cb
Showing with 59 additions and 0 deletions.
  1. +32 −0 GObject-Introspection.cabal
  2. +27 −0 test.hs
@@ -43,3 +43,35 @@ Executable haskell-gi
GI.Type,
GI.Value,
GI.Util
+
+Executable test
+ main-is: test.hs
+ pkgconfig-depends: gobject-introspection-1.0
+ build-depends: base >= 4, containers, glib, HUnit, mtl, test-framework, test-framework-hunit
+ build-tools: hsc2hs
+ extensions: ForeignFunctionInterface
+ ghc-options: -Wall -fno-warn-missing-signatures -fwarn-incomplete-patterns -fno-warn-name-shadowing
+ other-modules:
+ System.Glib.Initialize,
+ GI.Internal.Types,
+ GI.Internal.ArgInfo,
+ GI.Internal.BaseInfo,
+ GI.Internal.CallableInfo,
+ GI.Internal.ConstantInfo,
+ GI.Internal.EnumInfo,
+ GI.Internal.FieldInfo,
+ GI.Internal.FunctionInfo,
+ GI.Internal.InterfaceInfo,
+ GI.Internal.ObjectInfo,
+ GI.Internal.ParamFlag,
+ GI.Internal.PropertyInfo,
+ GI.Internal.RegisteredTypeInfo,
+ GI.Internal.StructInfo,
+ GI.Internal.TypeInfo,
+ GI.Internal.Typelib,
+ GI.Internal.UnionInfo,
+ GI.API,
+ GI.Code,
+ GI.Type,
+ GI.Value,
+ GI.Util
View
27 test.hs
@@ -0,0 +1,27 @@
+
+import Test.Framework
+import Test.Framework.Providers.HUnit
+import Test.HUnit
+
+import qualified Data.Map as M
+
+import GI.API
+import GI.Code
+import GI.CodeGen
+import GI.Value
+
+testConfig = Config {
+ prefixes = M.fromList [("test", "test")],
+ names = M.empty }
+
+testCodeGen api code = (codeToList $ runCodeGen' testConfig $ genCode api) @?= code
+
+testConstant = testCase "constant" $ testCodeGen
+ (APIConst (Named "test" "foo" (Constant (VInt8 42))))
+ [ Line "-- constant foo"
+ , Line "testFoo :: Int8"
+ , Line "testFoo = 42"
+ , Line ""]
+
+main = defaultMain [
+ testConstant]

0 comments on commit 381992f

Please sign in to comment.