oscbyspro / Ultimathnum

Binary arithmetic reimagined in Swift
Apache License 2.0
9 stars 1 forks source link

Add: more T/description #100

Closed oscbyspro closed 2 months ago

oscbyspro commented 2 months ago

As I continue to adopt swift-testing (#97), it is apparent that "Fallible\<Bit>(value: Bit.one, error: false)" isn't great for debugging. So I'll conform Fallible<T> to CustomStringConvertible and return the following description instead:

Fallible(Bit.zero, error: false) -> "0[ ]"
Fallible(Bit.zero, error: true ) -> "0[x]"
Fallible(Bit.one,  error: false) -> "1[ ]"
Fallible(Bit.one,  error: true ) -> "1[x]"
oscbyspro commented 2 months ago

The empty [ ] looked unintentional so I filled it with a hyphen: [-].

Fallible(Bit.zero, error: false) -> "0[-]"
Fallible(Bit.zero, error: true ) -> "0[x]"
Fallible(Bit.one,  error: false) -> "1[-]"
Fallible(Bit.one,  error: true ) -> "1[x]"
oscbyspro commented 2 months ago

LiteralInt suffers from a similar problem so I'll forward StaticBigInt/debugDescription:

extension LiteralInt: CustomStringConvertible {
    @inlinable public var description: String {
        self.base.debugDescription
    }
}
oscbyspro commented 2 months ago

I also added Bit/description prior to this post.

oscbyspro commented 1 month ago

I'll add "+" and "-" Sign descriptions too.