Skip to content

Commit

Permalink
Drop Models/Many.swift (#110).
Browse files Browse the repository at this point in the history
  • Loading branch information
oscbyspro committed Nov 9, 2024
1 parent 05193d4 commit 7134cd2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 66 deletions.
43 changes: 0 additions & 43 deletions Sources/TestKit/Models/Many.swift

This file was deleted.

21 changes: 10 additions & 11 deletions Tests/CoreKitTests/LiteralInt+Elements.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Many<LiteralInt, U8>>([
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<LiteralInt, U8>) {
])) 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)])
}
}
}
28 changes: 16 additions & 12 deletions Tests/RandomIntKitTests/FuzzerInt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,31 @@ import TestKit
#expect(MemoryLayout<FuzzerInt>.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<I64, U64>) {
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()

#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)
Expand Down

0 comments on commit 7134cd2

Please sign in to comment.