Skip to content

Commit

Permalink
OrTypeLeastUpperBound contains test
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Dec 5, 2023
1 parent 553c1fe commit 37e9823
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,33 @@ class OrTypeLeastUpperBoundTest extends AnyFunSuite with ResultAssertions {
assertEmpty(mustEmpty)
}

test("Matchable report `contains` with different type") {
val results = Seq(
WartTestTraverser(OrTypeLeastUpperBound.Matchable) {
List(2).contains("a")
},
WartTestTraverser(OrTypeLeastUpperBound.Matchable) {
Option(2).contains("a")
},
WartTestTraverser(OrTypeLeastUpperBound.Matchable) {
List("a").contains(1)
},
WartTestTraverser(OrTypeLeastUpperBound.Matchable) {
Option("a").contains(1)
},
)
results.foreach { result =>
assert(result.errors.size == 1)
assert(result.errors.forall(_.contains("least upper bound is")), result)
}

val mustEmpty = WartTestTraverser(OrTypeLeastUpperBound.All) {
Option(2).contains(1)
List(2).contains(1)
}
assertEmpty(mustEmpty)
}

test("Product") {
val mustError1 = WartTestTraverser(OrTypeLeastUpperBound.Product) {
List(A1(1), B(2))
Expand Down

0 comments on commit 37e9823

Please sign in to comment.