Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Martijn Hoekstra
    @martijnhoekstra
    what's an utf8 compatible string? A string that can be encoded in UTF-8?
    Martijn Hoekstra
    @martijnhoekstra
    UTF-8 should never encode codepoints that are unpaired surrogates, but I wouldn't count on that for anything
    Adrian Legaspi
    @akilegaspi
    Hi everyone, I tried accessing the scalacheck documentation on the website and it seems that it's down with the error
    <Error>
      <Code>NoSuchKey</Code>
      <Message>The specified key does not exist.</Message>
    </Error>
    Ryan Tomczik
    @Tomczik76
      val durationArb: Arbitrary[Double] = Arbitrary(
        arbitrary[Double].map(Math.abs)
          .map(BigDecimal(_).setScale(5).toDouble)
      )
    am I doing this wrong?
    I want a positive double with a precision to be 5 decimal places
    Fredrik Wärnsberg
    @frekw

    Hi!

    I'm trying to write stateful tests for an API. When I create a resource, I get an ID back that I want to keep track of in my state (because it's needed for subsequent API calls). The API doesn't allow me to provide an ID I've generated myself to the create call, and I can't seem to find a way to get data from a Command.run-call into my state

    Is that possible to solve somehow?
    Ryan Peters
    @sloshy
    @frekw are you trying to get a new ID for every test run, or do you want to generate one ID upfront and reuse that for all of your test iterations?
    Fredrik Wärnsberg
    @frekw
    @sloshy I'm trying to generate a new one per test run
    Fredrik Wärnsberg
    @frekw
    Having dug through the issues on GitHub I stumbled across this; typelevel/scalacheck#199
    Would the current solution be to issue the create call in newSut and store it in the sut?
    Jonas Amundsen
    @badeball
    Can this be found elsewhere?
    Aaron S. Hawley
    @ashawley
    Yeah, it is in need of update. Fortunately, not much has changed since 1.14.0. https://www.scalacheck.org/files/scalacheck_2.11-1.14.0-api/index.html
    Jonas Amundsen
    @badeball
    Thanks a lot :)
    David Kelly
    @kellydavid

    Hello, I’ve been working with scalacheck to generate lists of data. This lead me to using listOfN(). For some lists, I would like to guarantee the generated list is non empty or some minimum size which can be achieved using suchThat() eg. (Gen.listOfN(n, generator).suchThat(_.nonEmpty))
    However, I would also like to avoid using suchThat() because it discards test data, so I came up with this function:

    def genListSizeRange[T](min: Int, max: Int, generator: Gen[T]): Gen[List[T]] =
        Gen.chooseNum(min, max).flatMap(Gen.listOfN(_, generator))

    Is there a simpler way to achieve this behaviour with the scalacheck library that I might have missed?

    Filippo Mariotti
    @barambani

    Hi all. I have a scenario where I invoke this https://github.com/typelevel/scalacheck/blob/f64f0cc3f21d9ba34848853181eaca1ebd60e39e/src/main/scala/org/scalacheck/Test.scala#L402 with an inintial seed set either in the params with withInitialSeed or in the Prop itself with useSeed. I was wondering what would be the expected behaviour for something like

    forAll { i: Int =>
      println(i)
    }

    what I’m observing is that i has the same value in all the iterations. If that’s expected, is there a way to pass a seed and still have different values in there ? Thanks a lot, and thanks a lot for maintaining the library.

    Dario Abdulrehman
    @dabd
    Is there any written documentation for Cogen stuff?
    Dario Abdulrehman
    @dabd
    does anyone know why this project seems to be abandoned? https://github.com/ikuraj/SciFe
    Myroslav
    @odisseus
    I think this is not the right chat. You can try to inquire at https://gitter.im/kaptoxic/SciFe, but that chat seems to be abandoned as well
    Myroslav
    @odisseus
    If you need a property-based testing framework for Scala, I guess Scalacheck is the best option.
    If you want something more lightweight, try Probably: https://github.com/propensive/probably#property-based-testing
    Pau Alarcón
    @paualarco
    hello! I'm experiencing problems since scalacheck is generating a Doctest from the scaladocumentation of the source code of my project. And it makes the test to finish in failure... is there any way to disable this feature? I'm using "org.scalatestplus" %% "scalacheck-1-14" % "3.1.1.1"
    Lawrence Wagerfield
    @ljwagerfield

    How do I use a forAll in my regular ScalaTest specification, without going "full ScalaCheck" (and by that I mean I do not want to extend Properties(...) and wrap my forAlls in a property)?

    I can see there's forall(...).check but that doesn't fail the test, and the documentation also says it's only a convenience method.

    I've read the user guide but couldn't see anything that answers this (I could have missed something...)

    Lawrence Wagerfield
    @ljwagerfield
    Answer: import scalatestplus-scalacheck and extend with Checkers in your spec, then you can use check(forall(...)) to run your properties :)
    Jack Koenig
    @jackkoenig
    Is there a way to provide my own source of randomness to be used by generators?
    Matthew Coolbeth
    @mac01021

    I have a simple class for test cases:

    case class TestCase(db: Map[String, AnyRef], queries: List[String])

    What's the best way to define a Gen[TestCase] where at least one of the generated queries is guaranteed to be present in the db?

    Antoine Doeraene
    @sherpal
    Hello. Sorry if this a dumb question but I can't find an example of usage of the iff method. Could someone for example show me how to model "x is even iff x^2 is even" using that function? Thanks!
    Antoine Doeraene
    @sherpal
    Ah, perhaps it's simply this:
    forAll { (x: Int) =>
        (x % 2 == 0).iff {
          case true  => (x * x) % 2 == 0
          case false => true
        }
      }
    Princess | April
    @NthPortal
    is one meant to be able to define properties within properties?
    Aaron S. Hawley
    @ashawley
    @NthPortal No, the top-level Properties class wasn't designed to support nested property definitions. The Prop algebra (forAll, ...) can compose. I believe ScalaTest can support this and Typelevel discipline library may, as well.
    Princess | April
    @NthPortal
    awesome, thanks @ashawley! that means I can consider what one of the scala tests is doing a bug and don't need to worry about how to support it :thumbsup:
    Princess | April
    @NthPortal
    I'm looking at the BaseTask implementation. would it be fair to say that the Seq of properties should not be modified once it's assigned to props here? https://github.com/typelevel/scalacheck/blob/123cba0b21d8ecb8d61e84549ddcbf61890e008b/src/main/scala/org/scalacheck/ScalaCheckFramework.scala#L63-L66
    perhaps to ask a slightly different question: would it be safe to freeze the internal Seq of props once Properties#properties is called?
    Aaron S. Hawley
    @ashawley
    @NthPortal I'm not sure. Not a part of the code base I know thoroughly. What would be the purpose or benefit of "freezing"?
    Princess | April
    @NthPortal
    mostly so that you get a sensible error message
    one of the things I'm trying to do is make iterators in the stdlib fail-fast, and adding a property while iterating over them to execute them violates that. with just the core scala change, nesting a property would give you a rather unhelpful error message that "mutation occurred after iterator creation", which is unhelpful
    Princess | April
    @NthPortal
    to put it differently, violating the constraints of the testing framework should fail cleanly, rather than in an unexpected or inconsistent way
    Guillaume Martres
    @smarter
    I don't want to put undue pressure on anyone, but I'd really like to see a 1.15.0 release for scalacheck, there's now an open milestone for that but it's not clear to me how critical the issues in it are for the release: typelevel/scalacheck#668
    Sergey Torgashov
    @satorg
    Hi everyone. I'm struggling to find any guide on when and how Cogen should be used. Could you help me with it please?
    Keir Lawson
    @keirlawson
    Hello, I'm wondering how I can create a generator of a list of values sourced from two other generators, but guaranteeing that one of the generators is used at least once?
    Ie I have a genMobilePhone and a genHomePhone andI want to make a genPhoneListWithAtLeastOneMobile
    Obviously I can do Gen.nonEmptyList(Gen.oneOf(genMobilePhone, genHomePhone)) but that wont guarantee I have at least one mobile...
    Katherine Prevost
    @hypatian
    I'd generate that list then add one mobile to it and optionally shuffle.
    (Or generate a list, a single required item, and a position in the list, would be a way to do that completely in terms of generating a tuple of existing things.)
    Keir Lawson
    @keirlawson
    ok, that makes sense, thanks :)
    Ben Spencer
    @dangerousben
    I'm looking for a way to use magnolia to derive scalacheck generators and google has turned up at least 3 projects, 2 of which have relatively recent commits - is there a preferred / endorsed one?
    Deenar Toraskar
    @deenar
    Hi I was looking to a string generator based on regular expressions, there seems to be a couple of options that turn up https://github.com/wolfendale/scalacheck-gen-regexp and https://github.com/non/antimirov/#scalacheck-support. Has anyone used either of these? Is there a preferred option?