diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2016-06-19 03:48:01 -0400 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2016-06-19 03:48:01 -0400 |
commit | c2b51bbba200cfdfebf1e32bfd85fe40d55bf986 (patch) | |
tree | 759d49180d5eaed971588e98d75ac357249cfde1 /examples/scalatest-example/src | |
parent | 3c2310c9d092cc2589743a081a433103ab58e59b (diff) | |
download | cbt-c2b51bbba200cfdfebf1e32bfd85fe40d55bf986.tar.gz cbt-c2b51bbba200cfdfebf1e32bfd85fe40d55bf986.tar.bz2 cbt-c2b51bbba200cfdfebf1e32bfd85fe40d55bf986.zip |
Rename scalatest-example folder. Probably slightly more intuitive name now.
Diffstat (limited to 'examples/scalatest-example/src')
-rw-r--r-- | examples/scalatest-example/src/main/scala/Hello.scala | 7 | ||||
-rw-r--r-- | examples/scalatest-example/src/test/scala/Test.scala | 23 |
2 files changed, 30 insertions, 0 deletions
diff --git a/examples/scalatest-example/src/main/scala/Hello.scala b/examples/scalatest-example/src/main/scala/Hello.scala new file mode 100644 index 0000000..099a84d --- /dev/null +++ b/examples/scalatest-example/src/main/scala/Hello.scala @@ -0,0 +1,7 @@ +object Main extends App{ + + println("Hello World") + + def square(x: Int) = x * x + +} diff --git a/examples/scalatest-example/src/test/scala/Test.scala b/examples/scalatest-example/src/test/scala/Test.scala new file mode 100644 index 0000000..48b0a36 --- /dev/null +++ b/examples/scalatest-example/src/test/scala/Test.scala @@ -0,0 +1,23 @@ +import collection.mutable.Stack +import org.scalatest._ + +class Test extends FlatSpec with Matchers { + "square" should "return double" in { + Main.square(2) should be (4) + } + + "A Stack" should "pop values in last-in-first-out order" in { + val stack = new Stack[Int] + stack.push(1) + stack.push(2) + stack.pop() should be (2) + stack.pop() should be (1) + } + + it should "throw NoSuchElementException if an empty stack is popped" in { + val emptyStack = new Stack[Int] + a [NoSuchElementException] should be thrownBy { + emptyStack.pop() + } + } +}
\ No newline at end of file |