2

我有一个使用 FFI 绑定到 C 函数的模块。我怎样才能使这个模块使用doctest

我在运行时遇到的错误doctest Foo.hs是这样的:

ByteCodeLink: can't find label
During interactive linking, GHCi couldn't find the following symbol:
  bar
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session.  Restart GHCi, specifying
the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please send a bug report to:
  glasgow-haskell-bugs@haskell.org

### Failure in Foo.hs:41: expression `foo'
expected: [42]
 but got: 
          <interactive>:24:1: Not in scope: `bar'
Examples: 2  Tried: 2  Errors: 0  Failures: 1
4

1 回答 1

2

Doctest 接受任意 GHC 标志。如果您想使用 FFI 代码运行 Doctest,您需要传递与使用该代码运行 GHCi 会话所需的完全相同的标志。例如看看Doctest 驱动程序unix-time

于 2013-04-01T09:07:57.563 回答