summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library/scala/sys/SystemProperties.scala2
-rw-r--r--test/junit/scala/util/SystemPropertiesTest.scala27
2 files changed, 28 insertions, 1 deletions
diff --git a/src/library/scala/sys/SystemProperties.scala b/src/library/scala/sys/SystemProperties.scala
index 4d1d8f740f..ebe94651f9 100644
--- a/src/library/scala/sys/SystemProperties.scala
+++ b/src/library/scala/sys/SystemProperties.scala
@@ -32,7 +32,7 @@ class SystemProperties
extends mutable.AbstractMap[String, String]
with mutable.Map[String, String] {
- override def empty = new SystemProperties
+ override def empty = mutable.Map[String, String]()
override def default(key: String): String = null
def iterator: Iterator[(String, String)] = wrapAccess {
diff --git a/test/junit/scala/util/SystemPropertiesTest.scala b/test/junit/scala/util/SystemPropertiesTest.scala
new file mode 100644
index 0000000000..38e830eb88
--- /dev/null
+++ b/test/junit/scala/util/SystemPropertiesTest.scala
@@ -0,0 +1,27 @@
+package scala.util
+
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.junit.Test
+import org.junit.Assert._
+
+@RunWith(classOf[JUnit4])
+class SystemPropertiesTest {
+ @Test
+ def filterAll(): Unit = {
+ val isEmpty = sys.props.filter(_ => false).size == 0
+ assertTrue("A filter matching nothing should produce an empty result", isEmpty)
+ }
+
+ @Test
+ def filterNone(): Unit = {
+ val isUnchanged = sys.props.filter(_ => true) == sys.props
+ assertTrue("A filter matching everything should not change the result", isUnchanged)
+ }
+
+ @Test
+ def empty(): Unit = {
+ val hasSize0 = sys.props.empty.size == 0
+ assertTrue("SystemProperties.empty should have size of 0", hasSize0)
+ }
+}