Skip to content

Commit 8d72e89

Browse files
committed
Add test for int setting
1 parent 63e8e8b commit 8d72e89

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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)