Skip to content

Commit

Permalink
Added koans about literals such as Int, String, Float, and Symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
lamdor committed Sep 8, 2010
1 parent 74c8116 commit b44e728
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/test/scala/org/scalakoans/AboutAsserts.scala
Expand Up @@ -20,9 +20,17 @@ class AboutAsserts extends KoanSuite {
val v1 = 4
val v2 = 3

meditate
v1 should be(v2)
}

koan("can also use equal as a matcher") {
val v1 = 4
val v2 = 3

__ should equal(v2)
}

koan ("sometimes we expect you to fill in the values") {
(1+1) should __
}
Expand Down
42 changes: 42 additions & 0 deletions src/test/scala/org/scalakoans/AboutLiterals.scala
@@ -0,0 +1,42 @@
package org.scalakoans

import support.KoanSuite

class AboutLiterals extends KoanSuite {
koan("integer literals") {
val i = 1

i.isInstanceOf[Int] should __
}

koan("float literals") {
val f = 2.0

f.isInstanceOf[___] should be(true)
}

koan("string literals") {
val s = "abcd"

s.isInstanceOf[___] should be(true)

s.toUpperCase() should __
s.length() should __

s.isInstanceOf[java.lang.String] should __

// sadly no string interpolation
val str = "%s - %d".format("abc", 123)
str should __

__ should not be theSameInstanceAs("abcd")
}

koan("symbol literals") {
val s = 'abc

s.isInstanceOf[___] should be(true)

__ should be theSameInstanceAs('abc)
}
}
3 changes: 2 additions & 1 deletion src/test/scala/org/scalakoans/Koans.scala
Expand Up @@ -5,6 +5,7 @@ import org.scalatest._
class Koans extends Suite {
override def nestedSuites = List(
new AboutAsserts,
new AboutValAndVar
new AboutValAndVar,
new AboutLiterals
)
}

0 comments on commit b44e728

Please sign in to comment.