forked from scala-native/scala-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement
java.nio.file.{AccessMode,ReadOnlyFileSystemException}
(s…
- Loading branch information
1 parent
f50d68d
commit 3d72c1d
Showing
3 changed files
with
42 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package java.nio.file | ||
|
||
sealed class AccessMode(name: String, ordinal: Int) | ||
extends _Enum[AccessMode](name, ordinal) { | ||
override def toString() = this.name | ||
} | ||
|
||
object AccessMode { | ||
final val EXECUTE = new AccessMode("EXECUTE", 0) | ||
final val READ = new AccessMode("READ", 1) | ||
final val WRITE = new AccessMode("WRITE", 1) | ||
|
||
private[this] val cachedValues = | ||
Array(EXECUTE, READ, WRITE) | ||
def values(): Array[AccessMode] = cachedValues.clone() | ||
def valueOf(name: String): AccessMode = { | ||
cachedValues.find(_.name() == name).getOrElse { | ||
throw new IllegalArgumentException("No enum const AccessMode." + name) | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
javalib/src/main/scala/java/nio/file/ReadOnlyFileSystemException.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,3 @@ | ||
package java.nio.file | ||
|
||
class ReadOnlyFileSystemException extends UnsupportedOperationException |
18 changes: 18 additions & 0 deletions
18
...st/scala/org/scalanative/testsuite/javalib/nio/file/ReadOnlyFileSystemExceptionTest.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 org.scalanative.testsuite.javalib.nio.file | ||
|
||
import java.nio.file._ | ||
|
||
import org.junit.Test | ||
import org.junit.Assert._ | ||
|
||
import org.scalanative.testsuite.utils.AssertThrows.assertThrows | ||
|
||
class ReadOnlyFileSystemExceptionTest { | ||
|
||
@Test def readOnlyFileSystemExceptionExists(): Unit = { | ||
assertThrows( | ||
classOf[ReadOnlyFileSystemException], | ||
throw new ReadOnlyFileSystemException() | ||
) | ||
} | ||
} |