Questions tagged [scalactic]

The Scalactic library provides useful type-safe extensions to Scala both for production and test code. It is used extensively in scalatest. It has no dependencies except the Scala standard lib.

The Scalactic library is focused on constructs related to quality that are useful in both production code and tests. Although ScalaTest is tightly integrated with Scalactic, you can use Scalactic with any Scala project and any test framework. The Scalactic library has no dependencies other than Scala itself.

It provides a type-checked ===, an opinionated Either with Good and Bad results, and other syntactic niceties.

Quote via the Scalactic home page

9 questions
16
votes
7 answers

Why "could not find implicit" error in Scala + Intellij + ScalaTest + Scalactic but not from sbt

I have this code that is working 100% from sbt , executing sbt test but throw a compilation error in Intellij Idea. import org.scalatest.{BeforeAndAfter, FunSuite, GivenWhenThen} class SimpleTest extends FunSuite with GivenWhenThen with…
angelcervera
  • 3,699
  • 1
  • 40
  • 68
3
votes
3 answers

Scalactic Accumulation's withGood of Seq

How can I accumulate Scalactic's Or using withGood on a Seq[Or]? So I have something like following code: val cs: Seq[BigDecimal Or ErrorMessage] so I need to do something when all values in cs are Good like this Accumulation.withGood(cs){...} Any…
Wins
  • 3,420
  • 4
  • 36
  • 70
2
votes
1 answer

ScalaTest Scalactic - Custom Double Equality with tolerance including Double.NaN case

I am trying to create a custom matcher that will take into account Double.NaN and will use tolerance for non-nan values. import org.scalactic.{Equality, TolerantNumerics} import org.scalatest.Matchers trait MoreMatchers extends Matchers { …
ele
  • 471
  • 1
  • 5
  • 15
2
votes
2 answers

org.scalacheck and org.scalatest not found after sbt->compile

[trace] Stack trace suppressed: run last *:update for the full output. [error] (*:update) sbt.ResolveException: unresolved dependency: org.scalatest#scalatest_2.12;2.2.4: not found [error] unresolved dependency:…
2
votes
1 answer

How to build a wrapper around scalatest's "it" keyword?

I am attempting to build a wrapper around scalatest's it keyword. However, this solution does not seem to work as intended. Moreover, it does not even compile: trait MyFunSpec extends FunSpec { private val _it: FunSpec.this.ItWord = it …
DJ Gruby
  • 159
  • 1
  • 2
  • 11
1
vote
1 answer

Is there short and simple way to compose these functions in scala?

Here is the code: import org.scalactic._ import Accumulation._ def f(x: Int): List[Double] Or Every[String] = if (x > 0) Good(List(x, x * 2, x * 3)) else Bad(Many("One", "Two", "Three")) def g(y: Double): List[Char] Or Every[String] = if (y…
Unforgiven
  • 125
  • 6
0
votes
1 answer

Different Equality[DenseVector] types for different numerical tolerances

I've written a scalactic equality provider for DenseVectors that uses the breeze closeTo method to check if each double in the vector is close enough. implicit val vectorEquality: Equality[DenseVector[Double]] = new Equality[DenseVector[Double]] { …
shadow chris
  • 391
  • 3
  • 13
0
votes
0 answers

Scala - Combining Try, Option, Or, Good, ErrorMessage

I have two methods that are used to create Currency enums from Strings. The enum Currency is a Java enum. Their signatures are: def sCurrency: Option[Currency] Or One[ErrorMessage] = ??? def cCurrency: Currency Or One[ErrorMessage] = ??? Try as I…
Saf
  • 517
  • 1
  • 9
  • 24
0
votes
1 answer

Scalactic: convert an Iterable to Every

Using scalactic, one can convert an Every to a List like this: scala> Every(1,2,3).toList res6: List[Int] = List(1, 2, 3) How can I perform the reverse operation, though, i.e. try to convert a List or an Iterable to an Every? Is there a built-in…
jjst
  • 2,631
  • 2
  • 22
  • 34