Mercurial > hg > Members > nobuyasu > scala
diff chapter9/MyAssertion.scala @ 0:b316eec6fa7a draft default tip
add sample files
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 08 Jan 2013 16:41:46 +0900 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/chapter9/MyAssertion.scala Tue Jan 08 16:41:46 2013 +0900 @@ -0,0 +1,9 @@ +var assertionsEnabled = true +def myAssert(predicate: () => Boolean) = + if (assertionsEnabled && !predicate()) + throw new AssertionError + +def byNameAssert(predicate: => Boolean) = + if (assertionsEnabled && !predicate) + throw new AssertionError +