Skip to content

Commit be61bb5

Browse files
authored
Improve atom key description (#172)
1 parent 7d05237 commit be61bb5

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

Sources/Atoms/Core/AtomKey.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal struct AtomKey: Hashable, Sendable, CustomStringConvertible {
88
let atomLabel = String(describing: anyAtomType)
99

1010
if let scopeKey {
11-
return atomLabel + "-scoped:\(scopeKey)"
11+
return atomLabel + " scope:\(scopeKey)"
1212
}
1313
else {
1414
return atomLabel

Sources/Atoms/Core/ScopeKey.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal struct ScopeKey: Hashable, Sendable, CustomStringConvertible {
88

99
@usableFromInline
1010
var description: String {
11-
String(hashValue, radix: 36, uppercase: false)
11+
"0x\(String(UInt(bitPattern: identifier), radix: 16))"
1212
}
1313

1414
private init(token: Token) {

Tests/AtomsTests/Core/AtomKeyTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ final class AtomKeyTests: XCTestCase {
4747
let key1 = AtomKey(atom, scopeKey: scopeToken.key)
4848

4949
XCTAssertEqual(key0.description, "TestAtom<Int>")
50-
XCTAssertEqual(key1.description, "TestAtom<Int>-scoped:\(scopeToken.key.description)")
50+
XCTAssertEqual(key1.description, "TestAtom<Int> scope:\(scopeToken.key.description)")
5151
}
5252
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import XCTest
2+
3+
@testable import Atoms
4+
5+
final class ScopeKeyTests: XCTestCase {
6+
func testDescription() {
7+
let token = ScopeKey.Token()
8+
let objectAddress = String(UInt(bitPattern: ObjectIdentifier(token)), radix: 16)
9+
10+
XCTAssertEqual(token.key.description, "0x\(objectAddress)")
11+
}
12+
}

Tests/AtomsTests/SnapshotTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ final class SnapshotTests: XCTestCase {
9797
"TestAtom<Value2>" -> "TestAtom<Value3>"
9898
"TestAtom<Value3>"
9999
"TestAtom<Value3>" -> "Module/View.swift" [label="line:10"]
100-
"TestAtom<Value4>-scoped:\(scopeToken.key.description)"
101-
"TestAtom<Value4>-scoped:\(scopeToken.key.description)" -> "Module/View.swift" [label="line:10"]
100+
"TestAtom<Value4> scope:\(scopeToken.key.description)"
101+
"TestAtom<Value4> scope:\(scopeToken.key.description)" -> "Module/View.swift" [label="line:10"]
102102
}
103103
"""
104104
)

0 commit comments

Comments
 (0)