mirror of
https://github.com/github/semantic.git
synced 2024-12-26 08:25:19 +03:00
Rename down
to into
.
This commit is contained in:
parent
47a1e8eb0c
commit
9151d02655
@ -22,7 +22,7 @@ public struct Location<A>: SequenceType {
|
||||
/// The node currently in focus.
|
||||
public let it: A
|
||||
|
||||
public var down: Location? { return _down(it) }
|
||||
public var into: Location? { return _down(it) }
|
||||
|
||||
public var up: Location? { return _up(it) }
|
||||
|
||||
@ -38,7 +38,7 @@ public struct Location<A>: SequenceType {
|
||||
|
||||
/// Returns the logically next `Location` after the receiver in a pre-order depth-first traversal.
|
||||
public var next: Location? {
|
||||
return down ?? nextAfter
|
||||
return into ?? nextAfter
|
||||
}
|
||||
|
||||
/// Returns the logically next `Location` after the receiver and its children in a pre-order depth-first traversal.
|
||||
|
@ -13,35 +13,35 @@ final class LocationTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testCannotMoveDownwardsFromLeaves() {
|
||||
assert(leafA.explore().down?.it, ==, nil)
|
||||
assert(leafA.explore().into?.it, ==, nil)
|
||||
}
|
||||
|
||||
func testCanMoveDownwardsIntoBranches() {
|
||||
assert(term.explore().down?.it, ==, leafA)
|
||||
assert(term.explore().into?.it, ==, leafA)
|
||||
}
|
||||
|
||||
func testCanMoveBackUpwards() {
|
||||
assert(term.explore().down?.up?.it, ==, term)
|
||||
assert(term.explore().into?.up?.it, ==, term)
|
||||
}
|
||||
|
||||
func testCannotMoveLeftwardsFromFirstChildOfBranch() {
|
||||
assert(term.explore().down?.left?.it, ==, nil)
|
||||
assert(term.explore().into?.left?.it, ==, nil)
|
||||
}
|
||||
|
||||
func testCanMoveRightwardsFromLeftmostChildOfLongBranch() {
|
||||
assert(term.explore().down?.right?.it, ==, leafB)
|
||||
assert(term.explore().into?.right?.it, ==, leafB)
|
||||
}
|
||||
|
||||
func testCanExploreBranchesDeeply() {
|
||||
assert(term.explore().down?.right?.right?.down?.it, ==, innerLeafB)
|
||||
assert(term.explore().into?.right?.right?.into?.it, ==, innerLeafB)
|
||||
}
|
||||
|
||||
func testCanMoveBackUpwardsFromDeepExplorations() {
|
||||
assert(term.explore().down?.right?.right?.down?.right?.up?.up?.it, ==, term)
|
||||
assert(term.explore().into?.right?.right?.into?.right?.up?.up?.it, ==, term)
|
||||
}
|
||||
|
||||
func testCanReturnToStartOfExplorationFromArbitrarilyDeepNodes() {
|
||||
assert(term.explore().down?.right?.right?.down?.right?.root.it, ==, term)
|
||||
assert(term.explore().into?.right?.right?.into?.right?.root.it, ==, term)
|
||||
}
|
||||
|
||||
func testSequenceIsPreOrderDepthFirstTraversal() {
|
||||
@ -49,23 +49,23 @@ final class LocationTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testModifyReplacesSubtrees() {
|
||||
assert(term.explore().down?.modify(const(leafB)).right?.up?.it, ==, Cofree(0, .Indexed([ leafB, leafB, keyed ])))
|
||||
assert(term.explore().into?.modify(const(leafB)).right?.up?.it, ==, Cofree(0, .Indexed([ leafB, leafB, keyed ])))
|
||||
}
|
||||
|
||||
func testMultipleModificationsReplaceMultipleSubtrees() {
|
||||
assert(term.explore().down?.modify(const(leafB)).right?.modify(const(leafA)).up?.it, ==, Cofree(0, .Indexed([ leafB, leafA, keyed ])))
|
||||
assert(term.explore().into?.modify(const(leafB)).right?.modify(const(leafA)).up?.it, ==, Cofree(0, .Indexed([ leafB, leafA, keyed ])))
|
||||
}
|
||||
|
||||
func testModificationsPreserveKeys() {
|
||||
assert(keyed.explore().down?.modify(const(leafA)).root.it, ==, Cofree(3, .Keyed([ "a": innerLeafA, "b": leafA ])))
|
||||
assert(keyed.explore().into?.modify(const(leafA)).root.it, ==, Cofree(3, .Keyed([ "a": innerLeafA, "b": leafA ])))
|
||||
}
|
||||
|
||||
func testDeepModificationsReplaceDeepSubtrees() {
|
||||
assert(term.explore().down?.modify(const(leafB)).right?.modify(const(leafA)).right?.down?.modify(const(innerLeafA)).right?.modify(const(innerLeafB)).root.it, ==, Cofree(0, .Indexed([ leafB, leafA, Cofree(3, .Keyed([ "a": innerLeafB, "b": innerLeafA ])) ])))
|
||||
assert(term.explore().into?.modify(const(leafB)).right?.modify(const(leafA)).right?.into?.modify(const(innerLeafA)).right?.modify(const(innerLeafB)).root.it, ==, Cofree(0, .Indexed([ leafB, leafA, Cofree(3, .Keyed([ "a": innerLeafB, "b": innerLeafA ])) ])))
|
||||
}
|
||||
|
||||
func testModificationsCanRefineDiffs() {
|
||||
assert(diff.explore().down?.right?.modify(const(refined)).root.it, ==, Free.Roll(0, .Indexed([ Free.Roll(1, .Leaf("a string")), refined ])))
|
||||
assert(diff.explore().into?.right?.modify(const(refined)).root.it, ==, Free.Roll(0, .Indexed([ Free.Roll(1, .Leaf("a string")), refined ])))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user