Compares this Ordinal with the passed Ordinal for order.
Compares this Ordinal with the passed Ordinal for order. If this object is "less than" (ordered before)
the passed object, compare will return a negative integer. If this class is "greater than" (ordered after)
the passed object, compare will return a positive integer. Otherwise, this Ordinal is equal to
the passed object, and compare will return 0.
a negative integer, 0, or positive integer indicating this Ordinal is less than, equal to, or greater than the passed Ordinal.
Indicates whether the passed object is equal to this one.
Indicates whether the passed object is equal to this one.
true if the passed object is equal to this one
Returns a hash code value for this object.
Returns a hash code value for this object.
a hash code for this object
Construct the next Ordinal for the current suite or other entity, such as a runner.
Construct two new Ordinals, one for a new Suite about to be executed and
one for the current Suite or other entity, such as a runner.
Construct two new Ordinals, one for a new Suite about to be executed and
one for the current Suite or other entity, such as a runner. The Ordinal
for the new Suite is the first (_1) element in the tuple:
val (nextOrdinalForNewSuite, nextOrdinalForThisSuite) currentOrdinal.nextNewOldPair
The reason the next Ordinal for the new Suite is first is because it will
be ordered before the next Ordinal for the current Suite (or other
entity such as a runner). In fact, any event reported within the context of the new Suite or
its nested Suites will be ordered before the next Ordinal for the current Suite.
a tuple whose first element is the first Ordinal for the new Suite and whose
second element is the next Ordinal for the current Suite or other entity, such
as a runner.
A number that identifies a particular run
Returns a List[Int] representation of this Ordinal.
Returns a List[Int] representation of this Ordinal. A set of Ordinals will be ordered
in the same order as the set of List[Int]s that are returned by invoking this method on each of the Ordinals.
The first element of the returned List[Int] is the runStamp.
a List[Int] representation of this Ordinal.
Returns a string that includes the integers returned by toList.
Returns a string that includes the integers returned by toList.
Class used to specify a sequential order for events reported during a test run, so they can be arranged in that order in a report even if the events were fired in some other order during concurrent or distributed execution.
An
Ordinalis an immutable object holding a run stamp and a sequence of stamps. The run stamp is an integer that identifies a particular run. All events reported during the same run should share the same run stamp. By contrast, each event reported during a particular run should have a different stamp sequence. One use case for the run stamp is that the initial run from ScalaTest's GUI will have run stamp 0. Subsequent reruns will have run stamps 1, 2, 3, etc., so that reports in the GUI can simply be sorted in "ordinal" order. Another use case is a set of servers used to run multiple tests simultaneously in a distributed fashion. The run stamp can be used to identify the run to which an event belongs.The stamp sequence is designed to allow a sequential order of events to be specified during concurrent execution of ScalaTest suites. ScalaTest's model for concurrent execution is that the suites that make up a run may be executed concurrently, but the tests within a single suite will be executed sequentially. In addition to tests, suites may contain nested suites. The default implementation of
executein classSuitewill first invokerunNestedSuitesand thenrunTests. If noDistributoris passed toexecute, therunNestedSuitesmethod will execute the nested suites sequentially via the same thread that invokedrunNestedSuites. As a result, suites will by default executed in depth first order when executed sequentially. If aDistributoris passed toexecute, therunNestedSuitesmethod will simply put its nested suites into theDistributorand return. Some other threads or processes must then execute those nested suites. Given the default implementations ofexecuteandrunNestedSuitesdescribed here, theOrdinalwill allow the events from a concurrent run to be sorted in the same depth-first order that the events from a corresponding sequential run would arrive.Each event reported during a run should be given a unique
Ordinal. AnOrdinalis required by allEventsubclasses, instances of which are used to send information to thereportfunction passed to aSuite'sexecutemethod. The firstOrdinalfor a run can be produced by passing a run stamp toOrdinal's lone public constructor:The run stamp can be any integer. The
Ordinalcreated in this way can be passed along with the first reported event of the run, such as aRunStartingevent. Thereafter, newOrdinals for the same run can be obtained by calling eithernextornextNewOldPairon the previously obtainedOrdinal. In other words, given anOrdinal, you can obtain the nextOrdinalby invoking one of these two "next" methods on theOrdinalyou have in hand. Before executing a newSuite, thenextNewOldPairmethod should be invoked. This will return two newOrdinals, one for the newSuiteabout to be executed, and one for the currently executing entity (either aSuiteor some sort of test runner). At any other time, the nextOrdinalcan be obtained by simply invokingnexton the currentOrdinal.You can convert an
Ordinalto aListby invokingtoListon it. The resultingListwill contain the run stamp as its first element, and the contents of its stamps sequence as the subsequent elements. The stamps sequence will initially be composed of a single element with the value 0. Thus,toListinvoked on thefirstOrdinalshown above will result in:firstOrdinal.toList // results in: List(99, 0)Each time
nextis invoked, the rightmost integer returned bytoListwill increment:When
nextNewOldPairis invoked the result will be a tuple whose first element is the firstOrdinalfor the newSuiteabout to be executed (for example, a nestedSuiteof the currently executingSuite). The second element is the nextOrdinalfor the currently executingSuiteor other entity:The
toListmethod of theOrdinalfor the new suite starts with the same sequence of elements as theOrdinalfrom which it was created, but has one more element, a 0, appended at the end. Subsequent invocations ofnexton this series ofOrdinals will increment that last element:This behavior allows events fired by
Suiterunning concurrently to be reordered in a pre-determined sequence after all the events have been reported. The ordering of twoOrdinals can be determined by first comparing the first element of theLists obtained by invokingtoListon bothOrdinals. These values represent therunStamp. If one run stamp is a lower number than the other, thatOrdinalcomes first. For example, anOrdinalwith a run stamp of 98 is ordered before anOrdinalwith a run stamp of 99. If the run stamps are equal, the next number in the list is inspected. As with the run stamps, anOrdinalwith a lower number is ordered before anOrdinalwith a higher number. If two corresponding elements are equal, the next pair of elements will be inspected. This will continue no down the length of theLists until a position is found where the element values are not equal, or the end of one or both of theLists are reached. If the twoLists are identical all the way to the end, and bothLists have the same lengths, then theOrdinals are equal. (EqualOrdinals will not happen if correctly used by creating a newOrdinalfor each fired event and each newSuite.). If the twoLists are identical all the way to the end of one, but the otherListis longer (has more elements), then the shorter list is ordered before the longer one.As an example, here are some
OrdinalListforms in order: