Skip to content

Commit c90afeb

Browse files
authored
Merge pull request #34 from sjrd/open-input
Open up `Input` for custom extensions.
2 parents 79fa8b4 + cd27811 commit c90afeb

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

js-envs-test-kit/src/main/scala/org/scalajs/jsenv/test/RunTests.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import org.scalajs.jsenv.test.kit.{TestKit, Run}
2626

2727
private[test] class RunTests(config: JSEnvSuiteConfig, withCom: Boolean,
2828
defaultInputKind: TestKit.InputKind) {
29+
import RunTests._
30+
2931
private val kit = new TestKit(config.jsEnv, config.awaitTimeout, defaultInputKind)
3032

3133
private def withRun(input: Seq[Input])(body: Run => Unit) = {
@@ -181,4 +183,14 @@ private[test] class RunTests(config: JSEnvSuiteConfig, withCom: Boolean,
181183
val cfg = RunConfig().withEternallyUnsupportedOption(true)
182184
withRun("", cfg)(identity)
183185
}
186+
187+
@Test(expected = classOf[UnsupportedInputException])
188+
def ensureValidateInput: Unit = {
189+
val input = EternallyUnsupportedInput()
190+
withRun(Seq(input))(identity)
191+
}
192+
}
193+
194+
private[test] object RunTests {
195+
final case class EternallyUnsupportedInput() extends Input
184196
}

js-envs/src/main/scala/org/scalajs/jsenv/Input.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ import java.nio.file.Path
1919
* Implementors of a [[JSEnv]] are expected to pattern match on this input
2020
* type and handle the ones they support.
2121
*
22-
* Note that this type is not sealed, so future versions of Scala.js may add
23-
* additional input types. Older [[JSEnv]]s are expected to fail in this case
24-
* with an [[UnsupportedInputException]].
22+
* Note that this type is not sealed, so future versions of Scala.js, as well
23+
* as third-party libraries, may add additional input types.
24+
*
25+
* [[JSEnv]]s are expected to fail with an [[UnsupportedInputException]] on
26+
* `Input` types that they do not handle.
2527
*/
26-
abstract class Input private ()
28+
abstract class Input
2729

2830
object Input {
2931
/** The file is to be loaded as a script into the global scope. */

0 commit comments

Comments
 (0)