-
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.
- Loading branch information
1 parent
71009c2
commit 067682b
Showing
3 changed files
with
99 additions
and
2 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
53 changes: 53 additions & 0 deletions
53
morphir-ir/shared/src/test/scala/zio/morphir/ir/FQNameTest.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,53 @@ | ||
package zio.morphir.ir | ||
|
||
import zio.morphir.ir.testing.MorphirBaseSpec | ||
import zio.test.* | ||
|
||
object FQNameTest extends MorphirBaseSpec { | ||
def spec = suite("FQName")( | ||
suite("Create a FQName:")( | ||
test("By using a string") { | ||
assertTrue( | ||
FQName.fromString("moduleName/packageName/localName", "/") == | ||
FQName( | ||
PackageName(Path.fromString("moduleName")), | ||
ModulePath(Path.fromString("packageName")), | ||
Name.fromString("localName") | ||
) | ||
) | ||
}, | ||
test("By using a QName") { | ||
val path = Path.fromString("package Name") | ||
val qName = QName(Path.fromString("qualified.Name.Path"), Name.fromString("localName")) | ||
assertTrue(FQName.fromQName(path, qName) == FQName(path, qName.modulePath, qName.localName)) | ||
} | ||
), | ||
suite("Retrieving variables should work")( | ||
test("Get PackagePath") { | ||
val fqName = FQName.fromString("moduleName/packageName/localName", "/") | ||
assertTrue(FQName.getPackagePath(fqName) == Path.fromString("moduleName")) | ||
}, | ||
test("Get ModulePath") { | ||
val fqName = FQName.fromString("moduleName/packageName/localName", "/") | ||
assertTrue(FQName.getModulePath(fqName) == Path.fromString("packageName")) | ||
}, | ||
test("Get localName") { | ||
val fqName = FQName.fromString("moduleName/packageName/localName", "/") | ||
assertTrue(FQName.getLocalName(fqName) == Name.fromString("localName")) | ||
} | ||
), | ||
suite("Creating a string from FQName") { | ||
test("should work") { | ||
assertTrue( | ||
FQName.toString( | ||
FQName( | ||
PackageName(Path.fromString("com.example")), | ||
ModulePath(Path.fromString("java home")), | ||
Name.fromString("morphir") | ||
) | ||
) == "Com.Example:JavaHome:morphir" | ||
) | ||
} | ||
} | ||
) | ||
} |
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