小编Mat*_*att的帖子

在Scala测试中使用Scala列表中的"包含"匹配器

我正在尝试检查案例类列表是否包含一个特定的实例,但是当我尝试这样做时,我收到以下错误:

[info] Compiling 1 Scala source to /home/matt/Documents/transledge/app/target/scala-2.9.2/test-classes...
[error] /home/matt/Documents/transledge/app/src/test/scala/com/transledge/drewes/parser_suite.scala:40: overloaded method value should with alternatives:
[error]   (notWord: ParserSuite.this.NotWord)ParserSuite.this.ResultOfNotWordForSeq[com.transledge.Instruction,List[com.transledge.Instruction]] <and>
[error]   (haveWord: ParserSuite.this.HaveWord)ParserSuite.this.ResultOfHaveWordForSeq[com.transledge.Instruction] <and>
[error]   (beWord: ParserSuite.this.BeWord)ParserSuite.this.ResultOfBeWordForAnyRef[List[com.transledge.Instruction]] <and>
[error]   (rightMatcher: org.scalatest.matchers.Matcher[List[com.transledge.Instruction]])Unit
[error]  cannot be applied to (org.scalatest.matchers.Matcher[Traversable[com.transledge.AddNode]])
[error]       parsing(square_node, input) should contain(AddNode("foo"))
[error]                                   ^
[error] one error found
[error] (test:compile) Compilation failed
[error] Total time: 3 s, completed 21-Feb-2013 15:15:04
Run Code Online (Sandbox Code Playgroud)

有问题的测试套件是:

import org.scalatest.FunSpec
import scala.util.parsing.combinator._
import com.transledge.drewes.{Parser => DrewesParser}
import com.transledge._
import org.scalatest.matchers.ShouldMatchers

class ParserSuite extends DrewesParser with FunSpec with …
Run Code Online (Sandbox Code Playgroud)

scala scalatest scala-collections

3
推荐指数
1
解决办法
2718
查看次数

标签 统计

scala ×1

scala-collections ×1

scalatest ×1