1

这不起作用:

itAsync "subscribeEventedOn should receive any attached data" $ \done -> do      
  w <- getWindow
  subscribeEventedOn "foo" (\event -> do
    fprint event
    expect (unwrapDetail event) `toDeepEqual` d'
    itIs done
  ) w
  emitOn sampleEvent w
  expect true `toEqual` true

未知值'w'

但这确实有效:

w <- getWindow
itAsync "subscribeEventedOn should receive any attached data" $ \done -> do      
  subscribeEventedOn "foo" (\event -> do
    fprint event
    expect (unwrapDetail event) `toDeepEqual` d'
    itIs done
  ) w
  emitOn sampleEvent w
  expect true `toEqual` true

为什么?这对我来说没有意义。do(顺便说一句,我的单元测试中有嵌套块)

4

1 回答 1

1

我能够通过猜测示例代码中名称的类型来重现这一点,看起来这是由 PureScript 词法分析器的特殊性引起的。您可以通过将结束括号移动到上面的行来修复它:

itAsync "subscribeEventedOn should receive any attached data" $ \done -> do      
  w <- getWindow
  subscribeEventedOn "foo" (\event -> do
    fprint event
    expect (unwrapDetail event) `toDeepEqual` d'
    itIs done) w
  emitOn sampleEvent w
  expect true `toEqual` true
于 2014-07-26T05:54:47.420 回答