diff --git a/Sources/TestKit/Models/Many.swift b/Sources/TestKit/Models/Many.swift deleted file mode 100644 index 5bce956c..00000000 --- a/Sources/TestKit/Models/Many.swift +++ /dev/null @@ -1,43 +0,0 @@ -//=----------------------------------------------------------------------------= -// This source file is part of the Ultimathnum open source project. -// -// Copyright (c) 2023 Oscar Byström Ericsson -// Licensed under Apache License, Version 2.0 -// -// See http://www.apache.org/licenses/LICENSE-2.0 for license information. -//=----------------------------------------------------------------------------= - -//*============================================================================* -// MARK: * Many -//*============================================================================* - -@dynamicMemberLookup @frozen public struct Many: CustomTestStringConvertible { - - //=------------------------------------------------------------------------= - // MARK: State - //=------------------------------------------------------------------------= - - public let input: (repeat each Input) - public let output: Array - - //=------------------------------------------------------------------------= - // MARK: Initializers - //=------------------------------------------------------------------------= - - @inlinable public init(_ input: repeat each Input, yields output: Array) { - self.input = (repeat each input) - self.output = (output) - } - - //=------------------------------------------------------------------------= - // MARK: Utilities - //=------------------------------------------------------------------------= - - @inlinable public var testDescription: String { - "\(self.input) → \(self.output.count) elements" - } - - @inlinable public subscript(dynamicMember keyPath: KeyPath<(repeat each Input), T>) -> T { - self.input[keyPath: keyPath] - } -} diff --git a/Tests/CoreKitTests/LiteralInt+Elements.swift b/Tests/CoreKitTests/LiteralInt+Elements.swift index 24e8d96d..d5f0a650 100644 --- a/Tests/CoreKitTests/LiteralInt+Elements.swift +++ b/Tests/CoreKitTests/LiteralInt+Elements.swift @@ -51,23 +51,22 @@ import TestKit } @Test( - "LiteralInt/elements: subscript(_:) byte prefix", + "LiteralInt/elements: byte sequence prefix", Tag.List.tags(.documentation), ParallelizationTrait.serialized, - arguments: Array>([ + arguments: Array<(LiteralInt, [U8])>([ - Many(LiteralInt(-0000000000000000000000000000000001), yields: [U8](repeating: U8.max, count: 32)), - Many(LiteralInt( 0000000000000000000000000000000000), yields: [U8](repeating: U8.min, count: 32)), - Many(LiteralInt(-0xf0f1f2f3f4f5f6f7f8f9fafbfcfdff00), yields: [U8](0...15) + [U8](repeating: U8.max, count: 16)), - Many(LiteralInt( 0x0f0e0d0c0b0a09080706050403020100), yields: [U8](0...15) + [U8](repeating: U8.min, count: 16)), + (LiteralInt(-0000000000000000000000000000000001), [U8](repeating: U8.max, count: 32)), + (LiteralInt( 0000000000000000000000000000000000), [U8](repeating: U8.min, count: 32)), + (LiteralInt(-0xf0f1f2f3f4f5f6f7f8f9fafbfcfdff00), [U8](0...15) + [U8](repeating: U8.max, count: 16)), + (LiteralInt( 0x0f0e0d0c0b0a09080706050403020100), [U8](0...15) + [U8](repeating: U8.min, count: 16)), - ])) func elements(argument: Many) { + ])) func byteSequencePrefix(instance: LiteralInt, expectation: [U8]) { let ratio: IX = IX(size: UX.self) / IX(size: U8.self) - for index: IX in IX.zero ..< IX(argument.output.count) { - let word: UX = argument.input[UX(index / ratio)] + for index: IX in IX.zero ..< IX(expectation.count) { + let word: UX = instance[UX(index / ratio)] let byte: U8 = U8(load: word >> (index % ratio * 8)) - let expectation: U8 = argument.output[Swift.Int(index)] - #expect(byte == expectation) + #expect(byte == expectation[Swift.Int(index)]) } } } diff --git a/Tests/RandomIntKitTests/FuzzerInt.swift b/Tests/RandomIntKitTests/FuzzerInt.swift index b2b61a77..112541dc 100644 --- a/Tests/RandomIntKitTests/FuzzerInt.swift +++ b/Tests/RandomIntKitTests/FuzzerInt.swift @@ -26,16 +26,20 @@ import TestKit #expect(MemoryLayout.size == 8) } - @Test(.serialized, arguments: [ + @Test( + "FuzzerInt: prefix", + Tag.List.tags(.documentation, .unofficial), + ParallelizationTrait.serialized, + arguments: Array<(I64, [U64])>([ - Many( 0 as I64, yields: [0xe220a8397b1dcdaf, 0x6e789e6aa1b965f4, 0x06c45d188009454f, 0xf88bb8a8724c81ec] as [U64]), - Many( 1 as I64, yields: [0x910a2dec89025cc1, 0xbeeb8da1658eec67, 0xf893a2eefb32555e, 0x71c18690ee42c90b] as [U64]), - Many(~1 as I64, yields: [0xf3203e9039f4a821, 0xba56949915dcf9e9, 0xd0d5127a96e8d90d, 0x1ef156bb76650c37] as [U64]), - Many(~0 as I64, yields: [0xe4d971771b652c20, 0xe99ff867dbf682c9, 0x382ff84cb27281e9, 0x6d1db36ccba982d2] as [U64]), + ( 0 as I64, [0xe220a8397b1dcdaf, 0x6e789e6aa1b965f4, 0x06c45d188009454f, 0xf88bb8a8724c81ec] as [U64]), + ( 1 as I64, [0x910a2dec89025cc1, 0xbeeb8da1658eec67, 0xf893a2eefb32555e, 0x71c18690ee42c90b] as [U64]), + (~1 as I64, [0xf3203e9039f4a821, 0xba56949915dcf9e9, 0xd0d5127a96e8d90d, 0x1ef156bb76650c37] as [U64]), + (~0 as I64, [0xe4d971771b652c20, 0xe99ff867dbf682c9, 0x382ff84cb27281e9, 0x6d1db36ccba982d2] as [U64]), - ]) func seeded(_ expectation: Many) { - var randomness = FuzzerInt(seed: U64(raw: expectation.input)) - for element in expectation.output { + ])) func prefix(seed: I64, expectation: [U64]) { + var randomness = FuzzerInt(seed: U64(raw: seed)) + for element in expectation { var copy = randomness var stdlibX = randomness.stdlib var stdlibY = randomness.stdlib() @@ -43,10 +47,10 @@ import TestKit #expect(randomness == copy) #expect(stdlibX == stdlibY) - #expect(randomness .next() == (element)) // custom - #expect(copy.stdlib.next() == UInt64(element)) // stdlib modify - #expect(((stdlibX)).next() == UInt64(element)) // stdlib mutating read - #expect(((stdlibY)).next() == UInt64(element)) // stdlib consuming get + #expect(randomness .next() == (element), "normal") + #expect(copy.stdlib.next() == Swift.UInt64(element), "stdlib modify") + #expect(((stdlibX)).next() == Swift.UInt64(element), "stdlib read") + #expect(((stdlibY)).next() == Swift.UInt64(element), "stdlib consuming") #expect(randomness == copy) #expect(stdlibX == stdlibY)