<NME> VersionTest.kt
<BEF> ADDFILE
<MSG> Allow attaching "package" project `elm.json` file (#69)

This registers the package dependencies as external library roots. 
Unlike "application" projects, we cannot easily obtain:

- the exact version numbers used
- the transitive dependencies

So this PR just registers the package's direct dependencies and will
use an arbitrary version that it finds in ~/.elm that satisfies its own 
version constraint (but the full dependency graph).

More work needs to be done to make this better. Ideally the Elm 
toolchain itself would be able to describe how it would resolve a 
package's dependency graph.
<DFF> @@ -0,0 +1,47 @@
+package org.elm.workspace
+
+import org.junit.Assert.assertTrue
+import org.junit.Test
+import kotlin.test.assertEquals
+import kotlin.test.assertNull
+
+class VersionTest {
+
+    @Test
+    fun `version compare`() {
+        assertTrue(v(1, 0, 0) < v(2, 0, 0))
+        assertTrue(v(2, 0, 0) > v(1, 0, 0))
+        assertTrue(v(1, 0, 0) == v(1, 0, 0))
+
+        assertTrue(v(0, 1, 0) < v(0, 2, 0))
+        assertTrue(v(0, 2, 0) > v(0, 1, 0))
+        assertTrue(v(0, 1, 0) == v(0, 1, 0))
+
+        assertTrue(v(0, 0, 1) < v(0, 0, 2))
+        assertTrue(v(0, 0, 2) > v(0, 0, 1))
+        assertTrue(v(0, 0, 1) == v(0, 0, 1))
+    }
+
+    @Test
+    fun `version toString is dotted form`() {
+        assertEquals("1.2.3", v(1, 2, 3).toString())
+    }
+
+    @Test()
+    fun `parse works on good input`() {
+        Version.parse("1.2.3")
+    }
+
+    @Test(expected = ParseException::class)
+    fun `parse throws on bad input`() {
+        Version.parse("bogus.version.number")
+    }
+
+    @Test()
+    fun `parseOrNull does not throw on bad input`() {
+        assertNull(Version.parseOrNull("bogus.version.number"))
+    }
+
+    private fun v(x: Int, y: Int, z: Int) =
+            Version(x, y, z)
+}
\ No newline at end of file

Allow attaching "package" project `elm.json` file (#69)