Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the === (triple-equals) operator in Scala Koans?

I started working my way through the Scala Koans, which is organized around a suite of unit tests with blanks that one needs to fill in. (This idea was modeled after a similar Ruby Koans project.) You start the sbt tool running a test, and it admonishes:

 [info]   + *****************************************  [info]   +   [info]   +   [info]   +   [info]   + Please meditate on koan "None equals None" of suite "AboutEmptyValues"  [info]   +   [info]   +   [info]   +   [info]   + *****************************************  

...and so you go look at this unit test and it says:

 test("None equals None") {   assert(None === __) } 

...and, after meditation, you realize that you should fill in the blank like this:

 test("None equals None") {   assert(None === None) } 

...and then it moves on to the next unit test.

My question, though, is what is this === operator? I can't seem to find it anywhere. Is this a DSL operator defined in the Scala Koans project itself? Or is it part of the ScalaTest framework? Or in Scala proper?

like image 201
pohl Avatar asked May 07 '12 21:05

pohl


1 Answers

This is the triple-equals operator from ScalaTest. Have a look at this page: Getting Started with FunSuite. It says:

ScalaTest lets you use Scala's assertion syntax, but defines a triple equals operator (===) to give you better error messages. The following code would give you an error indicating only that an assertion failed:

assert(1 == 2) 

Using triple equals instead would give you the more informative error message, "1 did not equal 2":

assert(1 === 2) 
like image 58
rolve Avatar answered Sep 20 '22 04:09

rolve