@@ -15,13 +15,15 @@ import dotty.tools.io.PlainDirectory
1515import dotty .tools .io .Directory
1616import dotty .tools .dotc .config .ScalaVersion
1717
18- import java .nio .file ._
18+ import java .nio .file .*
1919
2020import org .junit .Test
21- import org .junit .Assert ._
21+ import org .junit .Assert .{ assertEquals , assertFalse , assertNotEquals , assertTrue }
2222import scala .util .Using
2323
24- class SettingsTests {
24+ class SettingsTests :
25+
26+ private val TestCategory = new SettingCategory { def prefixLetter = " T" }
2527
2628 @ Test def missingOutputDir : Unit =
2729 val options = Array (" -d" , " not_here" )
@@ -112,7 +114,7 @@ class SettingsTests {
112114 false
113115
114116 val default = Settings .defaultState
115- dotty.tools. assertThrows[IllegalArgumentException ](checkMessage(" found: not an option of type java.lang.String, required: Boolean" )) {
117+ assertThrows[IllegalArgumentException ](checkMessage(" found: not an option of type java.lang.String, required: Boolean" )) {
116118 Settings .option.updateIn(default, " not an option" )
117119 }
118120
@@ -172,11 +174,12 @@ class SettingsTests {
172174 )
173175 assertEquals(expectedErrors, summary.errors)
174176 }
177+ end validateChoices
175178
176179 @ Test def `Allow IntSetting's to be set with a colon` : Unit =
177180 object Settings extends SettingGroup :
178181 val foo = IntSetting (RootSetting , " foo" , " foo" , 80 )
179- import Settings ._
182+ import Settings .*
180183
181184 val args = List (" -foo:100" )
182185 val summary = processArguments(args, processAll = true )
@@ -191,7 +194,7 @@ class SettingsTests {
191194 val bar = BooleanSetting (RootSetting , " bar" , " bar" , true )
192195 val baz = BooleanSetting (RootSetting , " baz" , " baz" , false )
193196 val qux = BooleanSetting (RootSetting , " qux" , " qux" , false )
194- import Settings ._
197+ import Settings .*
195198
196199 val args = List (" -foo:true" , " -bar:false" , " -baz" , " -qux:true" , " -qux:false" )
197200 val summary = processArguments(args, processAll = true )
@@ -210,7 +213,7 @@ class SettingsTests {
210213 val defaultDir = new PlainDirectory (Directory (" ." ))
211214 val testOutput = OutputSetting (RootSetting , " testOutput" , " testOutput" , " " , defaultDir)
212215
213- import Settings ._
216+ import Settings .*
214217
215218 Files .write(file, " test" .getBytes())
216219 val fileStateBefore = String (Files .readAllBytes(file))
@@ -230,7 +233,7 @@ class SettingsTests {
230233 val defaultDir = new PlainDirectory (Directory (" ." ))
231234 val testOutput = OutputSetting (RootSetting , " testOutput" , " testOutput" , " " , defaultDir, preferPrevious = true )
232235
233- import Settings ._
236+ import Settings .*
234237
235238 Files .write(file1, " test1" .getBytes())
236239 Files .write(file2, " test2" .getBytes())
@@ -255,7 +258,7 @@ class SettingsTests {
255258 val defaultDir = new PlainDirectory (Directory (" ." ))
256259 val testOutput = OutputSetting (RootSetting , " testOutput" , " testOutput" , " " , defaultDir, preferPrevious = true , deprecation = Deprecation .renamed(" XtestOutput" ))
257260
258- import Settings ._
261+ import Settings .*
259262
260263 Files .write(file, " test" .getBytes())
261264 val fileStateBefore = String (Files .readAllBytes(file))
@@ -282,7 +285,7 @@ class SettingsTests {
282285 val phasesSetting = PhasesSetting (RootSetting , " phasesSetting" , " phasesSetting" , " all" )
283286 val versionSetting = VersionSetting (RootSetting , " versionSetting" , " versionSetting" )
284287
285- import Settings ._
288+ import Settings .*
286289 Using .resource(Files .createTempDirectory(" testDir" )) { dir =>
287290
288291 val args = List (
@@ -323,8 +326,17 @@ class SettingsTests {
323326
324327 }(Files .deleteIfExists(_))
325328
329+ @ Test def `Multi setting with empty default errors if missing` : Unit =
330+ object Settings extends SettingGroup :
331+ val answers = MultiStringSetting (TestCategory , name= " Tanswer" , helpArg= " your reply" , descr= " answer me this" )
332+ import Settings .{answers , processArguments }
333+ val summary = processArguments(" -Tanswer" :: Nil , processAll = true )
334+ assertTrue(summary.warnings.isEmpty)
335+ assertFalse(summary.errors.isEmpty)
336+ withProcessedArgs(summary):
337+ assertTrue(answers.value.isEmpty)
338+
326339 private def withProcessedArgs (summary : ArgsSummary )(f : SettingsState ?=> Unit ) = f(using summary.sstate)
327340
328341 extension [T ](setting : Setting [T ])
329342 private def value (using ss : SettingsState ): T = setting.valueIn(ss)
330- }
0 commit comments