Skip to content

Commit ce13350

Browse files
committed
Add test for int setting
1 parent a9be669 commit ce13350

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

compiler/test/dotty/tools/dotc/SettingsTests.scala

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import dotty.tools.vulpix.TestConfiguration.mkClasspath
1313
import java.nio.file._
1414

1515
import org.junit.Test
16-
import org.junit.Assert._
16+
import org.junit.Assert.{assertEquals, assertFalse, assertTrue}
1717

1818
class SettingsTests {
1919

@@ -106,7 +106,7 @@ class SettingsTests {
106106
false
107107

108108
val default = Settings.defaultState
109-
dotty.tools.assertThrows[IllegalArgumentException](checkMessage("found: not an option of type java.lang.String, required: Boolean")) {
109+
assertThrows[IllegalArgumentException](checkMessage("found: not an option of type java.lang.String, required: Boolean")) {
110110
Settings.option.updateIn(default, "not an option")
111111
}
112112

@@ -166,18 +166,23 @@ class SettingsTests {
166166
)
167167
assertEquals(expectedErrors, summary.errors)
168168
}
169+
end validateChoices
169170

170171
@Test def `Allow IntSetting's to be set with a colon`: Unit =
171172
object Settings extends SettingGroup:
172173
val foo = IntSetting("-foo", "foo", 80)
173174
import Settings._
174175

175-
val args = List("-foo:100")
176-
val summary = processArguments(args, processAll = true)
177-
assertTrue(s"Setting args errors:\n ${summary.errors.take(5).mkString("\n ")}", summary.errors.isEmpty)
178-
withProcessedArgs(summary) {
179-
assertEquals(100, foo.value)
176+
def check(args: List[String]) = {
177+
val summary = processArguments(args, processAll = true)
178+
assertTrue(s"Setting args errors:\n ${summary.errors.take(5).mkString("\n ")}", summary.errors.isEmpty)
179+
withProcessedArgs(summary) {
180+
assertEquals(100, foo.value)
181+
}
180182
}
183+
check(List("-foo:100"))
184+
check(List("-foo", "100"))
185+
assertThrows[AssertionError](_.getMessage.contains("missing argument for option -foo"))(check(List("-foo")))
181186

182187
private def withProcessedArgs(summary: ArgsSummary)(f: SettingsState ?=> Unit) = f(using summary.sstate)
183188

0 commit comments

Comments
 (0)