-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a3cf24
commit 7f96c3e
Showing
4 changed files
with
79 additions
and
86 deletions.
There are no files selected for viewing
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
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,79 @@ | ||
@main def Test() = { | ||
|
||
// This should generally obey 15.18.1. of the JLS (String Concatenation Operator +) | ||
def concatenatingVariousTypes(): String = { | ||
val str: String = "some string" | ||
val sb: StringBuffer = new StringBuffer("some stringbuffer") | ||
val cs: CharSequence = java.nio.CharBuffer.allocate(50).append("charsequence") | ||
val i: Int = 123456789 | ||
val s: Short = 345 | ||
val b: Byte = 12 | ||
val z: Boolean = true | ||
val f: Float = 3.14f | ||
val j: Long = 98762147483647L | ||
val d: Double = 3.1415d | ||
|
||
"String " + str + "\n" + | ||
"StringBuffer " + sb + "\n" + | ||
"CharSequence " + cs + "\n" + | ||
"Int " + i + "\n" + | ||
"Short " + s + "\n" + | ||
"Byte " + b + "\n" + | ||
"Boolean " + z + "\n" + | ||
"Float " + f + "\n" + | ||
"Long " + j + "\n" + | ||
"Double " + d + "\n" | ||
} | ||
// The characters `\u0001` and `\u0002` play a special role in `StringConcatFactory` | ||
def concatenationInvolvingSpecialCharacters(): String = { | ||
val s1 = "Qux" | ||
val s2 = "Quux" | ||
|
||
s"Foo \u0001 $s1 Bar \u0002 $s2 Baz" | ||
} | ||
// Concatenation involving more than 200 elements | ||
def largeConcatenation(): String = { | ||
val s00 = "s00" | ||
val s01 = "s01" | ||
val s02 = "s02" | ||
val s03 = "s03" | ||
val s04 = "s04" | ||
val s05 = "s05" | ||
val s06 = "s06" | ||
val s07 = "s07" | ||
val s08 = "s08" | ||
|
||
// 24 rows follow | ||
((s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" + | ||
s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" + | ||
s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" + | ||
s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" + | ||
s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" + | ||
s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n") + | ||
(s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" + | ||
s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" + | ||
s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" + | ||
s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" + | ||
s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" + | ||
s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n")) + | ||
((s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" + | ||
s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" + | ||
s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" + | ||
s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" + | ||
s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" + | ||
s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n") + | ||
(s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" + | ||
s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" + | ||
s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" + | ||
s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" + | ||
s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" + | ||
s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n")) | ||
} | ||
println("----------") | ||
println(concatenatingVariousTypes()) | ||
println("----------") | ||
println(concatenationInvolvingSpecialCharacters()) | ||
println("----------") | ||
println(largeConcatenation()) | ||
println("----------") | ||
} |