@@ -15,13 +15,15 @@ import dotty.tools.io.PlainDirectory
15
15
import dotty .tools .io .Directory
16
16
import dotty .tools .dotc .config .ScalaVersion
17
17
18
- import java .nio .file ._
18
+ import java .nio .file .*
19
19
20
20
import org .junit .Test
21
- import org .junit .Assert ._
21
+ import org .junit .Assert .{ assertEquals , assertFalse , assertNotEquals , assertTrue }
22
22
import scala .util .Using
23
23
24
- class SettingsTests {
24
+ class SettingsTests :
25
+
26
+ private val TestCategory = new SettingCategory { def prefixLetter = " T" }
25
27
26
28
@ Test def missingOutputDir : Unit =
27
29
val options = Array (" -d" , " not_here" )
@@ -112,7 +114,7 @@ class SettingsTests {
112
114
false
113
115
114
116
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" )) {
116
118
Settings .option.updateIn(default, " not an option" )
117
119
}
118
120
@@ -172,11 +174,12 @@ class SettingsTests {
172
174
)
173
175
assertEquals(expectedErrors, summary.errors)
174
176
}
177
+ end validateChoices
175
178
176
179
@ Test def `Allow IntSetting's to be set with a colon` : Unit =
177
180
object Settings extends SettingGroup :
178
181
val foo = IntSetting (RootSetting , " foo" , " foo" , 80 )
179
- import Settings ._
182
+ import Settings .*
180
183
181
184
val args = List (" -foo:100" )
182
185
val summary = processArguments(args, processAll = true )
@@ -191,7 +194,7 @@ class SettingsTests {
191
194
val bar = BooleanSetting (RootSetting , " bar" , " bar" , true )
192
195
val baz = BooleanSetting (RootSetting , " baz" , " baz" , false )
193
196
val qux = BooleanSetting (RootSetting , " qux" , " qux" , false )
194
- import Settings ._
197
+ import Settings .*
195
198
196
199
val args = List (" -foo:true" , " -bar:false" , " -baz" , " -qux:true" , " -qux:false" )
197
200
val summary = processArguments(args, processAll = true )
@@ -210,7 +213,7 @@ class SettingsTests {
210
213
val defaultDir = new PlainDirectory (Directory (" ." ))
211
214
val testOutput = OutputSetting (RootSetting , " testOutput" , " testOutput" , " " , defaultDir)
212
215
213
- import Settings ._
216
+ import Settings .*
214
217
215
218
Files .write(file, " test" .getBytes())
216
219
val fileStateBefore = String (Files .readAllBytes(file))
@@ -230,7 +233,7 @@ class SettingsTests {
230
233
val defaultDir = new PlainDirectory (Directory (" ." ))
231
234
val testOutput = OutputSetting (RootSetting , " testOutput" , " testOutput" , " " , defaultDir, preferPrevious = true )
232
235
233
- import Settings ._
236
+ import Settings .*
234
237
235
238
Files .write(file1, " test1" .getBytes())
236
239
Files .write(file2, " test2" .getBytes())
@@ -255,7 +258,7 @@ class SettingsTests {
255
258
val defaultDir = new PlainDirectory (Directory (" ." ))
256
259
val testOutput = OutputSetting (RootSetting , " testOutput" , " testOutput" , " " , defaultDir, preferPrevious = true , deprecation = Deprecation .renamed(" XtestOutput" ))
257
260
258
- import Settings ._
261
+ import Settings .*
259
262
260
263
Files .write(file, " test" .getBytes())
261
264
val fileStateBefore = String (Files .readAllBytes(file))
@@ -282,7 +285,7 @@ class SettingsTests {
282
285
val phasesSetting = PhasesSetting (RootSetting , " phasesSetting" , " phasesSetting" , " all" )
283
286
val versionSetting = VersionSetting (RootSetting , " versionSetting" , " versionSetting" )
284
287
285
- import Settings ._
288
+ import Settings .*
286
289
Using .resource(Files .createTempDirectory(" testDir" )) { dir =>
287
290
288
291
val args = List (
@@ -323,8 +326,17 @@ class SettingsTests {
323
326
324
327
}(Files .deleteIfExists(_))
325
328
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
+
326
339
private def withProcessedArgs (summary : ArgsSummary )(f : SettingsState ?=> Unit ) = f(using summary.sstate)
327
340
328
341
extension [T ](setting : Setting [T ])
329
342
private def value (using ss : SettingsState ): T = setting.valueIn(ss)
330
- }
0 commit comments