diff --git a/Sources/MMIO/MMIOMacros.swift b/Sources/MMIO/MMIOMacros.swift index 067238ee..028b0cd1 100644 --- a/Sources/MMIO/MMIOMacros.swift +++ b/Sources/MMIO/MMIOMacros.swift @@ -44,31 +44,46 @@ public macro Reserved(bits: UnboundedRange) = #externalMacro(module: "MMIOMacros", type: "ReservedMacro") @attached(accessor) -public macro ReadWrite(bits: Range..., as: Value.Type = Never.self) = +public macro ReadWrite( + bits: Range..., as: Value.Type = Never.self +) = #externalMacro(module: "MMIOMacros", type: "ReadWriteMacro") -where Range: RangeExpression, Range.Bound: BinaryInteger, Value: BitFieldProjectable +where + Range: RangeExpression, Range.Bound: BinaryInteger, Value: BitFieldProjectable @attached(accessor) -public macro ReadWrite(bits: UnboundedRange, as: Value.Type = Never.self) = +public macro ReadWrite( + bits: UnboundedRange, as: Value.Type = Never.self +) = #externalMacro(module: "MMIOMacros", type: "ReadWriteMacro") where Value: BitFieldProjectable @attached(accessor) -public macro ReadOnly(bits: Range..., as: Value.Type = Never.self) = +public macro ReadOnly( + bits: Range..., as: Value.Type = Never.self +) = #externalMacro(module: "MMIOMacros", type: "ReadOnlyMacro") -where Range: RangeExpression, Range.Bound: BinaryInteger, Value: BitFieldProjectable +where + Range: RangeExpression, Range.Bound: BinaryInteger, Value: BitFieldProjectable @attached(accessor) -public macro ReadOnly(bits: UnboundedRange, as: Value.Type = Never.self) = +public macro ReadOnly( + bits: UnboundedRange, as: Value.Type = Never.self +) = #externalMacro(module: "MMIOMacros", type: "ReadOnlyMacro") where Value: BitFieldProjectable @attached(accessor) -public macro WriteOnly(bits: Range..., as: Value.Type = Never.self) = +public macro WriteOnly( + bits: Range..., as: Value.Type = Never.self +) = #externalMacro(module: "MMIOMacros", type: "WriteOnlyMacro") -where Range: RangeExpression, Range.Bound: BinaryInteger, Value: BitFieldProjectable +where + Range: RangeExpression, Range.Bound: BinaryInteger, Value: BitFieldProjectable @attached(accessor) -public macro WriteOnly(bits: UnboundedRange, as: Value.Type = Never.self) = +public macro WriteOnly( + bits: UnboundedRange, as: Value.Type = Never.self +) = #externalMacro(module: "MMIOMacros", type: "WriteOnlyMacro") where Value: BitFieldProjectable diff --git a/Sources/MMIOMacros/SwiftSyntaxExtensions/ArgumentParsing/Argument.swift b/Sources/MMIOMacros/SwiftSyntaxExtensions/ArgumentParsing/Argument.swift index 12362bb5..03ae5ec3 100644 --- a/Sources/MMIOMacros/SwiftSyntaxExtensions/ArgumentParsing/Argument.swift +++ b/Sources/MMIOMacros/SwiftSyntaxExtensions/ArgumentParsing/Argument.swift @@ -58,17 +58,20 @@ struct Argument: ArgumentProtocol { } extension Argument { - init(label: String) where T: ExpressibleByExprSyntax, Container == ExactlyOne { + init(label: String) + where T: ExpressibleByExprSyntax, Container == ExactlyOne { self.label = label self.container = nil } - init(label: String) where T: ExpressibleByExprSyntax, Container == ZeroOrOne { + init(label: String) + where T: ExpressibleByExprSyntax, Container == ZeroOrOne { self.label = label self.container = .init(parsed: nil) } - init(label: String) where T: ExpressibleByExprSyntax, Container == OneOrMore { + init(label: String) + where T: ExpressibleByExprSyntax, Container == OneOrMore { self.label = label self.container = nil } diff --git a/Sources/MMIOUtilities/Parser.swift b/Sources/MMIOUtilities/Parser.swift index d0d889e4..3fb9e08c 100644 --- a/Sources/MMIOUtilities/Parser.swift +++ b/Sources/MMIOUtilities/Parser.swift @@ -96,7 +96,8 @@ public func zip( } extension Parser { - public func map(_ f: @escaping @Sendable (Output) -> T) -> Parser { + public func map(_ f: @escaping @Sendable (Output) -> T) -> Parser + { .init { input in self.run(&input).map(f) } } } @@ -130,12 +131,16 @@ extension Parser { zip(self, p).map { ab, c in (ab.0, ab.1, c) } } - public func take(_ p: Parser) -> Parser + public func take(_ p: Parser) -> Parser< + Input, (A, B, C, D) + > where Output == (A, B, C) { zip(self, p).map { abc, d in (abc.0, abc.1, abc.2, d) } } - public func take(_ p: Parser) -> Parser + public func take(_ p: Parser) -> Parser< + Input, (A, B, C, D, E) + > where Output == (A, B, C, D) { zip(self, p).map { abcd, e in (abcd.0, abcd.1, abcd.2, abcd.3, e) } } diff --git a/Sources/SVD/Macros/SVDMacros.swift b/Sources/SVD/Macros/SVDMacros.swift index 0512cc21..7d038a13 100644 --- a/Sources/SVD/Macros/SVDMacros.swift +++ b/Sources/SVD/Macros/SVDMacros.swift @@ -13,7 +13,8 @@ macro XMLAttribute() = #externalMacro(module: "SVDMacros", type: "XMLMarkerMacro") -@attached(extension, names: named(init(_:)), conformances: XMLElementInitializable) +@attached( + extension, names: named(init(_:)), conformances: XMLElementInitializable) macro XMLElement() = #externalMacro(module: "SVDMacros", type: "XMLElementMacro") diff --git a/Sources/SVD/Models/SVDWriteConstraint.swift b/Sources/SVD/Models/SVDWriteConstraint.swift index b32c88e1..ebca5a0f 100644 --- a/Sources/SVD/Models/SVDWriteConstraint.swift +++ b/Sources/SVD/Models/SVDWriteConstraint.swift @@ -42,11 +42,17 @@ extension SVDWriteConstraint: Sendable {} extension SVDWriteConstraint: XMLElementInitializable { init(_ element: XMLElement) throws { - if let value = try? element.decode(SVDWriteConstraintWriteAsRead.self, fromChild: "writeAsRead") { + if let value = try? element.decode( + SVDWriteConstraintWriteAsRead.self, fromChild: "writeAsRead") + { self = .writeAsRead(value) - } else if let value = try? element.decode(Bool.self, fromChild: "useEnumeratedValues") { + } else if let value = try? element.decode( + Bool.self, fromChild: "useEnumeratedValues") + { self = .useEnumeratedValues(value) - } else if let value = try? element.decode(SVDWriteConstraintRange.self, fromChild: "range") { + } else if let value = try? element.decode( + SVDWriteConstraintRange.self, fromChild: "range") + { self = .range(value) } else { throw XMLError.unknownElement(element) diff --git a/Sources/SVD2LLDB/DataStructures/PrefixTree.swift b/Sources/SVD2LLDB/DataStructures/PrefixTree.swift index 71f010c6..cfb871a7 100644 --- a/Sources/SVD2LLDB/DataStructures/PrefixTree.swift +++ b/Sources/SVD2LLDB/DataStructures/PrefixTree.swift @@ -33,7 +33,8 @@ extension PrefixTree { } private func insert(element: Element) -> PrefixTree { - guard let tree = self.children.first(where: { $0.element == element }) else { + guard let tree = self.children.first(where: { $0.element == element }) + else { let tree = Self(element: element) self.children.append(tree) return tree diff --git a/Sources/SVD2LLDB/Extensions/SVD/SVDItem.swift b/Sources/SVD2LLDB/Extensions/SVD/SVDItem.swift index 91fec7c6..9c6cbbc4 100644 --- a/Sources/SVD2LLDB/Extensions/SVD/SVDItem.swift +++ b/Sources/SVD2LLDB/Extensions/SVD/SVDItem.swift @@ -167,12 +167,18 @@ extension SVDRegister: SVDItem { if let protection = registerProperties.protection { info.append(("Protection", "\(protection)")) } - if let dataType = self.dataType { info.append(("Data Type", "\(dataType)")) } + if let dataType = self.dataType { + info.append(("Data Type", "\(dataType)")) + } if let modifiedWriteValues = self.modifiedWriteValues { info.append(("Modified Write Values", "\(modifiedWriteValues)")) } - if let writeConstraint = self.writeConstraint { info.append(("Write Constraint", "\(writeConstraint)")) } - if let readAction = self.readAction { info.append(("Read Action", "\(readAction)")) } + if let writeConstraint = self.writeConstraint { + info.append(("Write Constraint", "\(writeConstraint)")) + } + if let readAction = self.readAction { + info.append(("Read Action", "\(readAction)")) + } if let fields = self.fields, !fields.field.isEmpty { let description = fields.field.lazy.map(\.name).joined(separator: ", ") info.append(("Fields", "[\(description)]")) @@ -199,8 +205,12 @@ extension SVDField: SVDItem { if let modifiedWriteValues = self.modifiedWriteValues { info.append(("Modified Write Values", "\(modifiedWriteValues)")) } - if let writeConstraint = self.writeConstraint { info.append(("Write Constraint", "\(writeConstraint)")) } - if let readAction = self.readAction { info.append(("Read Action", "\(readAction)")) } + if let writeConstraint = self.writeConstraint { + info.append(("Write Constraint", "\(writeConstraint)")) + } + if let readAction = self.readAction { + info.append(("Read Action", "\(readAction)")) + } return info } } diff --git a/Sources/SVD2Swift/Extensions/Formatting.swift b/Sources/SVD2Swift/Extensions/Formatting.swift index 909de58c..7e063bbf 100644 --- a/Sources/SVD2Swift/Extensions/Formatting.swift +++ b/Sources/SVD2Swift/Extensions/Formatting.swift @@ -260,7 +260,8 @@ extension String.StringInterpolation { } mutating func appendInterpolation(identifier: String) { - let name = identifier.replacingOccurrences(of: "-", with: "_").quotingReservedWords + let name = identifier.replacingOccurrences(of: "-", with: "_") + .quotingReservedWords self.appendLiteral(name) } } diff --git a/Sources/SVD2Swift/Extensions/SVD+Export.swift b/Sources/SVD2Swift/Extensions/SVD+Export.swift index 59af2a3d..cc8eb9fd 100644 --- a/Sources/SVD2Swift/Extensions/SVD+Export.swift +++ b/Sources/SVD2Swift/Extensions/SVD+Export.swift @@ -111,7 +111,9 @@ extension SVDDevice { parentTypes.append(deviceName) } - var exportQueue = [([any SVDExportable], [String], SVDRegisterProperties)]() + var exportQueue = [ + ([any SVDExportable], [String], SVDRegisterProperties) + ]() exportQueue.append(([peripheral], parentTypes, self.registerProperties)) // Track indices instead of popping front to avoid O(N) pop. @@ -121,7 +123,8 @@ extension SVDDevice { if currentIndex != exportQueue.startIndex { context.outputWriter.append("\n") } - let (elements, parentTypes, registerProperties) = exportQueue[currentIndex] + let (elements, parentTypes, registerProperties) = exportQueue[ + currentIndex] if !parentTypes.isEmpty { let parentTypeFullName = parentTypes.joined(separator: ".") context.outputWriter.append("extension \(parentTypeFullName) {\n") @@ -179,7 +182,8 @@ extension SVDPeripheral: SVDExportable { var exports = [any SVDExportable]() if let derivedFrom = self.derivedFrom { // FIXME: Handle only exporting B where B deriveFrom A - context.outputWriter.append("\(context.accessLevel)typealias \(typeName) = \(derivedFrom)\n") + context.outputWriter.append( + "\(context.accessLevel)typealias \(typeName) = \(derivedFrom)\n") } else { context.outputWriter.append( """ @@ -297,7 +301,8 @@ extension SVDCluster: SVDExportable { var exports = [any SVDExportable]() if let derivedFrom = self.derivedFrom { - context.outputWriter.append("\(context.accessLevel)typealias \(self.swiftName) = \(derivedFrom)\n") + context.outputWriter.append( + "\(context.accessLevel)typealias \(self.swiftName) = \(derivedFrom)\n") } else { context.outputWriter.append( @@ -401,7 +406,8 @@ extension SVDRegister: SVDExportable { context.outputWriter.append("}\n") } else { // FIXME: warning diagnostic - print("warning: skipped exporting \(self.swiftName): unknown register size") + print( + "warning: skipped exporting \(self.swiftName): unknown register size") } return ([], registerProperties) } diff --git a/SupportingFiles/Tools/swift-format/.swift-format b/SupportingFiles/Tools/swift-format/.swift-format index 1524e636..397b0eef 100644 --- a/SupportingFiles/Tools/swift-format/.swift-format +++ b/SupportingFiles/Tools/swift-format/.swift-format @@ -11,7 +11,7 @@ "lineBreakBeforeControlFlowKeywords" : false, "lineBreakBeforeEachArgument" : false, "lineBreakBeforeEachGenericRequirement" : false, - "lineLength" : 120, + "lineLength" : 80, "maximumBlankLines" : 1, "multiElementCollectionTrailingCommas" : true, "noAssignmentInExpressions" : { @@ -62,6 +62,7 @@ "UseWhereClausesInForLoops" : false, "ValidateDocumentationComments" : true }, + "spacesBeforeEndOfLineComments": 2, "spacesAroundRangeFormationOperators" : false, "tabWidth" : 2, "version" : 1 diff --git a/Tests/MMIOInterposableTests/MMIOTracingInterposerEventTests.swift b/Tests/MMIOInterposableTests/MMIOTracingInterposerEventTests.swift index d82761a6..8d11cfe2 100644 --- a/Tests/MMIOInterposableTests/MMIOTracingInterposerEventTests.swift +++ b/Tests/MMIOInterposableTests/MMIOTracingInterposerEventTests.swift @@ -33,13 +33,16 @@ final class MMIOTracingInterposerEventTests: XCTestCase { MMIOTracingInterposerEvent(load: false, address: 0x10, size: 8, value: 1)) XCTAssertEqual( MMIOTracingInterposerEvent.store(of: UInt16(2), to: 0x10), - MMIOTracingInterposerEvent(load: false, address: 0x10, size: 16, value: 2)) + MMIOTracingInterposerEvent(load: false, address: 0x10, size: 16, value: 2) + ) XCTAssertEqual( MMIOTracingInterposerEvent.store(of: UInt32(3), to: 0x10), - MMIOTracingInterposerEvent(load: false, address: 0x10, size: 32, value: 3)) + MMIOTracingInterposerEvent(load: false, address: 0x10, size: 32, value: 3) + ) XCTAssertEqual( MMIOTracingInterposerEvent.store(of: UInt64(4), to: 0x10), - MMIOTracingInterposerEvent(load: false, address: 0x10, size: 64, value: 4)) + MMIOTracingInterposerEvent(load: false, address: 0x10, size: 64, value: 4) + ) } func test_description() { diff --git a/Tests/MMIOMacrosTests/Macros/RegisterBlockMacroTests.swift b/Tests/MMIOMacrosTests/Macros/RegisterBlockMacroTests.swift index 2460bcc0..a3ee1019 100644 --- a/Tests/MMIOMacrosTests/Macros/RegisterBlockMacroTests.swift +++ b/Tests/MMIOMacrosTests/Macros/RegisterBlockMacroTests.swift @@ -95,33 +95,42 @@ final class RegisterBlockMacroTests: XCTestCase { diagnostics: [ .init( message: - ErrorDiagnostic.expectedMemberAnnotatedWithMacro(registerBlockMemberMacros).message, + ErrorDiagnostic.expectedMemberAnnotatedWithMacro( + registerBlockMemberMacros + ).message, line: 3, column: 3, highlights: ["var v1: Int"], fixIts: [ .init(message: "Insert '@RegisterBlock(offset:)' macro"), - .init(message: "Insert '@RegisterBlock(offset:stride:count:)' macro"), + .init( + message: "Insert '@RegisterBlock(offset:stride:count:)' macro"), ]), .init( message: - ErrorDiagnostic.expectedMemberAnnotatedWithMacro(registerBlockMemberMacros).message, + ErrorDiagnostic.expectedMemberAnnotatedWithMacro( + registerBlockMemberMacros + ).message, line: 4, column: 3, highlights: ["@OtherAttribute var v2: Int"], fixIts: [ .init(message: "Insert '@RegisterBlock(offset:)' macro"), - .init(message: "Insert '@RegisterBlock(offset:stride:count:)' macro"), + .init( + message: "Insert '@RegisterBlock(offset:stride:count:)' macro"), ]), .init( message: - ErrorDiagnostic.expectedMemberAnnotatedWithMacro(registerBlockMemberMacros).message, + ErrorDiagnostic.expectedMemberAnnotatedWithMacro( + registerBlockMemberMacros + ).message, line: 5, column: 3, highlights: ["var v3: Int { willSet {} }"], fixIts: [ .init(message: "Insert '@RegisterBlock(offset:)' macro"), - .init(message: "Insert '@RegisterBlock(offset:stride:count:)' macro"), + .init( + message: "Insert '@RegisterBlock(offset:stride:count:)' macro"), ]), ], macros: Self.macros, diff --git a/Tests/MMIOMacrosTests/Macros/RegisterBlockOffsetMacroTests.swift b/Tests/MMIOMacrosTests/Macros/RegisterBlockOffsetMacroTests.swift index 5fd00fd0..e832fef7 100644 --- a/Tests/MMIOMacrosTests/Macros/RegisterBlockOffsetMacroTests.swift +++ b/Tests/MMIOMacrosTests/Macros/RegisterBlockOffsetMacroTests.swift @@ -18,7 +18,9 @@ import XCTest @testable import MMIOMacros final class RegisterBlockOffsetMacroTests: XCTestCase { - typealias ErrorDiagnostic = MMIOMacros.ErrorDiagnostic + typealias ErrorDiagnostic = MMIOMacros.ErrorDiagnostic< + RegisterBlockScalarMemberMacro + > static let macros: [String: Macro.Type] = [ "RegisterBlock": RegisterBlockScalarMemberMacro.self diff --git a/Tests/MMIOMacrosTests/Macros/RegisterMacroTests.swift b/Tests/MMIOMacrosTests/Macros/RegisterMacroTests.swift index 68b5e92f..1b3b55d5 100644 --- a/Tests/MMIOMacrosTests/Macros/RegisterMacroTests.swift +++ b/Tests/MMIOMacrosTests/Macros/RegisterMacroTests.swift @@ -100,7 +100,9 @@ final class RegisterMacroTests: XCTestCase { """, diagnostics: [ .init( - message: ErrorDiagnostic.expectedMemberAnnotatedWithMacro(bitFieldMacros).message, + message: ErrorDiagnostic.expectedMemberAnnotatedWithMacro( + bitFieldMacros + ).message, line: 3, column: 3, highlights: ["var v1: Int"], @@ -111,7 +113,9 @@ final class RegisterMacroTests: XCTestCase { .init(message: "Insert '@WriteOnly(bits:as:)' macro"), ]), .init( - message: ErrorDiagnostic.expectedMemberAnnotatedWithMacro(bitFieldMacros).message, + message: ErrorDiagnostic.expectedMemberAnnotatedWithMacro( + bitFieldMacros + ).message, line: 4, column: 3, highlights: ["@OtherAttribute var v2: Int"], @@ -122,7 +126,9 @@ final class RegisterMacroTests: XCTestCase { .init(message: "Insert '@WriteOnly(bits:as:)' macro"), ]), .init( - message: ErrorDiagnostic.expectedMemberAnnotatedWithMacro(bitFieldMacros).message, + message: ErrorDiagnostic.expectedMemberAnnotatedWithMacro( + bitFieldMacros + ).message, line: 5, column: 3, highlights: ["var v3: Int { willSet {} }"], diff --git a/Tests/MMIOMacrosTests/SwiftSyntaxExtensions/ArgumentParsing/ParsableMacroTests.swift b/Tests/MMIOMacrosTests/SwiftSyntaxExtensions/ArgumentParsing/ParsableMacroTests.swift index db9a4278..5f838d5d 100644 --- a/Tests/MMIOMacrosTests/SwiftSyntaxExtensions/ArgumentParsing/ParsableMacroTests.swift +++ b/Tests/MMIOMacrosTests/SwiftSyntaxExtensions/ArgumentParsing/ParsableMacroTests.swift @@ -69,7 +69,8 @@ final class ParsableMacroTests: XCTestCase { """, diagnostics: [ .init( - message: ErrorDiagnostic.unexpectedExtraArgument(label: "_").message, + message: ErrorDiagnostic.unexpectedExtraArgument(label: "_") + .message, line: 1, column: 4, highlights: ["0"]) @@ -116,7 +117,8 @@ final class ParsableMacroTests: XCTestCase { """, diagnostics: [ .init( - message: ErrorDiagnostic.unexpectedMissingArgument(label: "foo").message, + message: ErrorDiagnostic.unexpectedMissingArgument(label: "foo") + .message, line: 1, column: 1, highlights: ["@A"]) @@ -132,7 +134,8 @@ final class ParsableMacroTests: XCTestCase { """, diagnostics: [ .init( - message: ErrorDiagnostic.unexpectedMissingArgument(label: "foo").message, + message: ErrorDiagnostic.unexpectedMissingArgument(label: "foo") + .message, line: 1, column: 1, highlights: ["@A()"]) @@ -148,7 +151,9 @@ final class ParsableMacroTests: XCTestCase { """, diagnostics: [ .init( - message: ErrorDiagnostic.unexpectedArgumentLabel(expected: "foo", actual: "bar").message, + message: ErrorDiagnostic.unexpectedArgumentLabel( + expected: "foo", actual: "bar" + ).message, line: 1, column: 4, highlights: ["bar: 1"]) @@ -164,7 +169,8 @@ final class ParsableMacroTests: XCTestCase { """, diagnostics: [ .init( - message: ErrorDiagnostic.unexpectedExtraArgument(label: "baz").message, + message: ErrorDiagnostic.unexpectedExtraArgument(label: "baz") + .message, line: 1, column: 12, highlights: ["baz: 1"]) @@ -229,7 +235,8 @@ final class ParsableMacroTests: XCTestCase { """, diagnostics: [ .init( - message: ErrorDiagnostic.unexpectedExtraArgument(label: "bar").message, + message: ErrorDiagnostic.unexpectedExtraArgument(label: "bar") + .message, line: 1, column: 4, highlights: ["bar: 1"]) @@ -245,7 +252,8 @@ final class ParsableMacroTests: XCTestCase { """, diagnostics: [ .init( - message: ErrorDiagnostic.unexpectedExtraArgument(label: "baz").message, + message: ErrorDiagnostic.unexpectedExtraArgument(label: "baz") + .message, line: 1, column: 12, highlights: ["baz: 1"]) @@ -333,7 +341,8 @@ final class ParsableMacroTests: XCTestCase { """, diagnostics: [ .init( - message: ErrorDiagnostic.unexpectedExtraArgument(label: "baz").message, + message: ErrorDiagnostic.unexpectedExtraArgument(label: "baz") + .message, line: 1, column: 12, highlights: ["baz: 1"]) @@ -390,7 +399,8 @@ final class ParsableMacroTests: XCTestCase { """, diagnostics: [ .init( - message: ErrorDiagnostic.unexpectedMissingArgument(label: "foo").message, + message: ErrorDiagnostic.unexpectedMissingArgument(label: "foo") + .message, line: 1, column: 1, highlights: ["@A"]) @@ -407,7 +417,8 @@ final class ParsableMacroTests: XCTestCase { """, diagnostics: [ .init( - message: ErrorDiagnostic.unexpectedMissingArgument(label: "foo").message, + message: ErrorDiagnostic.unexpectedMissingArgument(label: "foo") + .message, line: 1, column: 1, highlights: ["@A()"]) @@ -424,7 +435,9 @@ final class ParsableMacroTests: XCTestCase { """, diagnostics: [ .init( - message: ErrorDiagnostic.unexpectedArgumentLabel(expected: "foo", actual: "bar").message, + message: ErrorDiagnostic.unexpectedArgumentLabel( + expected: "foo", actual: "bar" + ).message, line: 1, column: 4, highlights: ["bar: 1"]) @@ -440,7 +453,8 @@ final class ParsableMacroTests: XCTestCase { """, diagnostics: [ .init( - message: ErrorDiagnostic.unexpectedExtraArgument(label: "baz").message, + message: ErrorDiagnostic.unexpectedExtraArgument(label: "baz") + .message, line: 1, column: 12, highlights: ["baz: 1"]) @@ -501,7 +515,9 @@ final class ParsableMacroTests: XCTestCase { """, diagnostics: [ .init( - message: ErrorDiagnostic.unexpectedArgumentLabel(expected: "foo", actual: "bar").message, + message: ErrorDiagnostic.unexpectedArgumentLabel( + expected: "foo", actual: "bar" + ).message, line: 1, column: 4, highlights: ["bar: 2"]) @@ -517,7 +533,8 @@ final class ParsableMacroTests: XCTestCase { """, diagnostics: [ .init( - message: ErrorDiagnostic.unexpectedExtraArgument(label: "baz").message, + message: ErrorDiagnostic.unexpectedExtraArgument(label: "baz") + .message, line: 1, column: 12, highlights: ["baz: 1"]) @@ -560,7 +577,8 @@ final class ParsableMacroTests: XCTestCase { XCTAssertEqual("\(A.attributeWithPlaceholders)", "@A") XCTAssertEqual("\(B.attributeWithPlaceholders)", "@B(foo: <#Int#>)") - XCTAssertEqual("\(C.attributeWithPlaceholders)", "@C(foo: <#Int#>, bar: <#Int#>)") + XCTAssertEqual( + "\(C.attributeWithPlaceholders)", "@C(foo: <#Int#>, bar: <#Int#>)") XCTAssertEqual("\(D.attributeWithPlaceholders)", "@D(foo: <#Int#>)") XCTAssertEqual("\(E.attributeWithPlaceholders)", "@E(foo: <#Int#>)") XCTAssertEqual("\(F.attributeWithPlaceholders)", "@F(foo: <#Int#>)") diff --git a/Tests/MMIOMacrosTests/SwiftSyntaxExtensions/SyntaxStringInterpolationTests.swift b/Tests/MMIOMacrosTests/SwiftSyntaxExtensions/SyntaxStringInterpolationTests.swift index 4c32898a..48857208 100644 --- a/Tests/MMIOMacrosTests/SwiftSyntaxExtensions/SyntaxStringInterpolationTests.swift +++ b/Tests/MMIOMacrosTests/SwiftSyntaxExtensions/SyntaxStringInterpolationTests.swift @@ -19,7 +19,8 @@ final class SyntaxStringInterpolationTests: XCTestCase { func test_appendInterpolationNodesIntermediateTrivia_none() { let expected: DeclSyntax = "struct S {}" let decls: [DeclSyntax] = [] - let actual: DeclSyntax = "struct S {\(nodes: decls, intermediateTrivia: .newlines(2))}" + let actual: DeclSyntax = + "struct S {\(nodes: decls, intermediateTrivia: .newlines(2))}" XCTAssertEqual(expected.description, actual.description) } diff --git a/Tests/MMIOTests/BitFieldTests.swift b/Tests/MMIOTests/BitFieldTests.swift index e6b4632a..a11637e6 100644 --- a/Tests/MMIOTests/BitFieldTests.swift +++ b/Tests/MMIOTests/BitFieldTests.swift @@ -87,8 +87,10 @@ final class BitFieldTests: XCTestCase { XCTAssertFalse(UInt8.bitRangeWithinBounds(bits: -2..<12)) // both side XCTAssertFalse(UInt32.bitRangeWithinBounds(bits: -1..<2)) // partial lower - XCTAssertFalse(UInt32.bitRangeWithinBounds(bits: -2..<(-1))) // fully lower - XCTAssertFalse(UInt32.bitRangeWithinBounds(bits: 30..<36)) // partial upper + // fully lower + XCTAssertFalse(UInt32.bitRangeWithinBounds(bits: -2..<(-1))) + // partial upper + XCTAssertFalse(UInt32.bitRangeWithinBounds(bits: 30..<36)) XCTAssertFalse(UInt32.bitRangeWithinBounds(bits: 33..<36)) // fully upper XCTAssertFalse(UInt32.bitRangeWithinBounds(bits: -2..<36)) // both side } @@ -96,7 +98,8 @@ final class BitFieldTests: XCTestCase { func test_bitRangeCoalesced() { // Coalesced XCTAssertTrue(UInt8.bitRangesCoalesced(bits: [0..<1, 2..<5, 7..<8])) - XCTAssertTrue(UInt8.bitRangesCoalesced(bits: [2..<3, 0..<1])) // Not sorted + // Not sorted + XCTAssertTrue(UInt8.bitRangesCoalesced(bits: [2..<3, 0..<1])) // FIXME: this should only be valid if in reverse order 1..<2, 0..<1 XCTAssertTrue(UInt8.bitRangesCoalesced(bits: [0..<1, 1..<2])) // Touching // v Good. ^ Bad. diff --git a/Tests/MMIOUtilitiesTests/ParserTests.swift b/Tests/MMIOUtilitiesTests/ParserTests.swift index 508dd36a..b6408749 100644 --- a/Tests/MMIOUtilitiesTests/ParserTests.swift +++ b/Tests/MMIOUtilitiesTests/ParserTests.swift @@ -105,23 +105,33 @@ final class ParserTests: XCTestCase { XCTAssertParse(Parser.swiftInteger(Int.self), "0b1_0__1___0", 10) XCTAssertParse(Parser.swiftInteger(Int.self), "0o1_0_23456___7", 2_177_399) - XCTAssertParse(Parser.swiftInteger(Int.self), "01_0_2345678___9", 1_023_456_789) + XCTAssertParse( + Parser.swiftInteger(Int.self), "01_0_2345678___9", 1_023_456_789) #if arch(x86_64) || arch(arm64) - XCTAssertParse(Parser.swiftInteger(Int.self), "0x1_0_23456789abcde___f", 1_162_849_439_785_405_935) + XCTAssertParse( + Parser.swiftInteger(Int.self), "0x1_0_23456789abcde___f", + 1_162_849_439_785_405_935) #endif XCTAssertParse(Parser.swiftInteger(Int.self), "-0b1_0__1___0", -10) - XCTAssertParse(Parser.swiftInteger(Int.self), "-0o1_0_23456___7", -2_177_399) - XCTAssertParse(Parser.swiftInteger(Int.self), "-01_0_2345678___9", -1_023_456_789) + XCTAssertParse( + Parser.swiftInteger(Int.self), "-0o1_0_23456___7", -2_177_399) + XCTAssertParse( + Parser.swiftInteger(Int.self), "-01_0_2345678___9", -1_023_456_789) #if arch(x86_64) || arch(arm64) - XCTAssertParse(Parser.swiftInteger(Int.self), "-0x1_0_23456789abcde___f", -1_162_849_439_785_405_935) + XCTAssertParse( + Parser.swiftInteger(Int.self), "-0x1_0_23456789abcde___f", + -1_162_849_439_785_405_935) #endif XCTAssertParse(Parser.swiftInteger(Int.self), "+0b1_0__1___0", 10) XCTAssertParse(Parser.swiftInteger(Int.self), "+0o1_0_23456___7", 2_177_399) - XCTAssertParse(Parser.swiftInteger(Int.self), "+01_0_2345678___9", 1_023_456_789) + XCTAssertParse( + Parser.swiftInteger(Int.self), "+01_0_2345678___9", 1_023_456_789) #if arch(x86_64) || arch(arm64) - XCTAssertParse(Parser.swiftInteger(Int.self), "+0x1_0_23456789abcde___f", 1_162_849_439_785_405_935) + XCTAssertParse( + Parser.swiftInteger(Int.self), "+0x1_0_23456789abcde___f", + 1_162_849_439_785_405_935) #endif XCTAssertNoParse(Parser.swiftInteger(Int.self), "0b_0") diff --git a/Tests/MMIOUtilitiesTests/StringInterpolation+BinaryTests.swift b/Tests/MMIOUtilitiesTests/StringInterpolation+BinaryTests.swift index db58c845..f678ccdb 100644 --- a/Tests/MMIOUtilitiesTests/StringInterpolation+BinaryTests.swift +++ b/Tests/MMIOUtilitiesTests/StringInterpolation+BinaryTests.swift @@ -29,23 +29,38 @@ final class StringInterpolationBinaryTests: XCTestCase { XCTAssertEqual("\(binary: Int16.max)", "0b0111_1111_1111_1111") // Int32 - XCTAssertEqual("\(binary: Int32.min)", "0b1000_0000_0000_0000_0000_0000_0000_0000") - XCTAssertEqual("\(binary: Int32(-1))", "0b1111_1111_1111_1111_1111_1111_1111_1111") - XCTAssertEqual("\(binary: Int32(0))", "0b0000_0000_0000_0000_0000_0000_0000_0000") - XCTAssertEqual("\(binary: Int32(1))", "0b0000_0000_0000_0000_0000_0000_0000_0001") - XCTAssertEqual("\(binary: Int32.max)", "0b0111_1111_1111_1111_1111_1111_1111_1111") + XCTAssertEqual( + "\(binary: Int32.min)", "0b1000_0000_0000_0000_0000_0000_0000_0000") + XCTAssertEqual( + "\(binary: Int32(-1))", "0b1111_1111_1111_1111_1111_1111_1111_1111") + XCTAssertEqual( + "\(binary: Int32(0))", "0b0000_0000_0000_0000_0000_0000_0000_0000") + XCTAssertEqual( + "\(binary: Int32(1))", "0b0000_0000_0000_0000_0000_0000_0000_0001") + XCTAssertEqual( + "\(binary: Int32.max)", "0b0111_1111_1111_1111_1111_1111_1111_1111") // Int64 XCTAssertEqual( - "\(binary: Int64.min)", "0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000") + "\(binary: Int64.min)", + "0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000" + ) XCTAssertEqual( - "\(binary: Int64(-1))", "0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111") + "\(binary: Int64(-1))", + "0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111" + ) XCTAssertEqual( - "\(binary: Int64(0))", "0b0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000") + "\(binary: Int64(0))", + "0b0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000" + ) XCTAssertEqual( - "\(binary: Int64(1))", "0b0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0001") + "\(binary: Int64(1))", + "0b0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0001" + ) XCTAssertEqual( - "\(binary: Int64.max)", "0b0111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111") + "\(binary: Int64.max)", + "0b0111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111" + ) // UInt8 XCTAssertEqual("\(binary: UInt8.min)", "0b0000_0000") @@ -58,17 +73,26 @@ final class StringInterpolationBinaryTests: XCTestCase { XCTAssertEqual("\(binary: UInt16.max)", "0b1111_1111_1111_1111") // UInt32 - XCTAssertEqual("\(binary: UInt32.min)", "0b0000_0000_0000_0000_0000_0000_0000_0000") - XCTAssertEqual("\(binary: UInt32(1))", "0b0000_0000_0000_0000_0000_0000_0000_0001") - XCTAssertEqual("\(binary: UInt32.max)", "0b1111_1111_1111_1111_1111_1111_1111_1111") + XCTAssertEqual( + "\(binary: UInt32.min)", "0b0000_0000_0000_0000_0000_0000_0000_0000") + XCTAssertEqual( + "\(binary: UInt32(1))", "0b0000_0000_0000_0000_0000_0000_0000_0001") + XCTAssertEqual( + "\(binary: UInt32.max)", "0b1111_1111_1111_1111_1111_1111_1111_1111") // UInt64 XCTAssertEqual( - "\(binary: UInt64.min)", "0b0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000") + "\(binary: UInt64.min)", + "0b0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000" + ) XCTAssertEqual( - "\(binary: UInt64(1))", "0b0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0001") + "\(binary: UInt64(1))", + "0b0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0001" + ) XCTAssertEqual( - "\(binary: UInt64.max)", "0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111") + "\(binary: UInt64.max)", + "0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111" + ) } func test_appendInterpolation_binary_bytes() { diff --git a/Tests/SVD2LLDBTests/SVD2LLDBTestDevice.swift b/Tests/SVD2LLDBTests/SVD2LLDBTestDevice.swift index 01b1d713..3193de49 100644 --- a/Tests/SVD2LLDBTests/SVD2LLDBTestDevice.swift +++ b/Tests/SVD2LLDBTests/SVD2LLDBTestDevice.swift @@ -65,126 +65,228 @@ private let fields: [SVDField] = [ bitRange: .lsbMsb(.init(lsb: 31, msb: 31)), enumeratedValues: .init( enumeratedValue: [ - .init(name: "STOP", data: .value(.init(value: .init(value: 0, mask: mask)))), - .init(name: "START", data: .value(.init(value: .init(value: 1, mask: mask)))), + .init( + name: "STOP", data: .value(.init(value: .init(value: 0, mask: mask)))), + .init( + name: "START", data: .value(.init(value: .init(value: 1, mask: mask))) + ), ])), .init( name: "IDR", bitRange: .lsbMsb(.init(lsb: 26, msb: 27)), enumeratedValues: .init( enumeratedValue: [ - .init(name: "KEEP", data: .value(.init(value: .init(value: 0, mask: mask)))), - .init(name: "INCREMENT", data: .value(.init(value: .init(value: 1, mask: mask)))), - .init(name: "DECREMENT", data: .value(.init(value: .init(value: 2, mask: mask)))), + .init( + name: "KEEP", data: .value(.init(value: .init(value: 0, mask: mask)))), + .init( + name: "INCREMENT", + data: .value(.init(value: .init(value: 1, mask: mask)))), + .init( + name: "DECREMENT", + data: .value(.init(value: .init(value: 2, mask: mask)))), ])), .init( name: "RELOAD", bitRange: .lsbMsb(.init(lsb: 24, msb: 25)), enumeratedValues: .init( enumeratedValue: [ - .init(name: "RELOAD0", data: .value(.init(value: .init(value: 0, mask: mask)))), - .init(name: "RELOAD1", data: .value(.init(value: .init(value: 1, mask: mask)))), - .init(name: "RELOAD2", data: .value(.init(value: .init(value: 2, mask: mask)))), - .init(name: "RELOAD3", data: .value(.init(value: .init(value: 3, mask: mask)))), + .init( + name: "RELOAD0", + data: .value(.init(value: .init(value: 0, mask: mask)))), + .init( + name: "RELOAD1", + data: .value(.init(value: .init(value: 1, mask: mask)))), + .init( + name: "RELOAD2", + data: .value(.init(value: .init(value: 2, mask: mask)))), + .init( + name: "RELOAD3", + data: .value(.init(value: .init(value: 3, mask: mask)))), ])), .init( name: "TRGEXT", bitRange: .lsbMsb(.init(lsb: 20, msb: 21)), enumeratedValues: .init( enumeratedValue: [ - .init(name: "NONE", data: .value(.init(value: .init(value: 0, mask: mask)))), - .init(name: "DMA1", data: .value(.init(value: .init(value: 1, mask: mask)))), - .init(name: "DMA2", data: .value(.init(value: .init(value: 2, mask: mask)))), - .init(name: "UART", data: .value(.init(value: .init(value: 3, mask: mask)))), + .init( + name: "NONE", data: .value(.init(value: .init(value: 0, mask: mask)))), + .init( + name: "DMA1", data: .value(.init(value: .init(value: 1, mask: mask)))), + .init( + name: "DMA2", data: .value(.init(value: .init(value: 2, mask: mask)))), + .init( + name: "UART", data: .value(.init(value: .init(value: 3, mask: mask)))), ])), .init( name: "CAPEDGE", bitRange: .lsbMsb(.init(lsb: 16, msb: 17)), enumeratedValues: .init( enumeratedValue: [ - .init(name: "RISING", data: .value(.init(value: .init(value: 0, mask: mask)))), - .init(name: "FALLING", data: .value(.init(value: .init(value: 1, mask: mask)))), - .init(name: "BOTH", data: .value(.init(value: .init(value: 2, mask: mask)))), + .init( + name: "RISING", + data: .value(.init(value: .init(value: 0, mask: mask)))), + .init( + name: "FALLING", + data: .value(.init(value: .init(value: 1, mask: mask)))), + .init( + name: "BOTH", data: .value(.init(value: .init(value: 2, mask: mask)))), ])), .init( name: "CAPSRC", bitRange: .lsbMsb(.init(lsb: 12, msb: 15)), enumeratedValues: .init( enumeratedValue: [ - .init(name: "CClk", data: .value(.init(value: .init(value: 0, mask: mask)))), - .init(name: "GPIOA_0", data: .value(.init(value: .init(value: 1, mask: mask)))), - .init(name: "GPIOA_1", data: .value(.init(value: .init(value: 2, mask: mask)))), - .init(name: "GPIOA_2", data: .value(.init(value: .init(value: 3, mask: mask)))), - .init(name: "GPIOA_3", data: .value(.init(value: .init(value: 4, mask: mask)))), - .init(name: "GPIOA_4", data: .value(.init(value: .init(value: 5, mask: mask)))), - .init(name: "GPIOA_5", data: .value(.init(value: .init(value: 6, mask: mask)))), - .init(name: "GPIOA_6", data: .value(.init(value: .init(value: 7, mask: mask)))), - .init(name: "GPIOA_7", data: .value(.init(value: .init(value: 8, mask: mask)))), - .init(name: "GPIOB_0", data: .value(.init(value: .init(value: 9, mask: mask)))), - .init(name: "GPIOB_1", data: .value(.init(value: .init(value: 10, mask: mask)))), - .init(name: "GPIOB_2", data: .value(.init(value: .init(value: 11, mask: mask)))), - .init(name: "GPIOB_3", data: .value(.init(value: .init(value: 12, mask: mask)))), - .init(name: "GPIOC_0", data: .value(.init(value: .init(value: 13, mask: mask)))), - .init(name: "GPIOC_5", data: .value(.init(value: .init(value: 14, mask: mask)))), - .init(name: "GPIOC_6", data: .value(.init(value: .init(value: 15, mask: mask)))), + .init( + name: "CClk", data: .value(.init(value: .init(value: 0, mask: mask)))), + .init( + name: "GPIOA_0", + data: .value(.init(value: .init(value: 1, mask: mask)))), + .init( + name: "GPIOA_1", + data: .value(.init(value: .init(value: 2, mask: mask)))), + .init( + name: "GPIOA_2", + data: .value(.init(value: .init(value: 3, mask: mask)))), + .init( + name: "GPIOA_3", + data: .value(.init(value: .init(value: 4, mask: mask)))), + .init( + name: "GPIOA_4", + data: .value(.init(value: .init(value: 5, mask: mask)))), + .init( + name: "GPIOA_5", + data: .value(.init(value: .init(value: 6, mask: mask)))), + .init( + name: "GPIOA_6", + data: .value(.init(value: .init(value: 7, mask: mask)))), + .init( + name: "GPIOA_7", + data: .value(.init(value: .init(value: 8, mask: mask)))), + .init( + name: "GPIOB_0", + data: .value(.init(value: .init(value: 9, mask: mask)))), + .init( + name: "GPIOB_1", + data: .value(.init(value: .init(value: 10, mask: mask)))), + .init( + name: "GPIOB_2", + data: .value(.init(value: .init(value: 11, mask: mask)))), + .init( + name: "GPIOB_3", + data: .value(.init(value: .init(value: 12, mask: mask)))), + .init( + name: "GPIOC_0", + data: .value(.init(value: .init(value: 13, mask: mask)))), + .init( + name: "GPIOC_5", + data: .value(.init(value: .init(value: 14, mask: mask)))), + .init( + name: "GPIOC_6", + data: .value(.init(value: .init(value: 15, mask: mask)))), ])), .init( name: "CNTSRC", bitRange: .lsbMsb(.init(lsb: 8, msb: 11)), enumeratedValues: .init( enumeratedValue: [ - .init(name: "CAP_SRC", data: .value(.init(value: .init(value: 0, mask: mask)))), - .init(name: "CAP_SRC_div2", data: .value(.init(value: .init(value: 1, mask: mask)))), - .init(name: "CAP_SRC_div4", data: .value(.init(value: .init(value: 2, mask: mask)))), - .init(name: "CAP_SRC_div8", data: .value(.init(value: .init(value: 3, mask: mask)))), - .init(name: "CAP_SRC_div16", data: .value(.init(value: .init(value: 4, mask: mask)))), - .init(name: "CAP_SRC_div32", data: .value(.init(value: .init(value: 5, mask: mask)))), - .init(name: "CAP_SRC_div64", data: .value(.init(value: .init(value: 6, mask: mask)))), - .init(name: "CAP_SRC_div128", data: .value(.init(value: .init(value: 7, mask: mask)))), - .init(name: "CAP_SRC_div256", data: .value(.init(value: .init(value: 8, mask: mask)))), + .init( + name: "CAP_SRC", + data: .value(.init(value: .init(value: 0, mask: mask)))), + .init( + name: "CAP_SRC_div2", + data: .value(.init(value: .init(value: 1, mask: mask)))), + .init( + name: "CAP_SRC_div4", + data: .value(.init(value: .init(value: 2, mask: mask)))), + .init( + name: "CAP_SRC_div8", + data: .value(.init(value: .init(value: 3, mask: mask)))), + .init( + name: "CAP_SRC_div16", + data: .value(.init(value: .init(value: 4, mask: mask)))), + .init( + name: "CAP_SRC_div32", + data: .value(.init(value: .init(value: 5, mask: mask)))), + .init( + name: "CAP_SRC_div64", + data: .value(.init(value: .init(value: 6, mask: mask)))), + .init( + name: "CAP_SRC_div128", + data: .value(.init(value: .init(value: 7, mask: mask)))), + .init( + name: "CAP_SRC_div256", + data: .value(.init(value: .init(value: 8, mask: mask)))), ])), .init( name: "PSC", bitRange: .lsbMsb(.init(lsb: 7, msb: 7)), enumeratedValues: .init( enumeratedValue: [ - .init(name: "Disabled", data: .value(.init(value: .init(value: 0, mask: mask)))), - .init(name: "Enabled", data: .value(.init(value: .init(value: 1, mask: mask)))), + .init( + name: "Disabled", + data: .value(.init(value: .init(value: 0, mask: mask)))), + .init( + name: "Enabled", + data: .value(.init(value: .init(value: 1, mask: mask)))), ])), .init( name: "MODE", bitRange: .lsbMsb(.init(lsb: 4, msb: 6)), enumeratedValues: .init( enumeratedValue: [ - .init(name: "Continous", data: .value(.init(value: .init(value: 0, mask: mask)))), - .init(name: "Single_ZERO_MAX", data: .value(.init(value: .init(value: 1, mask: mask)))), - .init(name: "Single_MATCH", data: .value(.init(value: .init(value: 2, mask: mask)))), - .init(name: "Reload_ZERO_MAX", data: .value(.init(value: .init(value: 3, mask: mask)))), - .init(name: "Reload_MATCH", data: .value(.init(value: .init(value: 4, mask: mask)))), + .init( + name: "Continous", + data: .value(.init(value: .init(value: 0, mask: mask)))), + .init( + name: "Single_ZERO_MAX", + data: .value(.init(value: .init(value: 1, mask: mask)))), + .init( + name: "Single_MATCH", + data: .value(.init(value: .init(value: 2, mask: mask)))), + .init( + name: "Reload_ZERO_MAX", + data: .value(.init(value: .init(value: 3, mask: mask)))), + .init( + name: "Reload_MATCH", + data: .value(.init(value: .init(value: 4, mask: mask)))), ])), .init( name: "CNT", bitRange: .lsbMsb(.init(lsb: 2, msb: 3)), enumeratedValues: .init( enumeratedValue: [ - .init(name: "Count_UP", data: .value(.init(value: .init(value: 0, mask: mask)))), - .init(name: "Count_DOWN", data: .value(.init(value: .init(value: 1, mask: mask)))), - .init(name: "Toggle", data: .value(.init(value: .init(value: 2, mask: mask)))), + .init( + name: "Count_UP", + data: .value(.init(value: .init(value: 0, mask: mask)))), + .init( + name: "Count_DOWN", + data: .value(.init(value: .init(value: 1, mask: mask)))), + .init( + name: "Toggle", + data: .value(.init(value: .init(value: 2, mask: mask)))), ])), .init( name: "RST", bitRange: .lsbMsb(.init(lsb: 1, msb: 1)), enumeratedValues: .init( enumeratedValue: [ - .init(name: "Reserved", data: .value(.init(value: .init(value: 0, mask: mask)))), - .init(name: "Reset_Timer", data: .value(.init(value: .init(value: 1, mask: mask)))), + .init( + name: "Reserved", + data: .value(.init(value: .init(value: 0, mask: mask)))), + .init( + name: "Reset_Timer", + data: .value(.init(value: .init(value: 1, mask: mask)))), ])), .init( name: "EN", bitRange: .lsbMsb(.init(lsb: 0, msb: 0)), enumeratedValues: .init( enumeratedValue: [ - .init(name: "Disable", data: .value(.init(value: .init(value: 0, mask: mask)))), - .init(name: "Enable", data: .value(.init(value: .init(value: 1, mask: mask)))), + .init( + name: "Disable", + data: .value(.init(value: .init(value: 0, mask: mask)))), + .init( + name: "Enable", + data: .value(.init(value: .init(value: 1, mask: mask)))), ])), ] diff --git a/Tests/SVD2SwiftTests/SVD2SwiftTests+BitWidths.swift b/Tests/SVD2SwiftTests/SVD2SwiftTests+BitWidths.swift index 4fa10b95..d9d24a71 100644 --- a/Tests/SVD2SwiftTests/SVD2SwiftTests+BitWidths.swift +++ b/Tests/SVD2SwiftTests/SVD2SwiftTests+BitWidths.swift @@ -51,7 +51,8 @@ extension SVD2SwiftTests { bitRange: .offsetWidth(.init(bitOffset: 8, bitWidth: 2))), .init( name: "E", - bitRange: .literal(.init(bitRange: .init(lsb: 10, msb: 14)))), + bitRange: .literal( + .init(bitRange: .init(lsb: 10, msb: 14)))), ])) ])) ])) diff --git a/Tests/SVD2SwiftTests/SVD2SwiftTests+ExportOptions.swift b/Tests/SVD2SwiftTests/SVD2SwiftTests+ExportOptions.swift index 51131a68..164d0705 100644 --- a/Tests/SVD2SwiftTests/SVD2SwiftTests+ExportOptions.swift +++ b/Tests/SVD2SwiftTests/SVD2SwiftTests+ExportOptions.swift @@ -342,7 +342,8 @@ extension SVD2SwiftTests { ]) } - func test_outputOptions_namespaceUnderDeviceInstanceMemberPeripherals() throws { + func test_outputOptions_namespaceUnderDeviceInstanceMemberPeripherals() throws + { XCTAssertSVD2SwiftOutput( svdDevice: Self.testOutputOptionsDevice, options: .init(