-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
174 additions
and
6 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
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
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
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
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
51 changes: 51 additions & 0 deletions
51
morphir-ir/shared/src/test/scala/zio/morphir/ir/QNameSpec.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,51 @@ | ||
package zio.morphir.ir | ||
|
||
import zio.test.* | ||
import zio.morphir.ir.testing.MorphirBaseSpec | ||
|
||
object QNameSpec extends MorphirBaseSpec { | ||
def spec = suite("QName")( | ||
suite("Creating a tuple from QName")( | ||
test("toTuple should provide the Path and Name as a tuple") { | ||
val path = Path.fromString("ice.cream") | ||
val name = Name.fromString("float") | ||
val expected = (path, name) | ||
assertTrue(QName(path, name).toTuple == expected) | ||
} | ||
), | ||
suite("Creating a QName")( | ||
test("Creating a QName with a tuple") { | ||
val path = Path.fromString("friday") | ||
val name = Name.fromString("night") | ||
assertTrue(QName.fromTuple((path, name)) == QName(path, name)) | ||
}, | ||
test("Creating a QName from a name") { | ||
val path = Path.fromString("blog.Author") | ||
val name = Name.fromString("book") | ||
assertTrue(QName.fromName(path, name) == QName(path, name)) | ||
} | ||
), | ||
suite("Fetching values from QName")( | ||
test("localName and path") { | ||
val path = Path.fromString("path") | ||
val name = Name.fromString("name") | ||
assertTrue(QName.getLocalName(QName(path, name)) == name) | ||
assertTrue(QName.getModulePath(QName(path, name)) == path) | ||
} | ||
), | ||
suite("QName and Strings")( | ||
test("Create String from QName") { | ||
val path = Path.fromString("front.page") | ||
val name = Name.fromString("dictionary words") | ||
assertTrue(QName(path, name).toString == "Front.Page:dictionaryWords") | ||
}, | ||
test("Create QName from String") { | ||
val str = "Proper.Path:name" | ||
assertTrue(QName.fromString(str) == Some(QName(Path.fromString("Proper.Path"), Name.fromString("name")))) | ||
|
||
val str2 = "invalidpathname" | ||
assertTrue(QName.fromString(str2) == None) | ||
} | ||
) | ||
) | ||
} |