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

I began my journey through Scala Koans , which is organized around a set of unit tests with spaces to fill. (This idea was modeled after a similar Ruby Koans project.) You run the sbt tool, which runs the test, and it warns:

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

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

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

... and after meditation you understand that you must fill in the gap as follows:

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

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

My question, however, is what kind of operator === ? I can't seem to find anything. Is this the DSL statement defined in the Scala Koans project? Or is it part of the ScalaTest framework? Or is Scala correct?

+42
scala scalatest
May 7, '12 at 21:40
source share
1 answer

This is a three-value statement from ScalaTest . Take a look at this page: Get started with FunSuite . It says:

ScalaTest allows you to use the Scala statement syntax, but defines the triple equals operator (===) to give you better error messages. The following code will give you an error indicating only that the statement has failed:

 assert(1 == 2) 

Using triple equals instead will give you a more informative error message "1 is not equal to 2":

 assert(1 === 2) 
+68
May 7 '12 at 21:44
source share



All Articles