oscbyspro / Ultimathnum

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

Use: swift-testing (1st half) #97

Closed oscbyspro closed 1 month ago

oscbyspro commented 1 month ago

Testing is in the toolchain now, so I don't have to build it myself.

I'll adopt it incrementally, since that's the direction Swift is headed.

oscbyspro commented 1 month ago

Something silly is going on in the #expect macro:

@Test func what() {
    #expect(U32(256 * 256) ==     000065536 ) // true
    #expect(U32(256 * 256) == U32(000065536)) // true
    #expect(U32(256 * 256) ==     256 * 256 ) // Expectation failed: (U32(256 * 256) → 65536) == (256 * 256 → 65536)
    #expect(U32(256 * 256) == U32(256 * 256)) // true

    print(  U32(256 * 256) ==     000065536 ) // true
    print(  U32(256 * 256) == U32(000065536)) // true
    print(  U32(256 * 256) ==     256 * 256 ) // true
    print(  U32(256 * 256) == U32(256 * 256)) // true
}

Edit: It looks like the multiplication maps 256 * 256 to AnyHashable in the #expect case.