Git Product home page Git Product logo

scalaprops's Introduction

scalaprops

Scala.js scaladoc

property based testing library for Scala

features

latest stable version

please use sbt plugin because there are some convenient features.

setup without sbt plugin
testFrameworks += new TestFramework("scalaprops.ScalapropsFramework")

parallelExecution in Test := false // currently, does not support parallel execution

libraryDependencies += "com.github.scalaprops" %% "scalaprops" % "0.9.1" % "test"
libraryDependencies += "com.github.scalaprops" %% "scalaprops-scalaz" % "0.9.1" % "test"

screencast

deterministic testing

Scalaprops emitting which seed it started with during a failing test, and providing an interface --seed=<value> for re-running the failing test with the same seed.

deterministic-testing

examples

See scalaprops-example project.

for scalaz 7.1.x

https://github.com/scalaprops/scalaprops/tree/0.1.x

scalaprops's People

Contributors

densh avatar dependabot[bot] avatar dwijnand avatar kxbmap avatar makenowjust avatar nequissimus avatar non avatar pocketberserker avatar scala-steward-bot avatar taisukeoe avatar xuwei-k avatar yoohaemin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scalaprops's Issues

improve Gen[FunctionN]

version 0.1.7

Welcome to Scala version 2.11.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_45).
Type in expressions to have them evaluated.
Type :help for more information.

scala> import scalaprops._
import scalaprops._

scala> Gen[Int => Int].samples(listSize = 5).map{f => (1 to 10).map(f)} foreach println
Vector(794921487, -117319807, 2147483647, -135116815, -2147483648, 1916507803, 34561382, 1402977518, -2124061576, -1544661226)
Vector(794921487, -117319807, 2147483647, -135116815, -2147483648, 1916507803, 34561382, 1402977518, -2124061576, -1544661226)
Vector(794921487, -117319807, 2147483647, -135116815, -2147483648, 1916507803, 34561382, 1402977518, -2124061576, -1544661226)
Vector(794921487, -117319807, 2147483647, -135116815, -2147483648, 1916507803, 34561382, 1402977518, -2124061576, -1544661226)
Vector(794921487, -117319807, 2147483647, -135116815, -2147483648, 1916507803, 34561382, 1402977518, -2124061576, -1544661226)

Sensitive to Scala implementation artefacts

With

object AlgorithmCheckerProps extends Scalaprops {

  private val mkLogger = NoopLogger.factory()

  private def checker(sigs: Seq[String], keys: Seq[String]) = {
    new AlgorithmChecker(mkLogger, sigs.map(s => parseAll(expression, s).get).toSet,
      keys.map(s => parseAll(expression, s).get).toSet)
  }

  val `pass a good key algorithm (RSA > 1024)` = Property.exception {
    Property.prop {
      val certificate: Certificate = CertificateGenerator.generateRSAWithSHA256(2048)
      checker(Nil, Seq("RSA keySize < 1024")).check(certificate, emptySet())
      true
    }
  }

}

Running scalapropsOnly com.typesafe.sslconfig.ssl.AlgorithmCheckerProps runs two properties instead of one:

com.typesafe.sslconfig.ssl.AlgorithmCheckerProps$
+- $anonfun$pass a good key algorithm (RSA > 1024)$1  Proven(1,0,LongSeed(1601297310331947)) 3ms
`- pass a good key algorithm (RSA > 1024)  Proven(1,0,LongSeed(1601297342674608)) 0ms

Shrink law

On the current implementation, every Shrink instance must obey the following law, or they might invoke infinite loop at shrinking process:

def shrinkNotContainItself[A](a: A)(implicit s: Shrink[A]): Boolean =
  !s(a).contains(a)

Shrink[Boolean] does not obey the above law for instance.
(In fact Shrink[Boolean].apply(false) == Stream(false))
This prop fails immediately, however shrinking process never stop, so the final result is timeout.

import scalaprops._

object ShrinkTests extends Scalaprops {
  val prop = Property.forAllS[Boolean](_ == true)
}

Tests for checking every Shrink are needed.

Example test in sample project

Would it be possible to set up the scalazlaws subproject so that running test would check a few of the laws? Right now it's not totally clear how to hook it all together.

improve timeout implementation in Scala.js

scala-native support

WIP https://github.com/scalaprops/scalaprops/compare/native

current status

scala-native 0.2.1 does not support sbt-test-interface

  • download (in build-time) scalajs-test-interface_2.12 and apply some hack(remove scala-js specific annotations). use scala-native 0.3.0 test-interface
  • auto generate test-main class for native from existing test files.
  • or wait scala-native/scala-native#435 ?

some (unresolved/will be fix) issues

sxr 1.0.2

Hi. For what it may be worth, I published updated sxr artifacts under version 1.0.2 which include 2.10/2.11/2.12 so if you want you can upgrade and lose most of the conditional logic in Sxr.scala.

Location of self contained example?

The only self-contained example (one that doesn't reference laws in the scalaz project) is visible for a less than a second in the gif. An example that does not require looking into scalaz's source code would be helpful for quick-starting use of scalaprops.

Avoiding duplicates vs. having the same law included twice in one `Properties` instance

I'm just checking out this library and have two questions (that go against each other):

  1. Are duplicate properties avoided? For example, monad.all inherits apply.all both via bind.all and applicative.all. Is this duplication eliminated?
  2. If the answer to question 1. is yes, can I have the same law included twice in a property set, for different aspects of the type class? For example, if I have a Ring, I want to check the monoid laws for both addition and multiplication.

discipline can achieve both of the above, but I find its approach rather cumbersome and fragile, which is why I wrote my own tool, Principled. Principled, however, relies on universal equality (==) of type classes, which is not ideal either (although the worst that can happen is failure to avoid duplicates, when the same type class is instantiated twice with the same arguments, but == returns false).

I wonder if and how scalaprops deals with this problem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.