Skip to content

Commit f6b0755

Browse files
committed
Prefer context functions for ReplTests
1 parent 729d76e commit f6b0755

File tree

7 files changed

+108
-116
lines changed

7 files changed

+108
-116
lines changed

compiler/test/dotty/tools/repl/DocTests.scala

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,109 +7,109 @@ import org.junit.Assert.assertEquals
77
class DocTests extends ReplTest {
88

99
@Test def docOfDef =
10-
eval("/** doc */ def foo = 0").andThen { implicit s =>
10+
eval("/** doc */ def foo = 0").andThen {
1111
assertEquals("doc", doc("foo"))
1212
}
1313

1414
@Test def docOfVal =
15-
eval("/** doc */ val foo = 0").andThen { implicit s =>
15+
eval("/** doc */ val foo = 0").andThen {
1616
assertEquals("doc", doc("foo"))
1717
}
1818

1919
@Test def docOfObject =
20-
eval("/** doc */ object Foo").andThen { implicit s =>
20+
eval("/** doc */ object Foo").andThen {
2121
assertEquals("doc", doc("Foo"))
2222
}
2323

2424
@Test def docOfClass =
25-
eval("/** doc */ class Foo").andThen { implicit s =>
25+
eval("/** doc */ class Foo").andThen {
2626
assertEquals("doc", doc("new Foo"))
2727
}
2828

2929
@Test def docOfTrait =
30-
eval("/** doc */ trait Foo").andThen { implicit s =>
30+
eval("/** doc */ trait Foo").andThen {
3131
assertEquals("doc", doc("new Foo"))
3232
}
3333
/*
3434
@Test def docOfExtension1 =
35-
eval("/** doc */ extension (x: Int) def foo = 0").andThen { implicit s =>
35+
eval("/** doc */ extension (x: Int) def foo = 0").andThen {
3636
assertEquals("doc", doc("extension_foo"))
3737
}
3838
3939
@Test def docOfExtension2 =
40-
eval("extension (x: Int) /** doc */ def foo = 0").andThen { implicit s =>
40+
eval("extension (x: Int) /** doc */ def foo = 0").andThen {
4141
assertEquals("doc", doc("extension_foo"))
4242
}
4343
4444
@Test def docOfExtension3 =
45-
eval("/** doc0 */ extension (x: Int) { /** doc1 */ def foo = 0; /** doc2 */ def bar = 0; def baz = 0 }").andThen { implicit s =>
45+
eval("/** doc0 */ extension (x: Int) { /** doc1 */ def foo = 0; /** doc2 */ def bar = 0; def baz = 0 }").andThen {
4646
assertEquals("doc1", doc("extension_foo"))
4747
assertEquals("doc2", doc("extension_bar"))
4848
assertEquals("doc0", doc("extension_baz"))
4949
}
5050
*/
5151
@Test def docOfDefInObject =
52-
eval("object O { /** doc */ def foo = 0 }").andThen { implicit s =>
52+
eval("object O { /** doc */ def foo = 0 }").andThen {
5353
assertEquals("doc", doc("O.foo"))
5454
}
5555

5656
@Test def docOfValInObject =
57-
eval("object O { /** doc */ val foo = 0 }").andThen { implicit s =>
57+
eval("object O { /** doc */ val foo = 0 }").andThen {
5858
assertEquals("doc", doc("O.foo"))
5959
}
6060

6161
@Test def docOfObjectInObject =
62-
eval("object O { /** doc */ object Foo }").andThen { implicit s =>
62+
eval("object O { /** doc */ object Foo }").andThen {
6363
assertEquals("doc", doc("O.Foo"))
6464
}
6565

6666
@Test def docOfClassInObject =
67-
eval("object O { /** doc */ class Foo }").andThen { implicit s =>
67+
eval("object O { /** doc */ class Foo }").andThen {
6868
assertEquals("doc", doc("new O.Foo"))
6969
}
7070

7171
@Test def docOfTraitInObject =
72-
eval("object O { /** doc */ trait Foo }").andThen { implicit s =>
72+
eval("object O { /** doc */ trait Foo }").andThen {
7373
assertEquals("doc", doc("new O.Foo"))
7474
}
7575

7676
@Test def docOfDefInClass =
7777
eval(
7878
"""class C { /** doc */ def foo = 0 }
7979
|val c = new C
80-
""".stripMargin).andThen { implicit s =>
80+
""".stripMargin).andThen {
8181
assertEquals("doc", doc("c.foo"))
8282
}
8383

8484
@Test def docOfValInClass =
8585
eval(
8686
"""class C { /** doc */ val foo = 0 }
8787
|val c = new C
88-
""".stripMargin).andThen { implicit s =>
88+
""".stripMargin).andThen {
8989
assertEquals("doc", doc("c.foo"))
9090
}
9191

9292
@Test def docOfObjectInClass =
9393
eval(
9494
"""class C { /** doc */ object Foo }
9595
|val c = new C
96-
""".stripMargin).andThen { implicit s =>
96+
""".stripMargin).andThen {
9797
assertEquals("doc", doc("c.Foo"))
9898
}
9999

100100
@Test def docOfClassInClass =
101101
eval(
102102
"""class C { /** doc */ class Foo }
103103
|val c = new C
104-
""".stripMargin).andThen { implicit s =>
104+
""".stripMargin).andThen {
105105
assertEquals("doc", doc("new c.Foo"))
106106
}
107107

108108
@Test def docOfTraitInClass =
109109
eval(
110110
"""class C { /** doc */ trait Foo }
111111
|val c = new C
112-
""".stripMargin).andThen { implicit s =>
112+
""".stripMargin).andThen {
113113
assertEquals("doc", doc("new c.Foo"))
114114
}
115115

@@ -119,7 +119,7 @@ class DocTests extends ReplTest {
119119
| /** doc0 */ def foo(x: Int) = x
120120
| /** doc1 */ def foo(x: String) = x
121121
|}
122-
""".stripMargin).andThen { implicit s =>
122+
""".stripMargin).andThen {
123123
assertEquals("doc0", doc("O.foo(_: Int)"))
124124
assertEquals("doc1", doc("O.foo(_: String)"))
125125
}
@@ -128,7 +128,7 @@ class DocTests extends ReplTest {
128128
eval(
129129
"""class C { /** doc */ def foo = 0 }
130130
|object O extends C
131-
""".stripMargin).andThen { implicit s =>
131+
""".stripMargin).andThen {
132132
assertEquals("doc", doc("O.foo"))
133133
}
134134

@@ -142,7 +142,7 @@ class DocTests extends ReplTest {
142142
| override def foo(x: Int): Int = x
143143
| /** overridden doc */ override def foo(x: String): String = x
144144
|}
145-
""".stripMargin).andThen { implicit s =>
145+
""".stripMargin).andThen {
146146
assertEquals("doc0", doc("O.foo(_: Int)"))
147147
assertEquals("overridden doc", doc("O.foo(_: String)"))
148148
}
@@ -158,7 +158,7 @@ class DocTests extends ReplTest {
158158
| override def bar: Int = 0
159159
| }
160160
|}
161-
""".stripMargin).andThen { implicit s =>
161+
""".stripMargin).andThen {
162162
assertEquals("companion", doc("O.foo"))
163163
assertEquals("doc0", doc("O.foo.bar"))
164164
}
@@ -173,18 +173,16 @@ class DocTests extends ReplTest {
173173
| /** Expansion: $Variable */
174174
| def hello = "world"
175175
|}
176-
""".stripMargin).andThen { implicit s =>
176+
""".stripMargin).andThen {
177177
assertEquals("Expansion: some-value", doc("Foo.hello"))
178178
}
179179

180-
@Test def docOfEmpty =
181-
fromInitialState { implicit s =>
180+
@Test def docOfEmpty = initially {
182181
run(":doc")
183182
assertEquals(":doc <expression>", storedOutput().trim)
184183
}
185184

186-
private def eval(code: String): State =
187-
fromInitialState { implicit s => run(code) }
185+
private def eval(code: String): State = initially(run(code))
188186

189187
private def doc(expr: String)(implicit s: State): String = {
190188
storedOutput()

compiler/test/dotty/tools/repl/JavaDefinedTests.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import org.junit.Assert._
44
import org.junit.Test
55

66
class JavaDefinedTests extends ReplTest {
7-
@Test def typeOfJavaDefinedString = fromInitialState { implicit s =>
7+
@Test def typeOfJavaDefinedString = initially {
88
run("String")
99
assertTrue(storedOutput().contains("Java defined class String is not a value"))
1010
}
1111

12-
@Test def typeOfJavaDefinedClass = fromInitialState { implicit s =>
12+
@Test def typeOfJavaDefinedClass = initially {
1313
run("Class")
1414
assertTrue(storedOutput().contains("Java defined class Class is not a value"))
1515
}

compiler/test/dotty/tools/repl/LoadTests.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,13 @@ class LoadTests extends ReplTest {
4646
)
4747

4848
def loadTest(file: String, defs: String, runCode: String, output: String) =
49-
eval(s":load ${writeFile(file)}").andThen { implicit s =>
49+
eval(s":load ${writeFile(file)}").andThen {
5050
assertMultiLineEquals(defs, storedOutput())
5151
run(runCode)
5252
assertMultiLineEquals(output, storedOutput())
5353
}
5454

55-
private def eval(code: String): State =
56-
fromInitialState { implicit s => run(code) }
57-
55+
private def eval(code: String): State = initially(run(code))
5856
}
5957

6058
object LoadTests {

0 commit comments

Comments
 (0)