Skip to content

Commit adaa2c1

Browse files
committed
Fix tests
The init code of top-level objects goes to the static init. It's simpler to use a normal class instead.
1 parent ef48dc0 commit adaa2c1

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

compiler/test/dotty/tools/dotc/transform/SpecializeFunctionsTests.scala

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class SpecializeFunctionsTests extends DottyBytecodeTest {
6767

6868
@Test def noBoxingSpecFunction0 = {
6969
implicit val source: String =
70-
"""|object Test {
70+
"""|class Test {
7171
| class Func0 extends Function0[Int] {
7272
| def apply() = 1337
7373
| }
@@ -76,13 +76,13 @@ class SpecializeFunctionsTests extends DottyBytecodeTest {
7676
|}""".stripMargin
7777

7878
checkBCode(source) { dir =>
79-
assertNoBoxing("<init>", findClass("Test$", dir).methods)
79+
assertNoBoxing("<init>", findClass("Test", dir).methods)
8080
}
8181
}
8282

8383
@Test def boxingFunction1 = {
8484
implicit val source: String =
85-
"""|object Test {
85+
"""|class Test {
8686
| class Func1 extends Function1[Char, Int] {
8787
| def apply(c: Char) = c.toInt
8888
| }
@@ -92,13 +92,13 @@ class SpecializeFunctionsTests extends DottyBytecodeTest {
9292

9393
checkBCode(source) { dir =>
9494
// No specialization for Function1[Char, Int]
95-
assertBoxing("<init>", findClass("Test$", dir).methods)
95+
assertBoxing("<init>", findClass("Test", dir).methods)
9696
}
9797
}
9898

9999
@Test def noBoxingSpecFunction1 = {
100100
implicit val source: String =
101-
"""|object Test {
101+
"""|class Test {
102102
| class Func1 extends Function1[Int, Int] {
103103
| def apply(i: Int) = i + 1
104104
| }
@@ -107,13 +107,13 @@ class SpecializeFunctionsTests extends DottyBytecodeTest {
107107
|}""".stripMargin
108108

109109
checkBCode(source) { dir =>
110-
assertNoBoxing("<init>", findClass("Test$", dir).methods)
110+
assertNoBoxing("<init>", findClass("Test", dir).methods)
111111
}
112112
}
113113

114114
@Test def noBoxingSpecFunction2 = {
115115
implicit val source: String =
116-
"""|object Test {
116+
"""|class Test {
117117
| class Func2 extends Function2[Int, Int, Int] {
118118
| def apply(i: Int, j: Int) = i + j
119119
| }
@@ -122,13 +122,13 @@ class SpecializeFunctionsTests extends DottyBytecodeTest {
122122
|}""".stripMargin
123123

124124
checkBCode(source) { dir =>
125-
assertNoBoxing("<init>", findClass("Test$", dir).methods)
125+
assertNoBoxing("<init>", findClass("Test", dir).methods)
126126
}
127127
}
128128

129129
@Test def boxingFunction2 = {
130130
implicit val source: String =
131-
"""|object Test {
131+
"""|class Test {
132132
| class Func2 extends Function2[Char, Char, Char] {
133133
| def apply(c1: Char, c2: Char) = c1
134134
| }
@@ -138,13 +138,13 @@ class SpecializeFunctionsTests extends DottyBytecodeTest {
138138

139139
checkBCode(source) { dir =>
140140
// No specialization for Function2[Char, Char, Char]
141-
assertBoxing("<init>", findClass("Test$", dir).methods)
141+
assertBoxing("<init>", findClass("Test", dir).methods)
142142
}
143143
}
144144

145145
@Test def multipleParentsNoBoxing = {
146146
implicit val source: String =
147-
"""|object Test {
147+
"""|class Test {
148148
| class Func01 extends Function0[Int] with Function1[Int, Int] {
149149
| def apply(): Int = 0
150150
| def apply(x: Int): Int = x
@@ -154,13 +154,13 @@ class SpecializeFunctionsTests extends DottyBytecodeTest {
154154
|}""".stripMargin
155155

156156
checkBCode(source) { dir =>
157-
assertNoBoxing("<init>", findClass("Test$", dir).methods)
157+
assertNoBoxing("<init>", findClass("Test", dir).methods)
158158
}
159159
}
160160

161161
@Test def multipleLevelInheritanceNoBoxing = {
162162
implicit val source: String =
163-
"""|object Test {
163+
"""|class Test {
164164
| class Func1[T](fn: T => Int) extends Function1[T, Int] {
165165
| def apply(x: T): Int = fn(x)
166166
| }
@@ -169,25 +169,25 @@ class SpecializeFunctionsTests extends DottyBytecodeTest {
169169
|}""".stripMargin
170170

171171
checkBCode(source) { dir =>
172-
assertNoBoxing("<init>", findClass("Test$", dir).methods)
172+
assertNoBoxing("<init>", findClass("Test", dir).methods)
173173
}
174174
}
175175

176176
@Test def lambdaNoBoxing1 = {
177177
implicit val source: String =
178-
"""|object Test {
178+
"""|class Test {
179179
| val fn = (x: Int) => x + 1
180180
| fn(2)
181181
|}""".stripMargin
182182

183183
checkBCode(source) { dir =>
184-
assertNoBoxing("<init>", findClass("Test$", dir).methods)
184+
assertNoBoxing("<init>", findClass("Test", dir).methods)
185185
}
186186
}
187187

188188
@Test def lambdaNoBoxing2 = {
189189
implicit val source: String =
190-
"""|object Test {
190+
"""|class Test {
191191
| def fn[T, U, V](op0: T => U, op1: U => V): T => V = (x: T) => op1(op0(x))
192192
| val f0: Int => Double = _.toDouble
193193
| val f1: Double => Int = _.toInt
@@ -196,13 +196,13 @@ class SpecializeFunctionsTests extends DottyBytecodeTest {
196196
|}""".stripMargin
197197

198198
checkBCode(source) { dir =>
199-
assertNoBoxing("<init>", findClass("Test$", dir).methods)
199+
assertNoBoxing("<init>", findClass("Test", dir).methods)
200200
}
201201
}
202202

203203
@Test def classWithFieldBoxing = {
204204
implicit val source: String =
205-
"""|object Test {
205+
"""|class Test {
206206
| class Func0[T](x: T) extends Function0[T] {
207207
| def apply(): T = x
208208
| }
@@ -211,19 +211,19 @@ class SpecializeFunctionsTests extends DottyBytecodeTest {
211211

212212
checkBCode(source) { dir =>
213213
// Boxing happens because of the field of `Func0`.
214-
assertBoxing("<init>", findClass("Test$", dir).methods)
214+
assertBoxing("<init>", findClass("Test", dir).methods)
215215
}
216216
}
217217

218218
@Test def passByNameNoBoxing = {
219219
implicit val source: String =
220-
"""|object Test {
220+
"""|class Test {
221221
| def fn(x: => Int): Int = x
222222
| fn(2)
223223
|}""".stripMargin
224224

225225
checkBCode(source) { dir =>
226-
assertNoBoxing("fn", findClass("Test$", dir).methods)
226+
assertNoBoxing("fn", findClass("Test", dir).methods)
227227
}
228228
}
229229
}

0 commit comments

Comments
 (0)