-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9731 from som-snytt/issue/9719
Multivalued setting can be set multiply
- Loading branch information
Showing
4 changed files
with
100 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package dotty.tools.dotc | ||
package config | ||
|
||
import CommandLineParser.tokenize | ||
import Settings._ | ||
|
||
import org.junit.Test | ||
import org.junit.Assert._ | ||
|
||
class ScalaSettingsTests: | ||
|
||
@Test def `A multistring setting is multivalued`: Unit = | ||
class SUT extends SettingGroup: | ||
val language: Setting[List[String]] = MultiStringSetting("-language", "feature", "Enable one or more language features.") | ||
val sut = SUT() | ||
val args = tokenize("-language:implicitConversions,dynamics") | ||
val sumy = ArgsSummary(sut.defaultState, args, errors = Nil, warnings = Nil) | ||
val res = sut.processArguments(sumy, processAll = true, skipped = Nil) | ||
val set = sut.language.valueIn(res.sstate) | ||
assertEquals(1, args.length) | ||
assertTrue("No warnings!", res.warnings.isEmpty) | ||
assertTrue("No errors!", res.errors.isEmpty) | ||
assertTrue("Has the feature", set.contains("implicitConversions")) | ||
assertTrue("Has the feature", set.contains("dynamics")) | ||
|
||
@Test def `t9719 Apply -language more than once`: Unit = | ||
class SUT extends SettingGroup: | ||
val language: Setting[List[String]] = MultiStringSetting("-language", "feature", "Enable one or more language features.") | ||
val sut = SUT() | ||
val args = tokenize("-language:implicitConversions -language:dynamics") | ||
val sumy = ArgsSummary(sut.defaultState, args, errors = Nil, warnings = Nil) | ||
val res = sut.processArguments(sumy, processAll = true, skipped = Nil) | ||
val set = sut.language.valueIn(res.sstate) | ||
assertEquals(2, args.length) | ||
assertTrue("No warnings!", res.warnings.isEmpty) | ||
assertTrue("No errors!", res.errors.isEmpty) | ||
assertTrue("Has the feature", set.contains("implicitConversions")) | ||
assertTrue("Has the feature", set.contains("dynamics")) | ||
|
||
@Test def `Warn if multistring element is supplied multiply`: Unit = | ||
class SUT extends SettingGroup: | ||
val language: Setting[List[String]] = MultiStringSetting("-language", "feature", "Enable one or more language features.") | ||
val sut = SUT() | ||
val args = tokenize("-language:dynamics -language:implicitConversions -language:dynamics") | ||
val sumy = ArgsSummary(sut.defaultState, args, errors = Nil, warnings = Nil) | ||
val res = sut.processArguments(sumy, processAll = true, skipped = Nil) | ||
val set = sut.language.valueIn(res.sstate) | ||
assertEquals(3, args.length) | ||
assertEquals("Must warn", 1, res.warnings.length) | ||
assertTrue("No errors!", res.errors.isEmpty) | ||
assertTrue("Has the feature", set.contains("implicitConversions")) | ||
assertTrue("Has the feature", set.contains("dynamics")) | ||
|
||
end ScalaSettingsTests |