diff options
author | Paul Phillips <paulp@improving.org> | 2012-11-28 09:32:18 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-11-28 09:32:18 -0800 |
commit | b149c7b5f26b6771557849aa04b96a3ca3bdedee (patch) | |
tree | 310918089ca81392b72b99e1a0058fa90636fa76 /test/files/run | |
parent | 4c3aaad77fd41765aa2a06039ede143d6911d422 (diff) | |
parent | 8fcbee5e2d0fcff2f42c94b9ecf6599e586c8166 (diff) | |
download | scala-b149c7b5f26b6771557849aa04b96a3ca3bdedee.tar.gz scala-b149c7b5f26b6771557849aa04b96a3ca3bdedee.tar.bz2 scala-b149c7b5f26b6771557849aa04b96a3ca3bdedee.zip |
Merge pull request #1676 from retronym/topic/sm-interpolator
Adds a margin stripping string interpolator.
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/sm-interpolator.scala | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/files/run/sm-interpolator.scala b/test/files/run/sm-interpolator.scala new file mode 100644 index 0000000000..7f7b9f061a --- /dev/null +++ b/test/files/run/sm-interpolator.scala @@ -0,0 +1,41 @@ +object Test extends App { + import scala.reflect.internal.util.StringContextStripMarginOps + def check(actual: Any, expected: Any) = if (actual != expected) sys.error(s"expected: [$expected], actual: [$actual])") + + val bar = "|\n ||" + + check( + sm"""|ab + |de + |${bar} | ${1}""", + "ab \nde\n|\n || | 1") + + check( + sm"|", + "") + + check( + sm"${0}", + "0") + + check( + sm"${0}", + "0") + + check( + sm"""${0}|${1} + |""", + "0|1\n") + + check( + sm""" ||""", + "|") + + check( + sm""" ${" "} ||""", + " ||") + + check( + sm"\n", + raw"\n".stripMargin) +} |