Coder Social home page Coder Social logo

smock's Introduction

smock Build Status

A relatively-trivial library for testing Free programs, inspired by purescript-mockfree and the testing internals within Nelson.

Usage

libraryDependencies += "com.codecommit" %% "smock" % "0.4.1-specs2-4.2.0" % "test"

Depends on scalaz 7.2.18. Cross-builds are available for Scala 2.12 and 2.11. Different builds are published for various specs2 versions. Specifically:

  • Specs2 4.2.0
    • Scala 2.11
    • Scala 2.12
  • Specs2 4.0.2
    • Scala 2.11
    • Scala 2.12
  • Specs2 3.9.1
    • Scala 2.11
    • Scala 2.12
  • Specs2 3.8.4
    • Scala 2.11

A quick example stolen from the current version of the spec:

    "check a multi-suspension program" in {
      val H = Harness[FileSystemOp, IO]

      val harness = for {
        _ <- H.pattern[Array[Byte]] {
          case Read(name) =>
            IO {
              name mustEqual "foo.txt"

              Array(1, 2, 3, 4, 5)
            }
        }

        _ <- H.pattern[Unit] {
          case Write(name, contents) =>
            IO {
              name mustEqual "bar.txt"
              contents mustEqual Array(3, 2, 1)
            }
        }
      } yield ()

      harness(read("foo.txt") >> write("bar.txt", Array(3, 2, 1))).unsafePerformIO()

      ok
    }

The program under test is on the penultimate line (read >> write). The harness we construct in the for-comprehension asserts that the first suspension is a Read, and the second suspension is a Write, and there are no further suspensions. When the assertion is passed, we have the opportunity to run further assertions (within the side-effect lifted into IO) as well as the ability to produce the value to which the suspension will interpret.

Further features of this framework (such as support for branching workflows, or state passing) are very possible, but out of scope for this afternoon. We

smock's People

Contributors

djspiewak avatar wemrysi avatar lukaszwawrzyk avatar

Stargazers

Kamil Adam avatar  avatar Oscar Vargas Torres avatar Alex Gryzlov avatar Bocheng Zhou avatar Jay C Stiles avatar William Harvey avatar Ihor Mielientiev avatar Grigory avatar Jisoo Park avatar strobe avatar Pierangelo Cecchetto avatar Aron Trauring avatar Yash Yadavalli avatar Fran Perez avatar Kevin Walter avatar Richard Ashworth avatar  avatar >>= avatar Joshua Junqueira avatar Konstantin Silin avatar Daniel Pous Montardit avatar Albert Serrallé Ríos avatar Andrea Passaglia avatar Michal Sitko avatar n4to4 avatar Mark avatar Cem Turan avatar Irakli Safareli avatar

Watchers

 avatar kenji yoshida avatar James Cloos avatar Jisoo Park avatar  avatar

smock's Issues

Bintray doesn't work

Hi 👋

Please publish the lib to gh-packages or whatever else, since bintray doesn't work anymore

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.