Skip to content

Instantly share code, notes, and snippets.

@hyunjun
Last active December 13, 2020 15:51
Show Gist options
  • Save hyunjun/c47c7e1956c2bea685b337458fa51883 to your computer and use it in GitHub Desktop.
Save hyunjun/c47c7e1956c2bea685b337458fa51883 to your computer and use it in GitHub Desktop.
ammonite
@ import $ivy.`qa.hedgehog::hedgehog-core:0.6.0`
https://repo1.maven.org/maven2/qa/hedgehog/hedgehog-core_2.13/0.6.0/hedgehog-core_2.13-0.6.0.pom
100.0% [##########] 1.8 KiB (2.1 KiB / s)
https://repo1.maven.org/maven2/qa/hedgehog/hedgehog-core_2.13/0.6.0/hedgehog-core_2.13-0.6.0-sources.jar
100.0% [##########] 33.6 KiB (41.9 KiB / s)
https://repo1.maven.org/maven2/qa/hedgehog/hedgehog-core_2.13/0.6.0/hedgehog-core_2.13-0.6.0.jar
100.0% [##########] 378.1 KiB (429.1 KiB / s)
import $ivy.$
@ import hedgehog._
import hedgehog._
@ import $ivy.`qa.hedgehog::hedgehog-runner:0.6.0`
https://repo1.maven.org/maven2/qa/hedgehog/hedgehog-runner_2.13/0.6.0/hedgehog-runner_2.13-0.6.0.pom
100.0% [##########] 2.2 KiB (326 B / s)
https://repo1.maven.org/maven2/org/portable-scala/portable-scala-reflect_2.13/1.0.0/portable-scala-reflect_2.13-1.0.0.pom
100.0% [##########] 2.4 KiB (13.0 KiB / s)
https://repo1.maven.org/maven2/qa/hedgehog/hedgehog-runner_2.13/0.6.0/hedgehog-runner_2.13-0.6.0.jar
100.0% [##########] 25.9 KiB (92.0 KiB / s)
https://repo1.maven.org/maven2/org/portable-scala/portable-scala-reflect_2.13/1.0.0/portable-scala-reflect_2.13-1.0.0.jar
100.0% [##########] 26.8 KiB (46.1 KiB / s)
https://repo1.maven.org/maven2/org/portable-scala/portable-scala-reflect_2.13/1.0.0/portable-scala-reflect_2.13-1.0.0-sources.jar
100.0% [##########] 5.2 KiB (6.8 KiB / s)
import $ivy.$
@ import $ivy.`qa.hedgehog::hedgehog-sbt:0.6.0`
https://repo1.maven.org/maven2/qa/hedgehog/hedgehog-sbt_2.13/0.6.0/hedgehog-sbt_2.13-0.6.0.pom
100.0% [##########] 2.5 KiB (7.0 KiB / s)
https://repo1.maven.org/maven2/qa/hedgehog/hedgehog-sbt_2.13/0.6.0/hedgehog-sbt_2.13-0.6.0-sources.jar
100.0% [##########] 2.3 KiB (8.9 KiB / s)
import $ivy.$
@ import hedgehog.runner._
import hedgehog.runner._
@ object PropertyTest extends Properties {
def tests: List[Test] =
List(
property("reverse", testReverse)
)
def testReverse: Property =
for {
xs <- Gen.alpha.list(Range.linear(0, 100)).forAll
} yield xs.reverse.reverse ==== xs
}
defined object PropertyTest
// https://blog.softwaremill.com/squeezing-extra-productivity-out-of-ammonite-scala-repl-b4e4001cca07
@ import $ivy.`org.typelevel::cats-core:2.0.0`, cats._, cats.implicits._
import $ivy.`io.monix::monix:3.0.0`
import $ivy.`dev.zio::zio:1.0.0-RC12-1`
import $ivy.`org.typelevel::cats-effect:2.3.0`
import $ivy.`org.scalatest::scalatest:3.0.8`,org.scalatest._
import $ivy.`org.scalacheck::scalacheck:1.14.0`
import $ivy.`com.github.chocpanda::scalacheck-magnolia:0.5.1`
import $ivy.`io.chrisdavenport::cats-scalacheck:0.2.0-M1`
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
import scala.concurrent.Future
import scala.util.{Failure, Success}
import scala.concurrent.Await
import org.scalacheck.{Arbitrary, Gen}
import org.scalacheck.magnolia._
@ def randomObj[T: Arbitrary] = implicitly[Arbitrary[T]].arbitrary.sample.get
@ case class User(name: String, age: Int, address: String)
@ randomObj[User]
res19: User = User(
"\u9b37\u9406\u6b0f\u9258\u95e9\ub76e\u99ea\ua651\u2cb2\u2cfa\u928e\ub608\u707e\uf0e0\ub3c9\u394a\u75b6\ucf8e\u39d9\u5998\u0e7d\ua179",
1363832983,
"\u8a8f\u62f4\u57a9\ub417\ubb5c\uacf6\ub694\ue7f6\ue698\ue95a\u6832\uf72b\u6e14\u710d\u0f31\u6833\u383d\ua464\u7fd7\ub966\u0599\u6254\uad7f\u9b8a\u1faf\uf535\u3052\u28dd\u2899\u6625\ua758\u1085\u73b1\u62cd\uc266\u0a65\ud4d9\uab91\u45b5\u8b07\u560a\uc2dc\u5c1a\u24b4\uc7b9\u7785\u0169\ubb24\u8fa3\u411a\uc065\ubcc1\ud63a\u6203\ua4e2\ud663\uff76\ue093\uc117\u0b83\u5dea\u5949\u0b84\u5f93\uf8cf\uf2fb\u5563\u64d0\u3966\u7d9c\u2714\u4c2f\u581a\u2256\u0892\uc31c\u5f33\uedd2\u27e2\u260a\ub6df\u830e\u7f36\ubc07\u4959\u4bea\u59f6\u46f2\uff59\u50f0\u67f1\u120c\ua562\u7d1f\uaeff\ufeb2"
)
@ import $ivy.`com.lihaoyi::scalatags:0.8.2`, scalatags.Text.all._
https://repo1.maven.org/maven2/com/lihaoyi/scalatags_2.13/0.8.2/scalatags_2.13-0.8.2.pom
100.0% [##########] 1.6 KiB (426 B / s)
https://repo1.maven.org/maven2/com/lihaoyi/scalatags_2.13/0.8.2/scalatags_2.13-0.8.2.jar
100.0% [##########] 475.8 KiB (626.9 KiB / s)
import $ivy.$ , scalatags.Text.all._
@ println(a("Hello", href := "http://www.google.com").render)
<a href="http://www.google.com">Hello</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment