Permalink
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (21 sloc) 786 Bytes
// Copyright © 2010-2016, Esko Luontola <www.orfjackal.net>
// This software is released under the Apache License 2.0.
// The license text is at http://www.apache.org/licenses/LICENSE-2.0
package org.specsy.examples.scala
import org.specsy.scala.ScalaSpecsy
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers._
class FibonacciSpec extends ScalaSpecsy {
val sequenceLength = 10
val fib = new Fibonacci().sequence(sequenceLength)
assertThat(fib.length, is(sequenceLength))
"The first two Fibonacci numbers are 0 and 1" >> {
assertThat(fib(0), is(0))
assertThat(fib(1), is(1))
}
"Each remaining number is the sum of the previous two" >> {
for (i <- 2 until fib.length) {
assertThat(fib(i), is(fib(i - 1) + fib(i - 2)))
}
}
}