Skip to content

Commit 113c587

Browse files
committed
Small cleanups to CodeGen and Test.
1 parent 5eb1313 commit 113c587

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

project/CodeGen.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ default ${r.prim} $name(${t1.prim} v1, ${t2.prim} v2) {
154154
case x => fNHeader(arity) + "\n}\n"
155155
}
156156

157-
def pN(arity: Int) = {
157+
def pN(arity: Int): String = {
158158
def csv(f: Int => String): String =
159159
(1 to arity).map(f).mkString(", ")
160160
val tparams = (1 to arity).map("T" + _).mkString(", ")
@@ -174,6 +174,7 @@ public interface P${arity}<${tparams}> extends ${parent}<$tparams, BoxedUnit> {
174174
}
175175

176176
void applyVoid($vparams);
177+
177178
default BoxedUnit apply($vparams) {
178179
applyVoid($vparamRefs);
179180
return BoxedUnit.UNIT;
@@ -182,7 +183,7 @@ public interface P${arity}<${tparams}> extends ${parent}<$tparams, BoxedUnit> {
182183
"""
183184
}
184185

185-
def factory = {
186+
def factory: String = {
186187
def factory0(n: Int) = {
187188
val tparams = (1 to n).map("T" + _).mkString(", ")
188189
s"""
@@ -221,7 +222,7 @@ static void acceptFunction${n}Unit(scala.Function$n<$targs, scala.runtime.BoxedU
221222
"""
222223
}
223224

224-
def testApi = {
225+
def testApi: String = {
225226
s"""
226227
$copyright
227228

src/test/java/scala/runtime/test/Test.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
import scala.runtime.*;
77
import static scala.runtime.test.TestAPI.*;
8-
import static scala.runtime.F.func;
9-
import static scala.runtime.F.proc;
8+
import static scala.runtime.F.*;
109

1110
public class Test {
1211
public static void main(String[] args) {
@@ -61,7 +60,7 @@ public static void main(String[] args) {
6160
// as are `curried`, `tupled`, `compose`, `andThen`.
6261
f3.compose(f3).andThen(f3).apply("");
6362
scala.Function2<String, String, String> f6 = func((s1, s2) -> join(s1, s2));
64-
assert(f6.curried().apply("1").apply("2") == "12");
63+
assert(f6.curried().apply("1").apply("2").equals("12"));
6564

6665
// Functions returning unit must use the `P1`, ... functional interfaces
6766
// in order to convert a void lamdba return to Scala's Unit.
@@ -76,20 +75,20 @@ public static void main(String[] args) {
7675

7776
// Function0 is also available
7877
scala.Function0<String> f9 = F.f0(() -> "42");
79-
assert(f9.apply() == "42");
78+
assert(f9.apply().equals("42"));
8079

8180
// You can go up to 22 (the highest arity function defined in the Scala standard library.)
82-
assert(acceptFunction1(func(v1 -> v1.toUpperCase())) == "1");
81+
assert(acceptFunction1(func(v1 -> v1.toUpperCase())).equals("1"));
8382
acceptFunction1Unit(proc(v1 -> sideEffect()));
8483
acceptFunction1Unit(proc(v1 -> {v1.toUpperCase(); return;}));
8584

86-
assert(acceptFunction2(func((v1, v2) -> join(v1, v2))) == "12");
85+
assert(acceptFunction2(func((v1, v2) -> join(v1, v2))).equals("12"));
8786
acceptFunction2Unit(proc((v1, v2) -> {v1.toUpperCase(); return;}));
8887

89-
assert(acceptFunction3(func((v1, v2, v3) -> join(v1, v2, v3))) == "123");
88+
assert(acceptFunction3(func((v1, v2, v3) -> join(v1, v2, v3))).equals("123"));
9089
acceptFunction3Unit(proc((v1, v2, v3) -> {v1.toUpperCase(); return;}));
9190

92-
assert(acceptFunction22(func((v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) -> join(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22))) == "12345678910111213141516171819202122");
91+
assert(acceptFunction22(func((v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) -> join(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22))).equals("12345678910111213141516171819202122"));
9392
acceptFunction22Unit( proc((v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) -> {v1.toUpperCase(); return;}));
9493
}
9594

0 commit comments

Comments
 (0)