package prop
- Alphabetic
- Public
- Protected
Type Members
- trait Configuration extends AnyRef
Trait providing methods and classes used to configure property checks provided by the the
forAllmethods of traitGeneratorDrivenPropertyChecks(for ScalaTest-style property checks) and thecheckmethods of traitCheckers(for ScalaCheck-style property checks). - trait TableDrivenPropertyChecks extends Whenever with Tables
Trait containing methods that faciliate property checks against tables of data.
Trait containing methods that faciliate property checks against tables of data.
This trait contains one
exists,forAll, andforEverymethod for eachTableForNclass,TableFor1throughTableFor22, which allow properties to be checked against the rows of a table. It also contains awhenevermethod that can be used to indicate a property need only hold whenever some condition is true.For an example of trait
TableDrivenPropertyChecksin action, imagine you want to test thisFractionclass:class Fraction(n: Int, d: Int) {
require(d != 0) require(d != Integer.MIN_VALUE) require(n != Integer.MIN_VALUE)
val numer = if (d < 0) -1 * n else n val denom = d.abs
override def toString = numer + " / " + denom }TableDrivenPropertyChecksallows you to create tables with between 1 and 22 columns and any number of rows. You create a table by passing tuples to one of the factory methods of objectTable. Each tuple must have the same arity (number of members). The first tuple you pass must all be strings, because it defines names for the columns. Subsequent tuples define the data. After the initial tuple that contains string column names, all tuples must have the same type. For example, if the first tuple after the column names contains twoInts, all subsequent tuples must contain twoInt(i.e., have typeTuple2[Int, Int]).To test the behavior of
Fraction, you could create a table of numerators and denominators to pass to the constructor of theFractionclass using one of theapplyfactory methods declared inTable, like this:import org.scalatest.prop.TableDrivenPropertyChecks._
val fractions = Table( ("n", "d"), // First tuple defines column names ( 1, 2), // Subsequent tuples define the data ( -1, 2), ( 1, -2), ( -1, -2), ( 3, 1), ( -3, 1), ( -3, 0), ( 3, -1), ( 3, Integer.MIN_VALUE), (Integer.MIN_VALUE, 3), ( -3, -1) )You could then check a property against each row of the table using a
forAllmethod, like this:import org.scalatest.Matchers._
forAll (fractions) { (n: Int, d: Int) =>
whenever (d != 0 && d != Integer.MIN_VALUE && n != Integer.MIN_VALUE) {
val f = new Fraction(n, d)
if (n < 0 && d < 0 || n > 0 && d > 0) f.numer should be > 0 else if (n != 0) f.numer should be < 0 else f.numer should be === 0
f.denom should be > 0 } }Trait
TableDrivenPropertyChecksprovides 22 overloadedexists,forAll, andforEverymethods that allow you to check properties using the data provided by a table. Eachexists,forAll, andforEverymethod takes two parameter lists. The first parameter list is a table. The second parameter list is a function whose argument types and number matches that of the tuples in the table. For example, if the tuples in the table supplied toforAlleach contain anInt, aString, and aList[Char], then the function supplied toforAllmust take 3 parameters, anInt, aString, and aList[Char]. TheforAllmethod will pass each row of data to the function, and generate aTableDrivenPropertyCheckFailedExceptionif the function completes abruptly for any row of data with any exception that would normally cause a test to fail in ScalaTest other thanDiscardedEvaluationException. ADiscardedEvaluationException, which is thrown by thewhenevermethod (also defined in this trait) to indicate a condition required by the property function is not met by a row of passed data, will simply causeforAllto skip that row of data.The full list of table methods are:
exists- succeeds if the assertion holds true for at least one elementforAll- succeeds if the assertion holds true for every elementforEvery- same asforAll, but lists all failing elements if it fails (whereasforAlljust reports the first failing element) and throwsTestFailedExceptionwith the first failed check as the cause.
Testing stateful functions
One way to use a table with one column is to test subsequent return values of a stateful function. Imagine, for example, you had an object named
FiboGenwhosenextmethod returned the next fibonacci number, where next means the next number in the series following the number previously returned bynext. So the first timenextwas called, it would return 0. The next time it was called it would return 1. Then 1. Then 2. Then 3, and so on.FiboGenwould need to maintain state, 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.val first14FiboNums = Table("n", 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233)
Then in your
forAllsimply call the function and compare it with the expected return value, like this:forAll (first14FiboNums) { n => FiboGen.next should equal (n) }Testing mutable objects
If you need to test a mutable object, one way you can use tables is to specify state transitions in a table. For example, imagine you wanted to test this mutable
Counterclass:class Counter { private var c = 0 def reset() { c = 0 } def click() { c += 1 } def enter(n: Int) { c = n } def count = c }
A
Counterkeeps track of how many times itsclickmethod is called. The count starts out at zero and increments with eachclickinvocation. You can also set the count to a specific value by callingenterand passing the value in. And theresetmethod returns the count back to zero. You could define the actions that initiate state transitions with case classes, like this:abstract class Action case object Start extends Action case object Click extends Action case class Enter(n: Int) extends Action
Given these actions, you could define a state-transition table like this:
val stateTransitions = Table( ("action", "expectedCount"), (Start, 0), (Click, 1), (Click, 2), (Click, 3), (Enter(5), 5), (Click, 6), (Enter(1), 1), (Click, 2), (Click, 3) )
To use this in a test, simply do a pattern match inside the function you pass to
forAll. Make a pattern for each action, and have the body perform that action when there's a match. Then check that the actual value equals the expected value:val counter = new Counter forAll (stateTransitions) { (action, expectedCount) => action match { case Start => counter.reset() case Click => counter.click() case Enter(n) => counter.enter(n) } counter.count should equal (expectedCount) }
Testing invalid argument combinations
A table-driven property check can also be helpful to ensure that the proper exception is thrown when invalid data is passed to a method or constructor. For example, the
Fractionconstructor shown above should throwIllegalArgumentExceptionifInteger.MIN_VALUEis passed for either the numerator or denominator, or zero is passed for the denominator. This yields the following five combinations of invalid data:ndInteger.MIN_VALUEInteger.MIN_VALUEa valid value Integer.MIN_VALUEInteger.MIN_VALUEa valid value Integer.MIN_VALUEzero a valid value zero You can express these combinations in a table:
val invalidCombos = Table( ("n", "d"), (Integer.MIN_VALUE, Integer.MIN_VALUE), (1, Integer.MIN_VALUE), (Integer.MIN_VALUE, 1), (Integer.MIN_VALUE, 0), (1, 0) )
Given this table, you could check that all invalid combinations produce
IllegalArgumentException, like this:forAll (invalidCombos) { (n: Int, d: Int) => evaluating { new Fraction(n, d) } should produce [IllegalArgumentException] } - class TableFor1[A] extends IndexedSeq[A] with IndexedSeqOps[A, IndexedSeq, IndexedSeq[A]]
A table with 1 column.
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
TableFor1is via anapplyfactory method in theTablesingleton object provided by theTablestrait. Here's an example:val examples = Table( "a", 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 )
Because you supplied a list of non-tuple objects, the type you'll get back will be a
TableFor1.The table provides an
applymethod that takes a function with a parameter list that matches the type of the objects contained in this table. Theapplymethod 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 theapplymethod will complete abruptly with aTableDrivenPropertyCheckFailedExceptionthat wraps the exception thrown by the supplied property function.The usual way you'd invoke the
applymethod that checks a property is via aforAllmethod provided by traitTableDrivenPropertyChecks. TheforAllmethod takes aTableFor1as its first argument, then in a curried argument list takes the property check function. It invokesapplyon theTableFor1, passing in the property check function. Here's an example:forAll (examples) { (a) => a should equal (a * 1) }Because
TableFor1is aSeq[(A)], you can use it as aSeq. For example, here's how you could get a sequence ofOutcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:for (row <- examples) yield { outcomeOf { row._1 should not equal (7) } }
Note: the
outcomeOfmethod, contained in theOutcomeOftrait, will execute the supplied code (a by-name parameter) and transform it to anOutcome. If no exception is thrown by the code,outcomeOfwill result in aSucceeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail,outcomeOfwill result in in aFailedinstance containing that exception. For example, the previous for expression would give you:Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
This shows that all the property checks succeeded, except for the one at index 7.
One other way to use a
TableFor1is to test subsequent return values of a stateful function. Imagine, for example, you had an object namedFiboGenwhosenextmethod returned the next fibonacci number, where next means the next number in the series following the number previously returned bynext. So the first timenextwas called, it would return 0. The next time it was called it would return 1. Then 1. Then 2. Then 3, and so on.FiboGenwould 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.val first14FiboNums = Table("n", 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233)
Then in your
forAllsimply call the function and compare it with the expected return value, like this:forAll (first14FiboNums) { n => FiboGen.next should equal (n) } - class TableFor10[A, B, C, D, E, F, G, H, I, J] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J)] with IndexedSeqOps[(A, B, C, D, E, F, G, H, I, J), IndexedSeq, IndexedSeq[(A, B, C, D, E, F, G, H, I, J)]]
A table with 10 columns.
A table with 10 columns.
For an introduction to using tables, see the documentation for trait TableDrivenPropertyChecks.
This table is a sequence of
Tuple10objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.A handy way to create a
TableFor10is via anapplyfactory method in theTablesingleton object provided by theTablestrait. Here's an example:val examples = Table( ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j"), * ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), ( 2, 2, 2, 2, 2, 2, 2, 2, 2, 2), ( 3, 3, 3, 3, 3, 3, 3, 3, 3, 3), ( 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), ( 5, 5, 5, 5, 5, 5, 5, 5, 5, 5), ( 6, 6, 6, 6, 6, 6, 6, 6, 6, 6), ( 7, 7, 7, 7, 7, 7, 7, 7, 7, 7), ( 8, 8, 8, 8, 8, 8, 8, 8, 8, 8), ( 9, 9, 9, 9, 9, 9, 9, 9, 9, 9) )
Because you supplied 10 members in each tuple, the type you'll get back will be a
TableFor10.The table provides an
applymethod that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. Theapplymethod will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple 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 theapplymethod will complete abruptly with aTableDrivenPropertyCheckFailedExceptionthat wraps the exception thrown by the supplied property function.The usual way you'd invoke the
applymethod that checks a property is via aforAllmethod provided by traitTableDrivenPropertyChecks. TheforAllmethod takes aTableFor10as its first argument, then in a curried argument list takes the property check function. It invokesapplyon theTableFor10, passing in the property check function. Here's an example:forAll (examples) { (a, b, c, d, e, f, g, h, i, j) => a + b + c + d + e + f + g + h + i + j should equal (a * 10) }Because
TableFor10is aSeq[(A, B, C, D, E, F, G, H, I, J)], you can use it as aSeq. For example, here's how you could get a sequence ofOutcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:for (row <- examples) yield { outcomeOf { row._1 should not equal (7) } }
Note: the
outcomeOfmethod, contained in theOutcomeOftrait, will execute the supplied code (a by-name parameter) and transform it to anOutcome. If no exception is thrown by the code,outcomeOfwill result in aSucceeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail,outcomeOfwill result in in aFailedinstance containing that exception. For example, the previous for expression would give you:Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
This shows that all the property checks succeeded, except for the one at index 7.
- class TableFor11[A, B, C, D, E, F, G, H, I, J, K] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K)] with IndexedSeqOps[(A, B, C, D, E, F, G, H, I, J, K), IndexedSeq, IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K)]]
A table with 11 columns.
A table with 11 columns.
For an introduction to using tables, see the documentation for trait TableDrivenPropertyChecks.
This table is a sequence of
Tuple11objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.A handy way to create a
TableFor11is via anapplyfactory method in theTablesingleton object provided by theTablestrait. Here's an example:val examples = Table( ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k"), * ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), ( 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2), ( 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3), ( 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), ( 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5), ( 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6), ( 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7), ( 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8), ( 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9) )
Because you supplied 11 members in each tuple, the type you'll get back will be a
TableFor11.The table provides an
applymethod that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. Theapplymethod will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple 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 theapplymethod will complete abruptly with aTableDrivenPropertyCheckFailedExceptionthat wraps the exception thrown by the supplied property function.The usual way you'd invoke the
applymethod that checks a property is via aforAllmethod provided by traitTableDrivenPropertyChecks. TheforAllmethod takes aTableFor11as its first argument, then in a curried argument list takes the property check function. It invokesapplyon theTableFor11, passing in the property check function. Here's an example:forAll (examples) { (a, b, c, d, e, f, g, h, i, j, k) => a + b + c + d + e + f + g + h + i + j + k should equal (a * 11) }Because
TableFor11is aSeq[(A, B, C, D, E, F, G, H, I, J, K)], you can use it as aSeq. For example, here's how you could get a sequence ofOutcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:for (row <- examples) yield { outcomeOf { row._1 should not equal (7) } }
Note: the
outcomeOfmethod, contained in theOutcomeOftrait, will execute the supplied code (a by-name parameter) and transform it to anOutcome. If no exception is thrown by the code,outcomeOfwill result in aSucceeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail,outcomeOfwill result in in aFailedinstance containing that exception. For example, the previous for expression would give you:Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
This shows that all the property checks succeeded, except for the one at index 7.
- class TableFor12[A, B, C, D, E, F, G, H, I, J, K, L] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L)] with IndexedSeqOps[(A, B, C, D, E, F, G, H, I, J, K, L), IndexedSeq, IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L)]]
A table with 12 columns.
A table with 12 columns.
For an introduction to using tables, see the documentation for trait TableDrivenPropertyChecks.
This table is a sequence of
Tuple12objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.A handy way to create a
TableFor12is via anapplyfactory method in theTablesingleton object provided by theTablestrait. Here's an example:val examples = Table( ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"), * ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), ( 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2), ( 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3), ( 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), ( 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5), ( 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6), ( 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7), ( 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8), ( 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9) )
Because you supplied 12 members in each tuple, the type you'll get back will be a
TableFor12.The table provides an
applymethod that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. Theapplymethod will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple 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 theapplymethod will complete abruptly with aTableDrivenPropertyCheckFailedExceptionthat wraps the exception thrown by the supplied property function.The usual way you'd invoke the
applymethod that checks a property is via aforAllmethod provided by traitTableDrivenPropertyChecks. TheforAllmethod takes aTableFor12as its first argument, then in a curried argument list takes the property check function. It invokesapplyon theTableFor12, passing in the property check function. Here's an example:forAll (examples) { (a, b, c, d, e, f, g, h, i, j, k, l) => a + b + c + d + e + f + g + h + i + j + k + l should equal (a * 12) }Because
TableFor12is aSeq[(A, B, C, D, E, F, G, H, I, J, K, L)], you can use it as aSeq. For example, here's how you could get a sequence ofOutcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:for (row <- examples) yield { outcomeOf { row._1 should not equal (7) } }
Note: the
outcomeOfmethod, contained in theOutcomeOftrait, will execute the supplied code (a by-name parameter) and transform it to anOutcome. If no exception is thrown by the code,outcomeOfwill result in aSucceeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail,outcomeOfwill result in in aFailedinstance containing that exception. For example, the previous for expression would give you:Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
This shows that all the property checks succeeded, except for the one at index 7.
- class TableFor13[A, B, C, D, E, F, G, H, I, J, K, L, M] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M)] with IndexedSeqOps[(A, B, C, D, E, F, G, H, I, J, K, L, M), IndexedSeq, IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M)]]
A table with 13 columns.
A table with 13 columns.
For an introduction to using tables, see the documentation for trait TableDrivenPropertyChecks.
This table is a sequence of
Tuple13objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.A handy way to create a
TableFor13is via anapplyfactory method in theTablesingleton object provided by theTablestrait. Here's an example:val examples = Table( ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"), * ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), ( 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2), ( 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3), ( 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), ( 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5), ( 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6), ( 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7), ( 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8), ( 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9) )
Because you supplied 13 members in each tuple, the type you'll get back will be a
TableFor13.The table provides an
applymethod that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. Theapplymethod will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple 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 theapplymethod will complete abruptly with aTableDrivenPropertyCheckFailedExceptionthat wraps the exception thrown by the supplied property function.The usual way you'd invoke the
applymethod that checks a property is via aforAllmethod provided by traitTableDrivenPropertyChecks. TheforAllmethod takes aTableFor13as its first argument, then in a curried argument list takes the property check function. It invokesapplyon theTableFor13, passing in the property check function. Here's an example:forAll (examples) { (a, b, c, d, e, f, g, h, i, j, k, l, m) => a + b + c + d + e + f + g + h + i + j + k + l + m should equal (a * 13) }Because
TableFor13is aSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M)], you can use it as aSeq. For example, here's how you could get a sequence ofOutcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:for (row <- examples) yield { outcomeOf { row._1 should not equal (7) } }
Note: the
outcomeOfmethod, contained in theOutcomeOftrait, will execute the supplied code (a by-name parameter) and transform it to anOutcome. If no exception is thrown by the code,outcomeOfwill result in aSucceeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail,outcomeOfwill result in in aFailedinstance containing that exception. For example, the previous for expression would give you:Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
This shows that all the property checks succeeded, except for the one at index 7.
- class TableFor14[A, B, C, D, E, F, G, H, I, J, K, L, M, N] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N)] with IndexedSeqOps[(A, B, C, D, E, F, G, H, I, J, K, L, M, N), IndexedSeq, IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N)]]
A table with 14 columns.
A table with 14 columns.
For an introduction to using tables, see the documentation for trait TableDrivenPropertyChecks.
This table is a sequence of
Tuple14objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.A handy way to create a
TableFor14is via anapplyfactory method in theTablesingleton object provided by theTablestrait. Here's an example:val examples = Table( ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n"), * ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), ( 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2), ( 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3), ( 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), ( 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5), ( 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6), ( 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7), ( 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8), ( 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9) )
Because you supplied 14 members in each tuple, the type you'll get back will be a
TableFor14.The table provides an
applymethod that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. Theapplymethod will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple 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 theapplymethod will complete abruptly with aTableDrivenPropertyCheckFailedExceptionthat wraps the exception thrown by the supplied property function.The usual way you'd invoke the
applymethod that checks a property is via aforAllmethod provided by traitTableDrivenPropertyChecks. TheforAllmethod takes aTableFor14as its first argument, then in a curried argument list takes the property check function. It invokesapplyon theTableFor14, passing in the property check function. Here's an example:forAll (examples) { (a, b, c, d, e, f, g, h, i, j, k, l, m, n) => a + b + c + d + e + f + g + h + i + j + k + l + m + n should equal (a * 14) }Because
TableFor14is aSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N)], you can use it as aSeq. For example, here's how you could get a sequence ofOutcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:for (row <- examples) yield { outcomeOf { row._1 should not equal (7) } }
Note: the
outcomeOfmethod, contained in theOutcomeOftrait, will execute the supplied code (a by-name parameter) and transform it to anOutcome. If no exception is thrown by the code,outcomeOfwill result in aSucceeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail,outcomeOfwill result in in aFailedinstance containing that exception. For example, the previous for expression would give you:Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
This shows that all the property checks succeeded, except for the one at index 7.
- class TableFor15[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)] with IndexedSeqOps[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O), IndexedSeq, IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)]]
A table with 15 columns.
A table with 15 columns.
For an introduction to using tables, see the documentation for trait TableDrivenPropertyChecks.
This table is a sequence of
Tuple15objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.A handy way to create a
TableFor15is via anapplyfactory method in theTablesingleton object provided by theTablestrait. Here's an example:val examples = Table( ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o"), * ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), ( 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2), ( 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3), ( 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), ( 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5), ( 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6), ( 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7), ( 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8), ( 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9) )
Because you supplied 15 members in each tuple, the type you'll get back will be a
TableFor15.The table provides an
applymethod that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. Theapplymethod will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple 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 theapplymethod will complete abruptly with aTableDrivenPropertyCheckFailedExceptionthat wraps the exception thrown by the supplied property function.The usual way you'd invoke the
applymethod that checks a property is via aforAllmethod provided by traitTableDrivenPropertyChecks. TheforAllmethod takes aTableFor15as its first argument, then in a curried argument list takes the property check function. It invokesapplyon theTableFor15, passing in the property check function. Here's an example:forAll (examples) { (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) => a + b + c + d + e + f + g + h + i + j + k + l + m + n + o should equal (a * 15) }Because
TableFor15is aSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)], you can use it as aSeq. For example, here's how you could get a sequence ofOutcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:for (row <- examples) yield { outcomeOf { row._1 should not equal (7) } }
Note: the
outcomeOfmethod, contained in theOutcomeOftrait, will execute the supplied code (a by-name parameter) and transform it to anOutcome. If no exception is thrown by the code,outcomeOfwill result in aSucceeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail,outcomeOfwill result in in aFailedinstance containing that exception. For example, the previous for expression would give you:Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
This shows that all the property checks succeeded, except for the one at index 7.
- class TableFor16[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)] with IndexedSeqOps[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P), IndexedSeq, IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)]]
A table with 16 columns.
A table with 16 columns.
For an introduction to using tables, see the documentation for trait TableDrivenPropertyChecks.
This table is a sequence of
Tuple16objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.A handy way to create a
TableFor16is via anapplyfactory method in theTablesingleton object provided by theTablestrait. Here's an example:val examples = Table( ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"), * ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), ( 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2), ( 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3), ( 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), ( 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5), ( 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6), ( 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7), ( 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8), ( 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9) )
Because you supplied 16 members in each tuple, the type you'll get back will be a
TableFor16.The table provides an
applymethod that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. Theapplymethod will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple 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 theapplymethod will complete abruptly with aTableDrivenPropertyCheckFailedExceptionthat wraps the exception thrown by the supplied property function.The usual way you'd invoke the
applymethod that checks a property is via aforAllmethod provided by traitTableDrivenPropertyChecks. TheforAllmethod takes aTableFor16as its first argument, then in a curried argument list takes the property check function. It invokesapplyon theTableFor16, passing in the property check function. Here's an example:forAll (examples) { (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) => a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p should equal (a * 16) }Because
TableFor16is aSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)], you can use it as aSeq. For example, here's how you could get a sequence ofOutcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:for (row <- examples) yield { outcomeOf { row._1 should not equal (7) } }
Note: the
outcomeOfmethod, contained in theOutcomeOftrait, will execute the supplied code (a by-name parameter) and transform it to anOutcome. If no exception is thrown by the code,outcomeOfwill result in aSucceeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail,outcomeOfwill result in in aFailedinstance containing that exception. For example, the previous for expression would give you:Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
This shows that all the property checks succeeded, except for the one at index 7.
- class TableFor17[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q)] with IndexedSeqOps[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q), IndexedSeq, IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q)]]
A table with 17 columns.
A table with 17 columns.
For an introduction to using tables, see the documentation for trait TableDrivenPropertyChecks.
This table is a sequence of
Tuple17objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.A handy way to create a
TableFor17is via anapplyfactory method in theTablesingleton object provided by theTablestrait. Here's an example:val examples = Table( ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q"), * ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), ( 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2), ( 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3), ( 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), ( 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5), ( 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6), ( 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7), ( 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8), ( 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9) )
Because you supplied 17 members in each tuple, the type you'll get back will be a
TableFor17.The table provides an
applymethod that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. Theapplymethod will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple 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 theapplymethod will complete abruptly with aTableDrivenPropertyCheckFailedExceptionthat wraps the exception thrown by the supplied property function.The usual way you'd invoke the
applymethod that checks a property is via aforAllmethod provided by traitTableDrivenPropertyChecks. TheforAllmethod takes aTableFor17as its first argument, then in a curried argument list takes the property check function. It invokesapplyon theTableFor17, passing in the property check function. Here's an example:forAll (examples) { (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) => a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + q should equal (a * 17) }Because
TableFor17is aSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q)], you can use it as aSeq. For example, here's how you could get a sequence ofOutcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:for (row <- examples) yield { outcomeOf { row._1 should not equal (7) } }
Note: the
outcomeOfmethod, contained in theOutcomeOftrait, will execute the supplied code (a by-name parameter) and transform it to anOutcome. If no exception is thrown by the code,outcomeOfwill result in aSucceeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail,outcomeOfwill result in in aFailedinstance containing that exception. For example, the previous for expression would give you:Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
This shows that all the property checks succeeded, except for the one at index 7.
- class TableFor18[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R)] with IndexedSeqOps[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R), IndexedSeq, IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R)]]
A table with 18 columns.
A table with 18 columns.
For an introduction to using tables, see the documentation for trait TableDrivenPropertyChecks.
This table is a sequence of
Tuple18objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.A handy way to create a
TableFor18is via anapplyfactory method in theTablesingleton object provided by theTablestrait. Here's an example:val examples = Table( ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r"), * ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), ( 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2), ( 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3), ( 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), ( 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5), ( 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6), ( 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7), ( 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8), ( 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9) )
Because you supplied 18 members in each tuple, the type you'll get back will be a
TableFor18.The table provides an
applymethod that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. Theapplymethod will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple 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 theapplymethod will complete abruptly with aTableDrivenPropertyCheckFailedExceptionthat wraps the exception thrown by the supplied property function.The usual way you'd invoke the
applymethod that checks a property is via aforAllmethod provided by traitTableDrivenPropertyChecks. TheforAllmethod takes aTableFor18as its first argument, then in a curried argument list takes the property check function. It invokesapplyon theTableFor18, passing in the property check function. Here's an example:forAll (examples) { (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r) => a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r should equal (a * 18) }Because
TableFor18is aSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R)], you can use it as aSeq. For example, here's how you could get a sequence ofOutcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:for (row <- examples) yield { outcomeOf { row._1 should not equal (7) } }
Note: the
outcomeOfmethod, contained in theOutcomeOftrait, will execute the supplied code (a by-name parameter) and transform it to anOutcome. If no exception is thrown by the code,outcomeOfwill result in aSucceeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail,outcomeOfwill result in in aFailedinstance containing that exception. For example, the previous for expression would give you:Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
This shows that all the property checks succeeded, except for the one at index 7.
- class TableFor19[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S)] with IndexedSeqOps[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S), IndexedSeq, IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S)]]
A table with 19 columns.
A table with 19 columns.
For an introduction to using tables, see the documentation for trait TableDrivenPropertyChecks.
This table is a sequence of
Tuple19objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.A handy way to create a
TableFor19is via anapplyfactory method in theTablesingleton object provided by theTablestrait. Here's an example:val examples = Table( ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s"), * ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), ( 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2), ( 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3), ( 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), ( 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5), ( 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6), ( 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7), ( 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8), ( 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9) )
Because you supplied 19 members in each tuple, the type you'll get back will be a
TableFor19.The table provides an
applymethod that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. Theapplymethod will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple 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 theapplymethod will complete abruptly with aTableDrivenPropertyCheckFailedExceptionthat wraps the exception thrown by the supplied property function.The usual way you'd invoke the
applymethod that checks a property is via aforAllmethod provided by traitTableDrivenPropertyChecks. TheforAllmethod takes aTableFor19as its first argument, then in a curried argument list takes the property check function. It invokesapplyon theTableFor19, passing in the property check function. Here's an example:forAll (examples) { (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s) => a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r + s should equal (a * 19) }Because
TableFor19is aSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S)], you can use it as aSeq. For example, here's how you could get a sequence ofOutcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:for (row <- examples) yield { outcomeOf { row._1 should not equal (7) } }
Note: the
outcomeOfmethod, contained in theOutcomeOftrait, will execute the supplied code (a by-name parameter) and transform it to anOutcome. If no exception is thrown by the code,outcomeOfwill result in aSucceeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail,outcomeOfwill result in in aFailedinstance containing that exception. For example, the previous for expression would give you:Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
This shows that all the property checks succeeded, except for the one at index 7.
- class TableFor2[A, B] extends IndexedSeq[(A, B)] with IndexedSeqOps[(A, B), IndexedSeq, IndexedSeq[(A, B)]]
A table with 2 columns.
A table with 2 columns.
For an introduction to using tables, see the documentation for trait TableDrivenPropertyChecks.
This table is a sequence of
Tuple2objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.A handy way to create a
TableFor2is via anapplyfactory method in theTablesingleton object provided by theTablestrait. Here's an example:val examples = Table( ("a", "b"), * ( 0, 0), ( 1, 1), ( 2, 2), ( 3, 3), ( 4, 4), ( 5, 5), ( 6, 6), ( 7, 7), ( 8, 8), ( 9, 9) )
Because you supplied 2 members in each tuple, the type you'll get back will be a
TableFor2.The table provides an
applymethod that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. Theapplymethod will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple 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 theapplymethod will complete abruptly with aTableDrivenPropertyCheckFailedExceptionthat wraps the exception thrown by the supplied property function.The usual way you'd invoke the
applymethod that checks a property is via aforAllmethod provided by traitTableDrivenPropertyChecks. TheforAllmethod takes aTableFor2as its first argument, then in a curried argument list takes the property check function. It invokesapplyon theTableFor2, passing in the property check function. Here's an example:forAll (examples) { (a, b) => a + b should equal (a * 2) }Because
TableFor2is aSeq[(A, B)], you can use it as aSeq. For example, here's how you could get a sequence ofOutcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:for (row <- examples) yield { outcomeOf { row._1 should not equal (7) } }
Note: the
outcomeOfmethod, contained in theOutcomeOftrait, will execute the supplied code (a by-name parameter) and transform it to anOutcome. If no exception is thrown by the code,outcomeOfwill result in aSucceeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail,outcomeOfwill result in in aFailedinstance containing that exception. For example, the previous for expression would give you:Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
This shows that all the property checks succeeded, except for the one at index 7.
- class TableFor20[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T)] with IndexedSeqOps[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T), IndexedSeq, IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T)]]
A table with 20 columns.
A table with 20 columns.
For an introduction to using tables, see the documentation for trait TableDrivenPropertyChecks.
This table is a sequence of
Tuple20objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.A handy way to create a
TableFor20is via anapplyfactory method in theTablesingleton object provided by theTablestrait. Here's an example:val examples = Table( ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t"), * ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), ( 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2), ( 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3), ( 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), ( 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5), ( 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6), ( 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7), ( 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8), ( 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9) )
Because you supplied 20 members in each tuple, the type you'll get back will be a
TableFor20.The table provides an
applymethod that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. Theapplymethod will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple 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 theapplymethod will complete abruptly with aTableDrivenPropertyCheckFailedExceptionthat wraps the exception thrown by the supplied property function.The usual way you'd invoke the
applymethod that checks a property is via aforAllmethod provided by traitTableDrivenPropertyChecks. TheforAllmethod takes aTableFor20as its first argument, then in a curried argument list takes the property check function. It invokesapplyon theTableFor20, passing in the property check function. Here's an example:forAll (examples) { (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t) => a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r + s + t should equal (a * 20) }Because
TableFor20is aSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T)], you can use it as aSeq. For example, here's how you could get a sequence ofOutcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:for (row <- examples) yield { outcomeOf { row._1 should not equal (7) } }
Note: the
outcomeOfmethod, contained in theOutcomeOftrait, will execute the supplied code (a by-name parameter) and transform it to anOutcome. If no exception is thrown by the code,outcomeOfwill result in aSucceeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail,outcomeOfwill result in in aFailedinstance containing that exception. For example, the previous for expression would give you:Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
This shows that all the property checks succeeded, except for the one at index 7.
- class TableFor21[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U)] with IndexedSeqOps[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U), IndexedSeq, IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U)]]
A table with 21 columns.
A table with 21 columns.
For an introduction to using tables, see the documentation for trait TableDrivenPropertyChecks.
This table is a sequence of
Tuple21objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.A handy way to create a
TableFor21is via anapplyfactory method in theTablesingleton object provided by theTablestrait. Here's an example:val examples = Table( ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u"), * ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), ( 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2), ( 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3), ( 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), ( 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5), ( 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6), ( 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7), ( 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8), ( 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9) )
Because you supplied 21 members in each tuple, the type you'll get back will be a
TableFor21.The table provides an
applymethod that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. Theapplymethod will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple 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 theapplymethod will complete abruptly with aTableDrivenPropertyCheckFailedExceptionthat wraps the exception thrown by the supplied property function.The usual way you'd invoke the
applymethod that checks a property is via aforAllmethod provided by traitTableDrivenPropertyChecks. TheforAllmethod takes aTableFor21as its first argument, then in a curried argument list takes the property check function. It invokesapplyon theTableFor21, passing in the property check function. Here's an example:forAll (examples) { (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u) => a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r + s + t + u should equal (a * 21) }Because
TableFor21is aSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U)], you can use it as aSeq. For example, here's how you could get a sequence ofOutcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:for (row <- examples) yield { outcomeOf { row._1 should not equal (7) } }
Note: the
outcomeOfmethod, contained in theOutcomeOftrait, will execute the supplied code (a by-name parameter) and transform it to anOutcome. If no exception is thrown by the code,outcomeOfwill result in aSucceeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail,outcomeOfwill result in in aFailedinstance containing that exception. For example, the previous for expression would give you:Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
This shows that all the property checks succeeded, except for the one at index 7.
- class TableFor22[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V)] with IndexedSeqOps[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V), IndexedSeq, IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V)]]
A table with 22 columns.
A table with 22 columns.
For an introduction to using tables, see the documentation for trait TableDrivenPropertyChecks.
This table is a sequence of
Tuple22objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.A handy way to create a
TableFor22is via anapplyfactory method in theTablesingleton object provided by theTablestrait. Here's an example:val examples = Table( ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v"), * ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), ( 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2), ( 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3), ( 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), ( 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5), ( 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6), ( 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7), ( 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8), ( 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9) )
Because you supplied 22 members in each tuple, the type you'll get back will be a
TableFor22.The table provides an
applymethod that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. Theapplymethod will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple 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 theapplymethod will complete abruptly with aTableDrivenPropertyCheckFailedExceptionthat wraps the exception thrown by the supplied property function.The usual way you'd invoke the
applymethod that checks a property is via aforAllmethod provided by traitTableDrivenPropertyChecks. TheforAllmethod takes aTableFor22as its first argument, then in a curried argument list takes the property check function. It invokesapplyon theTableFor22, passing in the property check function. Here's an example:forAll (examples) { (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v) => a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r + s + t + u + v should equal (a * 22) }Because
TableFor22is aSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V)], you can use it as aSeq. For example, here's how you could get a sequence ofOutcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:for (row <- examples) yield { outcomeOf { row._1 should not equal (7) } }
Note: the
outcomeOfmethod, contained in theOutcomeOftrait, will execute the supplied code (a by-name parameter) and transform it to anOutcome. If no exception is thrown by the code,outcomeOfwill result in aSucceeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail,outcomeOfwill result in in aFailedinstance containing that exception. For example, the previous for expression would give you:Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
This shows that all the property checks succeeded, except for the one at index 7.
- class TableFor3[A, B, C] extends IndexedSeq[(A, B, C)] with IndexedSeqOps[(A, B, C), IndexedSeq, IndexedSeq[(A, B, C)]]
A table with 3 columns.
A table with 3 columns.
For an introduction to using tables, see the documentation for trait TableDrivenPropertyChecks.
This table is a sequence of
Tuple3objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.A handy way to create a
TableFor3is via anapplyfactory method in theTablesingleton object provided by theTablestrait. Here's an example:val examples = Table( ("a", "b", "c"), * ( 0, 0, 0), ( 1, 1, 1), ( 2, 2, 2), ( 3, 3, 3), ( 4, 4, 4), ( 5, 5, 5), ( 6, 6, 6), ( 7, 7, 7), ( 8, 8, 8), ( 9, 9, 9) )
Because you supplied 3 members in each tuple, the type you'll get back will be a
TableFor3.The table provides an
applymethod that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. Theapplymethod will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple 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 theapplymethod will complete abruptly with aTableDrivenPropertyCheckFailedExceptionthat wraps the exception thrown by the supplied property function.The usual way you'd invoke the
applymethod that checks a property is via aforAllmethod provided by traitTableDrivenPropertyChecks. TheforAllmethod takes aTableFor3as its first argument, then in a curried argument list takes the property check function. It invokesapplyon theTableFor3, passing in the property check function. Here's an example:forAll (examples) { (a, b, c) => a + b + c should equal (a * 3) }Because
TableFor3is aSeq[(A, B, C)], you can use it as aSeq. For example, here's how you could get a sequence ofOutcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:for (row <- examples) yield { outcomeOf { row._1 should not equal (7) } }
Note: the
outcomeOfmethod, contained in theOutcomeOftrait, will execute the supplied code (a by-name parameter) and transform it to anOutcome. If no exception is thrown by the code,outcomeOfwill result in aSucceeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail,outcomeOfwill result in in aFailedinstance containing that exception. For example, the previous for expression would give you:Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
This shows that all the property checks succeeded, except for the one at index 7.
- class TableFor4[A, B, C, D] extends IndexedSeq[(A, B, C, D)] with IndexedSeqOps[(A, B, C, D), IndexedSeq, IndexedSeq[(A, B, C, D)]]
A table with 4 columns.
A table with 4 columns.
For an introduction to using tables, see the documentation for trait TableDrivenPropertyChecks.
This table is a sequence of
Tuple4objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.A handy way to create a
TableFor4is via anapplyfactory method in theTablesingleton object provided by theTablestrait. Here's an example:val examples = Table( ("a", "b", "c", "d"), * ( 0, 0, 0, 0), ( 1, 1, 1, 1), ( 2, 2, 2, 2), ( 3, 3, 3, 3), ( 4, 4, 4, 4), ( 5, 5, 5, 5), ( 6, 6, 6, 6), ( 7, 7, 7, 7), ( 8, 8, 8, 8), ( 9, 9, 9, 9) )
Because you supplied 4 members in each tuple, the type you'll get back will be a
TableFor4.The table provides an
applymethod that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. Theapplymethod will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple 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 theapplymethod will complete abruptly with aTableDrivenPropertyCheckFailedExceptionthat wraps the exception thrown by the supplied property function.The usual way you'd invoke the
applymethod that checks a property is via aforAllmethod provided by traitTableDrivenPropertyChecks. TheforAllmethod takes aTableFor4as its first argument, then in a curried argument list takes the property check function. It invokesapplyon theTableFor4, passing in the property check function. Here's an example:forAll (examples) { (a, b, c, d) => a + b + c + d should equal (a * 4) }Because
TableFor4is aSeq[(A, B, C, D)], you can use it as aSeq. For example, here's how you could get a sequence ofOutcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:for (row <- examples) yield { outcomeOf { row._1 should not equal (7) } }
Note: the
outcomeOfmethod, contained in theOutcomeOftrait, will execute the supplied code (a by-name parameter) and transform it to anOutcome. If no exception is thrown by the code,outcomeOfwill result in aSucceeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail,outcomeOfwill result in in aFailedinstance containing that exception. For example, the previous for expression would give you:Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
This shows that all the property checks succeeded, except for the one at index 7.
- class TableFor5[A, B, C, D, E] extends IndexedSeq[(A, B, C, D, E)] with IndexedSeqOps[(A, B, C, D, E), IndexedSeq, IndexedSeq[(A, B, C, D, E)]]
A table with 5 columns.
A table with 5 columns.
For an introduction to using tables, see the documentation for trait TableDrivenPropertyChecks.
This table is a sequence of
Tuple5objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.A handy way to create a
TableFor5is via anapplyfactory method in theTablesingleton object provided by theTablestrait. Here's an example:val examples = Table( ("a", "b", "c", "d", "e"), * ( 0, 0, 0, 0, 0), ( 1, 1, 1, 1, 1), ( 2, 2, 2, 2, 2), ( 3, 3, 3, 3, 3), ( 4, 4, 4, 4, 4), ( 5, 5, 5, 5, 5), ( 6, 6, 6, 6, 6), ( 7, 7, 7, 7, 7), ( 8, 8, 8, 8, 8), ( 9, 9, 9, 9, 9) )
Because you supplied 5 members in each tuple, the type you'll get back will be a
TableFor5.The table provides an
applymethod that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. Theapplymethod will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple 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 theapplymethod will complete abruptly with aTableDrivenPropertyCheckFailedExceptionthat wraps the exception thrown by the supplied property function.The usual way you'd invoke the
applymethod that checks a property is via aforAllmethod provided by traitTableDrivenPropertyChecks. TheforAllmethod takes aTableFor5as its first argument, then in a curried argument list takes the property check function. It invokesapplyon theTableFor5, passing in the property check function. Here's an example:forAll (examples) { (a, b, c, d, e) => a + b + c + d + e should equal (a * 5) }Because
TableFor5is aSeq[(A, B, C, D, E)], you can use it as aSeq. For example, here's how you could get a sequence ofOutcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:for (row <- examples) yield { outcomeOf { row._1 should not equal (7) } }
Note: the
outcomeOfmethod, contained in theOutcomeOftrait, will execute the supplied code (a by-name parameter) and transform it to anOutcome. If no exception is thrown by the code,outcomeOfwill result in aSucceeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail,outcomeOfwill result in in aFailedinstance containing that exception. For example, the previous for expression would give you:Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
This shows that all the property checks succeeded, except for the one at index 7.
- class TableFor6[A, B, C, D, E, F] extends IndexedSeq[(A, B, C, D, E, F)] with IndexedSeqOps[(A, B, C, D, E, F), IndexedSeq, IndexedSeq[(A, B, C, D, E, F)]]
A table with 6 columns.
A table with 6 columns.
For an introduction to using tables, see the documentation for trait TableDrivenPropertyChecks.
This table is a sequence of
Tuple6objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.A handy way to create a
TableFor6is via anapplyfactory method in theTablesingleton object provided by theTablestrait. Here's an example:val examples = Table( ("a", "b", "c", "d", "e", "f"), * ( 0, 0, 0, 0, 0, 0), ( 1, 1, 1, 1, 1, 1), ( 2, 2, 2, 2, 2, 2), ( 3, 3, 3, 3, 3, 3), ( 4, 4, 4, 4, 4, 4), ( 5, 5, 5, 5, 5, 5), ( 6, 6, 6, 6, 6, 6), ( 7, 7, 7, 7, 7, 7), ( 8, 8, 8, 8, 8, 8), ( 9, 9, 9, 9, 9, 9) )
Because you supplied 6 members in each tuple, the type you'll get back will be a
TableFor6.The table provides an
applymethod that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. Theapplymethod will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple 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 theapplymethod will complete abruptly with aTableDrivenPropertyCheckFailedExceptionthat wraps the exception thrown by the supplied property function.The usual way you'd invoke the
applymethod that checks a property is via aforAllmethod provided by traitTableDrivenPropertyChecks. TheforAllmethod takes aTableFor6as its first argument, then in a curried argument list takes the property check function. It invokesapplyon theTableFor6, passing in the property check function. Here's an example:forAll (examples) { (a, b, c, d, e, f) => a + b + c + d + e + f should equal (a * 6) }Because
TableFor6is aSeq[(A, B, C, D, E, F)], you can use it as aSeq. For example, here's how you could get a sequence ofOutcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:for (row <- examples) yield { outcomeOf { row._1 should not equal (7) } }
Note: the
outcomeOfmethod, contained in theOutcomeOftrait, will execute the supplied code (a by-name parameter) and transform it to anOutcome. If no exception is thrown by the code,outcomeOfwill result in aSucceeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail,outcomeOfwill result in in aFailedinstance containing that exception. For example, the previous for expression would give you:Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
This shows that all the property checks succeeded, except for the one at index 7.
- class TableFor7[A, B, C, D, E, F, G] extends IndexedSeq[(A, B, C, D, E, F, G)] with IndexedSeqOps[(A, B, C, D, E, F, G), IndexedSeq, IndexedSeq[(A, B, C, D, E, F, G)]]
A table with 7 columns.
A table with 7 columns.
For an introduction to using tables, see the documentation for trait TableDrivenPropertyChecks.
This table is a sequence of
Tuple7objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.A handy way to create a
TableFor7is via anapplyfactory method in theTablesingleton object provided by theTablestrait. Here's an example:val examples = Table( ("a", "b", "c", "d", "e", "f", "g"), * ( 0, 0, 0, 0, 0, 0, 0), ( 1, 1, 1, 1, 1, 1, 1), ( 2, 2, 2, 2, 2, 2, 2), ( 3, 3, 3, 3, 3, 3, 3), ( 4, 4, 4, 4, 4, 4, 4), ( 5, 5, 5, 5, 5, 5, 5), ( 6, 6, 6, 6, 6, 6, 6), ( 7, 7, 7, 7, 7, 7, 7), ( 8, 8, 8, 8, 8, 8, 8), ( 9, 9, 9, 9, 9, 9, 9) )
Because you supplied 7 members in each tuple, the type you'll get back will be a
TableFor7.The table provides an
applymethod that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. Theapplymethod will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple 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 theapplymethod will complete abruptly with aTableDrivenPropertyCheckFailedExceptionthat wraps the exception thrown by the supplied property function.The usual way you'd invoke the
applymethod that checks a property is via aforAllmethod provided by traitTableDrivenPropertyChecks. TheforAllmethod takes aTableFor7as its first argument, then in a curried argument list takes the property check function. It invokesapplyon theTableFor7, passing in the property check function. Here's an example:forAll (examples) { (a, b, c, d, e, f, g) => a + b + c + d + e + f + g should equal (a * 7) }Because
TableFor7is aSeq[(A, B, C, D, E, F, G)], you can use it as aSeq. For example, here's how you could get a sequence ofOutcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:for (row <- examples) yield { outcomeOf { row._1 should not equal (7) } }
Note: the
outcomeOfmethod, contained in theOutcomeOftrait, will execute the supplied code (a by-name parameter) and transform it to anOutcome. If no exception is thrown by the code,outcomeOfwill result in aSucceeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail,outcomeOfwill result in in aFailedinstance containing that exception. For example, the previous for expression would give you:Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
This shows that all the property checks succeeded, except for the one at index 7.
- class TableFor8[A, B, C, D, E, F, G, H] extends IndexedSeq[(A, B, C, D, E, F, G, H)] with IndexedSeqOps[(A, B, C, D, E, F, G, H), IndexedSeq, IndexedSeq[(A, B, C, D, E, F, G, H)]]
A table with 8 columns.
A table with 8 columns.
For an introduction to using tables, see the documentation for trait TableDrivenPropertyChecks.
This table is a sequence of
Tuple8objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.A handy way to create a
TableFor8is via anapplyfactory method in theTablesingleton object provided by theTablestrait. Here's an example:val examples = Table( ("a", "b", "c", "d", "e", "f", "g", "h"), * ( 0, 0, 0, 0, 0, 0, 0, 0), ( 1, 1, 1, 1, 1, 1, 1, 1), ( 2, 2, 2, 2, 2, 2, 2, 2), ( 3, 3, 3, 3, 3, 3, 3, 3), ( 4, 4, 4, 4, 4, 4, 4, 4), ( 5, 5, 5, 5, 5, 5, 5, 5), ( 6, 6, 6, 6, 6, 6, 6, 6), ( 7, 7, 7, 7, 7, 7, 7, 7), ( 8, 8, 8, 8, 8, 8, 8, 8), ( 9, 9, 9, 9, 9, 9, 9, 9) )
Because you supplied 8 members in each tuple, the type you'll get back will be a
TableFor8.The table provides an
applymethod that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. Theapplymethod will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple 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 theapplymethod will complete abruptly with aTableDrivenPropertyCheckFailedExceptionthat wraps the exception thrown by the supplied property function.The usual way you'd invoke the
applymethod that checks a property is via aforAllmethod provided by traitTableDrivenPropertyChecks. TheforAllmethod takes aTableFor8as its first argument, then in a curried argument list takes the property check function. It invokesapplyon theTableFor8, passing in the property check function. Here's an example:forAll (examples) { (a, b, c, d, e, f, g, h) => a + b + c + d + e + f + g + h should equal (a * 8) }Because
TableFor8is aSeq[(A, B, C, D, E, F, G, H)], you can use it as aSeq. For example, here's how you could get a sequence ofOutcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:for (row <- examples) yield { outcomeOf { row._1 should not equal (7) } }
Note: the
outcomeOfmethod, contained in theOutcomeOftrait, will execute the supplied code (a by-name parameter) and transform it to anOutcome. If no exception is thrown by the code,outcomeOfwill result in aSucceeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail,outcomeOfwill result in in aFailedinstance containing that exception. For example, the previous for expression would give you:Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
This shows that all the property checks succeeded, except for the one at index 7.
- class TableFor9[A, B, C, D, E, F, G, H, I] extends IndexedSeq[(A, B, C, D, E, F, G, H, I)] with IndexedSeqOps[(A, B, C, D, E, F, G, H, I), IndexedSeq, IndexedSeq[(A, B, C, D, E, F, G, H, I)]]
A table with 9 columns.
A table with 9 columns.
For an introduction to using tables, see the documentation for trait TableDrivenPropertyChecks.
This table is a sequence of
Tuple9objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.A handy way to create a
TableFor9is via anapplyfactory method in theTablesingleton object provided by theTablestrait. Here's an example:val examples = Table( ("a", "b", "c", "d", "e", "f", "g", "h", "i"), * ( 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 1, 1, 1, 1, 1, 1, 1, 1, 1), ( 2, 2, 2, 2, 2, 2, 2, 2, 2), ( 3, 3, 3, 3, 3, 3, 3, 3, 3), ( 4, 4, 4, 4, 4, 4, 4, 4, 4), ( 5, 5, 5, 5, 5, 5, 5, 5, 5), ( 6, 6, 6, 6, 6, 6, 6, 6, 6), ( 7, 7, 7, 7, 7, 7, 7, 7, 7), ( 8, 8, 8, 8, 8, 8, 8, 8, 8), ( 9, 9, 9, 9, 9, 9, 9, 9, 9) )
Because you supplied 9 members in each tuple, the type you'll get back will be a
TableFor9.The table provides an
applymethod that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. Theapplymethod will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple 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 theapplymethod will complete abruptly with aTableDrivenPropertyCheckFailedExceptionthat wraps the exception thrown by the supplied property function.The usual way you'd invoke the
applymethod that checks a property is via aforAllmethod provided by traitTableDrivenPropertyChecks. TheforAllmethod takes aTableFor9as its first argument, then in a curried argument list takes the property check function. It invokesapplyon theTableFor9, passing in the property check function. Here's an example:forAll (examples) { (a, b, c, d, e, f, g, h, i) => a + b + c + d + e + f + g + h + i should equal (a * 9) }Because
TableFor9is aSeq[(A, B, C, D, E, F, G, H, I)], you can use it as aSeq. For example, here's how you could get a sequence ofOutcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:for (row <- examples) yield { outcomeOf { row._1 should not equal (7) } }
Note: the
outcomeOfmethod, contained in theOutcomeOftrait, will execute the supplied code (a by-name parameter) and transform it to anOutcome. If no exception is thrown by the code,outcomeOfwill result in aSucceeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail,outcomeOfwill result in in aFailedinstance containing that exception. For example, the previous for expression would give you:Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
This shows that all the property checks succeeded, except for the one at index 7.
- trait Tables extends AnyRef
Trait containing the
Tableobject, which offers oneapplyfactory method for eachTableForNclass,TableFor1throughTableFor22.Trait containing the
Tableobject, which offers oneapplyfactory method for eachTableForNclass,TableFor1throughTableFor22.For an introduction to using tables, see the documentation for trait TableDrivenPropertyChecks.
- trait Whenever extends AnyRef
Trait that contains the
wheneverclause that can be used in table- or generator-driven property checks.
Value Members
- object Configuration extends Configuration
Companion object that facilitates the importing of
Configurationmembers as an alternative to mixing it in.Companion object that facilitates the importing of
Configurationmembers as an alternative to mixing it in. One use case is to importConfigurationmembers so you can use them in the Scala interpreter. - object TableDrivenPropertyChecks extends TableDrivenPropertyChecks
- object TableFor1
Companion object for class
TableFor1that provides an implicitcanBuildFrommethod that enables higher order functions defined onTableFor1to return anotherTableFor1. - object TableFor10
Companion object for class
TableFor10that provides an implicitcanBuildFrommethod that enables higher order functions defined onTableFor10to return anotherTableFor10. - object TableFor11
Companion object for class
TableFor11that provides an implicitcanBuildFrommethod that enables higher order functions defined onTableFor11to return anotherTableFor11. - object TableFor12
Companion object for class
TableFor12that provides an implicitcanBuildFrommethod that enables higher order functions defined onTableFor12to return anotherTableFor12. - object TableFor13
Companion object for class
TableFor13that provides an implicitcanBuildFrommethod that enables higher order functions defined onTableFor13to return anotherTableFor13. - object TableFor14
Companion object for class
TableFor14that provides an implicitcanBuildFrommethod that enables higher order functions defined onTableFor14to return anotherTableFor14. - object TableFor15
Companion object for class
TableFor15that provides an implicitcanBuildFrommethod that enables higher order functions defined onTableFor15to return anotherTableFor15. - object TableFor16
Companion object for class
TableFor16that provides an implicitcanBuildFrommethod that enables higher order functions defined onTableFor16to return anotherTableFor16. - object TableFor17
Companion object for class
TableFor17that provides an implicitcanBuildFrommethod that enables higher order functions defined onTableFor17to return anotherTableFor17. - object TableFor18
Companion object for class
TableFor18that provides an implicitcanBuildFrommethod that enables higher order functions defined onTableFor18to return anotherTableFor18. - object TableFor19
Companion object for class
TableFor19that provides an implicitcanBuildFrommethod that enables higher order functions defined onTableFor19to return anotherTableFor19. - object TableFor2
Companion object for class
TableFor2that provides an implicitcanBuildFrommethod that enables higher order functions defined onTableFor2to return anotherTableFor2. - object TableFor20
Companion object for class
TableFor20that provides an implicitcanBuildFrommethod that enables higher order functions defined onTableFor20to return anotherTableFor20. - object TableFor21
Companion object for class
TableFor21that provides an implicitcanBuildFrommethod that enables higher order functions defined onTableFor21to return anotherTableFor21. - object TableFor22
Companion object for class
TableFor22that provides an implicitcanBuildFrommethod that enables higher order functions defined onTableFor22to return anotherTableFor22. - object TableFor3
Companion object for class
TableFor3that provides an implicitcanBuildFrommethod that enables higher order functions defined onTableFor3to return anotherTableFor3. - object TableFor4
Companion object for class
TableFor4that provides an implicitcanBuildFrommethod that enables higher order functions defined onTableFor4to return anotherTableFor4. - object TableFor5
Companion object for class
TableFor5that provides an implicitcanBuildFrommethod that enables higher order functions defined onTableFor5to return anotherTableFor5. - object TableFor6
Companion object for class
TableFor6that provides an implicitcanBuildFrommethod that enables higher order functions defined onTableFor6to return anotherTableFor6. - object TableFor7
Companion object for class
TableFor7that provides an implicitcanBuildFrommethod that enables higher order functions defined onTableFor7to return anotherTableFor7. - object TableFor8
Companion object for class
TableFor8that provides an implicitcanBuildFrommethod that enables higher order functions defined onTableFor8to return anotherTableFor8. - object TableFor9
Companion object for class
TableFor9that provides an implicitcanBuildFrommethod that enables higher order functions defined onTableFor9to return anotherTableFor9. - object Tables extends Tables
Companion object that facilitates the importing of
Tablesmembers as an alternative to mixing it in.Companion object that facilitates the importing of
Tablesmembers as an alternative to mixing it in. One use case is to importTablesmembers so you can use them in the Scala interpreter:Welcome to Scala version 2.8.0.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_22). Type in expressions to have them evaluated. Type :help for more information. scala> import org.scalatest.prop.Tables._ import org.scalatest.prop.Tables._ scala> val examples = | Table( | ("a", "b"), | ( 1, 2), | ( 3, 4) | ) examples: org.scalatest.prop.TableFor2[Int,Int] = TableFor2((1,2), (3,4))