diff options
author | Som Snytt <som.snytt@gmail.com> | 2013-06-20 09:41:08 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2013-07-04 12:40:56 -0700 |
commit | 06606e83dc942693dd95a30f704876c41eb4d8e5 (patch) | |
tree | ad303e79331ba9b714e4d72c024d4ca4ec0149c0 /test/pending | |
parent | d0df4c514f662312e2a9284fef2cf24a284aff28 (diff) | |
download | scala-06606e83dc942693dd95a30f704876c41eb4d8e5.tar.gz scala-06606e83dc942693dd95a30f704876c41eb4d8e5.tar.bz2 scala-06606e83dc942693dd95a30f704876c41eb4d8e5.zip |
SI-7265 General test for spec version
The test for isJavaAtLeast uses the specification.version.
The method argument must have the form "major.minor".
The scaladoc is updated to reflect the new reality and a
test is added under junit.
Note that this implementation aims to be a simple
compromise between the functional and imperative camps,
that is, to be free of both closures and while loops.
And to elicit no cruft like regexes and wrappers for strings.
No doubt even more could be done in this department, but we
don't wish to spoil the fun on codegolf.stackexchange.com.
However, we might decide to sponsor a new site:
codereviewpingpong.com
For 2.10.x, javaSpecVersion is provided as a private member.
The active test is under `run` and the `junit` test must
bide its time in `pending`.
For 2.11, the private members can be public and the app test
replaced with the unit test.
Diffstat (limited to 'test/pending')
-rw-r--r-- | test/pending/junit/scala/util/t7265.scala | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/pending/junit/scala/util/t7265.scala b/test/pending/junit/scala/util/t7265.scala new file mode 100644 index 0000000000..3b8fa80dbe --- /dev/null +++ b/test/pending/junit/scala/util/t7265.scala @@ -0,0 +1,46 @@ + +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")) + } + @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 notASpec(): Unit = { + sut isJavaAtLeast "1.7.1" + } +} |