Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example of TypeCheckedTripleEquals mixed in a test class #62

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/views/userGuide/usingMatchers.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,23 @@ <h2> Checking equality with matchers </h2>
the equality constraints provided by <code>TypeCheckedTripleEquals</code>, however, the statement fails to compile. For more information
and examples, see the main documentation for <a href="@latestScaladoc/#org.scalactic.TypeCheckedTripleEquals">trait <code>TypeCheckedTripleEquals</code></a>.</p>

<p>An example of TypeCheckedTripleEquals mixed in a test class:</p>

<pre class="stHighlighted">
<span class="stReserved">import</span> org.scalatest._
<span class="stReserved">import</span> org.scalactic.TypeCheckedTripleEquals

<span class="stReserved">class</span> MyTest <span class="stReserved">extends</span> FunSuite <span class="stReserved">with</span> Matchers <span class="stReserved">with</span> TypeCheckedTripleEquals {

test("Type checked ===") {
val i: Int = 42
val s: String = "42"

i should === (s) // Do not compile because i is an Int and s is a String, great !
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a little confusing, since this isn't really a valid test case, and the code would never compile...does it make more sense to have an example with i !=== (s)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to show the behaviour of TypeCheckedTripleEquals at compile-time.

}
}
</pre>

<a name="checkingSizeAndLength"> </a>
<h2> Checking size and length </h2>

Expand Down