-
Notifications
You must be signed in to change notification settings - Fork 94
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 #441 from armanbilge/issue/437
Move JDK shims to `munit.internal`
- Loading branch information
Showing
21 changed files
with
125 additions
and
111 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 was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...g/reflect/InvocationTargetException.scala → .../internal/InvocationTargetException.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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
package java.lang.reflect | ||
package munit.internal | ||
|
||
class InvocationTargetException extends java.lang.RuntimeException |
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 was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...eflect/UndeclaredThrowableException.scala → ...ternal/UndeclaredThrowableException.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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
package java.lang.reflect | ||
package munit.internal | ||
|
||
class UndeclaredThrowableException extends java.lang.RuntimeException |
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
8 changes: 3 additions & 5 deletions
8
.../src/main/scala/java/nio/file/Files.scala → .../main/scala/munit/internal/io/Files.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
2 changes: 1 addition & 1 deletion
2
.../src/main/scala/munit/internal/JSIO.scala → ...c/main/scala/munit/internal/io/JSIO.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package munit.internal | ||
package munit.internal.io | ||
|
||
import scala.scalajs.js | ||
import scala.util.Try | ||
|
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
15 changes: 6 additions & 9 deletions
15
.../src/main/scala/java/nio/file/Paths.scala → .../main/scala/munit/internal/io/Paths.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 |
---|---|---|
@@ -1,32 +1,29 @@ | ||
package java.nio.file | ||
package munit.internal.io | ||
|
||
import java.io.File | ||
import java.net.URI | ||
|
||
import munit.internal.NodeNIOPath | ||
|
||
object Paths { | ||
// NOTE: We can't use Scala-style varargs since those have a different jvm | ||
// signature than Java-style varargs. The boot classpath contains nio.file.Path | ||
// so call-sites to `get` will resolve to the original java.nio.file.Paths.get, | ||
// which results in a Scala.js linking error when using Scala varargs. | ||
def get(first: String, more: Array[String] = Array.empty): Path = { | ||
def get(first: String, more: Array[String] = Array.empty): MunitPath = { | ||
val path = | ||
if (more.isEmpty) first | ||
else first + File.separator + more.mkString(File.separator) | ||
NodeNIOPath(path) | ||
MunitPath(path) | ||
} | ||
|
||
def get(uri: URI): Path = { | ||
def get(uri: URI): MunitPath = { | ||
if (uri.getScheme != "file") | ||
throw new IllegalArgumentException("only file: URIs are supported") | ||
val uripath = uri.getPath | ||
val parts = uripath.split('/').toList | ||
val (leading, trailing) = parts.span(_ == "") | ||
trailing match { | ||
case drive :: path if (drive.length == 2 && drive(1) == ':') => | ||
NodeNIOPath(trailing.mkString("\\")) | ||
case _ => NodeNIOPath(uripath) | ||
MunitPath(trailing.mkString("\\")) | ||
case _ => MunitPath(uripath) | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
munit/js/src/main/scala/munit/internal/io/PlatformIO.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,16 @@ | ||
package munit.internal.io | ||
|
||
object PlatformIO { | ||
type File = munit.internal.io.File | ||
object File { | ||
def separatorChar = munit.internal.io.File.separatorChar | ||
} | ||
|
||
object Files { | ||
def readAllLines(path: Path): java.util.List[String] = | ||
munit.internal.io.Files.readAllLines(path) | ||
} | ||
|
||
type Path = MunitPath | ||
val Paths = munit.internal.io.Paths | ||
} |
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
18 changes: 18 additions & 0 deletions
18
munit/jvm/src/main/scala/munit/internal/io/PlatformIO.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,18 @@ | ||
package munit.internal.io | ||
|
||
object PlatformIO { | ||
type File = java.io.File | ||
object File { | ||
def separatorChar = java.io.File.separatorChar | ||
} | ||
|
||
object Files { | ||
def readAllLines(path: Path): java.util.List[String] = | ||
java.nio.file.Files.readAllLines(path) | ||
} | ||
|
||
type Path = java.nio.file.Path | ||
object Paths { | ||
def get(path: String): Path = java.nio.file.Paths.get(path) | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.