forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScalaCommandTest.scala
More file actions
39 lines (31 loc) · 1.48 KB
/
ScalaCommandTest.scala
File metadata and controls
39 lines (31 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package dotty.tools.dotc
import org.junit.Test
import org.junit.Assert._
import org.junit.Rule
import org.junit.rules.TemporaryFolder
import dotty.tools.dotc.config.Settings._
class ScalaCommandTest:
private val _temporaryFolder = new TemporaryFolder
@Rule
def temporaryFolder = _temporaryFolder
@Test def `Simple one parameter`: Unit =
val settings = config.ScalaSettings()
val args = "-cp path/to/classes1:other/path/to/classes2 files".split(" ")
val summary = ScalacCommand.distill(args, settings, settings.defaultState)
given SettingsState = summary.sstate
assertEquals("path/to/classes1:other/path/to/classes2", settings.classpath.value)
assertEquals("files" :: Nil, summary.arguments)
@Test def `Unfold @file`: Unit =
val settings = config.ScalaSettings()
val file = temporaryFolder.newFile("config")
val writer = java.io.FileWriter(file);
writer.write("-sourceroot myNewRoot someMoreFiles");
writer.close();
val args = s"-cp path/to/classes1:other/path/to/classes2 @$file someFiles".split(" ")
val summary = ScalacCommand.distill(args, settings, settings.defaultState)
given SettingsState = summary.sstate
assertEquals("path/to/classes1:other/path/to/classes2", settings.classpath.value)
assertEquals("myNewRoot", settings.sourceroot.value)
assertEquals("someMoreFiles" :: "someFiles" :: Nil, summary.arguments)
extension [T](setting: Setting[T])
private def value(using ss: SettingsState): T = setting.valueIn(ss)