Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
concat (".") and repeat ("x") operators for strings
- Loading branch information
Showing
4 changed files
with
85 additions
and
12 deletions.
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
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
44 changes: 44 additions & 0 deletions
44
src/test/scala/org/moe/parser/SimpleExpressionStrTestSuite.scala
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,44 @@ | ||
package org.moe.parser | ||
|
||
import org.scalatest.FunSuite | ||
import org.scalatest.BeforeAndAfter | ||
import org.scalatest.matchers.ShouldMatchers | ||
|
||
import org.moe.runtime._ | ||
import org.moe.interpreter._ | ||
import org.moe.ast._ | ||
import org.moe.parser._ | ||
|
||
class SimpleExpressionStrTestSuite extends FunSuite with BeforeAndAfter with ParserTestUtils with ShouldMatchers { | ||
|
||
test("... literal string concatenation ... [\"Hello \" . \"Moe\"]") { | ||
val result = interpretCode(""""Hello " . "Moe"""") | ||
result.unboxToString.get should equal ("Hello Moe") | ||
} | ||
|
||
test("... literal string concatenation ... ['foo' . 'bar']") { | ||
val result = interpretCode("'foo' . 'bar'") | ||
result.unboxToString.get should equal ("foobar") | ||
} | ||
|
||
test("... literal string concatenation ... ['1' . 2]") { | ||
val result = interpretCode("'1' . 2") | ||
result.unboxToString.get should equal ("12") | ||
} | ||
|
||
test("... literal string concatenation ... ['1' . 2 * 3]") { | ||
val result = interpretCode("'1' . 2 * 3") | ||
result.unboxToString.get should equal ("16") | ||
} | ||
|
||
test("""... literal string repetition ... ["Moe" x 5]""") { | ||
val result = interpretCode(""""Moe" x 5""") | ||
result.unboxToString.get should equal ("MoeMoeMoeMoeMoe") | ||
} | ||
|
||
test("""... literal string repetition ... ["Moe" x "5"]""") { | ||
val result = interpretCode(""""Moe" x "5"""") | ||
result.unboxToString.get should equal ("MoeMoeMoeMoeMoe") | ||
} | ||
|
||
} |