ここの所、数か月おきにjsのユニットテストってどうやるのが良いのか悩んでいる気がするので、一つ情報集約の為にメモ書きをしておきます。
何かちゃんと文章書いておけば、それに対する反応が集まって、オレサマハッピー的な展開を望んでいます。
単体テストというか、ユニットテストというか、そういうアレを書く為のフレームワークを探しています。
覚える事が少なくて強力なやつ。
機能テストというか、e2eテストいうか、そういうアレの事は別途考える必要がありますので、今回はスコープ外とします。
| // Start by adding these | |
| import scala.util.{ Try, Success, Failure } | |
| /** | |
| * Sample runs code that raises the exception: | |
| * java.lang.ArithmeticException: / by zero | |
| */ | |
| object Sample { | |
| def main(args: Array[String]): Unit = { |
| (function() { | |
| function bind(d, f) { | |
| return d.pipe(f) | |
| } | |
| function point(a) { | |
| var d = $.Deferred(); | |
| d.resolve(a); | |
| return d.promise(); | |
| } |
| object BenchmarkCommon { | |
| import scala.util.Random | |
| val DatasetSize = 10000 | |
| val Iterations = 10000 | |
| val ArrayPoolSize = 1000 | |
| val ArrayPool = { | |
| def randomArray(): Array[Int] = { | |
| val array = new Array[Int](DatasetSize) | |
Have you ever had to write code that made a complex series of succesive modifications to a single piece of mutable state? (Almost certainly yes.)
Did you ever wish you could make the compiler tell you if a particular operation on the state was illegal at a given point in the modifications? (If you're a fan of static typing, probably yes.)
If that's the case, the indexed state monad can help!
Motivation
| import scala.util.Try | |
| import scalaz._, Scalaz._ | |
| import scalaz.effect._, IO._ | |
| import com.clarifi.machines._ | |
| import argonaut._, Argonaut._ | |
| object Sample extends SafeApp { |
| import scala.language.postfixOps | |
| import java.io._ | |
| import scalaj.http._ | |
| import scalaz._, Scalaz._ | |
| import scalaz.effect._, Effect._, IO._ | |
| import scalaz.concurrent.Promise |
!SLIDE
!SLIDE
https://twitter.com/pocketberserker/status/313441791766564864
type T[-A, -B] = (A => Any) \/ (B => Any)| diff --git a/v0.12.3:main/Keys.scala b/v0.13.0-M2:main/src/main/scala/sbt/Keys.scala | |
| index 49bf4d1..fa0e04e 100644 | |
| --- a/v0.12.3:main/Keys.scala | |
| +++ b/v0.13.0-M2:main/src/main/scala/sbt/Keys.scala | |
| @@ -5,7 +5,7 @@ package sbt | |
| import java.io.File | |
| import java.net.URL | |
| - import Project.ScopedKey | |
| + import Def.ScopedKey |