Skip to content

Commit d9549fa

Browse files
committed
REPL: Sort displayed definitions
This makes REPL tests deterministic.
1 parent cbfc469 commit d9549fa

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

compiler/src/dotty/tools/repl/ReplDriver.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,16 @@ class ReplDriver(settings: Array[String],
254254
denot.symbol.owner == defn.ObjectClass ||
255255
denot.symbol.isConstructor
256256
}
257+
.sortBy(_.name)
257258

258259
val vals =
259260
info.fields
260261
.filterNot(_.symbol.is(ParamAccessor | Private | Synthetic | Module))
261262
.filter(_.symbol.name.is(SimpleNameKind))
263+
.sortBy(_.name)
262264

263265
val typeAliases =
264-
info.bounds.hi.typeMembers.filter(_.symbol.info.isTypeAlias)
266+
info.bounds.hi.typeMembers.filter(_.symbol.info.isTypeAlias).sortBy(_.name)
265267

266268
(
267269
typeAliases.map("// defined alias " + _.symbol.showUser) ++

compiler/test-resources/repl/top-level-block

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ scala> A()
1010
val res2: A = A()
1111

1212
scala> { def f: Int = g; def g: Int = 5 }
13-
def g: Int
1413
def f: Int
14+
def g: Int
1515

1616
scala> f + g
1717
val res3: Int = 10
1818

1919
scala> { val x = 3; 4; val y = 5 }
20-
val x: Int = 3
2120
val res4: Int = 4
21+
val x: Int = 3
2222
val y: Int = 5

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ class ReplCompilerTests extends ReplTest {
4848

4949
val expected = List(
5050
"def foo: Int",
51-
"val x: Int = 10",
5251
"val res0: Int = 2",
53-
"var y: Int = 5",
54-
"val res1: Int = 20"
52+
"val res1: Int = 20",
53+
"val x: Int = 10",
54+
"var y: Int = 5"
5555
)
5656

5757
assertEquals(expected, lines())

language-server/test/dotty/tools/languageserver/WorksheetTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class WorksheetTest {
8585

8686
@Test def patternMatching1: Unit = {
8787
ws"""${m1}val (foo, bar) = (1, 2)""".withSource
88-
.run(m1, s"1:val foo: Int = 1${nl}val bar: Int = 2")
88+
.run(m1, s"1:val bar: Int = 2${nl}val foo: Int = 1")
8989
}
9090

9191
@Test def evaluationException: Unit = {

0 commit comments

Comments
 (0)