@@ -13,13 +13,15 @@ import dotty.tools.io.PlainDirectory
13
13
import dotty .tools .io .Directory
14
14
import dotty .tools .dotc .config .ScalaVersion
15
15
16
- import java .nio .file ._
16
+ import java .nio .file .*
17
17
18
18
import org .junit .Test
19
- import org .junit .Assert ._
19
+ import org .junit .Assert .{ assertEquals , assertFalse , assertNotEquals , assertTrue }
20
20
import scala .util .Using
21
21
22
- class SettingsTests {
22
+ class SettingsTests :
23
+
24
+ private val TestCategory = new SettingCategory { def prefixLetter = " T" }
23
25
24
26
@ Test def missingOutputDir : Unit =
25
27
val options = Array (" -d" , " not_here" )
@@ -110,7 +112,7 @@ class SettingsTests {
110
112
false
111
113
112
114
val default = Settings .defaultState
113
- dotty.tools. assertThrows[IllegalArgumentException ](checkMessage(" found: not an option of type java.lang.String, required: Boolean" )) {
115
+ assertThrows[IllegalArgumentException ](checkMessage(" found: not an option of type java.lang.String, required: Boolean" )) {
114
116
Settings .option.updateIn(default, " not an option" )
115
117
}
116
118
@@ -170,11 +172,12 @@ class SettingsTests {
170
172
)
171
173
assertEquals(expectedErrors, summary.errors)
172
174
}
175
+ end validateChoices
173
176
174
177
@ Test def `Allow IntSetting's to be set with a colon` : Unit =
175
178
object Settings extends SettingGroup :
176
179
val foo = IntSetting (RootSetting , " foo" , " foo" , 80 )
177
- import Settings ._
180
+ import Settings .*
178
181
179
182
val args = List (" -foo:100" )
180
183
val summary = processArguments(args, processAll = true )
@@ -189,7 +192,7 @@ class SettingsTests {
189
192
val bar = BooleanSetting (RootSetting , " bar" , " bar" , true )
190
193
val baz = BooleanSetting (RootSetting , " baz" , " baz" , false )
191
194
val qux = BooleanSetting (RootSetting , " qux" , " qux" , false )
192
- import Settings ._
195
+ import Settings .*
193
196
194
197
val args = List (" -foo:true" , " -bar:false" , " -baz" , " -qux:true" , " -qux:false" )
195
198
val summary = processArguments(args, processAll = true )
@@ -208,7 +211,7 @@ class SettingsTests {
208
211
val defaultDir = new PlainDirectory (Directory (" ." ))
209
212
val testOutput = OutputSetting (RootSetting , " testOutput" , " testOutput" , " " , defaultDir)
210
213
211
- import Settings ._
214
+ import Settings .*
212
215
213
216
Files .write(file, " test" .getBytes())
214
217
val fileStateBefore = String (Files .readAllBytes(file))
@@ -228,7 +231,7 @@ class SettingsTests {
228
231
val defaultDir = new PlainDirectory (Directory (" ." ))
229
232
val testOutput = OutputSetting (RootSetting , " testOutput" , " testOutput" , " " , defaultDir, preferPrevious = true )
230
233
231
- import Settings ._
234
+ import Settings .*
232
235
233
236
Files .write(file1, " test1" .getBytes())
234
237
Files .write(file2, " test2" .getBytes())
@@ -253,7 +256,7 @@ class SettingsTests {
253
256
val defaultDir = new PlainDirectory (Directory (" ." ))
254
257
val testOutput = OutputSetting (RootSetting , " testOutput" , " testOutput" , " " , defaultDir, preferPrevious = true , deprecation = Deprecation .renamed(" XtestOutput" ))
255
258
256
- import Settings ._
259
+ import Settings .*
257
260
258
261
Files .write(file, " test" .getBytes())
259
262
val fileStateBefore = String (Files .readAllBytes(file))
@@ -280,7 +283,7 @@ class SettingsTests {
280
283
val phasesSetting = PhasesSetting (RootSetting , " phasesSetting" , " phasesSetting" , " all" )
281
284
val versionSetting = VersionSetting (RootSetting , " versionSetting" , " versionSetting" )
282
285
283
- import Settings ._
286
+ import Settings .*
284
287
Using .resource(Files .createTempDirectory(" testDir" )) { dir =>
285
288
286
289
val args = List (
@@ -321,8 +324,17 @@ class SettingsTests {
321
324
322
325
}(Files .deleteIfExists(_))
323
326
327
+ @ Test def `Multi setting with empty default errors if missing` : Unit =
328
+ object Settings extends SettingGroup :
329
+ val answers = MultiStringSetting (TestCategory , name= " Tanswer" , helpArg= " your reply" , descr= " answer me this" )
330
+ import Settings .{answers , processArguments }
331
+ val summary = processArguments(" -Tanswer" :: Nil , processAll = true )
332
+ assertTrue(summary.warnings.isEmpty)
333
+ assertFalse(summary.errors.isEmpty)
334
+ withProcessedArgs(summary):
335
+ assertTrue(answers.value.isEmpty)
336
+
324
337
private def withProcessedArgs (summary : ArgsSummary )(f : SettingsState ?=> Unit ) = f(using summary.sstate)
325
338
326
339
extension [T ](setting : Setting [T ])
327
340
private def value (using ss : SettingsState ): T = setting.valueIn(ss)
328
- }
0 commit comments