I'm just getting started with Scala, and I'm wondering which language feature allows you to do this:
"PersistentQueue" should {
"add and remove one item" in {
withTempFolder {
val q = new PersistentQueue(folderName, "work", Config.fromMap(Map.empty))
q.setup
q.length mustEqual 0
q.totalItems mustEqual 0
q.bytes mustEqual 0
q.journalSize mustEqual 0
q.add("hello kitty".getBytes)
q.length mustEqual 1
q.totalItems mustEqual 1
q.bytes mustEqual 11
q.journalSize mustEqual 32
new String(q.remove.get.data) mustEqual "hello kitty"
q.length mustEqual 0
q.totalItems mustEqual 1
q.bytes mustEqual 0
q.journalSize mustEqual 33
q.close
dumpJournal("work") mustEqual "add(11:0:hello kitty), remove"
}
}
}
That's from the unit tests for Kestrel.
What's going on here? Does "PersistentQueue" should
mean that the Scala string class has been extended with a "should" method, or is something else happening here? I had a quick look through the Scala documentation but couldn't see which language features are being used for this code sample.