summaryrefslogtreecommitdiff
path: root/test/junit/scala/util/t7265.scala
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2013-08-01 02:09:09 -0700
committerSom Snytt <som.snytt@gmail.com>2013-08-01 02:09:09 -0700
commit8f5a892512ba848a52a4ddd5d79e9c79d12ccfc1 (patch)
tree60fcf213b77b7a8b7887b3f3ff09fd276f09cd3b /test/junit/scala/util/t7265.scala
parent46616ea2e94fa6ac7100b1cde66295f68338e18e (diff)
downloadscala-8f5a892512ba848a52a4ddd5d79e9c79d12ccfc1.tar.gz
scala-8f5a892512ba848a52a4ddd5d79e9c79d12ccfc1.tar.bz2
scala-8f5a892512ba848a52a4ddd5d79e9c79d12ccfc1.zip
SI-7265 javaSpecVersion, adjust isJava... tests
Make this and related properties public, because they are useful. This change ought to have been committed at 2.11 and then backported with restrictions, rather than vice-versa. Note that they are defined in the order, version, vendor and name, which is the order from the underlying javadoc. It would be a neat feature of the PR validator, as previously imagined, to run a "pending" test and then, on success and merge, to move it automatically to the canonical suite.
Diffstat (limited to 'test/junit/scala/util/t7265.scala')
-rw-r--r--test/junit/scala/util/t7265.scala59
1 files changed, 59 insertions, 0 deletions
diff --git a/test/junit/scala/util/t7265.scala b/test/junit/scala/util/t7265.scala
new file mode 100644
index 0000000000..71f085d21d
--- /dev/null
+++ b/test/junit/scala/util/t7265.scala
@@ -0,0 +1,59 @@
+
+package scala.util
+package test
+
+import org.junit.Assert._
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+import scala.util.PropertiesTrait
+
+/** The java version property uses the spec version
+ * and must work for all "major.minor" and fail otherwise.
+ */
+@RunWith(classOf[JUnit4])
+class SpecVersionTest {
+ val sut = new PropertiesTrait {
+ override def javaSpecVersion = "1.7"
+
+ override protected def pickJarBasedOn: Class[_] = ???
+ override protected def propCategory: String = "test"
+
+ // override because of vals like releaseVersion
+ override lazy val scalaProps = new java.util.Properties
+ }
+
+ @Test
+ def comparesCorrectly(): Unit = {
+ assert(sut isJavaAtLeast "1.5")
+ assert(sut isJavaAtLeast "1.6")
+ assert(sut isJavaAtLeast "1.7")
+ assert(!(sut isJavaAtLeast "1.8"))
+ assert(!(sut isJavaAtLeast "1.71"))
+ }
+ @Test(expected = classOf[NumberFormatException])
+ def badVersion(): Unit = {
+ sut isJavaAtLeast "1.a"
+ }
+ @Test(expected = classOf[NumberFormatException])
+ def missingVersion(): Unit = {
+ sut isJavaAtLeast "1"
+ }
+ @Test(expected = classOf[NumberFormatException])
+ def noVersion(): Unit = {
+ sut isJavaAtLeast ""
+ }
+ @Test(expected = classOf[NumberFormatException])
+ def dotOnly(): Unit = {
+ sut isJavaAtLeast "."
+ }
+ @Test(expected = classOf[NumberFormatException])
+ def leadingDot(): Unit = {
+ sut isJavaAtLeast ".5"
+ }
+ @Test(expected = classOf[NumberFormatException])
+ def notASpec(): Unit = {
+ sut isJavaAtLeast "1.7.1"
+ }
+}