Dynamic Members

This commit is contained in:
Max Howell
2019-01-22 14:05:33 -05:00
parent 44be1c45a9
commit 859164e59f
5 changed files with 41 additions and 5 deletions

View File

@@ -14,10 +14,10 @@ class PathTests: XCTestCase {
func testEnumeration() throws {
let tmpdir_ = try TemporaryDirectory()
let tmpdir = tmpdir_.path
try tmpdir.join("a").mkdir().join("c").touch()
try tmpdir.join("b").touch()
try tmpdir.join("c").touch()
try tmpdir.join(".d").mkdir().join("e").touch()
try tmpdir.a.mkdir().c.touch()
try tmpdir.b.touch()
try tmpdir.c.touch()
try tmpdir.join(".d").mkdir().e.touch()
var paths = Set<String>()
var dirs = 0
@@ -139,6 +139,13 @@ class PathTests: XCTestCase {
XCTAssertEqual(Path.root/"a/foo"/"../../../bar", Path.root/"bar")
}
func testDynamicMember() {
XCTAssertEqual(Path.root.Documents, Path.root/"Documents")
let a = Path.home.foo
XCTAssertEqual(a.Documents, Path.home/"foo/Documents")
}
func testCopyInto() throws {
try Path.mktemp { root in
let bar = try root.join("bar").touch()

View File

@@ -6,6 +6,7 @@ extension PathTests {
("testCodable", testCodable),
("testConcatenation", testConcatenation),
("testCopyInto", testCopyInto),
("testDynamicMember", testDynamicMember),
("testEnumeration", testEnumeration),
("testEnumerationSkippingHiddenFiles", testEnumerationSkippingHiddenFiles),
("testExists", testExists),