Skip to content

Commit 56cfaad

Browse files
committed
Add test for int setting
1 parent 7584a30 commit 56cfaad

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
@@ -164,18 +164,23 @@ class SettingsTests {
164164
)
165165
assertEquals(expectedErrors, summary.errors)
166166
}
167+
end validateChoices
167168

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

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

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

0 commit comments

Comments
 (0)