forked from lamdor/scala-koans
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added koans about literals such as Int, String, Float, and Symbols
- Loading branch information
Showing
3 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters