Skip to content

Commit a44924d

Browse files
zmerrromanowski
authored andcommitted
fixed the Left test through .get with .swap.exists
1 parent eb0a369 commit a44924d

File tree

2 files changed

+29
-25
lines changed

2 files changed

+29
-25
lines changed

modules/build/src/test/scala/scala/build/tests/BuildOptionsTests.scala

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ class BuildOptionsTests extends munit.FunSuite {
5050
)
5151
)
5252
assert(
53-
options.projectParams.isLeft && options.projectParams.left.get.isInstanceOf[
54-
InvalidBinaryScalaVersionError
55-
],
53+
options.projectParams.swap.exists {
54+
case _: InvalidBinaryScalaVersionError => true; case _ => false
55+
},
5656
s"specifying the 3.${Int.MaxValue} scala version does not lead to the Invalid Binary Scala Version Error"
5757
)
5858
}
@@ -67,7 +67,9 @@ class BuildOptionsTests extends munit.FunSuite {
6767
)
6868
)
6969
assert(
70-
options.projectParams.swap.exists { case _: UnsupportedScalaVersionError => true; case _ => false },
70+
options.projectParams.swap.exists {
71+
case _: UnsupportedScalaVersionError => true; case _ => false
72+
},
7173
"specifying the 2.11.2 scala version does not lead to the Unsupported Scala Version Error"
7274
)
7375
}
@@ -82,9 +84,9 @@ class BuildOptionsTests extends munit.FunSuite {
8284
)
8385
)
8486
assert(
85-
options.projectParams.isLeft && options.projectParams.left.get.isInstanceOf[
86-
UnsupportedScalaVersionError
87-
],
87+
options.projectParams.swap.exists {
88+
case _: UnsupportedScalaVersionError => true; case _ => false
89+
},
8890
"specifying the 2.11 scala version does not lead to the Unsupported Scala Version Error"
8991
)
9092
}
@@ -99,9 +101,9 @@ class BuildOptionsTests extends munit.FunSuite {
99101
)
100102
)
101103
assert(
102-
options.projectParams.isLeft && options.projectParams.left.get.isInstanceOf[
103-
InvalidBinaryScalaVersionError
104-
],
104+
options.projectParams.swap.exists {
105+
case _: InvalidBinaryScalaVersionError => true; case _ => false
106+
},
105107
"specifying the 3.2147483647.3 scala version does not lead to the Invalid Binary Scala Version Error"
106108
)
107109
}
@@ -116,9 +118,9 @@ class BuildOptionsTests extends munit.FunSuite {
116118
)
117119
)
118120
assert(
119-
options.projectParams.isLeft && options.projectParams.left.get.isInstanceOf[
120-
NoValidScalaVersionFoundError
121-
],
121+
options.projectParams.swap.exists {
122+
case _: NoValidScalaVersionFoundError => true; case _ => false
123+
},
122124
"specifying the wrong full scala 3 nightly version does not lead to the No Valid Scala Version Found Error"
123125
)
124126
}
@@ -131,9 +133,9 @@ class BuildOptionsTests extends munit.FunSuite {
131133
)
132134
)
133135
assert(
134-
options.projectParams.isLeft && options.projectParams.left.get.isInstanceOf[
135-
NoValidScalaVersionFoundError
136-
],
136+
options.projectParams.swap.exists {
137+
case _: NoValidScalaVersionFoundError => true; case _ => false
138+
},
137139
"specifying the wrong full scala 2 nightly version does not lead to the No Valid Scala Version Found Error"
138140
)
139141
}
@@ -147,9 +149,12 @@ class BuildOptionsTests extends munit.FunSuite {
147149
supportedScalaVersionsUrl = None
148150
)
149151
)
150-
assert(options.projectParams.isLeft && options.projectParams.left.get.isInstanceOf[
151-
InvalidBinaryScalaVersionError
152-
])
152+
assert(
153+
options.projectParams.swap.exists {
154+
case _: InvalidBinaryScalaVersionError => true; case _ => false
155+
},
156+
s"specifying 2.${Int.MaxValue} as Scala version does not lead to Invalid Binary Scala Version Error"
157+
)
153158
}
154159

155160
test("-S 2.nightly option works") {
@@ -210,10 +215,7 @@ class BuildOptionsTests extends munit.FunSuite {
210215
scalaOptions = ScalaOptions(
211216
scalaVersion = prefix,
212217
scalaBinaryVersion = None,
213-
supportedScalaVersionsUrl =
214-
Some(
215-
Random.alphanumeric.take(10).mkString("")
216-
) // invalid url, it should use defaults from Deps.sc
218+
supportedScalaVersionsUrl = None
217219
)
218220
)
219221
val scalaParams = options.scalaParams.orThrow

modules/build/src/test/scala/scala/build/tests/BuildTests.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,8 +830,10 @@ class BuildTests extends munit.FunSuite {
830830
)
831831
)
832832
testInputs.withBuild(buildOptions, buildThreads, bloopConfig) { (_, _, maybeBuild) =>
833-
assert(maybeBuild.isLeft)
834-
assert(maybeBuild.left.get.isInstanceOf[InvalidBinaryScalaVersionError])
833+
assert(
834+
maybeBuild.swap.exists { case _: InvalidBinaryScalaVersionError => true; case _ => false },
835+
s"specifying Scala 3.${Int.MaxValue}.3 as version does not lead to InvalidBinaryScalaVersionError"
836+
)
835837
}
836838
}
837839

0 commit comments

Comments
 (0)