Scalactic User Guide

Custom equality

Default equality

Constrained equality

Tolerance

Normalization

The Explicitly DSL

Or and Every

Requirements

Snapshots

TimesOnInt

Snapshots

The Snapshots trait provides a snap method that takes one or more arguments and results in a SnapshotSeq, whose toString lists the names and values of each argument.

The intended use case of this trait is to help you write debug and log messages that give a "snapshot" of program state. Here's an example:

scala> import Snapshots._
import Snapshots._

scala> snap(a, b, c, d, e, f) res3: org.scalactic.SnapshotSeq = a was 1, b was 2, c was 3, d was 4, e was null, f was null

SnapshotSeq offers a lines method that places each variable name/value pair on its own line:

scala> snap(a, b, c, d, e, f).lines
res4: String =
a was 1
b was 2
c was 3
d was 4
e was null
f was null

Or, because a SnapshotSeq is a IndexedSeq[Snapshot], you can process it just like any other Seq, for example:

scala> snap(a, b, c, d, e, f).mkString("Wow! ", ", and ", ". That's so awesome!")
res6: String = Wow! a was 1, and b was 2, and c was 3, and d was 4, and e was null, and f was null. That's so awesome!

Next, learn about TimesOnInt.

Scalactic is brought to you by Bill Venners, with contributions from several other folks. It is sponsored by Artima, Inc.
ScalaTest is free, open-source software released under the Apache 2.0 license.

Copyright © 2009-2024 Artima, Inc. All Rights Reserved.

artima