8000 GitHub - japgolly/nyaya: Random Data Generation and/or Property Testing in Scala & Scala.JS. · GitHub
[go: up one dir, main page]

Skip to content
japgollyPublic

About

Random Data Generation and/or Property Testing in Scala & Scala.JS.

Topics

Resources

Stars

195 stars

Watchers

3 watching

Forks

Repository files navigation

Nyaya

Nyaya is a Scala/Scala.JS library to:

  • Generate random data.
  • Ensure uniqueness in random data.
  • Test properties using random data.
  • Prove properties with (reasonably-sized) finite domains.
  • Assert properties in real data.

Unlike other property-testing libraries:

  • random data generation is its own separate module
  • properties can be tested against single instances of real data (as opposed to only random samples)
  • can prove properties of finite domains

It is:

  • Fast. Probably the fastest Scala random data gen / prop tester. (Benchmarks coming soon…)
  • Has a nice, fluent API for generating random data. (examples)
scala> import nyaya.gen._
import nyaya.gen._

scala> val g = Gen.int mapTo Gen.boolean.option
g: nyaya.gen.Gen[Map[Int,Option[Boolean]]] = Gen(<function1>)

scala> g.sample()
Map(609117252 -> None, -339 -> Some(true), 1684851879 -> Some(false), 78379 -> None)

SBT setup

ver nyayaVer = "1.2.0"

// Property expression, evaluation, assertion.
libraryDependencies += "com.github.japgolly.nyaya" %%% "nyaya-prop" % nyayaVer

// Random data generation.
libraryDependencies += "com.github.japgolly.nyaya" %%% "nyaya-gen" % nyayaVer

// Random JSON generation (with Circe).
libraryDependencies += "com.github.japgolly.nyaya" %%% "nyaya-gen-circe" % nyayaVer

// Property testing with random data.
// Property proving.
libraryDependencies += "com.github.japgolly.nyaya" %%% "nyaya-test" % nyayaVer % Test

Doc


Requires:

  • Scala 2.13+
  • Scala.JS 1.20+ (optional)

What does Nyaya mean?

See:


Support

If you like what I do —my OSS libraries, my contributions to other OSS libs, my programming blog— and you'd like to support me, more content, more lib maintenance, please become a patron! I do all my OSS work unpaid so showing your support will make a big difference.


Licence

Copyright (C) 2014-2026 David Barri

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

About

Random Data Generation and/or Property Testing in Scala & Scala.JS.

Topics

Resources

Stars

195 stars

Watchers

3 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages

0