Instance Constructors
-
new
TableFor1
(heading: String, rows: A*)
Value Members
-
def
!=
(arg0: AnyRef): Boolean
-
def
!=
(arg0: Any): Boolean
-
def
##
(): Int
-
def
++
[B >: A, That]
(that: TraversableOnce[B])(implicit bf: CanBuildFrom[TableFor1[A], B, That]): That
-
def
++
[B >: A, That]
(that: GenTraversableOnce[B])(implicit bf: CanBuildFrom[TableFor1[A], B, That]): That
-
def
++:
[B >: A, That]
(that: Traversable[B])(implicit bf: CanBuildFrom[TableFor1[A], B, That]): That
-
def
++:
[B >: A, That]
(that: TraversableOnce[B])(implicit bf: CanBuildFrom[TableFor1[A], B, That]): That
-
def
+:
[B >: A, That]
(elem: B)(implicit bf: CanBuildFrom[TableFor1[A], B, That]): That
-
def
/:
[B]
(z: B)(op: (B, A) ⇒ B): B
-
def
/:\
[A1 >: A]
(z: A1)(op: (A1, A1) ⇒ A1): A1
-
def
:+
[B >: A, That]
(elem: B)(implicit bf: CanBuildFrom[TableFor1[A], B, That]): That
-
def
:\
[B]
(z: B)(op: (A, B) ⇒ B): B
-
def
==
(arg0: AnyRef): Boolean
-
def
==
(arg0: Any): Boolean
-
def
addString
(b: StringBuilder): StringBuilder
-
def
addString
(b: StringBuilder, sep: String): StringBuilder
-
def
addString
(b: StringBuilder, start: String, sep: String, end: String): StringBuilder
-
def
aggregate
[B]
(z: B)(seqop: (B, A) ⇒ B, combop: (B, B) ⇒ B): B
-
def
andThen
[C]
(k: (A) ⇒ C): PartialFunction[Int, C]
-
def
apply
(fun: (A) ⇒ Unit): Unit
-
def
apply
(idx: Int): A
-
def
asInstanceOf
[T0]
: T0
-
def
canEqual
(that: Any): Boolean
-
def
clone
(): AnyRef
-
def
collect
[B, That]
(pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[TableFor1[A], B, That]): That
-
def
collectFirst
[B]
(pf: PartialFunction[A, B]): Option[B]
-
def
combinations
(n: Int): Iterator[TableFor1[A]]
-
def
companion
: GenericCompanion[IndexedSeq]
-
def
compose
[A]
(g: (A) ⇒ Int): (A) ⇒ A
-
def
contains
(elem: Any): Boolean
-
def
containsSlice
[B]
(that: Seq[B]): Boolean
-
def
containsSlice
[B]
(that: GenSeq[B]): Boolean
-
def
copyToArray
[B >: A]
(xs: Array[B], start: Int, len: Int): Unit
-
def
copyToArray
[B >: A]
(xs: Array[B]): Unit
-
def
copyToArray
[B >: A]
(xs: Array[B], start: Int): Unit
-
def
copyToBuffer
[B >: A]
(dest: Buffer[B]): Unit
-
def
corresponds
[B]
(that: Seq[B])(p: (A, B) ⇒ Boolean): Boolean
-
def
corresponds
[B]
(that: GenSeq[B])(p: (A, B) ⇒ Boolean): Boolean
-
def
count
(p: (A) ⇒ Boolean): Int
-
def
diff
[B >: A]
(that: Seq[B]): TableFor1[A]
-
def
diff
[B >: A]
(that: GenSeq[B]): TableFor1[A]
-
-
def
drop
(n: Int): TableFor1[A]
-
def
dropRight
(n: Int): TableFor1[A]
-
def
dropWhile
(p: (A) ⇒ Boolean): TableFor1[A]
-
def
endsWith
[B]
(that: Seq[B]): Boolean
-
def
endsWith
[B]
(that: GenSeq[B]): Boolean
-
def
eq
(arg0: AnyRef): Boolean
-
def
equals
(that: Any): Boolean
-
def
exists
(p: (A) ⇒ Boolean): Boolean
-
def
filter
(p: (A) ⇒ Boolean): TableFor1[A]
-
def
filterNot
(p: (A) ⇒ Boolean): TableFor1[A]
-
def
finalize
(): Unit
-
def
find
(p: (A) ⇒ Boolean): Option[A]
-
def
flatMap
[B, That]
(f: (A) ⇒ GenTraversableOnce[B])(implicit bf: CanBuildFrom[TableFor1[A], B, That]): That
-
def
flatten
[B]
(implicit asTraversable: (A) ⇒ TraversableOnce[B]): Traversable[B]
-
def
fold
[A1 >: A]
(z: A1)(op: (A1, A1) ⇒ A1): A1
-
def
foldLeft
[B]
(z: B)(op: (B, A) ⇒ B): B
-
def
foldRight
[B]
(z: B)(op: (A, B) ⇒ B): B
-
def
forall
(p: (A) ⇒ Boolean): Boolean
-
def
foreach
[U]
(f: (A) ⇒ U): Unit
-
def
genericBuilder
[B]
: Builder[B, IndexedSeq[B]]
-
def
getClass
(): java.lang.Class[_]
-
def
groupBy
[K]
(f: (A) ⇒ K): Map[K, TableFor1[A]]
-
def
grouped
(size: Int): Iterator[TableFor1[A]]
-
def
hasDefiniteSize
: Boolean
-
def
hashCode
(): Int
-
def
head
: A
-
def
headOption
: Option[A]
-
val
heading
: String
-
def
indexOf
[B >: A]
(elem: B, from: Int): Int
-
def
indexOf
[B >: A]
(elem: B): Int
-
def
indexOfSlice
[B >: A]
(that: Seq[B], from: Int): Int
-
def
indexOfSlice
[B >: A]
(that: GenSeq[B], from: Int): Int
-
def
indexOfSlice
[B >: A]
(that: Seq[B]): Int
-
def
indexOfSlice
[B >: A]
(that: GenSeq[B]): Int
-
def
indexWhere
(p: (A) ⇒ Boolean, from: Int): Int
-
def
indexWhere
(p: (A) ⇒ Boolean): Int
-
def
indices
: Range
-
-
def
inits
: Iterator[TableFor1[A]]
-
def
intersect
[B >: A]
(that: Seq[B]): TableFor1[A]
-
def
intersect
[B >: A]
(that: GenSeq[B]): TableFor1[A]
-
def
isDefinedAt
(idx: Int): Boolean
-
def
isEmpty
: Boolean
-
def
isInstanceOf
[T0]
: Boolean
-
def
isTraversableAgain
: Boolean
-
def
iterator
: Iterator[A]
-
def
last
: A
-
def
lastIndexOf
[B >: A]
(elem: B, end: Int): Int
-
def
lastIndexOf
[B >: A]
(elem: B): Int
-
def
lastIndexOfSlice
[B >: A]
(that: Seq[B], end: Int): Int
-
def
lastIndexOfSlice
[B >: A]
(that: GenSeq[B], end: Int): Int
-
def
lastIndexOfSlice
[B >: A]
(that: Seq[B]): Int
-
def
lastIndexOfSlice
[B >: A]
(that: GenSeq[B]): Int
-
def
lastIndexWhere
(p: (A) ⇒ Boolean, end: Int): Int
-
def
lastIndexWhere
(p: (A) ⇒ Boolean): Int
-
def
lastOption
: Option[A]
-
def
length
: Int
-
def
lengthCompare
(len: Int): Int
-
def
lift
: (Int) ⇒ Option[A]
-
def
map
[B, That]
(f: (A) ⇒ B)(implicit bf: CanBuildFrom[TableFor1[A], B, That]): That
-
def
max
[B >: A]
(implicit cmp: Ordering[B]): A
-
def
maxBy
[B]
(f: (A) ⇒ B)(implicit cmp: Ordering[B]): A
-
def
min
[B >: A]
(implicit cmp: Ordering[B]): A
-
def
minBy
[B]
(f: (A) ⇒ B)(implicit cmp: Ordering[B]): A
-
def
mkString
: String
-
def
mkString
(sep: String): String
-
def
mkString
(start: String, sep: String, end: String): String
-
def
ne
(arg0: AnyRef): Boolean
-
def
newBuilder
: Builder[A, TableFor1[A]]
-
def
nonEmpty
: Boolean
-
def
notify
(): Unit
-
def
notifyAll
(): Unit
-
def
orElse
[A1 <: Int, B1 >: A]
(that: PartialFunction[A1, B1]): PartialFunction[A1, B1]
-
def
padTo
[B >: A, That]
(len: Int, elem: B)(implicit bf: CanBuildFrom[TableFor1[A], B, That]): That
-
def
par
: ParSeq[A]
-
def
parCombiner
: Combiner[A, ParSeq[A]]
-
def
partition
(p: (A) ⇒ Boolean): (TableFor1[A], TableFor1[A])
-
def
patch
[B >: A, That]
(from: Int, patch: Seq[B], replaced: Int)(implicit bf: CanBuildFrom[TableFor1[A], B, That]): That
-
def
patch
[B >: A, That]
(from: Int, patch: GenSeq[B], replaced: Int)(implicit bf: CanBuildFrom[TableFor1[A], B, That]): That
-
def
permutations
: Iterator[TableFor1[A]]
-
def
prefixLength
(p: (A) ⇒ Boolean): Int
-
def
product
[B >: A]
(implicit num: Numeric[B]): B
-
def
reduce
[A1 >: A]
(op: (A1, A1) ⇒ A1): A1
-
def
reduceLeft
[B >: A]
(op: (B, A) ⇒ B): B
-
def
reduceLeftOption
[B >: A]
(op: (B, A) ⇒ B): Option[B]
-
def
reduceOption
[A1 >: A]
(op: (A1, A1) ⇒ A1): Option[A1]
-
def
reduceRight
[B >: A]
(op: (A, B) ⇒ B): B
-
def
reduceRightOption
[B >: A]
(op: (A, B) ⇒ B): Option[B]
-
-
-
def
reverseIterator
: Iterator[A]
-
def
reverseMap
[B, That]
(f: (A) ⇒ B)(implicit bf: CanBuildFrom[TableFor1[A], B, That]): That
-
def
reversed
: List[A]
-
def
sameElements
[B >: A]
(that: Iterable[B]): Boolean
-
def
sameElements
[B >: A]
(that: GenIterable[B]): Boolean
-
def
scan
[B >: A, That]
(z: B)(op: (B, B) ⇒ B)(implicit cbf: CanBuildFrom[TableFor1[A], B, That]): That
-
def
scanLeft
[B, That]
(z: B)(op: (B, A) ⇒ B)(implicit bf: CanBuildFrom[TableFor1[A], B, That]): That
-
def
scanRight
[B, That]
(z: B)(op: (A, B) ⇒ B)(implicit bf: CanBuildFrom[TableFor1[A], B, That]): That
-
def
segmentLength
(p: (A) ⇒ Boolean, from: Int): Int
-
def
seq
: Seq[A]
-
def
size
: Int
-
def
slice
(from: Int, until: Int): TableFor1[A]
-
def
sliding
[B >: A]
(size: Int, step: Int): Iterator[TableFor1[A]]
-
def
sliding
[B >: A]
(size: Int): Iterator[TableFor1[A]]
-
def
sortBy
[B]
(f: (A) ⇒ B)(implicit ord: Ordering[B]): TableFor1[A]
-
def
sortWith
(lt: (A, A) ⇒ Boolean): TableFor1[A]
-
def
sorted
[B >: A]
(implicit ord: Ordering[B]): TableFor1[A]
-
def
span
(p: (A) ⇒ Boolean): (TableFor1[A], TableFor1[A])
-
-
def
startsWith
[B]
(that: Seq[B], offset: Int): Boolean
-
def
startsWith
[B]
(that: GenSeq[B], offset: Int): Boolean
-
def
startsWith
[B]
(that: Seq[B]): Boolean
-
def
startsWith
[B]
(that: GenSeq[B]): Boolean
-
def
stringPrefix
: String
-
def
sum
[B >: A]
(implicit num: Numeric[B]): B
-
def
synchronized
[T0]
(arg0: ⇒ T0): T0
-
-
def
tails
: Iterator[TableFor1[A]]
-
def
take
(n: Int): TableFor1[A]
-
def
takeRight
(n: Int): TableFor1[A]
-
def
takeWhile
(p: (A) ⇒ Boolean): TableFor1[A]
-
def
thisCollection
: IndexedSeq[A]
-
def
toArray
[B >: A]
(implicit arg0: ClassManifest[B]): Array[B]
-
def
toBuffer
[A1 >: A]
: Buffer[A1]
-
def
toCollection
(repr: TableFor1[A]): IndexedSeq[A]
-
def
toIndexedSeq
[B >: A]
: IndexedSeq[B]
-
def
toIterable
: Iterable[A]
-
def
toIterator
: Iterator[A]
-
def
toList
: List[A]
-
def
toMap
[T, U]
(implicit ev: <:<[A, (T, U)]): Map[T, U]
-
def
toSeq
: Seq[A]
-
def
toSet
[B >: A]
: Set[B]
-
def
toStream
: Stream[A]
-
def
toString
(): String
-
def
toTraversable
: Traversable[A]
-
def
transpose
[B]
(implicit asTraversable: (A) ⇒ TraversableOnce[B]): Traversable[Traversable[B]]
-
def
union
[B >: A, That]
(that: GenSeq[B])(implicit bf: CanBuildFrom[TableFor1[A], B, That]): That
-
def
union
[B >: A, That]
(that: Seq[B])(implicit bf: CanBuildFrom[TableFor1[A], B, That]): That
-
def
unzip
[A1, A2]
(implicit asPair: (A) ⇒ (A1, A2)): (IndexedSeq[A1], IndexedSeq[A2])
-
def
unzip3
[A1, A2, A3]
(implicit asTriple: (A) ⇒ (A1, A2, A3)): (IndexedSeq[A1], IndexedSeq[A2], IndexedSeq[A3])
-
def
updated
[B >: A, That]
(index: Int, elem: B)(implicit bf: CanBuildFrom[TableFor1[A], B, That]): That
-
def
view
(from: Int, until: Int): SeqView[A, TableFor1[A]]
-
def
view
: SeqView[A, TableFor1[A]]
-
def
wait
(): Unit
-
def
wait
(arg0: Long, arg1: Int): Unit
-
def
wait
(arg0: Long): Unit
-
def
withFilter
(p: (A) ⇒ Boolean): FilterMonadic[A, TableFor1[A]]
-
def
zip
[A1 >: A, B, That]
(that: Iterable[B])(implicit bf: CanBuildFrom[TableFor1[A], (A1, B), That]): That
-
def
zip
[A1 >: A, B, That]
(that: GenIterable[B])(implicit bf: CanBuildFrom[TableFor1[A], (A1, B), That]): That
-
def
zipAll
[B, A1 >: A, That]
(that: Iterable[B], thisElem: A1, thatElem: B)(implicit bf: CanBuildFrom[TableFor1[A], (A1, B), That]): That
-
def
zipAll
[B, A1 >: A, That]
(that: GenIterable[B], thisElem: A1, thatElem: B)(implicit bf: CanBuildFrom[TableFor1[A], (A1, B), That]): That
-
def
zipWithIndex
[A1 >: A, That]
(implicit bf: CanBuildFrom[TableFor1[A], (A1, Int), That]): That
-
def
elements
: Iterator[A]
-
def
equalsWith
[B]
(that: Seq[B])(f: (A, B) ⇒ Boolean): Boolean
-
def
findIndexOf
(p: (A) ⇒ Boolean): Int
-
def
findLastIndexOf
(p: (A) ⇒ Boolean): Int
-
def
first
: A
-
def
firstOption
: Option[A]
-
def
projection
: SeqView[A, TableFor1[A]]
-
def
reversedElements
: Iterator[A]
Inherited from IndexedSeq[A]
Inherited from IndexedSeqLike[A, TableFor1[A]]
Inherited from Seq[A]
Inherited from GenSeq[A]
Inherited from Iterable[A]
Inherited from Equals
Inherited from GenIterable[A]
Inherited from GenIterableLike[A, TableFor1[A]]
Inherited from Traversable[A]
Inherited from GenTraversable[A]
Inherited from GenericTraversableTemplate[A, IndexedSeq]
Inherited from TraversableLike[A, TableFor1[A]]
Inherited from GenTraversableLike[A, TableFor1[A]]
Inherited from Parallelizable[A, ParSeq[A]]
Inherited from TraversableOnce[A]
Inherited from GenTraversableOnce[A]
Inherited from FilterMonadic[A, TableFor1[A]]
Inherited from HasNewBuilder[A, TableFor1[A]]
Inherited from PartialFunction[Int, A]
Inherited from (Int) ⇒ A
Inherited from AnyRef
Inherited from Any
A table with 1 column.
For an overview of using tables, see the documentation for trait TableDrivenPropertyChecks.
This table is a sequence of objects, where each object represents one row of the (one-column) table. This table also carries with it a heading tuple that gives a string name to the lone column of the table.
A handy way to create a
TableFor1
is via anapply
factory method in theTable
singleton object provided by theTables
trait. Here's an example:Because you supplied a list of non-tuple objects, the type you'll get back will be a
TableFor1
.The table provides an
apply
method that takes a function with a parameter list that matches the type of the objects contained in this table. Theapply
method will invoke the function with the object in each row passed as the lone argument, in ascending order by index. (I.e., the zeroth object is checked first, then the object with index 1, then index 2, and so on until all the rows have been checked (or until a failure occurs). The function represents a property of the code under test that should succeed for every row of the table. If the function returns normally, that indicates the property check succeeded for that row. If the function completes abruptly with an exception, that indicates the property check failed and theapply
method will complete abruptly with aTableDrivenPropertyCheckFailedException
that wraps the exception thrown by the supplied property function.The usual way you'd invoke the
apply
method that checks a property is via aforAll
method provided by traitTableDrivenPropertyChecks
. TheforAll
method takes aTableFor1
as its first argument, then in a curried argument list takes the property check function. It invokesapply
on theTableFor1
, passing in the property check function. Here's an example:forAll (examples) { (a) => a should equal (a * 1) }
Because
TableFor1
is aSeq[(A)]
, you can use it as aSeq
. For example, here's how you could get a sequence of optional exceptions for each row of the table, indicating whether a property check succeeded or failed on each row of the table:Note: the
failureOf
method, contained in theFailureOf
trait, will execute the supplied code (a by-name parameter) and catch any exception. If no exception is thrown by the code,failureOf
will result inNone
, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail,failureOf
will result in aSome
wrapping that exception. For example, the previous for expression would give you:This shows that all the property checks succeeded, except for the one at index 7.
One other way to use a
TableFor1
is to test subsequent return values of a stateful function. Imagine, for example, you had an object namedFiboGen
whosenext
method returned the next fibonacci number, where next means the next number in the series following the number previously returned bynext
. So the first timenext
was called, it would return 0. The next time it was called it would return 1. Then 1. Then 2. Then 3, and so on.FiboGen
would need to be stateful, because it has to remember where it is in the series. In such a situation, you could create aTableFor1
(a table with one column, which you could alternatively think of as one row), in which each row represents the next value you expect.Then in your
forAll
simply call the function and compare it with the expected return value, like this: