Object

scalatutorial.sections

PolymorphicTypes

Related Doc: package sections

Permalink

object PolymorphicTypes extends FlatSpec with ScalaTutorialSection

Linear Supertypes
ScalaTutorialSection, Section, Matchers, Explicitly, MatcherWords, Tolerance, FlatSpec, FlatSpecLike, Documenting, Alerting, Notifying, Informing, CanVerb, MustVerb, ShouldVerb, TestRegistration, TestSuite, Suite, Serializable, Serializable, Assertions, TripleEquals, TripleEqualsSupport, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. PolymorphicTypes
  2. ScalaTutorialSection
  3. Section
  4. Matchers
  5. Explicitly
  6. MatcherWords
  7. Tolerance
  8. FlatSpec
  9. FlatSpecLike
  10. Documenting
  11. Alerting
  12. Notifying
  13. Informing
  14. CanVerb
  15. MustVerb
  16. ShouldVerb
  17. TestRegistration
  18. TestSuite
  19. Suite
  20. Serializable
  21. Serializable
  22. Assertions
  23. TripleEquals
  24. TripleEqualsSupport
  25. AnyRef
  26. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. final class AWord extends AnyRef

    Permalink
    Definition Classes
    Matchers
  2. final class AnWord extends AnyRef

    Permalink
    Definition Classes
    Matchers
  3. sealed class AnyShouldWrapper[T] extends AnyRef

    Permalink
    Definition Classes
    Matchers
  4. class AssertionsHelper extends AnyRef

    Permalink
    Definition Classes
    Assertions
  5. final class BehaviorWord extends AnyRef

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike
  6. class CheckingEqualizer[L] extends AnyRef

    Permalink
    Definition Classes
    TripleEqualsSupport
  7. class DecidedByEquality[A] extends Equality[A]

    Permalink
    Definition Classes
    Explicitly
  8. class DecidedWord extends AnyRef

    Permalink
    Definition Classes
    Explicitly
  9. class DeterminedByEquivalence[T] extends Equivalence[T]

    Permalink
    Definition Classes
    Explicitly
  10. class DeterminedWord extends AnyRef

    Permalink
    Definition Classes
    Explicitly
  11. class Equalizer[L] extends AnyRef

    Permalink
    Definition Classes
    TripleEqualsSupport
  12. final class HavePropertyMatcherGenerator extends AnyRef

    Permalink
    Definition Classes
    Matchers
  13. final class IgnoreVerbString extends AnyRef

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike
  14. final class IgnoreVerbStringTaggedAs extends AnyRef

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike
  15. final class IgnoreWord extends AnyRef

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike
  16. final class InAndIgnoreMethods extends AnyRef

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike
  17. final class InAndIgnoreMethodsAfterTaggedAs extends AnyRef

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike
  18. final class ItVerbString extends AnyRef

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike
  19. final class ItVerbStringTaggedAs extends AnyRef

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike
  20. final class ItWord extends AnyRef

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike
  21. final class KeyWord extends AnyRef

    Permalink
    Definition Classes
    Matchers
  22. trait NoArgTest extends () ⇒ Outcome with TestData

    Permalink
    Attributes
    protected
    Definition Classes
    TestSuite
  23. final class PlusOrMinusWrapper[T] extends AnyRef

    Permalink
    Definition Classes
    Tolerance
  24. final class RegexWord extends AnyRef

    Permalink
    Definition Classes
    Matchers
  25. final class RegexWrapper extends AnyRef

    Permalink
    Definition Classes
    Matchers
  26. class ResultOfBeWordForAny[T] extends AnyRef

    Permalink
    Definition Classes
    Matchers
  27. sealed class ResultOfBeWordForCollectedAny[T] extends AnyRef

    Permalink
    Definition Classes
    Matchers
  28. final class ResultOfBeWordForCollectedArray[T] extends ResultOfBeWordForCollectedAny[Array[T]]

    Permalink
    Definition Classes
    Matchers
  29. final class ResultOfCollectedAny[T] extends AnyRef

    Permalink
    Definition Classes
    Matchers
  30. final class ResultOfContainWordForCollectedAny[T] extends AnyRef

    Permalink
    Definition Classes
    Matchers
  31. final class ResultOfEndWithWordForCollectedString extends AnyRef

    Permalink
    Definition Classes
    Matchers
  32. final class ResultOfEndWithWordForString extends AnyRef

    Permalink
    Definition Classes
    Matchers
  33. final class ResultOfFullyMatchWordForCollectedString extends AnyRef

    Permalink
    Definition Classes
    Matchers
  34. final class ResultOfFullyMatchWordForString extends AnyRef

    Permalink
    Definition Classes
    Matchers
  35. final class ResultOfHaveWordForCollectedExtent[A] extends AnyRef

    Permalink
    Definition Classes
    Matchers
  36. final class ResultOfHaveWordForExtent[A] extends AnyRef

    Permalink
    Definition Classes
    Matchers
  37. final class ResultOfIncludeWordForCollectedString extends AnyRef

    Permalink
    Definition Classes
    Matchers
  38. final class ResultOfIncludeWordForString extends AnyRef

    Permalink
    Definition Classes
    Matchers
  39. final class ResultOfNotWordForCollectedAny[T] extends AnyRef

    Permalink
    Definition Classes
    Matchers
  40. final class ResultOfStartWithWordForCollectedString extends AnyRef

    Permalink
    Definition Classes
    Matchers
  41. final class ResultOfStartWithWordForString extends AnyRef

    Permalink
    Definition Classes
    Matchers
  42. trait StringCanWrapperForVerb extends AnyRef

    Permalink
    Definition Classes
    CanVerb
  43. trait StringMustWrapperForVerb extends AnyRef

    Permalink
    Definition Classes
    MustVerb
  44. final class StringShouldWrapper extends AnyShouldWrapper[String] with org.scalatest.Matchers.StringShouldWrapperForVerb

    Permalink
    Definition Classes
    Matchers
  45. trait StringShouldWrapperForVerb extends AnyRef

    Permalink
    Definition Classes
    ShouldVerb
  46. class TheAfterWord extends AnyRef

    Permalink
    Definition Classes
    Explicitly
  47. final class TheSameInstanceAsPhrase extends AnyRef

    Permalink
    Definition Classes
    Matchers
  48. final class TheyVerbString extends AnyRef

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike
  49. final class TheyVerbStringTaggedAs extends AnyRef

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike
  50. final class TheyWord extends AnyRef

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike
  51. final class ValueWord extends AnyRef

    Permalink
    Definition Classes
    Matchers

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. def !==[T](right: Spread[T]): TripleEqualsInvocationOnSpread[T]

    Permalink
    Definition Classes
    TripleEqualsSupport
  3. def !==(right: Null): TripleEqualsInvocation[Null]

    Permalink
    Definition Classes
    TripleEqualsSupport
  4. def !==[T](right: T): TripleEqualsInvocation[T]

    Permalink
    Definition Classes
    TripleEqualsSupport
  5. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  6. def <[T](right: T)(implicit arg0: Ordering[T]): ResultOfLessThanComparison[T]

    Permalink
    Definition Classes
    Matchers
  7. def <=[T](right: T)(implicit arg0: Ordering[T]): ResultOfLessThanOrEqualToComparison[T]

    Permalink
    Definition Classes
    Matchers
  8. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  9. def ===[T](right: Spread[T]): TripleEqualsInvocationOnSpread[T]

    Permalink
    Definition Classes
    TripleEqualsSupport
  10. def ===(right: Null): TripleEqualsInvocation[Null]

    Permalink
    Definition Classes
    TripleEqualsSupport
  11. def ===[T](right: T): TripleEqualsInvocation[T]

    Permalink
    Definition Classes
    TripleEqualsSupport
  12. def >[T](right: T)(implicit arg0: Ordering[T]): ResultOfGreaterThanComparison[T]

    Permalink
    Definition Classes
    Matchers
  13. def >=[T](right: T)(implicit arg0: Ordering[T]): ResultOfGreaterThanOrEqualToComparison[T]

    Permalink
    Definition Classes
    Matchers
  14. def a[T](implicit arg0: ClassTag[T]): ResultOfATypeInvocation[T]

    Permalink
    Definition Classes
    Matchers
  15. val a: AWord

    Permalink
    Definition Classes
    Matchers
  16. val after: TheAfterWord

    Permalink
    Definition Classes
    Explicitly
  17. def alert: Alerter

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike → Alerting
  18. def all(xs: String)(implicit collecting: Collecting[Char, String], prettifier: Prettifier, pos: Position): ResultOfCollectedAny[Char]

    Permalink
    Definition Classes
    Matchers
  19. def all[K, V, JMAP[k, v] <: Map[k, v]](xs: JMAP[K, V])(implicit collecting: Collecting[Entry[K, V], JMAP[K, V]], prettifier: Prettifier, pos: Position): ResultOfCollectedAny[Entry[K, V]]

    Permalink
    Definition Classes
    Matchers
  20. def all[E, C[_]](xs: C[E])(implicit collecting: Collecting[E, C[E]], prettifier: Prettifier, pos: Position): ResultOfCollectedAny[E]

    Permalink
    Definition Classes
    Matchers
  21. def allElementsOf[R](elements: GenTraversable[R]): ResultOfAllElementsOfApplication

    Permalink
    Definition Classes
    Matchers
  22. def allOf(firstEle: Any, secondEle: Any, remainingEles: Any*)(implicit pos: Position): ResultOfAllOfApplication

    Permalink
    Definition Classes
    Matchers
  23. def an[T](implicit arg0: ClassTag[T]): ResultOfAnTypeInvocation[T]

    Permalink
    Definition Classes
    Matchers
  24. val an: AnWord

    Permalink
    Definition Classes
    Matchers
  25. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  26. macro def assert(condition: Boolean, clue: Any)(implicit prettifier: Prettifier, pos: Position): Assertion

    Permalink
    Definition Classes
    Assertions
  27. macro def assert(condition: Boolean)(implicit prettifier: Prettifier, pos: Position): Assertion

    Permalink
    Definition Classes
    Assertions
  28. macro def assertCompiles(code: String)(implicit pos: Position): Assertion

    Permalink
    Definition Classes
    Assertions
  29. macro def assertDoesNotCompile(code: String)(implicit pos: Position): Assertion

    Permalink
    Definition Classes
    Assertions
  30. def assertResult(expected: Any)(actual: Any)(implicit prettifier: Prettifier, pos: Position): Assertion

    Permalink
    Definition Classes
    Assertions
  31. def assertResult(expected: Any, clue: Any)(actual: Any)(implicit prettifier: Prettifier, pos: Position): Assertion

    Permalink
    Definition Classes
    Assertions
  32. def assertThrows[T <: AnyRef](f: ⇒ Any)(implicit classTag: ClassTag[T], pos: Position): Assertion

    Permalink
    Definition Classes
    Assertions
  33. macro def assertTypeError(code: String)(implicit pos: Position): Assertion

    Permalink
    Definition Classes
    Assertions
  34. val assertionsHelper: AssertionsHelper

    Permalink
    Definition Classes
    Assertions
  35. macro def assume(condition: Boolean, clue: Any)(implicit prettifier: Prettifier, pos: Position): Assertion

    Permalink
    Definition Classes
    Assertions
  36. macro def assume(condition: Boolean)(implicit prettifier: Prettifier, pos: Position): Assertion

    Permalink
    Definition Classes
    Assertions
  37. def atLeast(num: Int, xs: String)(implicit collecting: Collecting[Char, String], prettifier: Prettifier, pos: Position): ResultOfCollectedAny[Char]

    Permalink
    Definition Classes
    Matchers
  38. def atLeast[K, V, JMAP[k, v] <: Map[k, v]](num: Int, xs: JMAP[K, V])(implicit collecting: Collecting[Entry[K, V], JMAP[K, V]], prettifier: Prettifier, pos: Position): ResultOfCollectedAny[Entry[K, V]]

    Permalink
    Definition Classes
    Matchers
  39. def atLeast[E, C[_]](num: Int, xs: C[E])(implicit collecting: Collecting[E, C[E]], prettifier: Prettifier, pos: Position): ResultOfCollectedAny[E]

    Permalink
    Definition Classes
    Matchers
  40. def atLeastOneElementOf(elements: GenTraversable[Any]): ResultOfAtLeastOneElementOfApplication

    Permalink
    Definition Classes
    Matchers
  41. def atLeastOneOf(firstEle: Any, secondEle: Any, remainingEles: Any*)(implicit pos: Position): ResultOfAtLeastOneOfApplication

    Permalink
    Definition Classes
    Matchers
  42. def atMost(num: Int, xs: String)(implicit collecting: Collecting[Char, String], prettifier: Prettifier, pos: Position): ResultOfCollectedAny[Char]

    Permalink
    Definition Classes
    Matchers
  43. def atMost[K, V, JMAP[k, v] <: Map[k, v]](num: Int, xs: JMAP[K, V])(implicit collecting: Collecting[Entry[K, V], JMAP[K, V]], prettifier: Prettifier, pos: Position): ResultOfCollectedAny[Entry[K, V]]

    Permalink
    Definition Classes
    Matchers
  44. def atMost[E, C[_]](num: Int, xs: C[E])(implicit collecting: Collecting[E, C[E]], prettifier: Prettifier, pos: Position): ResultOfCollectedAny[E]

    Permalink
    Definition Classes
    Matchers
  45. def atMostOneElementOf[R](elements: GenTraversable[R]): ResultOfAtMostOneElementOfApplication

    Permalink
    Definition Classes
    Matchers
  46. def atMostOneOf(firstEle: Any, secondEle: Any, remainingEles: Any*)(implicit pos: Position): ResultOfAtMostOneOfApplication

    Permalink
    Definition Classes
    Matchers
  47. val be: BeWord

    Permalink
    Definition Classes
    MatcherWords
  48. val behave: BehaveWord

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike
  49. val behavior: BehaviorWord

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike
  50. def between(from: Int, upTo: Int, xs: String)(implicit collecting: Collecting[Char, String], prettifier: Prettifier, pos: Position): ResultOfCollectedAny[Char]

    Permalink
    Definition Classes
    Matchers
  51. def between[K, V, JMAP[k, v] <: Map[k, v]](from: Int, upTo: Int, xs: JMAP[K, V])(implicit collecting: Collecting[Entry[K, V], JMAP[K, V]], prettifier: Prettifier, pos: Position): ResultOfCollectedAny[Entry[K, V]]

    Permalink
    Definition Classes
    Matchers
  52. def between[E, C[_]](from: Int, upTo: Int, xs: C[E])(implicit collecting: Collecting[E, C[E]], prettifier: Prettifier, pos: Position): ResultOfCollectedAny[E]

    Permalink
    Definition Classes
    Matchers
  53. def cancel(cause: Throwable)(implicit pos: Position): Nothing

    Permalink
    Definition Classes
    Assertions
  54. def cancel(message: String, cause: Throwable)(implicit pos: Position): Nothing

    Permalink
    Definition Classes
    Assertions
  55. def cancel(message: String)(implicit pos: Position): Nothing

    Permalink
    Definition Classes
    Assertions
  56. def cancel()(implicit pos: Position): Nothing

    Permalink
    Definition Classes
    Assertions
  57. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  58. val compile: CompileWord

    Permalink
    Definition Classes
    MatcherWords
  59. val contain: ContainWord

    Permalink
    Definition Classes
    MatcherWords
  60. def conversionCheckedConstraint[A, B](implicit equivalenceOfA: Equivalence[A], cnv: (B) ⇒ A): CanEqual[A, B]

    Permalink
    Definition Classes
    TripleEquals → TripleEqualsSupport
  61. def convertEquivalenceToAToBConstraint[A, B](equivalenceOfB: Equivalence[B])(implicit ev: <:<[A, B]): CanEqual[A, B]

    Permalink
    Definition Classes
    TripleEquals → TripleEqualsSupport
  62. def convertEquivalenceToAToBConversionConstraint[A, B](equivalenceOfB: Equivalence[B])(implicit ev: (A) ⇒ B): CanEqual[A, B]

    Permalink
    Definition Classes
    TripleEquals → TripleEqualsSupport
  63. def convertEquivalenceToBToAConstraint[A, B](equivalenceOfA: Equivalence[A])(implicit ev: <:<[B, A]): CanEqual[A, B]

    Permalink
    Definition Classes
    TripleEquals → TripleEqualsSupport
  64. def convertEquivalenceToBToAConversionConstraint[A, B](equivalenceOfA: Equivalence[A])(implicit ev: (B) ⇒ A): CanEqual[A, B]

    Permalink
    Definition Classes
    TripleEquals → TripleEqualsSupport
  65. implicit def convertNumericToPlusOrMinusWrapper[T](pivot: T)(implicit arg0: Numeric[T]): PlusOrMinusWrapper[T]

    Permalink
    Definition Classes
    Tolerance
  66. implicit def convertSymbolToHavePropertyMatcherGenerator(symbol: Symbol)(implicit prettifier: Prettifier, pos: Position): HavePropertyMatcherGenerator

    Permalink
    Definition Classes
    Matchers
  67. implicit def convertToAnyShouldWrapper[T](o: T)(implicit pos: Position, prettifier: Prettifier): AnyShouldWrapper[T]

    Permalink
    Definition Classes
    Matchers
  68. def convertToCheckingEqualizer[T](left: T): CheckingEqualizer[T]

    Permalink
    Definition Classes
    TripleEquals → TripleEqualsSupport
  69. implicit def convertToEqualizer[T](left: T): Equalizer[T]

    Permalink
    Definition Classes
    TripleEquals → TripleEqualsSupport
  70. implicit def convertToInAndIgnoreMethods(resultOfStringPassedToVerb: ResultOfStringPassedToVerb): InAndIgnoreMethods

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike
  71. implicit def convertToInAndIgnoreMethodsAfterTaggedAs(resultOfTaggedAsInvocation: ResultOfTaggedAsInvocation): InAndIgnoreMethodsAfterTaggedAs

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike
  72. implicit def convertToRegexWrapper(o: Regex): RegexWrapper

    Permalink
    Definition Classes
    Matchers
  73. implicit def convertToStringCanWrapper(o: String)(implicit position: Position): StringCanWrapperForVerb

    Permalink
    Definition Classes
    CanVerb
  74. implicit def convertToStringMustWrapperForVerb(o: String)(implicit position: Position): StringMustWrapperForVerb

    Permalink
    Definition Classes
    MustVerb
  75. implicit def convertToStringShouldWrapper(o: String)(implicit pos: Position, prettifier: Prettifier): StringShouldWrapper

    Permalink
    Definition Classes
    Matchers
  76. implicit def convertToStringShouldWrapperForVerb(o: String)(implicit position: Position): StringShouldWrapperForVerb

    Permalink
    Definition Classes
    ShouldVerb
  77. val decided: DecidedWord

    Permalink
    Definition Classes
    Explicitly
  78. def defaultEquality[A]: Equality[A]

    Permalink
    Definition Classes
    TripleEqualsSupport
  79. val defined: DefinedWord

    Permalink
    Definition Classes
    MatcherWords
  80. def definedAt[T](right: T): ResultOfDefinedAt[T]

    Permalink
    Definition Classes
    Matchers
  81. val determined: DeterminedWord

    Permalink
    Definition Classes
    Explicitly
  82. val empty: EmptyWord

    Permalink
    Definition Classes
    MatcherWords
  83. val endWith: EndWithWord

    Permalink
    Definition Classes
    MatcherWords
  84. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  85. def equal(o: Null): Matcher[AnyRef]

    Permalink
    Definition Classes
    Matchers
  86. def equal[T](spread: Spread[T]): Matcher[T]

    Permalink
    Definition Classes
    Matchers
  87. def equal(right: Any): MatcherFactory1[Any, Equality]

    Permalink
    Definition Classes
    MatcherWords
  88. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  89. def every(xs: String)(implicit collecting: Collecting[Char, String], prettifier: Prettifier, pos: Position): ResultOfCollectedAny[Char]

    Permalink
    Definition Classes
    Matchers
  90. def every[K, V, JMAP[k, v] <: Map[k, v]](xs: JMAP[K, V])(implicit collecting: Collecting[Entry[K, V], JMAP[K, V]], prettifier: Prettifier, pos: Position): ResultOfCollectedAny[Entry[K, V]]

    Permalink
    Definition Classes
    Matchers
  91. def every[E, C[_]](xs: C[E])(implicit collecting: Collecting[E, C[E]], prettifier: Prettifier, pos: Position): ResultOfCollectedAny[E]

    Permalink
    Definition Classes
    Matchers
  92. def exactly(num: Int, xs: String)(implicit collecting: Collecting[Char, String], prettifier: Prettifier, pos: Position): ResultOfCollectedAny[Char]

    Permalink
    Definition Classes
    Matchers
  93. def exactly[K, V, JMAP[k, v] <: Map[k, v]](num: Int, xs: JMAP[K, V])(implicit collecting: Collecting[Entry[K, V], JMAP[K, V]], prettifier: Prettifier, pos: Position): ResultOfCollectedAny[Entry[K, V]]

    Permalink
    Definition Classes
    Matchers
  94. def exactly[E, C[_]](num: Int, xs: C[E])(implicit collecting: Collecting[E, C[E]], prettifier: Prettifier, pos: Position): ResultOfCollectedAny[E]

    Permalink
    Definition Classes
    Matchers
  95. final def execute(testName: String, configMap: ConfigMap, color: Boolean, durations: Boolean, shortstacks: Boolean, fullstacks: Boolean, stats: Boolean): Unit

    Permalink
    Definition Classes
    Suite
  96. val exist: ExistWord

    Permalink
    Definition Classes
    MatcherWords
  97. def expectedTestCount(filter: Filter): Int

    Permalink
    Definition Classes
    Suite
  98. def fail(cause: Throwable)(implicit pos: Position): Nothing

    Permalink
    Definition Classes
    Assertions
  99. def fail(message: String, cause: Throwable)(implicit pos: Position): Nothing

    Permalink
    Definition Classes
    Assertions
  100. def fail(message: String)(implicit pos: Position): Nothing

    Permalink
    Definition Classes
    Assertions
  101. def fail()(implicit pos: Position): Nothing

    Permalink
    Definition Classes
    Assertions
  102. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  103. val fullyMatch: FullyMatchWord

    Permalink
    Definition Classes
    MatcherWords
  104. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  105. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  106. val have: HaveWord

    Permalink
    Definition Classes
    MatcherWords
  107. val ignore: IgnoreWord

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike
  108. def inOrder(firstEle: Any, secondEle: Any, remainingEles: Any*)(implicit pos: Position): ResultOfInOrderApplication

    Permalink
    Definition Classes
    Matchers
  109. def inOrderElementsOf[R](elements: GenTraversable[R]): ResultOfInOrderElementsOfApplication

    Permalink
    Definition Classes
    Matchers
  110. def inOrderOnly[T](firstEle: Any, secondEle: Any, remainingEles: Any*)(implicit pos: Position): ResultOfInOrderOnlyApplication

    Permalink
    Definition Classes
    Matchers
  111. val include: IncludeWord

    Permalink
    Definition Classes
    MatcherWords
  112. def info: Informer

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike → Informing
  113. def intercept[T <: AnyRef](f: ⇒ Any)(implicit classTag: ClassTag[T], pos: Position): T

    Permalink
    Definition Classes
    Assertions
  114. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  115. val it: ItWord

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike
  116. val key: KeyWord

    Permalink
    Definition Classes
    Matchers
  117. val length: LengthWord

    Permalink
    Definition Classes
    MatcherWords
  118. def lowPriorityConversionCheckedConstraint[A, B](implicit equivalenceOfB: Equivalence[B], cnv: (A) ⇒ B): CanEqual[A, B]

    Permalink
    Definition Classes
    TripleEquals → TripleEqualsSupport
  119. def lowPriorityTypeCheckedConstraint[A, B](implicit equivalenceOfB: Equivalence[B], ev: <:<[A, B]): CanEqual[A, B]

    Permalink
    Definition Classes
    TripleEquals → TripleEqualsSupport
  120. def markup: Documenter

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike → Documenting
  121. val matchPattern: MatchPatternWord

    Permalink
    Definition Classes
    MatcherWords
  122. def message(expectedMessage: String): ResultOfMessageWordApplication

    Permalink
    Definition Classes
    Matchers
  123. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  124. def nestedSuites: IndexedSeq[Suite]

    Permalink
    Definition Classes
    Suite
  125. def no(xs: String)(implicit collecting: Collecting[Char, String], prettifier: Prettifier, pos: Position): ResultOfCollectedAny[Char]

    Permalink
    Definition Classes
    Matchers
  126. def no[K, V, JMAP[k, v] <: Map[k, v]](xs: JMAP[K, V])(implicit collecting: Collecting[Entry[K, V], JMAP[K, V]], prettifier: Prettifier, pos: Position): ResultOfCollectedAny[Entry[K, V]]

    Permalink
    Definition Classes
    Matchers
  127. def no[E, C[_]](xs: C[E])(implicit collecting: Collecting[E, C[E]], prettifier: Prettifier, pos: Position): ResultOfCollectedAny[E]

    Permalink
    Definition Classes
    Matchers
  128. def noElementsOf(elements: GenTraversable[Any]): ResultOfNoElementsOfApplication

    Permalink
    Definition Classes
    Matchers
  129. def noException(implicit pos: Position): NoExceptionWord

    Permalink
    Definition Classes
    MatcherWords
  130. def noneOf(firstEle: Any, secondEle: Any, remainingEles: Any*)(implicit pos: Position): ResultOfNoneOfApplication

    Permalink
    Definition Classes
    Matchers
  131. val not: NotWord

    Permalink
    Definition Classes
    MatcherWords
  132. def note: Notifier

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike → Notifying
  133. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  134. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  135. def of[T](implicit ev: ClassTag[T]): ResultOfOfTypeInvocation[T]

    Permalink
    Definition Classes
    Matchers
  136. def oneElementOf(elements: GenTraversable[Any]): ResultOfOneElementOfApplication

    Permalink
    Definition Classes
    Matchers
  137. def oneOf(firstEle: Any, secondEle: Any, remainingEles: Any*)(implicit pos: Position): ResultOfOneOfApplication

    Permalink
    Definition Classes
    Matchers
  138. def only(xs: Any*)(implicit pos: Position): ResultOfOnlyApplication

    Permalink
    Definition Classes
    Matchers
  139. def pending: Assertion with PendingStatement

    Permalink
    Definition Classes
    Assertions
  140. def pendingUntilFixed(f: ⇒ Unit)(implicit pos: Position): Assertion with PendingStatement

    Permalink
    Definition Classes
    Assertions
  141. val readable: ReadableWord

    Permalink
    Definition Classes
    MatcherWords
  142. val regex: RegexWord

    Permalink
    Definition Classes
    Matchers
  143. final def registerIgnoredTest(testText: String, testTags: Tag*)(testFun: ⇒ Any)(implicit pos: Position): Unit

    Permalink
    Definition Classes
    FlatSpecLike → TestRegistration
  144. final def registerTest(testText: String, testTags: Tag*)(testFun: ⇒ Any)(implicit pos: Position): Unit

    Permalink
    Definition Classes
    FlatSpecLike → TestRegistration
  145. def rerunner: Option[String]

    Permalink
    Definition Classes
    Suite
  146. def run(testName: Option[String], args: Args): Status

    Permalink
    Definition Classes
    FlatSpecLike → Suite
  147. def runNestedSuites(args: Args): Status

    Permalink
    Attributes
    protected
    Definition Classes
    Suite
  148. def runTest(testName: String, args: Args): Status

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike → TestSuite → Suite
  149. def runTests(testName: Option[String], args: Args): Status

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike → Suite
  150. implicit val shorthandSharedTestRegistrationFunction: StringVerbBehaveLikeInvocation

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike
  151. implicit val shorthandTestRegistrationFunction: StringVerbStringInvocation

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike
  152. val size: SizeWord

    Permalink
    Definition Classes
    MatcherWords
  153. def sizeExercise(res0: Int, res1: Int): Unit

    Permalink

    Remember the definition of IntSet (in section Object Oriented Programming):

    Remember the definition of IntSet (in section Object Oriented Programming):

    abstract class IntSet {
      def incl(x: Int): IntSet
      def contains(x: Int): Boolean
    }

    Type Parameters

    It seems too narrow to define only sets with Int elements.

    We'd need another class hierarchy for Double lists, and so on, one for each possible element type.

    We can generalize the definition using a type parameter:

    abstract class Set[A] {
      def incl(a: A): Set[A]
      def contains(a: A): Boolean
    }
    class Empty[A] extends Set[A] {
      …
    }
    class NonEmpty[A](elem: A, left: Set[A], right: Set[A]) extends Set[A] {
      …
    }

    Type parameters are written in square brackets, e.g. [A].

    Generic Functions

    Like classes, functions can have type parameters.

    For instance, here is a function that creates a set consisting of a single element.

    def singleton[A](elem: A) = new NonEmpty[A](elem, new Empty[A], new Empty[A])

    We can then write:

    singleton[Int](1)
    singleton[Boolean](true)

    Type Inference

    In fact, the Scala compiler can usually deduce the correct type parameters from the value arguments of a function call.

    So, in most cases, type parameters can be left out. You could also write:

    singleton(1)
    singleton(true)

    Types and Evaluation

    Type parameters do not affect evaluation in Scala.

    We can assume that all type parameters and type arguments are removed before evaluating the program.

    This is also called type erasure.

    Languages that use type erasure include Java, Scala, Haskell, ML, OCaml.

    Some other languages keep the type parameters around at run time, these include C++, C#, F#.

    Polymorphism

    Polymorphism means that a function type comes "in many forms".

    In programming it means that

    • the function can be applied to arguments of many types, or
    • the type can have instances of many types.

    We have seen two principal forms of polymorphism:

    • subtyping: instances of a subclass can be passed to a base class
    • generics: instances of a function or class are created by type parameterization.

    The remaining subsections compare their interaction.

    Consider the following class hierarchy:

    trait Animal {
      def fitness: Int
    }
    
    trait Reptile extends Animal
    
    trait Mammal extends Animal
    
    trait Zebra extends Mammal {
      def zebraCount: Int
    }
    
    trait Giraffe extends Mammal

    Type Bounds

    Consider the method selection that takes two animals as parameters and returns the one with the highest fitness value:

    What would be the best type you can give to selection? Maybe:

    def selection(a1: Animal, a2: Animal): Animal

    In most situations this is fine, but can one be more precise?

    One might want to express that selection takes Zebras to Zebras and Reptiles to Reptiles.

    Upper Bounds

    A way to express this is:

    def selection[A <: Animal](a1: A, a2: A): A =
      if (a1.fitness > a2.fitness) a1 else a2

    Here, “<: Animal” is an upper bound of the type parameter A.

    It means that A can be instantiated only to types that conform to Animal.

    Generally, the notation

    • A <: B means: A is a subtype of B, and
    • A >: B means: A is a supertype of B, or B is a subtype of A.

    Lower Bounds

    You can also use a lower bound for a type variable.

    A >: Reptile

    The type parameter A that can range only over supertypes of Reptile.

    So A could be one of Reptile, Animal, AnyRef, or Any.

    (We will see later on in this section where lower bounds are useful).

    Mixed Bounds

    Finally, it is also possible to mix a lower bound with an upper bound.

    For instance,

    A >: Zebra <: Animal

    would restrict A any type on the interval between Zebra and Animal.

    Covariance

    There's another interaction between subtyping and type parameters we need to consider.

    Consider the following type modeling a field containing an animal:

    trait Field[A] {
      def get: A // returns the animal that lives in this field
    }

    Given

    Zebra <: Mammal

    is

    Field[Zebra] <: Field[Mammal]

    ?

    Intuitively, this makes sense: a field containing a zebra is a special case of a field containing an arbitrary mammal.

    We call types for which this relationship holds covariant because their subtyping relationship varies with the type parameter.

    Does covariance make sense for all types, not just for Field?

    Arrays

    For perspective, let's look at arrays in Java (and C#).

    Reminder:

    • An array of T elements is written T[] in Java.
    • In Scala we use parameterized type syntax Array[T] to refer to the same type.

    Arrays in Java are covariant, so one would have:

    Zebra[] <: Mammal[]

    But covariant array typing causes problems.

    To see why, consider the Java code below:

    Zebra[] zebras = new Zebra[]{ new Zebra() }  // Array containing 1 `Zebra`
    Mammal[] mammals = zebras      // Allowed because arrays are covariant in Java
    mammals[0] = new Giraffe()     // Allowed because a `Giraffe` is a subtype of `Mammal`
    Zebra zebra = zebras[0]        // Get the first `Zebra` … which is actually a `Giraffe`!

    It looks like we assigned in the last line a Giraffe to a variable of type Zebra!

    What went wrong?

    The Liskov Substitution Principle

    The following principle, stated by Barbara Liskov, tells us when a type can be a subtype of another.

    If A <: B, then everything one can to do with a value of type B one should also be able to do with a value of type A.

    The problematic array example would be written as follows in Scala:

    val zebras: Array[Zebra] = Array(new Zebra)
    val mammals: Array[Mammal] = zebras
    mammals(0) = new Giraffe
    val zebra: Zebra = zebras(0)

    If you try to compile this example you will get a compile error at line 2:

    type mismatch;
      found   : Array[Zebra]
      required: Array[Mammal]

    Variance

    We have seen that some types should be covariant whereas others should not.

    Roughly speaking, a type that accepts mutations of its elements should not be covariant.

    But immutable types can be covariant, if some conditions on methods are met.

    Definition of Variance

    Say C[T] is a parameterized type and A, B are types such that A <: B.

    In general, there are three possible relationships between C[A] and C[B]:

    • C[A] <: C[B], C is covariant,
    • C[A] >: C[B], C is contravariant,
    • neither C[A] nor C[B] is a subtype of the other, C is nonvariant.

    Scala lets you declare the variance of a type by annotating the type parameter:

    • class C[+A] { … }, C is covariant,
    • class C[-A] { … }, C is contravariant,
    • class C[A] { … }, C is nonvariant.

    Typing Rules for Functions

    Generally, we have the following rule for subtyping between function types:

    If A2 <: A1 and B1 <: B2, then

    A1 => B1 <: A2 => B2

    So functions are contravariant in their argument type(s) and covariant in their result type.

    This leads to the following revised definition of the Function1 trait:

    trait Function1[-T, +U] {
      def apply(x: T): U
    }

    Contravariance Example

    Consider the following type modeling a veterinary:

    trait Vet[A] {
      def treat(a: A): Unit // Treats an animal of type `A`
    }

    In such a case, intuitively, it makes sense to have Vet[Mammal] <: Vet[Zebra] because a vet that can treat any mammal is able to to treat a zebra in particular. This is an example of a contravariant type.

    Variance Checks

    We have seen in the array example that the combination of covariance with certain operations is unsound.

    In the case of Array, the problematic combination is:

    • the covariant type parameter T
    • which appears in parameter position of the method update.

    The Scala compiler will check that there are no problematic combinations when compiling a class with variance annotations.

    Roughly,

    • covariant type parameters can only appear in method results.
    • contravariant type parameters can only appear in method parameters.
    • invariant type parameters can appear anywhere.

    The precise rules are a bit more involved, fortunately the Scala compiler performs them for us.

    Variance-Checking the Function Trait

    Let's have a look again at Function1:

    trait Function1[-T, +U] {
      def apply(x: T): U
    }

    Here,

    • T is contravariant and appears only as a method parameter type
    • U is covariant and appears only as a method result type

    So the method is checks out OK.

    Making Classes Covariant

    Sometimes, we have to put in a bit of work to make a class covariant.

    Consider adding a prepend method to Stream which prepends a given element, yielding a new stream.

    A first implementation of prepend could look like this:

    trait Stream[+T] {
      def prepend(elem: T): Stream[T] = Stream.cons(elem, this)
    }

    But that does not work!

    Why does the above code not type-check?

    prepend fails variance checking.

    Indeed, the compiler is right to throw out Stream with prepend, because it violates the Liskov Substitution Principle:

    Here's something one can do with a stream mammals of type Stream[Mammal]:

    mammals.prepend(new Giraffe)

    But the same operation on a list zebras of type Stream[Zebra] would lead to a type error:

    zebras.prepend(new Giraffe)
                   ^ type mismatch
                   required: Zebra
                   found: Giraffe

    So, Stream[Zebra] cannot be a subtype of Stream[Mammal].

    But prepend is a natural method to have on immutable lists!

    How can we make it variance-correct?

    We can use a lower bound:

    def prepend [U >: T](elem: U): Stream[U] = Stream.cons(elem, this)

    This passes variance checks, because:

    • covariant type parameters may appear in lower bounds of method type parameters
    • contravariant type parameters may appear in upper bounds of method

    Exercise

    Complete the following implementation of the size function that returns the size of a given list.

  154. val sorted: SortedWord

    Permalink
    Definition Classes
    MatcherWords
  155. val startWith: StartWithWord

    Permalink
    Definition Classes
    MatcherWords
  156. final val styleName: String

    Permalink
    Definition Classes
    FlatSpecLike → Suite
  157. final val succeed: Assertion

    Permalink
    Definition Classes
    Assertions
  158. def suiteId: String

    Permalink
    Definition Classes
    Suite
  159. def suiteName: String

    Permalink
    Definition Classes
    Suite
  160. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  161. def tags: Map[String, Set[String]]

    Permalink
    Definition Classes
    FlatSpecLike → Suite
  162. def testDataFor(testName: String, theConfigMap: ConfigMap): TestData

    Permalink
    Definition Classes
    FlatSpecLike → Suite
  163. def testNames: Set[String]

    Permalink
    Definition Classes
    FlatSpecLike → Suite
  164. def the[T](implicit arg0: ClassTag[T], pos: Position): ResultOfTheTypeInvocation[T]

    Permalink
    Definition Classes
    Matchers
  165. def theSameElementsAs(xs: GenTraversable[_]): ResultOfTheSameElementsAsApplication

    Permalink
    Definition Classes
    Matchers
  166. def theSameElementsInOrderAs(xs: GenTraversable[_]): ResultOfTheSameElementsInOrderAsApplication

    Permalink
    Definition Classes
    Matchers
  167. val theSameInstanceAs: TheSameInstanceAsPhrase

    Permalink
    Definition Classes
    Matchers
  168. val they: TheyWord

    Permalink
    Attributes
    protected
    Definition Classes
    FlatSpecLike
  169. def thrownBy(fun: ⇒ Any): ResultOfThrownByApplication

    Permalink
    Definition Classes
    Matchers
  170. def toString(): String

    Permalink
    Definition Classes
    FlatSpec → AnyRef → Any
  171. val typeCheck: TypeCheckWord

    Permalink
    Definition Classes
    MatcherWords
  172. def typeCheckedConstraint[A, B](implicit equivalenceOfA: Equivalence[A], ev: <:<[B, A]): CanEqual[A, B]

    Permalink
    Definition Classes
    TripleEquals → TripleEqualsSupport
  173. implicit def unconstrainedEquality[A, B](implicit equalityOfA: Equality[A]): CanEqual[A, B]

    Permalink
    Definition Classes
    TripleEquals → TripleEqualsSupport
  174. val value: ValueWord

    Permalink
    Definition Classes
    Matchers
  175. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  176. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  177. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  178. def withClue[T](clue: Any)(fun: ⇒ T): T

    Permalink
    Definition Classes
    Assertions
  179. def withFixture(test: NoArgTest): Outcome

    Permalink
    Attributes
    protected
    Definition Classes
    TestSuite
  180. val writable: WritableWord

    Permalink
    Definition Classes
    MatcherWords

Deprecated Value Members

  1. final def execute: Unit

    Permalink
    Definition Classes
    Suite
    Annotations
    @deprecated
    Deprecated

    The parameterless execute method has been deprecated and will be removed in a future version of ScalaTest. Please invoke execute with empty parens instead: execute().

  2. def trap[T](f: ⇒ T): Throwable

    Permalink
    Definition Classes
    Assertions
    Annotations
    @deprecated
    Deprecated

    The trap method is no longer needed for demos in the REPL, which now abreviates stack traces, and will be removed in a future version of ScalaTest

Inherited from ScalaTutorialSection

Inherited from Section

Inherited from Matchers

Inherited from Explicitly

Inherited from MatcherWords

Inherited from Tolerance

Inherited from FlatSpec

Inherited from FlatSpecLike

Inherited from Documenting

Inherited from Alerting

Inherited from Notifying

Inherited from Informing

Inherited from CanVerb

Inherited from MustVerb

Inherited from ShouldVerb

Inherited from TestRegistration

Inherited from TestSuite

Inherited from Suite

Inherited from Serializable

Inherited from Serializable

Inherited from Assertions

Inherited from TripleEquals

Inherited from TripleEqualsSupport

Inherited from AnyRef

Inherited from Any

Ungrouped