Object

scalatutorial.sections

SyntacticConveniences

Related Doc: package sections

Permalink

object SyntacticConveniences 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. SyntacticConveniences
  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. def defaultParameters(res0: Int): Unit

    Permalink

    We have seen that Scala's numeric types and the Boolean type can be implemented like normal classes.

    Functions as Objects

    We have seen that Scala's numeric types and the Boolean type can be implemented like normal classes.

    But what about functions?

    In fact function values are treated as objects in Scala.

    The function type A => B is just an abbreviation for the class scala.Function1[A, B], which is defined as follows.

    package scala
    trait Function1[A, B] {
      def apply(x: A): B
    }

    So functions are objects with apply methods.

    There are also traits Function2, Function3, ... for functions which take more parameters (currently up to 22).

    Expansion of Function Values

    An anonymous function such as

    (x: Int) => x * x

    is expanded to:

    {
      class AnonFun extends Function1[Int, Int] {
        def apply(x: Int) = x * x
      }
      new AnonFun
    }

    or, shorter, using anonymous class syntax:

    new Function1[Int, Int] {
      def apply(x: Int) = x * x
    }

    Expansion of Function Calls

    A function call, such as f(a, b), where f is a value of some class type, is expanded to:

    f.apply(a, b)

    So the OO-translation of:

    val f = (x: Int) => x * x
    f(7)

    would be:

    val f = new Function1[Int, Int] {
      def apply(x: Int) = x * x
    }
    f.apply(7)

    Functions and Methods

    Note that a method such as

    def f(x: Int): Boolean = …

    is not itself a function value.

    But if f is used in a place where a Function type is expected, it is converted automatically to the function value

    (x: Int) => f(x)

    for expressions

    You probably noticed that several data types of the standard library have methods named map, flatMap and filter.

    These methods are so common in practice that Scala supports a dedicated syntax: for expressions.

    map

    Thus, instead of writing the following:

    xs.map(x => x + 1)

    You can write:

    for (x <- xs) yield x + 1

    You can read it as “for every value, that I name ‘x’, in ‘xs’, return ‘x + 1’”.

    filter

    Also, instead of writing the following:

    xs.filter(x => x % 2 == 0)

    You can write:

    for (x <- xs if x % 2 == 0) yield x

    The benefit of this syntax becomes more apparent when it is combined with the previous one:

    for (x <- xs if x % 2 == 0) yield x + 1
    
    // Equivalent to the following:
    xs.filter(x => x % 2 == 0).map(x => x + 1)

    flatMap

    Finally, instead of writing the following:

    xs.flatMap(x => ys.map(y => (x, y)))

    You can write:

    for (x <- xs; y <- ys) yield (x, y)

    You can read it as “for every value ‘x’ in ‘xs’, and then for every value ‘y’ in ‘ys’, return ‘(x, y)’”.

    Putting Things Together

    Here is an example that puts everything together:

    for {
      x <- xs if x % 2 == 0
      y <- ys
    } yield (x, y)

    The equivalent de-sugared code is the following:

    xs.filter { x =>
      x % 2 == 0
    }.flatMap { x =>
      ys.map { y =>
        (x, y)
      }
    }

    Method’s Parameters

    Named Parameters

    It can sometimes be difficult to figure out what is the meaning of each parameter passed to a function. Consider for instance the following expression:

    Range(1, 10, 2)

    What does it mean? We can improve the readability by using named parameters.

    Based on the fact that the Range constructor is defined as follows:

    case class Range(start: Int, end: Int, step: Int)

    We can rewrite our expression as follows:

    Range(start = 1, end = 10, step = 2)

    It is now clearer that this expression defines a range of numbers from 1 to 10 by increments of 2.

    Default Values

    Methods’ parameters can have default values. Let’s refine the Range constructor:

    case class Range(start: Int, end: Int, step: Int = 1)

    Here, we say that the step parameter has a default value, 1.

    Then, at use site we can omit to supply this parameter and the compiler will supply it for us, by using its default value:

  80. val defined: DefinedWord

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

    Permalink
    Definition Classes
    Matchers
  82. val determined: DeterminedWord

    Permalink
    Definition Classes
    Explicitly
  83. val empty: EmptyWord

    Permalink
    Definition Classes
    MatcherWords
  84. val endWith: EndWithWord

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

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

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

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

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

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

    Permalink
    Definition Classes
    Matchers
  91. 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
  92. def every[E, C[_]](xs: C[E])(implicit collecting: Collecting[E, C[E]], prettifier: Prettifier, pos: Position): ResultOfCollectedAny[E]

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

    Permalink
    Definition Classes
    Matchers
  94. 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
  95. 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
  96. final def execute(testName: String, configMap: ConfigMap, color: Boolean, durations: Boolean, shortstacks: Boolean, fullstacks: Boolean, stats: Boolean): Unit

    Permalink
    Definition Classes
    Suite
  97. val exist: ExistWord

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

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

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

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

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

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

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

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

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

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

    Permalink
    Definition Classes
    MatcherWords
  108. val ignore: IgnoreWord

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

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

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

    Permalink
    Definition Classes
    Matchers
  112. val include: IncludeWord

    Permalink
    Definition Classes
    MatcherWords
  113. def info: Informer

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

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

    Permalink
    Definition Classes
    Any
  116. val it: ItWord

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

    Permalink
    Definition Classes
    Matchers
  118. val length: LengthWord

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

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

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

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

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

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

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

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

    Permalink
    Definition Classes
    Matchers
  127. 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
  128. def no[E, C[_]](xs: C[E])(implicit collecting: Collecting[E, C[E]], prettifier: Prettifier, pos: Position): ResultOfCollectedAny[E]

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

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

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

    Permalink
    Definition Classes
    Matchers
  132. val not: NotWord

    Permalink
    Definition Classes
    MatcherWords
  133. def note: Notifier

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

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

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

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

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

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

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

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

    Permalink
    Definition Classes
    Assertions
  142. val readable: ReadableWord

    Permalink
    Definition Classes
    MatcherWords
  143. val regex: RegexWord

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

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

    Permalink
    Definition Classes
    FlatSpecLike → TestRegistration
  146. def repeatedParameters(res0: Double): Unit

    Permalink

    You can define a function that can receive an arbitrary number of parameters (of the same type) as follows:

    Repeated Parameters

    You can define a function that can receive an arbitrary number of parameters (of the same type) as follows:

  147. def rerunner: Option[String]

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

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

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

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

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

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

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

    Permalink
    Definition Classes
    MatcherWords
  155. val sorted: SortedWord

    Permalink
    Definition Classes
    MatcherWords
  156. val startWith: StartWithWord

    Permalink
    Definition Classes
    MatcherWords
  157. def stringInterpolation(res0: String): Unit

    Permalink

    This section introduces several syntactic sugars supported by the language.

    This section introduces several syntactic sugars supported by the language.

    String Interpolation

    To splice values into constant String at runtime, you can use string interpolation:

  158. def stringInterpolation2(res0: String): Unit

    Permalink

    After having prefixed the string literal with s you can introduce dynamic values in it with $.

    After having prefixed the string literal with s you can introduce dynamic values in it with $.

    If you want to splice a complex expression (more than just an identifier), surround it with braces:

  159. final val styleName: String

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

    Permalink
    Definition Classes
    Assertions
  161. def suiteId: String

    Permalink
    Definition Classes
    Suite
  162. def suiteName: String

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

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

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

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

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

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

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

    Permalink
    Definition Classes
    Matchers
  170. val theSameInstanceAs: TheSameInstanceAsPhrase

    Permalink
    Definition Classes
    Matchers
  171. val they: TheyWord

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

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

    Permalink
    Definition Classes
    FlatSpec → AnyRef → Any
  174. def tupleExtraction(res0: String): Unit

    Permalink

    In the above example, the type (Int, String) represents a pair whose first element is an Int and whose second element is a String.

    In the above example, the type (Int, String) represents a pair whose first element is an Int and whose second element is a String.

    Similarly, the value (i, s) is a pair whose first element is i and whose second element is s.

    More generally, a type (T1, …, Tn) is a tuple type of n elements whose ith element has type Ti.

    And a value (t1, … tn) is a tuple value of n elements.

    Manipulating Tuples

    You can retrieve the elements of a tuple by using a tuple pattern:

  175. def tupleExtraction2(res0: String): Unit

    Permalink

    Or, simply:

  176. def tupleManipulation(res0: String): Unit

    Permalink

    Alternatively, you can retrieve the 1st element with the _1 member, the 2nd element with the _2 member, etc:

  177. def tuples(res0: (Int, String)): Unit

    Permalink

    We saw earlier that case classes are useful to aggregate information.

    Tuples

    We saw earlier that case classes are useful to aggregate information. However, sometimes you want to aggregate information without having to define a complete case class for it. In such a case you can use tuples:

  178. def typeAlias(res0: Either[String, (Int, Int)]): Unit

    Permalink

    The average function takes at least one Int parameter and then an arbitrary number of other values and computes their average.

    The average function takes at least one Int parameter and then an arbitrary number of other values and computes their average. By forcing users to supply at least one parameter, we make it impossible for them to compute the average of an empty list of numbers.

    Sometimes you want to supply each element of a list as as many parameters. You can do that by adding a : _* type ascription to your list:

    val xs: List[Int] = …
    average(1, xs: _*)

    Type Aliases

    In the same way as you can give meaningful names to expressions, you can give meaningful names to type expressions:

  179. val typeCheck: TypeCheckWord

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

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

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

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

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

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

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

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

    Permalink
    Attributes
    protected
    Definition Classes
    TestSuite
  188. 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