From a190eccafa2f5cd478faeab76cbeb1c132fee3d5 Mon Sep 17 00:00:00 2001 From: Morgan McColl Date: Tue, 16 Apr 2024 23:27:17 +1000 Subject: [PATCH 01/12] Update dependencies to latest versions. --- Package.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index 5a636c8..bf324b7 100644 --- a/Package.swift +++ b/Package.swift @@ -20,10 +20,10 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.3.0"), - .package(url: "https://github.com/mipalgu/VHDLMachines", from: "3.1.0"), + .package(url: "https://github.com/mipalgu/VHDLMachines", from: "4.0.0"), .package(url: "https://github.com/mipalgu/VHDLParsing", from: "2.4.0"), .package(url: "https://github.com/apple/swift-argument-parser", from: "1.3.0"), - .package(url: "https://github.com/mipalgu/VHDLKripkeStructureGenerator.git", from: "0.2.1"), + .package(url: "https://github.com/mipalgu/VHDLKripkeStructureGenerator.git", from: "0.2.2"), .package(url: "https://github.com/CPSLabGU/SwiftUtils.git", from: "0.1.0") ], targets: [ From 15654a60520f30b92ff5e369b7d2baee44865b84 Mon Sep 17 00:00:00 2001 From: Morgan McColl Date: Tue, 16 Apr 2024 23:27:39 +1000 Subject: [PATCH 02/12] Fixed model inits for new arrangement format. --- .../VHDLMachineTransformations/Arrangement+modelInit.swift | 7 +------ Tests/TestHelpers/Arrangement+pingArrangement.swift | 6 +----- .../VHDLMachineTransformationsTests/ArrangementTests.swift | 4 ---- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/Sources/VHDLMachineTransformations/Arrangement+modelInit.swift b/Sources/VHDLMachineTransformations/Arrangement+modelInit.swift index 4f004e3..203dd1c 100644 --- a/Sources/VHDLMachineTransformations/Arrangement+modelInit.swift +++ b/Sources/VHDLMachineTransformations/Arrangement+modelInit.swift @@ -97,14 +97,10 @@ extension Arrangement { let clockNames = clocks.map(\.name) let signalNames = localSignals.map(\.name) + externalSignals.map(\.name) let allNames = clockNames + signalNames - let globalMappings = model.globalMappings.compactMap { - VHDLMachines.VariableMapping(mapping: $0) - } guard externalSignals.count == externalsRaw.count, localSignals.count == signalsRaw.count, clocks.count == model.clocks.count, - globalMappings.count == model.globalMappings.count, Set(allNames).count == allNames.count else { return nil @@ -113,8 +109,7 @@ extension Arrangement { mappings: machines, externalSignals: externalSignals, signals: localSignals, - clocks: clocks, - globalMappings: globalMappings + clocks: clocks ) } diff --git a/Tests/TestHelpers/Arrangement+pingArrangement.swift b/Tests/TestHelpers/Arrangement+pingArrangement.swift index b80fe6c..089095a 100644 --- a/Tests/TestHelpers/Arrangement+pingArrangement.swift +++ b/Tests/TestHelpers/Arrangement+pingArrangement.swift @@ -80,11 +80,7 @@ public extension Arrangement { signals: [ LocalSignal(type: .stdLogic, name: .ping), LocalSignal(type: .stdLogic, name: .pong) ], - clocks: [Clock(name: .clk, frequency: 125, unit: .MHz)], - globalMappings: [ - VHDLMachines.VariableMapping(source: .externalPing, destination: .ping), - VHDLMachines.VariableMapping(source: .externalPong, destination: .pong) - ] + clocks: [Clock(name: .clk, frequency: 125, unit: .MHz)] )! } diff --git a/Tests/VHDLMachineTransformationsTests/ArrangementTests.swift b/Tests/VHDLMachineTransformationsTests/ArrangementTests.swift index 7ec0e98..6bc4df5 100644 --- a/Tests/VHDLMachineTransformationsTests/ArrangementTests.swift +++ b/Tests/VHDLMachineTransformationsTests/ArrangementTests.swift @@ -132,10 +132,6 @@ final class ArrangementTests: TransformationsFileTester { XCTAssertNil(Arrangement(model: model, basePath: machinesDirectory)) model = oldModel XCTAssertNotNil(Arrangement(model: model, basePath: machinesDirectory)) - model.globalMappings += [ - JavascriptModel.VariableMapping(source: "invalid signal!", destination: "ping") - ] - XCTAssertNil(Arrangement(model: model, basePath: machinesDirectory)) } } From a75acd3d0d00b319ab522e20ab00e9ea79861e0d Mon Sep 17 00:00:00 2001 From: Morgan McColl Date: Tue, 16 Apr 2024 23:29:07 +1000 Subject: [PATCH 03/12] Removed global mappings from javascript model. --- Sources/JavascriptModel/ArrangementModel.swift | 7 +------ Tests/JavascriptModelTests/ArrangementModelTests.swift | 6 ++---- Tests/TestHelpers/ArrangementModel+pingArrangement.swift | 6 +----- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/Sources/JavascriptModel/ArrangementModel.swift b/Sources/JavascriptModel/ArrangementModel.swift index afd5551..52f4fde 100644 --- a/Sources/JavascriptModel/ArrangementModel.swift +++ b/Sources/JavascriptModel/ArrangementModel.swift @@ -74,9 +74,6 @@ public struct ArrangementModel: Equatable, Hashable, Codable, Sendable { /// but cannot affect the outside world. public var globalVariables: String - /// The mappings between external and global variables. - public var globalMappings: [VariableMapping] - /// Initialise the arrangement from it's stored properties. /// - Parameters: /// - clocks: The clocks used in this arrangement. @@ -89,14 +86,12 @@ public struct ArrangementModel: Equatable, Hashable, Codable, Sendable { clocks: [ClockModel], externalVariables: String, machines: [MachineReference], - globalVariables: String, - globalMappings: [VariableMapping] = [] + globalVariables: String ) { self.clocks = clocks self.externalVariables = externalVariables self.machines = machines self.globalVariables = globalVariables - self.globalMappings = globalMappings } } diff --git a/Tests/JavascriptModelTests/ArrangementModelTests.swift b/Tests/JavascriptModelTests/ArrangementModelTests.swift index 7dab7ef..a3eeca5 100644 --- a/Tests/JavascriptModelTests/ArrangementModelTests.swift +++ b/Tests/JavascriptModelTests/ArrangementModelTests.swift @@ -95,8 +95,7 @@ final class ArrangementModelTests: XCTestCase { clocks: clocks, externalVariables: externalVariables, machines: machines, - globalVariables: globalVariables, - globalMappings: [] + globalVariables: globalVariables ) /// Initialise the arrangement before every test. @@ -105,8 +104,7 @@ final class ArrangementModelTests: XCTestCase { clocks: clocks, externalVariables: externalVariables, machines: machines, - globalVariables: globalVariables, - globalMappings: [] + globalVariables: globalVariables ) } diff --git a/Tests/TestHelpers/ArrangementModel+pingArrangement.swift b/Tests/TestHelpers/ArrangementModel+pingArrangement.swift index dd8071a..24ff39a 100644 --- a/Tests/TestHelpers/ArrangementModel+pingArrangement.swift +++ b/Tests/TestHelpers/ArrangementModel+pingArrangement.swift @@ -80,11 +80,7 @@ public extension ArrangementModel { globalVariables: """ signal ping: std_logic; signal pong: std_logic; - """, - globalMappings: [ - VariableMapping(source: "externalPing", destination: "ping"), - VariableMapping(source: "externalPong", destination: "pong") - ] + """ ) } From 38342275662f25e7b481be10fc26764116d5ece9 Mon Sep 17 00:00:00 2001 From: Morgan McColl Date: Wed, 17 Apr 2024 16:04:16 +1000 Subject: [PATCH 04/12] Removed old targets and depend on new VHDLJSModels package. --- Package.swift | 35 +- Sources/JavascriptModel/ActionModel.swift | 76 ---- .../JavascriptModel/ArrangementModel.swift | 97 ----- Sources/JavascriptModel/BezierPath.swift | 87 ----- Sources/JavascriptModel/ClockModel.swift | 78 ---- .../MachineModel+jsonString.swift | 76 ---- Sources/JavascriptModel/MachineModel.swift | 119 ------ .../JavascriptModel/MachineReference.swift | 87 ----- Sources/JavascriptModel/Point2D.swift | 76 ---- Sources/JavascriptModel/StateLayout.swift | 78 ---- Sources/JavascriptModel/StateModel.swift | 97 ----- .../JavascriptModel/TransitionLayout.swift | 70 ---- Sources/JavascriptModel/TransitionModel.swift | 90 ----- Sources/JavascriptModel/VariableMapping.swift | 78 ---- .../ActionModel+modelInit.swift | 73 ---- .../Arrangement+modelInit.swift | 181 --------- .../Clock+modelInit.swift | 99 ----- .../ClockModel+clockInit.swift | 74 ---- .../Machine+jsInit.swift | 159 -------- .../MachineModel+machineInit.swift | 92 ----- .../State+jsInit.swift | 113 ------ .../StateModel+stateInit.swift | 95 ----- .../Transition+jsInit.swift | 86 ----- .../TransitionModel+transitionInit.swift | 80 ---- .../ActionModelTests.swift | 81 ---- .../ArrangementModelTests.swift | 288 -------------- .../BezierPathTests.swift | 112 ------ .../ClockModelTests.swift | 87 ----- .../MachineModelTests.swift | 351 ----------------- .../MachineReferenceTests.swift | 108 ------ Tests/JavascriptModelTests/Point2DTests.swift | 81 ---- .../StateLayoutTests.swift | 90 ----- .../StateModelTests.swift | 126 ------ .../TransitionLayoutTests.swift | 90 ----- .../TransitionModelTests.swift | 123 ------ .../VariableMappingTests.swift | 86 ----- .../ActionModelTests.swift | 83 ---- .../ArrangementTests.swift | 137 ------- .../ClockModelTests.swift | 80 ---- .../ClockTests.swift | 118 ------ .../MachineModelTests.swift | 271 ------------- .../MachineTests.swift | 358 ------------------ .../StateModelTests.swift | 158 -------- .../StateTests.swift | 211 ----------- .../TransformationsFileTester.swift | 107 ------ .../TransitionModelTests.swift | 98 ----- .../TransitionTests.swift | 113 ------ .../machines/.gitignore | 1 - 48 files changed, 7 insertions(+), 5547 deletions(-) delete mode 100644 Sources/JavascriptModel/ActionModel.swift delete mode 100644 Sources/JavascriptModel/ArrangementModel.swift delete mode 100644 Sources/JavascriptModel/BezierPath.swift delete mode 100644 Sources/JavascriptModel/ClockModel.swift delete mode 100644 Sources/JavascriptModel/MachineModel+jsonString.swift delete mode 100644 Sources/JavascriptModel/MachineModel.swift delete mode 100644 Sources/JavascriptModel/MachineReference.swift delete mode 100644 Sources/JavascriptModel/Point2D.swift delete mode 100644 Sources/JavascriptModel/StateLayout.swift delete mode 100644 Sources/JavascriptModel/StateModel.swift delete mode 100644 Sources/JavascriptModel/TransitionLayout.swift delete mode 100644 Sources/JavascriptModel/TransitionModel.swift delete mode 100644 Sources/JavascriptModel/VariableMapping.swift delete mode 100644 Sources/VHDLMachineTransformations/ActionModel+modelInit.swift delete mode 100644 Sources/VHDLMachineTransformations/Arrangement+modelInit.swift delete mode 100644 Sources/VHDLMachineTransformations/Clock+modelInit.swift delete mode 100644 Sources/VHDLMachineTransformations/ClockModel+clockInit.swift delete mode 100644 Sources/VHDLMachineTransformations/Machine+jsInit.swift delete mode 100644 Sources/VHDLMachineTransformations/MachineModel+machineInit.swift delete mode 100644 Sources/VHDLMachineTransformations/State+jsInit.swift delete mode 100644 Sources/VHDLMachineTransformations/StateModel+stateInit.swift delete mode 100644 Sources/VHDLMachineTransformations/Transition+jsInit.swift delete mode 100644 Sources/VHDLMachineTransformations/TransitionModel+transitionInit.swift delete mode 100644 Tests/JavascriptModelTests/ActionModelTests.swift delete mode 100644 Tests/JavascriptModelTests/ArrangementModelTests.swift delete mode 100644 Tests/JavascriptModelTests/BezierPathTests.swift delete mode 100644 Tests/JavascriptModelTests/ClockModelTests.swift delete mode 100644 Tests/JavascriptModelTests/MachineModelTests.swift delete mode 100644 Tests/JavascriptModelTests/MachineReferenceTests.swift delete mode 100644 Tests/JavascriptModelTests/Point2DTests.swift delete mode 100644 Tests/JavascriptModelTests/StateLayoutTests.swift delete mode 100644 Tests/JavascriptModelTests/StateModelTests.swift delete mode 100644 Tests/JavascriptModelTests/TransitionLayoutTests.swift delete mode 100644 Tests/JavascriptModelTests/TransitionModelTests.swift delete mode 100644 Tests/JavascriptModelTests/VariableMappingTests.swift delete mode 100644 Tests/VHDLMachineTransformationsTests/ActionModelTests.swift delete mode 100644 Tests/VHDLMachineTransformationsTests/ArrangementTests.swift delete mode 100644 Tests/VHDLMachineTransformationsTests/ClockModelTests.swift delete mode 100644 Tests/VHDLMachineTransformationsTests/ClockTests.swift delete mode 100644 Tests/VHDLMachineTransformationsTests/MachineModelTests.swift delete mode 100644 Tests/VHDLMachineTransformationsTests/MachineTests.swift delete mode 100644 Tests/VHDLMachineTransformationsTests/StateModelTests.swift delete mode 100644 Tests/VHDLMachineTransformationsTests/StateTests.swift delete mode 100644 Tests/VHDLMachineTransformationsTests/TransformationsFileTester.swift delete mode 100644 Tests/VHDLMachineTransformationsTests/TransitionModelTests.swift delete mode 100644 Tests/VHDLMachineTransformationsTests/TransitionTests.swift delete mode 100644 Tests/VHDLMachineTransformationsTests/machines/.gitignore diff --git a/Package.swift b/Package.swift index bf324b7..ed2d7ed 100644 --- a/Package.swift +++ b/Package.swift @@ -5,17 +5,13 @@ import PackageDescription /// Package definition. let package = Package( - name: "VHDLMachineTransformations", + name: "LLFSMGenerate", products: [ // Products define the executables and libraries a package produces, making them visible to other // packages. - .library( - name: "VHDLMachineTransformations", - targets: ["VHDLMachineTransformations", "JavascriptModel"] - ), .executable( name: "llfsmgenerate", - targets: ["MachineGenerator", "VHDLMachineTransformations", "JavascriptModel"] + targets: ["MachineGenerator"] ) ], dependencies: [ @@ -24,35 +20,23 @@ let package = Package( .package(url: "https://github.com/mipalgu/VHDLParsing", from: "2.4.0"), .package(url: "https://github.com/apple/swift-argument-parser", from: "1.3.0"), .package(url: "https://github.com/mipalgu/VHDLKripkeStructureGenerator.git", from: "0.2.2"), - .package(url: "https://github.com/CPSLabGU/SwiftUtils.git", from: "0.1.0") + .package(url: "https://github.com/CPSLabGU/SwiftUtils.git", from: "0.1.0"), + .package(url: "https://github.com/CPSLabGU/VHDLJSModels", from: "1.0.0") ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. // Targets can depend on other targets in this package and products from dependencies. - .target( - name: "JavascriptModel" - ), .executableTarget( name: "MachineGenerator", dependencies: [ - .target(name: "JavascriptModel"), - .target(name: "VHDLMachineTransformations"), .product(name: "ArgumentParser", package: "swift-argument-parser"), .product(name: "VHDLMachines", package: "VHDLMachines"), .product(name: "VHDLParsing", package: "VHDLParsing"), .product(name: "VHDLKripkeStructureGenerator", package: "VHDLKripkeStructureGenerator"), - .product(name: "SwiftUtils", package: "SwiftUtils") - ] - ), - .target( - name: "VHDLMachineTransformations", - dependencies: [ - .target(name: "JavascriptModel"), - .product(name: "VHDLMachines", package: "VHDLMachines"), - .product(name: "VHDLParsing", package: "VHDLParsing") + .product(name: "SwiftUtils", package: "SwiftUtils"), + .product(name: "VHDLJSModels", package: "VHDLJSModels") ] ), - .testTarget(name: "JavascriptModelTests", dependencies: ["JavascriptModel"]), .testTarget( name: "MachineGeneratorTests", dependencies: [ @@ -64,18 +48,13 @@ let package = Package( .product(name: "ArgumentParser", package: "swift-argument-parser"), .product(name: "VHDLKripkeStructureGenerator", package: "VHDLKripkeStructureGenerator"), .product(name: "SwiftUtils", package: "SwiftUtils"), + .product(name: "VHDLJSModels", package: "VHDLJSModels"), "TestHelpers" ] ), .testTarget( name: "TestHelpers", dependencies: ["VHDLMachineTransformations", "VHDLParsing", "VHDLMachines", "JavascriptModel"] - ), - .testTarget( - name: "VHDLMachineTransformationsTests", - dependencies: [ - "VHDLMachineTransformations", "VHDLParsing", "VHDLMachines", "JavascriptModel", "TestHelpers" - ] ) ] ) diff --git a/Sources/JavascriptModel/ActionModel.swift b/Sources/JavascriptModel/ActionModel.swift deleted file mode 100644 index 4b5a20d..0000000 --- a/Sources/JavascriptModel/ActionModel.swift +++ /dev/null @@ -1,76 +0,0 @@ -// ActionModel.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -/// A model that represents a single action within a state. -public struct ActionModel: Equatable, Hashable, Codable, Sendable { - - /// The name of the action. - public var name: String - - /// The code within the action. - public var code: String - - /// Creates a new action model with name and code. - /// - Parameters: - /// - name: The name of the action. - /// - code: The code within the action. - @inlinable - public init(name: String, code: String) { - self.name = name - self.code = code - } - -} diff --git a/Sources/JavascriptModel/ArrangementModel.swift b/Sources/JavascriptModel/ArrangementModel.swift deleted file mode 100644 index 52f4fde..0000000 --- a/Sources/JavascriptModel/ArrangementModel.swift +++ /dev/null @@ -1,97 +0,0 @@ -// ArrangementModel.swift -// LLFSMGenerate -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. - -/// This struct represents an `Arrangement`. -/// -/// An arrangement is the top-level structure of a group of Logic-Labelled Finite-State Machines. The -/// arrangement defines which variables are sensors/actuators/clocks and which variables are local to the -/// arrangement. It also contains a list of machines that are executing in the arrangement. -public struct ArrangementModel: Equatable, Hashable, Codable, Sendable { - - /// The clocks used in this arrangement. Clocks exist outside the scope of the arrangement. - public var clocks: [ClockModel] - - /// The external variables used in this arrangement. External variables represent external - /// actuators/sensors and may affect the environment. - public var externalVariables: String - - /// The machines executing within the arrangement, and the relavent variable mapping to each machine. - public var machines: [MachineReference] - - /// The variables that are local to the arrangement. These variables may be shared amongst many machines - /// but cannot affect the outside world. - public var globalVariables: String - - /// Initialise the arrangement from it's stored properties. - /// - Parameters: - /// - clocks: The clocks used in this arrangement. - /// - externalVariables: The external variables used in this arrangement. - /// - machines: The machines executing within the arrangement. - /// - globalVariables: The variables accessible to all machines within the arrangement but local to the - /// arrangement. - @inlinable - public init( - clocks: [ClockModel], - externalVariables: String, - machines: [MachineReference], - globalVariables: String - ) { - self.clocks = clocks - self.externalVariables = externalVariables - self.machines = machines - self.globalVariables = globalVariables - } - -} diff --git a/Sources/JavascriptModel/BezierPath.swift b/Sources/JavascriptModel/BezierPath.swift deleted file mode 100644 index 3813a40..0000000 --- a/Sources/JavascriptModel/BezierPath.swift +++ /dev/null @@ -1,87 +0,0 @@ -// BezierPath.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -/// A cubic bezier path defined between a `source` and target` and shaped by two control points (`onctrol0` -/// and `control1`). -public struct BezierPath: Equatable, Hashable, Codable, Sendable { - - /// The start point of the bezier path. - public var source: Point2D - - /// The last point of the bezier path. - public var target: Point2D - - /// The first control point. - public var control0: Point2D - - /// The second control point. - public var control1: Point2D - - /// Create a new bezier path from the coordinates of it's respective points. - /// - Parameters: - /// - source: The start point of the bezier path. - /// - target: The last point of the bezier path. - /// - control0: The first control point. - /// - control1: The second control point. - @inlinable - public init(source: Point2D, target: Point2D, control0: Point2D, control1: Point2D) { - self.source = source - self.target = target - self.control0 = control0 - self.control1 = control1 - } - -} diff --git a/Sources/JavascriptModel/ClockModel.swift b/Sources/JavascriptModel/ClockModel.swift deleted file mode 100644 index e61affa..0000000 --- a/Sources/JavascriptModel/ClockModel.swift +++ /dev/null @@ -1,78 +0,0 @@ -// ClockModel.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -/// A model of a clock signal. This struct represents the user-entered input for a clock signal definition. -public struct ClockModel: Equatable, Hashable, Codable, Sendable { - - /// The name of the clock. - public var name: String - - /// The frequency of the clock represented as where is one of: Hz, kHz, MHz, GHz, - /// THz. - public var frequency: String - - /// Create a new clock from its stored properties. - /// - Parameters: - /// - name: The name of the clock. - /// - frequency: The frequency of the clock represented as where is one of: Hz, - /// kHz, MHz, GHz, THz. - @inlinable - public init(name: String, frequency: String) { - self.name = name - self.frequency = frequency - } - -} diff --git a/Sources/JavascriptModel/MachineModel+jsonString.swift b/Sources/JavascriptModel/MachineModel+jsonString.swift deleted file mode 100644 index d6d018c..0000000 --- a/Sources/JavascriptModel/MachineModel+jsonString.swift +++ /dev/null @@ -1,76 +0,0 @@ -// MachineModel+jsonString.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -import Foundation - -/// Add initialisation from JSON string. -extension MachineModel { - - /// Initailise this model from its JSON string representation. - /// - Parameter value: The JSON string to parse. - @inlinable - public init?(jsonString value: String) { - let decoder = JSONDecoder() - guard - let data = value.data(using: .utf8), - let model = try? decoder.decode(MachineModel.self, from: data) - else { - return nil - } - self = model - } - -} diff --git a/Sources/JavascriptModel/MachineModel.swift b/Sources/JavascriptModel/MachineModel.swift deleted file mode 100644 index 9f58cfa..0000000 --- a/Sources/JavascriptModel/MachineModel.swift +++ /dev/null @@ -1,119 +0,0 @@ -// MachineModel.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -/// An abstract model for a single LLFSM. -public struct MachineModel: Equatable, Hashable, Codable, Sendable { - - /// The states within the machine. - public var states: [StateModel] - - /// The external variables this machine has access too. - public var externalVariables: String - - /// The variables local to this machine. - public var machineVariables: String - - /// The includes required for this machine. - public var includes: String - - /// The transitions between states in this machine. - public var transitions: [TransitionModel] - - /// The name of the initial state. - public var initialState: String - - /// The name of the suspended state. This property may be `nil` indicating that the machine has no - /// suspended state. - public var suspendedState: String? - - /// The clocks used in this machine. The first clock in the array represents the clock driving the - /// machines execution. - public var clocks: [ClockModel] - - /// Initialise this machine with it's stored properties. - /// - Parameters: - /// - states: The states within the machine. - /// - externalVariables: The external variables this machine has access too. - /// - machineVariables: The variables local to this machine. - /// - includes: The includes required for this machine. - /// - transitions: The transitions between states in this machine. - /// - initialState: The name of the initial state. - /// - suspendedState: The name of the suspended state. This property may be `nil` indicating that the - /// machine has no suspended state. - /// - clocks: The clocks used in the machine. - /// - SeeAlso: ``StateModel``, ``Clock``. - @inlinable - public init( - states: [StateModel], - externalVariables: String, - machineVariables: String, - includes: String, - transitions: [TransitionModel], - initialState: String, - suspendedState: String? = nil, - clocks: [ClockModel] - ) { - self.states = states - self.externalVariables = externalVariables - self.machineVariables = machineVariables - self.includes = includes - self.transitions = transitions - self.initialState = initialState - self.suspendedState = suspendedState - self.clocks = clocks - } - -} diff --git a/Sources/JavascriptModel/MachineReference.swift b/Sources/JavascriptModel/MachineReference.swift deleted file mode 100644 index c52fb8c..0000000 --- a/Sources/JavascriptModel/MachineReference.swift +++ /dev/null @@ -1,87 +0,0 @@ -// MachineReference.swift -// LLFSMGenerate -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. - -/// This struct represents an instance of a machine within the Arrangement context. -/// -/// A `MachineReference` acts as an instance of a particular machine within an `Arrangement`. The reference -/// consists of a `name` that identifies it as a unique instance of a machine, a `path` that points to the -/// machine that it references, and a list of `mappings` that map variables from the arrangement into the -/// machine's external variable and clock definitions. -public struct MachineReference: Equatable, Hashable, Codable, Sendable { - - /// The name of the reference. - public var name: String - - /// The path to the machine that this reference points to. - public var path: String - - /// The mappings from variables within the arrangement to the external variables and clocks within the - /// machines context. - public var mappings: [VariableMapping] - - /// Create a new `MachineReference` from it's stored properties. - /// - Parameters: - /// - name: The name of the reference. - /// - path: The path to the machine that this reference points to. - /// - mappings: The variable mappings from the external context into the machine's external and clock - /// variables. - @inlinable - public init(name: String, path: String, mappings: [VariableMapping]) { - self.name = name - self.path = path - self.mappings = mappings - } - -} diff --git a/Sources/JavascriptModel/Point2D.swift b/Sources/JavascriptModel/Point2D.swift deleted file mode 100644 index 32673f6..0000000 --- a/Sources/JavascriptModel/Point2D.swift +++ /dev/null @@ -1,76 +0,0 @@ -// Point2D.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -/// A point in 2-dimensions. -public struct Point2D: Equatable, Hashable, Codable, Sendable { - - /// The x-coordinate of the point. - public var x: Double - - /// The y-coordinate of the point. - public var y: Double - - /// Initialise this point from it's coordinates in cartesian space. - /// - Parameters: - /// - x: The x-coordinate of the point. - /// - y: The y-coordinate of the point. - @inlinable - public init(x: Double, y: Double) { - self.x = x - self.y = y - } - -} diff --git a/Sources/JavascriptModel/StateLayout.swift b/Sources/JavascriptModel/StateLayout.swift deleted file mode 100644 index 9745cd2..0000000 --- a/Sources/JavascriptModel/StateLayout.swift +++ /dev/null @@ -1,78 +0,0 @@ -// StateLayout.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -/// The layout of a single state in cartesian coordinates. -public struct StateLayout: Equatable, Hashable, Codable, Sendable { - - /// The position of the top-left corner in cartesian coordinates. - public var position: Point2D - - /// The width and height in cartesian coordinates. The x-coordinate represents the width, while the - /// y-coordinate represents the height. The y-coordinate is represented in an inverted plane where the - /// positive y-direction is downwards. - public var dimensions: Point2D - - /// Creates a new state layout from the position and dimensions. - /// - Parameters: - /// - position: The position of the top-left corner of the state. - /// - dimensions: The width and height of the state. - @inlinable - public init(position: Point2D, dimensions: Point2D) { - self.position = position - self.dimensions = dimensions - } - -} diff --git a/Sources/JavascriptModel/StateModel.swift b/Sources/JavascriptModel/StateModel.swift deleted file mode 100644 index 41f7de1..0000000 --- a/Sources/JavascriptModel/StateModel.swift +++ /dev/null @@ -1,97 +0,0 @@ -// StateModel.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -/// An abstract model of a state within an LLFSM. -public struct StateModel: Equatable, Hashable, Codable, Sendable { - - /// The name of the state. - public var name: String - - /// The variables local to the state. - public var variables: String - - /// The names of the external variables accessed by this state. - public var externalVariables: String - - /// The actions within the state. - public var actions: [ActionModel] - - /// The layout of the state. - public var layout: StateLayout - - /// Creates a new state model with name, variables, actions and layout. - /// - Parameters: - /// - name: The name of the state. - /// - variables: The variables local to the state. - /// - externalVariables: The names of the external variables accessed by this state. - /// - actions: The actions within the state. - /// - layout: The layout of the state. - @inlinable - public init( - name: String, - variables: String, - externalVariables: String, - actions: [ActionModel], - layout: StateLayout - ) { - self.name = name - self.variables = variables - self.externalVariables = externalVariables - self.actions = actions - self.layout = layout - } - -} diff --git a/Sources/JavascriptModel/TransitionLayout.swift b/Sources/JavascriptModel/TransitionLayout.swift deleted file mode 100644 index fda55e0..0000000 --- a/Sources/JavascriptModel/TransitionLayout.swift +++ /dev/null @@ -1,70 +0,0 @@ -// TransitionLayout.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -/// The layout of a single transition in cartesian coordinates. -public struct TransitionLayout: Equatable, Hashable, Codable, Sendable { - - /// The bezier path representing the shape of this transition. - public var path: BezierPath - - /// Creates a new transition layout from the shape of the transition. - /// - Parameter path: The bezier path representing the shape of the transition. - @inlinable - public init(path: BezierPath) { - self.path = path - } - -} diff --git a/Sources/JavascriptModel/TransitionModel.swift b/Sources/JavascriptModel/TransitionModel.swift deleted file mode 100644 index 63e6d56..0000000 --- a/Sources/JavascriptModel/TransitionModel.swift +++ /dev/null @@ -1,90 +0,0 @@ -// TransitionModel.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -/// An abstract model for a transition between states in an LLFSM. A transition represents a pathway between -/// two states that can be enacted when the condition is met. The transition also has a layout that describes -/// the shape of the arrow representing the transition. The transitions priority is not contained within this -/// struct, instead it is infered by it's placement within the parent model. -/// - SeeAlso: ``TransitionLayout``. -public struct TransitionModel: Equatable, Hashable, Codable, Sendable { - - /// The name of the source state. - public var source: String - - /// The name of the target state. - public var target: String - - /// The condition that causes this transition to fire. - public var condition: String - - /// The layout (shape) of the transition. - public var layout: TransitionLayout - - /// Create a new transition from it's stored properties. - /// - Parameters: - /// - source: The name of the state this transition originates from. - /// - target: The name of the state this transition leads to. - /// - condition: The condition that causes this transition to fire. - /// - layout: The layout of the transition. - @inlinable - public init(source: String, target: String, condition: String, layout: TransitionLayout) { - self.source = source - self.target = target - self.condition = condition - self.layout = layout - } - -} diff --git a/Sources/JavascriptModel/VariableMapping.swift b/Sources/JavascriptModel/VariableMapping.swift deleted file mode 100644 index fb99c37..0000000 --- a/Sources/JavascriptModel/VariableMapping.swift +++ /dev/null @@ -1,78 +0,0 @@ -// VariableMapping.swift -// LLFSMGenerate -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. - -/// A mapping of a variables value in one domain into a variables in another domain. -/// -/// This struct represents data flow from a `source` to a `destination`. The `source` and `destination` -/// properties represent the respective variable names for the data flow. -public struct VariableMapping: Equatable, Hashable, Codable, Sendable { - - /// The name of the source variable. - public var source: String - - /// The name of the destination variable. - public var destination: String - - /// Initialise the variable mapping with a source and destination. - /// - Parameters: - /// - source: The name of the source variable. - /// - destination: The name of the destination variable. - @inlinable - public init(source: String, destination: String) { - self.source = source - self.destination = destination - } - -} diff --git a/Sources/VHDLMachineTransformations/ActionModel+modelInit.swift b/Sources/VHDLMachineTransformations/ActionModel+modelInit.swift deleted file mode 100644 index 282e0c5..0000000 --- a/Sources/VHDLMachineTransformations/ActionModel+modelInit.swift +++ /dev/null @@ -1,73 +0,0 @@ -// ActionModel+modelInit.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -import JavascriptModel -import VHDLMachines -import VHDLParsing - -/// Add action model conversion. -extension ActionModel { - - /// Create an `ActionModel` from it's parsed VHDL components. - /// - Parameters: - /// - name: The name of the action. - /// - code: The code within the action. - @inlinable - public init(name: VariableName, code: SynchronousBlock) { - self.init(name: name.rawValue, code: code.rawValue) - } - -} diff --git a/Sources/VHDLMachineTransformations/Arrangement+modelInit.swift b/Sources/VHDLMachineTransformations/Arrangement+modelInit.swift deleted file mode 100644 index 203dd1c..0000000 --- a/Sources/VHDLMachineTransformations/Arrangement+modelInit.swift +++ /dev/null @@ -1,181 +0,0 @@ -// Arrangement+modelInit.swift -// LLFSMGenerate -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. - -import Foundation -import JavascriptModel -import VHDLMachines -import VHDLParsing - -/// Add conversion initialiser between ``ArrangementModel`` and `Arrangement`. -extension Arrangement { - - /// Create an `Arrangement` from its javascript representation. - /// - Parameter model: The javascript model to convert. - /// - Parameter basePath: The path of the directory containing the arrangement folder. - @inlinable - public init?(model: ArrangementModel, basePath: URL? = nil) { - let keyNames = model.machines.map(\.name) - guard keyNames.count == Set(keyNames).count else { - return nil - } - let machineTuples: [(MachineInstance, MachineMapping)] = model.machines - .compactMap { (reference: MachineReference) -> (MachineInstance, MachineMapping)? in - guard - let instance = MachineInstance(reference: reference), - let mapping = MachineMapping(reference: reference, basePath: basePath) - else { - return nil - } - return (instance, mapping) - } - guard - machineTuples.count == model.machines.count, - machineTuples.count == Set(machineTuples.map { $0.0 }).count - else { - return nil - } - let machines = Dictionary(uniqueKeysWithValues: machineTuples) - let externalsRaw = model.externalVariables.components(separatedBy: ";") - .filter { !$0.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty } - let externalSignals = externalsRaw.compactMap { PortSignal(rawValue: $0 + ";") } - let signalsRaw = model.globalVariables.components(separatedBy: ";") - .filter { !$0.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty } - let localSignals = signalsRaw.compactMap { LocalSignal(rawValue: $0 + ";") } - let clocks = model.clocks.compactMap { Clock(model: $0) } - let clockNames = clocks.map(\.name) - let signalNames = localSignals.map(\.name) + externalSignals.map(\.name) - let allNames = clockNames + signalNames - guard - externalSignals.count == externalsRaw.count, - localSignals.count == signalsRaw.count, - clocks.count == model.clocks.count, - Set(allNames).count == allNames.count - else { - return nil - } - self.init( - mappings: machines, - externalSignals: externalSignals, - signals: localSignals, - clocks: clocks - ) - } - -} - -/// Add init from javascript model. -extension MachineInstance { - - /// Create a `MachineInstace` from its javascript model. - /// - Parameter reference: The ``MachineReferece`` js model to convert. - @inlinable - init?(reference: MachineReference) { - let url = URL(fileURLWithPath: reference.path, isDirectory: true) - let nameRaw = url.lastPathComponent - guard - nameRaw.hasSuffix(".machine"), - let name = VariableName(rawValue: reference.name), - let type = VariableName(rawValue: String(nameRaw.dropLast(8))) - else { - return nil - } - self.init(name: name, type: type) - } - -} - -/// Add init from js model. -extension MachineMapping { - - /// Create a `MachineMapping` from its javascript model. - /// - Parameter reference: The ``MachineReferece`` js model to convert. - /// - Parameter basePath: The path of the directory containing the arrangement folder. - @inlinable - init?(reference: MachineReference, basePath: URL? = nil) { - let url = URL(fileURLWithPath: reference.path, isDirectory: true, relativeTo: basePath) - .appendingPathComponent("model.json", isDirectory: false) - let mappings: [VHDLMachines.VariableMapping] = reference.mappings.compactMap { - VHDLMachines.VariableMapping(mapping: $0) - } - guard - mappings.count == reference.mappings.count, - let data = try? Data(contentsOf: url), - let machineModel = try? JSONDecoder().decode(MachineModel.self, from: data), - let machine = Machine(model: machineModel) - else { - return nil - } - self.init(machine: machine, with: mappings) - } - -} - -/// Add init from js model. -extension VHDLMachines.VariableMapping { - - /// Create a `VariableMapping` from its javascript model. - /// - Parameter mapping: The ``VariableMapping`` js model to convert. - @inlinable - init?(mapping: JavascriptModel.VariableMapping) { - guard - let source = VariableName(rawValue: mapping.source), - let destination = VariableName(rawValue: mapping.destination) - else { - return nil - } - self.init(source: source, destination: destination) - } - -} diff --git a/Sources/VHDLMachineTransformations/Clock+modelInit.swift b/Sources/VHDLMachineTransformations/Clock+modelInit.swift deleted file mode 100644 index 3769957..0000000 --- a/Sources/VHDLMachineTransformations/Clock+modelInit.swift +++ /dev/null @@ -1,99 +0,0 @@ -// Clock+modelInit.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -import Foundation -import JavascriptModel -import VHDLMachines -import VHDLParsing - -/// Add init from ``ClockModel``. -extension Clock { - - /// Create a clock from its javascript model. - /// - Parameter model: The javascript model representing this clock. - @inlinable - public init?(model: ClockModel) { - guard let name = VariableName(rawValue: model.name) else { - return nil - } - let frequency = model.frequency.trimmingCharacters(in: .whitespacesAndNewlines) - guard frequency.count >= 3 else { - return nil - } - let separator = frequency[frequency.index( - frequency.startIndex, offsetBy: frequency.count - 3 - )] - guard let scalar = separator.unicodeScalars.first else { - return nil - } - let unitLength: Int - if UInt(String(separator)) != nil || CharacterSet.whitespacesAndNewlines.contains(scalar) { - unitLength = 2 - } else { - unitLength = 3 - } - guard let unit = Clock.FrequencyUnit(rawValue: String(frequency.suffix(unitLength))) else { - return nil - } - let numberRaw = String(frequency.prefix(frequency.count - unitLength)) - .trimmingCharacters(in: .whitespacesAndNewlines) - guard let number = UInt(numberRaw) else { - return nil - } - self.init(name: name, frequency: number, unit: unit) - } - -} diff --git a/Sources/VHDLMachineTransformations/ClockModel+clockInit.swift b/Sources/VHDLMachineTransformations/ClockModel+clockInit.swift deleted file mode 100644 index 714fc55..0000000 --- a/Sources/VHDLMachineTransformations/ClockModel+clockInit.swift +++ /dev/null @@ -1,74 +0,0 @@ -// ClockModel+clockInit.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -import JavascriptModel -import VHDLMachines -import VHDLParsing - -/// Add init for `Clock`. -extension ClockModel { - - /// Create a `ClockModel` for a specific `Clock`. - /// - Parameter clock: The clock to create this model from. - @inlinable - public init(clock: Clock) { - self.init( - name: clock.name.rawValue, - frequency: "\(clock.frequency) \(clock.unit.rawValue)" - ) - } - -} diff --git a/Sources/VHDLMachineTransformations/Machine+jsInit.swift b/Sources/VHDLMachineTransformations/Machine+jsInit.swift deleted file mode 100644 index 54f5f56..0000000 --- a/Sources/VHDLMachineTransformations/Machine+jsInit.swift +++ /dev/null @@ -1,159 +0,0 @@ -// Machine+jsInit.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -import Foundation -import JavascriptModel -import VHDLMachines -import VHDLParsing - -/// Add conversion from a `MachineModel` to a `Machine`. -extension Machine { - - // swiftlint:disable cyclomatic_complexity - // swiftlint:disable function_body_length - - /// Create a new machine from a javscript model located at an optional given path. - /// - Parameters: - /// - model: The model representing this machine. - /// - path: The path where the machine is located. - @inlinable - public init?(model: MachineModel) { - let actionNames = Set(["OnEntry", "OnExit", "Internal"]) - .union(model.states.flatMap { $0.actions.map(\.name) }) - let variableNames = actionNames.compactMap(VariableName.init(rawValue:)) - guard variableNames.count == actionNames.count else { - return nil - } - let actionVariableNames = Set(variableNames).sorted() - let getStatements: (String) -> [String] = { - $0.components(separatedBy: ";") - .map { $0.trimmingCharacters(in: .whitespacesAndNewlines) } - .filter { !$0.isEmpty } - .map { $0 + ";" } - } - let includes = getStatements(model.includes) - let parsedIncludes = includes.compactMap { Include(rawValue: $0) } - guard parsedIncludes.count == includes.count else { - return nil - } - let machineSignalsRaw = getStatements(model.machineVariables) - let machineSignals = machineSignalsRaw.compactMap { LocalSignal(rawValue: $0) } - guard machineSignalsRaw.count == machineSignals.count else { - return nil - } - let externalsRaw = getStatements(model.externalVariables) - let externalSignals = externalsRaw.compactMap(PortSignal.init(rawValue:)) - guard externalsRaw.count == externalSignals.count else { - return nil - } - let clocks = model.clocks.compactMap(Clock.init(model:)) - guard clocks.count == model.clocks.count, !clocks.isEmpty else { - return nil - } - let states = model.states.compactMap { State(model: $0) } - guard states.count == model.states.count else { - return nil - } - let transitions = model.transitions.compactMap { Transition(model: $0, states: states) } - guard - transitions.count == model.transitions.count, - let initialName = VariableName(rawValue: model.initialState), - let initialState = states.firstIndex(where: { $0.name == initialName }) - else { - return nil - } - var suspendedIndex: Int? - if let suspendedState = model.suspendedState { - guard - let suspendedName = VariableName(rawValue: suspendedState), - let index = states.firstIndex(where: { $0.name == suspendedName }) - else { - return nil - } - suspendedIndex = index - } - let stateNames: [VariableName] = states.map(\.name) + states.flatMap { $0.signals.map(\.name) } - + actionVariableNames - let signalNames: [VariableName] = externalSignals.map(\.name) + machineSignals.map(\.name) - + clocks.map(\.name) - let allNames: [VariableName] = stateNames + signalNames - // Check for duplicate names. - guard Set(allNames).count == allNames.count else { - return nil - } - self.init( - actions: actionVariableNames, - includes: parsedIncludes, - externalSignals: externalSignals, - clocks: clocks, - drivingClock: 0, - machineSignals: machineSignals, - isParameterised: false, - parameterSignals: [], - returnableSignals: [], - states: states, - transitions: transitions, - initialState: initialState, - suspendedState: suspendedIndex, - architectureHead: nil, - architectureBody: nil - ) - } - - // swiftlint:enable function_body_length - // swiftlint:enable cyclomatic_complexity - -} diff --git a/Sources/VHDLMachineTransformations/MachineModel+machineInit.swift b/Sources/VHDLMachineTransformations/MachineModel+machineInit.swift deleted file mode 100644 index 5c2ea95..0000000 --- a/Sources/VHDLMachineTransformations/MachineModel+machineInit.swift +++ /dev/null @@ -1,92 +0,0 @@ -// MachineModel+machineInit.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -import JavascriptModel -import VHDLMachines -import VHDLParsing - -/// Add conversion for a machine. -extension MachineModel { - - /// Create a javascript model of a machine. - /// - Parameters: - /// - machine: The machine to create the model for. - /// - stateLayouts: The layout of the states within the machine. - /// - transitionLayouts: The layout of the transitions in the machine. - /// - Warning: This will return nil if the number of stateLayouts or transitionLayouts do not match the - /// machine. - @inlinable - public init?(machine: Machine, stateLayouts: [StateLayout], transitionLayouts: [TransitionLayout]) { - guard - stateLayouts.count == machine.states.count, transitionLayouts.count == machine.transitions.count - else { - return nil - } - self.init( - states: machine.states.enumerated().map { StateModel(state: $1, layout: stateLayouts[$0]) }, - externalVariables: machine.externalSignals.map(\.rawValue).joined(separator: "\n"), - machineVariables: machine.machineSignals.map(\.rawValue).joined(separator: "\n"), - includes: machine.includes.map(\.rawValue).joined(separator: "\n"), - transitions: machine.transitions.enumerated().map { - TransitionModel(transition: $1, between: machine.states, layout: transitionLayouts[$0]) - }, - initialState: machine.states[machine.initialState].name.rawValue, - suspendedState: machine.suspendedState.flatMap { machine.states[$0].name.rawValue }, - clocks: machine.clocks.map(ClockModel.init(clock:)) - ) - } - -} diff --git a/Sources/VHDLMachineTransformations/State+jsInit.swift b/Sources/VHDLMachineTransformations/State+jsInit.swift deleted file mode 100644 index e962f0e..0000000 --- a/Sources/VHDLMachineTransformations/State+jsInit.swift +++ /dev/null @@ -1,113 +0,0 @@ -// State+jsInit.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -import Foundation -import JavascriptModel -import VHDLMachines -import VHDLParsing - -/// Add init from ``StateModel``. -extension State { - - /// Initialise a state from its Javascript model. - /// - Parameter model: The javascript model that represents this state. - /// - SeeAlso: ``StateModel``. - @inlinable - public init?(model: StateModel) { - guard let name = VariableName(rawValue: model.name) else { - return nil - } - let validActions = model.actions.filter { - !$0.code.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty - } - let actionNames = validActions.map(\.name) - let actionNamesParsed = actionNames.compactMap(VariableName.init(rawValue:)) - guard actionNames.count == actionNamesParsed.count else { - return nil - } - let actionCode = validActions.map(\.code) - let actionCodeParsed = actionCode.compactMap(SynchronousBlock.init(rawValue:)) - guard - actionCode.count == actionCodeParsed.count, - actionNamesParsed.count == actionCodeParsed.count - else { - return nil - } - let actions = Dictionary(uniqueKeysWithValues: zip(actionNamesParsed, actionCodeParsed)) - let signalsRaw = model.variables.components(separatedBy: ";") - .map { $0.trimmingCharacters(in: .whitespacesAndNewlines) } - .filter { !$0.isEmpty } - .map { $0 + ";" } - let signalsParsed = signalsRaw.compactMap(LocalSignal.init(rawValue:)) - guard signalsParsed.count == signalsRaw.count else { - return nil - } - let externalsRaw = model.externalVariables.components(separatedBy: .newlines) - .map { $0.trimmingCharacters(in: .whitespacesAndNewlines) } - .filter { !$0.isEmpty } - let externalVariables = externalsRaw.compactMap(VariableName.init(rawValue:)) - guard externalsRaw.count == externalVariables.count else { - return nil - } - self.init( - name: name, - actions: actions, - signals: signalsParsed, - externalVariables: externalVariables - ) - } - -} diff --git a/Sources/VHDLMachineTransformations/StateModel+stateInit.swift b/Sources/VHDLMachineTransformations/StateModel+stateInit.swift deleted file mode 100644 index 18311d3..0000000 --- a/Sources/VHDLMachineTransformations/StateModel+stateInit.swift +++ /dev/null @@ -1,95 +0,0 @@ -// StateModel+stateInit.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -import JavascriptModel -import VHDLMachines -import VHDLParsing - -/// Add conversion from `State`. -extension StateModel { - - /// Convert a `State` into it's javascrip model. - /// - Parameters: - /// - state: The state to convert. - /// - layout: The layout of the state. - @inlinable - public init(state: State, layout: StateLayout) { - let actionNames = Set(state.actions.map(\.key)) - // swiftlint:disable force_unwrapping - let actions = state.actions.map { - ActionModel(name: $0, code: $1) - } + [ - ActionName(rawValue: "Internal")!, - ActionName(rawValue: "OnEntry")!, - ActionName(rawValue: "OnExit")! - ] - .compactMap { - guard !actionNames.contains($0) else { - return nil - } - return ActionModel(name: $0.rawValue, code: "") - } - // swiftlint:enable force_unwrapping - self.init( - name: state.name.rawValue, - variables: state.signals.map(\.rawValue).joined(separator: "\n"), - externalVariables: state.externalVariables.map(\.rawValue).joined(separator: "\n"), - actions: actions.sorted { $0.name < $1.name }, - layout: layout - ) - } - -} diff --git a/Sources/VHDLMachineTransformations/Transition+jsInit.swift b/Sources/VHDLMachineTransformations/Transition+jsInit.swift deleted file mode 100644 index 67fdd33..0000000 --- a/Sources/VHDLMachineTransformations/Transition+jsInit.swift +++ /dev/null @@ -1,86 +0,0 @@ -// Transition+jsInit.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -import JavascriptModel -import VHDLMachines -import VHDLParsing - -/// Add javascript model conversion. -extension Transition { - - /// Convert a javascript model into a transition. - /// - Parameters: - /// - model: The javascript model of this transition. - /// - states: The states that exist in the machine this transition belongs too. - @inlinable - public init?(model: TransitionModel, states: [State]) { - guard - let condition = TransitionCondition(rawValue: model.condition), - let sourceName = VariableName(rawValue: model.source), - let targetName = VariableName(rawValue: model.target), - let source = states.firstIndex(where: { $0.name == sourceName }), - let target = states.firstIndex(where: { $0.name == targetName }) - else { - return nil - } - self.init( - condition: condition, - source: source, - target: target - ) - } - -} diff --git a/Sources/VHDLMachineTransformations/TransitionModel+transitionInit.swift b/Sources/VHDLMachineTransformations/TransitionModel+transitionInit.swift deleted file mode 100644 index b45aecc..0000000 --- a/Sources/VHDLMachineTransformations/TransitionModel+transitionInit.swift +++ /dev/null @@ -1,80 +0,0 @@ -// TransitionModel+transitionInit.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -import JavascriptModel -import VHDLMachines -import VHDLParsing - -/// Add conversion from `Transition` to `TransitionModel`. -extension TransitionModel { - - /// Create a transition model from a transition and layout. - /// - Parameters: - /// - transition: The transition to represent in this model. - /// - states: All states within the parent machine. - /// - layout: The layout of this transition. - /// - Warning: Please make sure the states array is valid as this initialiser will not perform any checks. - @inlinable - public init(transition: Transition, between states: [State], layout: TransitionLayout) { - self.init( - source: states[transition.source].name.rawValue, - target: states[transition.target].name.rawValue, - condition: transition.condition.rawValue, - layout: layout - ) - } - -} diff --git a/Tests/JavascriptModelTests/ActionModelTests.swift b/Tests/JavascriptModelTests/ActionModelTests.swift deleted file mode 100644 index c90b47d..0000000 --- a/Tests/JavascriptModelTests/ActionModelTests.swift +++ /dev/null @@ -1,81 +0,0 @@ -// ActionModelTests.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -@testable import JavascriptModel -import XCTest - -/// Tests for the `ActionModel` model. -final class ActionModelTests: XCTestCase { - - /// Test the `init` sets the stored values correctly. - func testInit() { - let action = ActionModel(name: "name", code: "code") - XCTAssertEqual(action.name, "name") - XCTAssertEqual(action.code, "code") - } - - /// Test the setter mutates the stored properties correctly. - func testSetter() { - var action = ActionModel(name: "name", code: "code") - action.name = "newName" - XCTAssertEqual(action.name, "newName") - XCTAssertEqual(action.code, "code") - action.code = "newCode" - XCTAssertEqual(action.name, "newName") - XCTAssertEqual(action.code, "newCode") - } - -} diff --git a/Tests/JavascriptModelTests/ArrangementModelTests.swift b/Tests/JavascriptModelTests/ArrangementModelTests.swift deleted file mode 100644 index a3eeca5..0000000 --- a/Tests/JavascriptModelTests/ArrangementModelTests.swift +++ /dev/null @@ -1,288 +0,0 @@ -// ArrangementModelTests.swift -// LLFSMGenerate -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. - -import Foundation -@testable import JavascriptModel -import XCTest - -/// Test class for ``ArrangementModel``. -final class ArrangementModelTests: XCTestCase { - - /// The clocks in the arrangement. - let clocks = [ - ClockModel(name: "clk", frequency: "50 MHz"), - ClockModel(name: "clk2", frequency: "100 MHz") - ] - - /// The external variables in the arrangement. - let externalVariables = """ - x: in std_logic; - y: out std_logic; - """ - - /// The global variables in the arrangement. - let globalVariables = """ - signal z: std_logic; - """ - - /// The machines in the arrangement. - let machines = [ - MachineReference(name: "machine0", path: "path/to/machine0.machine", mappings: [ - VariableMapping(source: "x", destination: "machine0_x"), - VariableMapping(source: "y", destination: "machine0_y"), - VariableMapping(source: "clk", destination: "clk") - ]), - MachineReference(name: "machine1", path: "path/to/machine1.machine", mappings: [ - VariableMapping(source: "z", destination: "machine1_z"), - VariableMapping(source: "clk2", destination: "clk") - ]) - ] - - /// The arrangement under test. - lazy var arrangement = ArrangementModel( - clocks: clocks, - externalVariables: externalVariables, - machines: machines, - globalVariables: globalVariables - ) - - /// Initialise the arrangement before every test. - override func setUp() { - arrangement = ArrangementModel( - clocks: clocks, - externalVariables: externalVariables, - machines: machines, - globalVariables: globalVariables - ) - } - - /// Test that the initialiser sets the stored properties correctly. - func testInit() { - XCTAssertEqual(arrangement.clocks, clocks) - XCTAssertEqual(arrangement.externalVariables, externalVariables) - XCTAssertEqual(arrangement.machines, machines) - XCTAssertEqual(arrangement.globalVariables, globalVariables) - } - - /// Test that the setters mutate the stored properties correctly. - func testSetters() { - let newClocks = [ClockModel(name: "clk3", frequency: "20 MHz")] - arrangement.clocks = newClocks - XCTAssertEqual(arrangement.clocks, newClocks) - XCTAssertEqual(arrangement.externalVariables, externalVariables) - XCTAssertEqual(arrangement.machines, machines) - XCTAssertEqual(arrangement.globalVariables, globalVariables) - let newExternalVariables = """ - x2: in std_logic; - """ - arrangement.externalVariables = newExternalVariables - XCTAssertEqual(arrangement.clocks, newClocks) - XCTAssertEqual(arrangement.externalVariables, newExternalVariables) - XCTAssertEqual(arrangement.machines, machines) - XCTAssertEqual(arrangement.globalVariables, globalVariables) - let newMachines = [ - MachineReference(name: "machine2", path: "path/to/machine2.machine", mappings: [ - VariableMapping(source: "x2", destination: "machine2_x2") - ]) - ] - arrangement.machines = newMachines - XCTAssertEqual(arrangement.clocks, newClocks) - XCTAssertEqual(arrangement.externalVariables, newExternalVariables) - XCTAssertEqual(arrangement.machines, newMachines) - XCTAssertEqual(arrangement.globalVariables, globalVariables) - let newGlobalVariables = """ - signal z2: std_logic; - """ - arrangement.globalVariables = newGlobalVariables - XCTAssertEqual(arrangement.clocks, newClocks) - XCTAssertEqual(arrangement.externalVariables, newExternalVariables) - XCTAssertEqual(arrangement.machines, newMachines) - XCTAssertEqual(arrangement.globalVariables, newGlobalVariables) - } - - // func testPrintModel() throws { - // let arrangement = ArrangementModel( - // clocks: [ClockModel(name: "clk", frequency: "125 MHz")], - // externalVariables: """ - // sw: in std_logic; - // led1: out std_logic; - // led2: out std_logic; - // """, - // machines: [ - // MachineReference( - // name: "LEDBlinker", - // path: "LEDBlinker.machine", - // mappings: [ - // VariableMapping(source: "clk", destination: "clk"), - // VariableMapping(source: "sw", destination: "sw"), - // VariableMapping(source: "led1", destination: "led") - // ] - // ), - // MachineReference( - // name: "LEDBlinker", - // path: "LEDBlinker.machine", - // mappings: [ - // VariableMapping(source: "clk", destination: "clk"), - // VariableMapping(source: "sw", destination: "sw"), - // VariableMapping(source: "led2", destination: "led") - // ] - // ) - // ], - // globalVariables: "" - // ) - // let encoder = JSONEncoder() - // let jsonData = try encoder.encode(arrangement) - // let jsonString = String(data: jsonData, encoding: .utf8)! - // print(jsonString) - // fflush(stdout) - // print("\n\n\n\n") - // fflush(stdout) - // let machineModel = MachineModel( - // states: [ - // StateModel( - // name: "Initial", - // variables: "", - // externalVariables: "", - // actions: [ - // ActionModel(name: "Internal", code: ""), - // ActionModel(name: "OnEntry", code: ""), - // ActionModel(name: "OnExit", code: "") - // ], - // layout: StateLayout( - // position: Point2D(x: 100.0, y: 100.0), dimensions: Point2D(x: 100.0, y: 50.0) - // ) - // ), - // StateModel( - // name: "LightOn", - // variables: "", - // externalVariables: "sw\nled", - // actions: [ - // ActionModel(name: "Internal", code: "led <= '1';"), - // ActionModel(name: "OnEntry", code: "led <= '1';"), - // ActionModel(name: "OnExit", code: "") - // ], - // layout: StateLayout( - // position: Point2D(x: 100.0, y: 200.0), dimensions: Point2D(x: 100.0, y: 50.0) - // ) - // ), - // StateModel( - // name: "LightOff", - // variables: "", - // externalVariables: "sw\nled", - // actions: [ - // ActionModel(name: "Internal", code: "led <= '0';"), - // ActionModel(name: "OnEntry", code: "led <= '0';"), - // ActionModel(name: "OnExit", code: "") - // ], - // layout: StateLayout( - // position: Point2D(x: 300.0, y: 200.0), dimensions: Point2D(x: 100.0, y: 50.0) - // ) - // ) - // ], - // externalVariables: """ - // sw: in std_logic; - // led: out std_logic; - // """, - // machineVariables: "", - // includes: """ - // library IEEE; - // use IEEE.std_logic_1164.all; - // """, - // transitions: [ - // TransitionModel( - // source: "Initial", - // target: "LightOff", - // condition: "true", - // layout: TransitionLayout(path: BezierPath( - // source: Point2D(x: 180.0, y: 150.0), - // target: Point2D(x: 350.0, y: 200.0), - // control0: Point2D(x: 222.5, y: 165.0), - // control1: Point2D(x: 307.5, y: 190.0) - // )) - // ), - // TransitionModel( - // source: "LightOn", - // target: "LightOff", - // condition: "sw = '0'", - // layout: TransitionLayout(path: BezierPath( - // source: Point2D(x: 200.0, y: 215.0), - // target: Point2D(x: 300.0, y: 215.0), - // control0: Point2D(x: 235.0, y: 215.0), - // control1: Point2D(x: 270.0, y: 215.0) - // )) - // ), - // TransitionModel( - // source: "LightOff", - // target: "LightOn", - // condition: "sw = '1'", - // layout: TransitionLayout(path: BezierPath( - // source: Point2D(x: 300, y: 235.0), - // target: Point2D(x: 200.0, y: 235.0), - // control0: Point2D(x: 270.0, y: 235.0), - // control1: Point2D(x: 235.0, y: 235.0) - // )) - // ) - // ], - // initialState: "Initial", - // suspendedState: nil, - // clocks: [ClockModel(name: "clk", frequency: "125 MHz")] - // ) - // let machineData = try encoder.encode(machineModel) - // let machineString = String(data: machineData, encoding: .utf8)! - // print(machineString) - // fflush(stdout) - // } - -} diff --git a/Tests/JavascriptModelTests/BezierPathTests.swift b/Tests/JavascriptModelTests/BezierPathTests.swift deleted file mode 100644 index c5ae849..0000000 --- a/Tests/JavascriptModelTests/BezierPathTests.swift +++ /dev/null @@ -1,112 +0,0 @@ -// BezierPathTests.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -@testable import JavascriptModel -import XCTest - -/// Test class for ``BezierPath``. -final class BezierPathTests: XCTestCase { - - /// A point at (0,0). - let point0 = Point2D(x: 0, y: 0) - - /// A point at (1,1). - let point1 = Point2D(x: 1, y: 1) - - /// A point at (2,2). - let point2 = Point2D(x: 2, y: 2) - - /// A point at (3,3). - let point3 = Point2D(x: 3, y: 3) - - /// A point at (4,4). - let point4 = Point2D(x: 4, y: 4) - - /// Test init sets stored properties correctly. - func testInit() { - let path = BezierPath(source: point0, target: point3, control0: point1, control1: point2) - XCTAssertEqual(path.source, point0) - XCTAssertEqual(path.target, point3) - XCTAssertEqual(path.control0, point1) - XCTAssertEqual(path.control1, point2) - } - - /// Test setters mutate correct stored properties. - func testSetters() { - var path = BezierPath(source: point0, target: point3, control0: point1, control1: point2) - path.source = point4 - XCTAssertEqual(path.source, point4) - XCTAssertEqual(path.target, point3) - XCTAssertEqual(path.control0, point1) - XCTAssertEqual(path.control1, point2) - path.target = point0 - XCTAssertEqual(path.source, point4) - XCTAssertEqual(path.target, point0) - XCTAssertEqual(path.control0, point1) - XCTAssertEqual(path.control1, point2) - path.control0 = point3 - XCTAssertEqual(path.source, point4) - XCTAssertEqual(path.target, point0) - XCTAssertEqual(path.control0, point3) - XCTAssertEqual(path.control1, point2) - path.control1 = point1 - XCTAssertEqual(path.source, point4) - XCTAssertEqual(path.target, point0) - XCTAssertEqual(path.control0, point3) - XCTAssertEqual(path.control1, point1) - } - -} diff --git a/Tests/JavascriptModelTests/ClockModelTests.swift b/Tests/JavascriptModelTests/ClockModelTests.swift deleted file mode 100644 index 6396fd1..0000000 --- a/Tests/JavascriptModelTests/ClockModelTests.swift +++ /dev/null @@ -1,87 +0,0 @@ -// ClockModelTests.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -@testable import JavascriptModel -import XCTest - -/// Test class for ``ClockModel``. -final class ClockModelTests: XCTestCase { - - /// The name of the clock under test. - let clkName = "clk" - - /// The frequency of the clock under test. - let frequency = "100 MHz" - - /// Test the init sets the stored properties correctly. - func testInit() { - let clock = ClockModel(name: clkName, frequency: frequency) - XCTAssertEqual(clock.name, clkName) - XCTAssertEqual(clock.frequency, frequency) - } - - /// Test the setters set the stored properties correctly. - func testSetters() { - var clock = ClockModel(name: clkName, frequency: frequency) - clock.name = "newName" - XCTAssertEqual(clock.name, "newName") - XCTAssertEqual(clock.frequency, frequency) - clock.frequency = "200 MHz" - XCTAssertEqual(clock.name, "newName") - XCTAssertEqual(clock.frequency, "200 MHz") - } - -} diff --git a/Tests/JavascriptModelTests/MachineModelTests.swift b/Tests/JavascriptModelTests/MachineModelTests.swift deleted file mode 100644 index c1cb5c1..0000000 --- a/Tests/JavascriptModelTests/MachineModelTests.swift +++ /dev/null @@ -1,351 +0,0 @@ -// MachineModelTests.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -@testable import JavascriptModel -import XCTest - -/// Test class for ``MachineModel``. -final class MachineModelTests: XCTestCase { - - /// The default states in the machine under test. - let states = [ - StateModel( - name: "state1", - variables: "state1_variables", - externalVariables: "state1_externals", - actions: [ - ActionModel(name: "action1", code: "state1_code1") - ], - layout: StateLayout(position: Point2D(x: 0, y: 0), dimensions: Point2D(x: 1, y: 1)) - ), - StateModel( - name: "state2", - variables: "state2_variables", - externalVariables: "state2_externals", - actions: [ - ActionModel(name: "action1", code: "state2_code1") - ], - layout: StateLayout(position: Point2D(x: 2, y: 2), dimensions: Point2D(x: 3, y: 3)) - ) - ] - - /// The default transitions in this machine. - let transitions = [ - TransitionModel( - source: "state1", - target: "state2", - condition: "condition", - layout: TransitionLayout(path: BezierPath( - source: Point2D(x: 1, y: 1), - target: Point2D(x: 2, y: 2), - control0: Point2D(x: 1, y: 2), - control1: Point2D(x: 2, y: 1) - )) - ) - ] - - /// The clocks in the machine. - let clocks = [ - ClockModel(name: "clk", frequency: "100 MHz") - ] - - /// The model under test. - lazy var model = MachineModel( - states: states, - externalVariables: "externals", - machineVariables: "machines", - includes: "includes", - transitions: transitions, - initialState: "state1", - suspendedState: "state2", - clocks: clocks - ) - - /// The JSON representation of the default model. - let json = """ - { - \"states\": [ - { - \"name\": \"state1\", - \"variables\": \"state1_variables\", - \"externalVariables\": \"state1_externals\", - \"actions\": [ - { - \"name\": \"action1\", - \"code\": \"state1_code1\" - } - ], - \"layout\": { - \"position\": { - \"x\": 0, - \"y\": 0 - }, - \"dimensions\": { - \"x\": 1, - \"y\": 1 - } - } - }, - { - \"name\": \"state2\", - \"variables\": \"state2_variables\", - \"externalVariables\": \"state2_externals\", - \"actions\": [ - { - \"name\": \"action1\", - \"code\": \"state2_code1\" - } - ], - \"layout\": { - \"position\": { - \"x\": 2, - \"y\": 2 - }, - \"dimensions\": { - \"x\": 3, - \"y\": 3 - } - } - } - ], - \"externalVariables\": \"externals\", - \"machineVariables\": \"machines\", - \"includes\": \"includes\", - \"transitions\": [ - { - \"source\": \"state1\", - \"target\": \"state2\", - \"condition\": \"condition\", - \"layout\": { - \"path\": { - \"source\": { - \"x\": 1, - \"y\": 1 - }, - \"target\": { - \"x\": 2, - \"y\": 2 - }, - \"control0\": { - \"x\": 1, - \"y\": 2 - }, - \"control1\": { - \"x\": 2, - \"y\": 1 - } - } - } - } - ], - \"initialState\": \"state1\", - \"suspendedState\": \"state2\", - \"clocks\": [{ - \"name\": \"clk\", - \"frequency\": \"100 MHz\" - }] - } - """ - - /// Reset the model before every test. - override func setUp() { - model = MachineModel( - states: states, - externalVariables: "externals", - machineVariables: "machines", - includes: "includes", - transitions: transitions, - initialState: "state1", - suspendedState: "state2", - clocks: clocks - ) - } - - /// Test the init sets the stored properties correctly. - func testInit() { - XCTAssertEqual(model.states, states) - XCTAssertEqual(model.externalVariables, "externals") - XCTAssertEqual(model.machineVariables, "machines") - XCTAssertEqual(model.includes, "includes") - XCTAssertEqual(model.transitions, transitions) - XCTAssertEqual(model.initialState, "state1") - XCTAssertEqual(model.suspendedState, "state2") - XCTAssertEqual(model.clocks, clocks) - } - - /// Test the state setter mutates the stored properties correctly. - func testStateSetter() { - let newStates = [ - StateModel( - name: "state3", - variables: "state3_variables", - externalVariables: "state3_externals", - actions: [ - ActionModel(name: "action1", code: "state3_code1") - ], - layout: StateLayout(position: Point2D(x: 3, y: 3), dimensions: Point2D(x: 4, y: 4)) - ) - ] - model.states = newStates - XCTAssertEqual(model.states, newStates) - XCTAssertEqual(model.externalVariables, "externals") - XCTAssertEqual(model.machineVariables, "machines") - XCTAssertEqual(model.includes, "includes") - XCTAssertEqual(model.transitions, transitions) - XCTAssertEqual(model.initialState, "state1") - XCTAssertEqual(model.suspendedState, "state2") - XCTAssertEqual(model.clocks, clocks) - } - - /// Test primitive setters function correctly. - func testPrimitveSetters() { - model.externalVariables = "newExternals" - XCTAssertEqual(model.states, states) - XCTAssertEqual(model.externalVariables, "newExternals") - XCTAssertEqual(model.machineVariables, "machines") - XCTAssertEqual(model.includes, "includes") - XCTAssertEqual(model.transitions, transitions) - XCTAssertEqual(model.initialState, "state1") - XCTAssertEqual(model.suspendedState, "state2") - XCTAssertEqual(model.clocks, clocks) - model.machineVariables = "newMachines" - XCTAssertEqual(model.states, states) - XCTAssertEqual(model.externalVariables, "newExternals") - XCTAssertEqual(model.machineVariables, "newMachines") - XCTAssertEqual(model.includes, "includes") - XCTAssertEqual(model.transitions, transitions) - XCTAssertEqual(model.initialState, "state1") - XCTAssertEqual(model.suspendedState, "state2") - XCTAssertEqual(model.clocks, clocks) - model.includes = "newIncludes" - XCTAssertEqual(model.states, states) - XCTAssertEqual(model.externalVariables, "newExternals") - XCTAssertEqual(model.machineVariables, "newMachines") - XCTAssertEqual(model.includes, "newIncludes") - XCTAssertEqual(model.transitions, transitions) - XCTAssertEqual(model.initialState, "state1") - XCTAssertEqual(model.suspendedState, "state2") - XCTAssertEqual(model.clocks, clocks) - model.initialState = "state3" - XCTAssertEqual(model.states, states) - XCTAssertEqual(model.externalVariables, "newExternals") - XCTAssertEqual(model.machineVariables, "newMachines") - XCTAssertEqual(model.includes, "newIncludes") - XCTAssertEqual(model.transitions, transitions) - XCTAssertEqual(model.initialState, "state3") - XCTAssertEqual(model.suspendedState, "state2") - XCTAssertEqual(model.clocks, clocks) - model.suspendedState = "state4" - XCTAssertEqual(model.states, states) - XCTAssertEqual(model.externalVariables, "newExternals") - XCTAssertEqual(model.machineVariables, "newMachines") - XCTAssertEqual(model.includes, "newIncludes") - XCTAssertEqual(model.transitions, transitions) - XCTAssertEqual(model.initialState, "state3") - XCTAssertEqual(model.suspendedState, "state4") - XCTAssertEqual(model.clocks, clocks) - } - - /// Test transition setter functions correctly. - func testTransitionSetters() { - let newTransitions = [ - TransitionModel( - source: "state3", - target: "state1", - condition: "condition", - layout: TransitionLayout(path: BezierPath( - source: Point2D(x: 4, y: 4), - target: Point2D(x: 5, y: 5), - control0: Point2D(x: 6, y: 6), - control1: Point2D(x: 7, y: 7) - )) - ) - ] - model.transitions = newTransitions - XCTAssertEqual(model.states, states) - XCTAssertEqual(model.externalVariables, "externals") - XCTAssertEqual(model.machineVariables, "machines") - XCTAssertEqual(model.includes, "includes") - XCTAssertEqual(model.transitions, newTransitions) - XCTAssertEqual(model.initialState, "state1") - XCTAssertEqual(model.suspendedState, "state2") - XCTAssertEqual(model.clocks, clocks) - } - - /// Check that the clock setter sets the clocks correctly. - func testClocksSetter() { - let newClock = [ - ClockModel(name: "clk2", frequency: "200 MHz") - ] - model.clocks = newClock - XCTAssertEqual(model.states, states) - XCTAssertEqual(model.externalVariables, "externals") - XCTAssertEqual(model.machineVariables, "machines") - XCTAssertEqual(model.includes, "includes") - XCTAssertEqual(model.transitions, transitions) - XCTAssertEqual(model.initialState, "state1") - XCTAssertEqual(model.suspendedState, "state2") - XCTAssertEqual(model.clocks, newClock) - } - - /// Test that the machine model can be initialised from a JSON string. - func testJSONInit() { - XCTAssertEqual(model, MachineModel(jsonString: json)) - XCTAssertNil(MachineModel(jsonString: "{}")) - XCTAssertNil(MachineModel(jsonString: "")) - } - -} diff --git a/Tests/JavascriptModelTests/MachineReferenceTests.swift b/Tests/JavascriptModelTests/MachineReferenceTests.swift deleted file mode 100644 index 35f83aa..0000000 --- a/Tests/JavascriptModelTests/MachineReferenceTests.swift +++ /dev/null @@ -1,108 +0,0 @@ -// MachineReferenceTests.swift -// LLFSMGenerate -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. - -@testable import JavascriptModel -import XCTest - -/// Test class for ``MachineReference``. -final class MachineReferenceTests: XCTestCase { - - /// The variable mappings. - let mappings = [ - VariableMapping(source: "source0", destination: "destination0"), - VariableMapping(source: "source1", destination: "destination1") - ] - - /// The name of the machine. - let machineName = "machine0" - - /// The path to the machine. - let path = "path/to/machine0" - - /// The reference under test. - lazy var reference = MachineReference(name: "machine0", path: "path/to/machine0", mappings: mappings) - - override func setUp() { - reference = MachineReference(name: "machine0", path: "path/to/machine0", mappings: mappings) - } - - /// Test stored properties are set correctly. - func testInit() { - XCTAssertEqual(reference.name, machineName) - XCTAssertEqual(reference.path, path) - XCTAssertEqual(reference.mappings, mappings) - } - - /// Test the setters work correctly. - func testSetters() { - reference.name = "machine1" - XCTAssertEqual(reference.name, "machine1") - XCTAssertEqual(reference.path, path) - XCTAssertEqual(reference.mappings, mappings) - reference.path = "path/to/machine1" - XCTAssertEqual(reference.name, "machine1") - XCTAssertEqual(reference.path, "path/to/machine1") - XCTAssertEqual(reference.mappings, mappings) - let newMappings = [ - VariableMapping(source: "source2", destination: "destination2"), - VariableMapping(source: "source3", destination: "destination3") - ] - reference.mappings = newMappings - XCTAssertEqual(reference.name, "machine1") - XCTAssertEqual(reference.path, "path/to/machine1") - XCTAssertEqual(reference.mappings, newMappings) - } - -} diff --git a/Tests/JavascriptModelTests/Point2DTests.swift b/Tests/JavascriptModelTests/Point2DTests.swift deleted file mode 100644 index a813870..0000000 --- a/Tests/JavascriptModelTests/Point2DTests.swift +++ /dev/null @@ -1,81 +0,0 @@ -// Point2DTests.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -@testable import JavascriptModel -import XCTest - -/// Test class for ``Point2D``. -final class Point2DTests: XCTestCase { - - /// Test the `init` sets the stored properties correctly. - func testPoint2D() { - let point = Point2D(x: 1, y: 2) - XCTAssertEqual(point.x, 1) - XCTAssertEqual(point.y, 2) - } - - /// Test the setters work correctly. - func testSetters() { - var point = Point2D(x: 1, y: 2) - point.x = 3 - XCTAssertEqual(point.x, 3) - XCTAssertEqual(point.y, 2) - point.y = 4 - XCTAssertEqual(point.x, 3) - XCTAssertEqual(point.y, 4) - } - -} diff --git a/Tests/JavascriptModelTests/StateLayoutTests.swift b/Tests/JavascriptModelTests/StateLayoutTests.swift deleted file mode 100644 index b3e68b6..0000000 --- a/Tests/JavascriptModelTests/StateLayoutTests.swift +++ /dev/null @@ -1,90 +0,0 @@ -// StateLayoutTests.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -@testable import JavascriptModel -import XCTest - -/// Test class for ``StateLayout``. -final class StateLayoutTests: XCTestCase { - - /// A point at (0,0). - let point0 = Point2D(x: 0, y: 0) - - /// A point at (1,1). - let point1 = Point2D(x: 1, y: 1) - - /// A point at (2,2). - let point2 = Point2D(x: 2, y: 2) - - /// Test the init sets the stored properties correctly. - func testInit() { - let layout = StateLayout(position: point0, dimensions: point1) - XCTAssertEqual(layout.position, point0) - XCTAssertEqual(layout.dimensions, point1) - } - - /// Test the setters set the stored properties correctly. - func testSetters() { - var layout = StateLayout(position: point0, dimensions: point1) - layout.position = point2 - XCTAssertEqual(layout.position, point2) - XCTAssertEqual(layout.dimensions, point1) - layout.dimensions = point0 - XCTAssertEqual(layout.position, point2) - XCTAssertEqual(layout.dimensions, point0) - } - -} diff --git a/Tests/JavascriptModelTests/StateModelTests.swift b/Tests/JavascriptModelTests/StateModelTests.swift deleted file mode 100644 index b7ff2a8..0000000 --- a/Tests/JavascriptModelTests/StateModelTests.swift +++ /dev/null @@ -1,126 +0,0 @@ -// StateModelTests.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -@testable import JavascriptModel -import XCTest - -/// Tests for the `StateModel` model. -final class StateModelTests: XCTestCase { - - /// Test the `init` sets the stored properties correctly. - func testInit() { - let actions = [ActionModel(name: "OnEntry", code: "123")] - let layout = StateLayout(position: Point2D(x: 0, y: 0), dimensions: Point2D(x: 1, y: 1)) - let state = StateModel( - name: "name", - variables: "variables", - externalVariables: "externals", - actions: actions, - layout: layout - ) - XCTAssertEqual(state.name, "name") - XCTAssertEqual(state.variables, "variables") - XCTAssertEqual(state.externalVariables, "externals") - XCTAssertEqual(state.actions, actions) - XCTAssertEqual(state.layout, layout) - } - - /// Test the setters mutate the stored properties correctly. - func testSetters() { - let actions = [ActionModel(name: "OnEntry", code: "123")] - let layout = StateLayout(position: Point2D(x: 0, y: 0), dimensions: Point2D(x: 1, y: 1)) - var state = StateModel( - name: "name", - variables: "variables", - externalVariables: "externals", - actions: actions, - layout: layout - ) - state.name = "newName" - XCTAssertEqual(state.name, "newName") - XCTAssertEqual(state.variables, "variables") - XCTAssertEqual(state.externalVariables, "externals") - XCTAssertEqual(state.actions, actions) - XCTAssertEqual(state.layout, layout) - state.variables = "newVariables" - XCTAssertEqual(state.name, "newName") - XCTAssertEqual(state.variables, "newVariables") - XCTAssertEqual(state.externalVariables, "externals") - XCTAssertEqual(state.actions, actions) - XCTAssertEqual(state.layout, layout) - state.externalVariables = "newExternals" - XCTAssertEqual(state.name, "newName") - XCTAssertEqual(state.variables, "newVariables") - XCTAssertEqual(state.externalVariables, "newExternals") - XCTAssertEqual(state.actions, actions) - XCTAssertEqual(state.layout, layout) - let newActions = [ActionModel(name: "OnExit", code: "456")] - state.actions = newActions - XCTAssertEqual(state.name, "newName") - XCTAssertEqual(state.variables, "newVariables") - XCTAssertEqual(state.externalVariables, "newExternals") - XCTAssertEqual(state.actions, newActions) - XCTAssertEqual(state.layout, layout) - let newLayout = StateLayout(position: Point2D(x: 2, y: 2), dimensions: Point2D(x: 3, y: 3)) - state.layout = newLayout - XCTAssertEqual(state.name, "newName") - XCTAssertEqual(state.variables, "newVariables") - XCTAssertEqual(state.externalVariables, "newExternals") - XCTAssertEqual(state.actions, newActions) - XCTAssertEqual(state.layout, newLayout) - } - -} diff --git a/Tests/JavascriptModelTests/TransitionLayoutTests.swift b/Tests/JavascriptModelTests/TransitionLayoutTests.swift deleted file mode 100644 index 91daba4..0000000 --- a/Tests/JavascriptModelTests/TransitionLayoutTests.swift +++ /dev/null @@ -1,90 +0,0 @@ -// TransitionLayoutTests.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -@testable import JavascriptModel -import XCTest - -/// Test class for ``TransitionLayout``. -final class TransitionLayoutTests: XCTestCase { - - /// The default path of the transition under test. - let path = BezierPath( - source: Point2D(x: 0, y: 0), - target: Point2D(x: 1, y: 1), - control0: Point2D(x: 2, y: 2), - control1: Point2D(x: 3, y: 3) - ) - - /// Test `init` sets stored properties correctly. - func testInit() { - let layout = TransitionLayout(path: path) - XCTAssertEqual(layout.path, path) - } - - /// Test setters set stored properties correctly. - func testSetters() { - let newPath = BezierPath( - source: Point2D(x: 4, y: 4), - target: Point2D(x: 5, y: 5), - control0: Point2D(x: 6, y: 6), - control1: Point2D(x: 7, y: 7) - ) - var layout = TransitionLayout(path: path) - layout.path = newPath - XCTAssertEqual(layout.path, newPath) - } - -} diff --git a/Tests/JavascriptModelTests/TransitionModelTests.swift b/Tests/JavascriptModelTests/TransitionModelTests.swift deleted file mode 100644 index 5dc3af0..0000000 --- a/Tests/JavascriptModelTests/TransitionModelTests.swift +++ /dev/null @@ -1,123 +0,0 @@ -// TransitionModelTests.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -@testable import JavascriptModel -import XCTest - -/// Test class for ``TransitionModel``. -final class TransitionModelTests: XCTestCase { - - /// A default layout of the transition. - let layout0 = TransitionLayout(path: BezierPath( - source: Point2D(x: 0, y: 0), - target: Point2D(x: 1, y: 1), - control0: Point2D(x: 2, y: 2), - control1: Point2D(x: 3, y: 3) - )) - - /// An alternative layout for the transition. - let layout1 = TransitionLayout(path: BezierPath( - source: Point2D(x: 4, y: 4), - target: Point2D(x: 5, y: 5), - control0: Point2D(x: 6, y: 6), - control1: Point2D(x: 7, y: 7) - )) - - /// Test the init sets the stored properties correctly. - func testInit() { - let transition = TransitionModel( - source: "source", - target: "target", - condition: "condition", - layout: layout0 - ) - XCTAssertEqual(transition.source, "source") - XCTAssertEqual(transition.target, "target") - XCTAssertEqual(transition.condition, "condition") - XCTAssertEqual(transition.layout, layout0) - } - - /// Test the setters set the stored properties correctly. - func testSetters() { - var transition = TransitionModel( - source: "source", - target: "target", - condition: "condition", - layout: layout0 - ) - transition.source = "newSource" - XCTAssertEqual(transition.source, "newSource") - XCTAssertEqual(transition.target, "target") - XCTAssertEqual(transition.condition, "condition") - XCTAssertEqual(transition.layout, layout0) - transition.target = "newTarget" - XCTAssertEqual(transition.source, "newSource") - XCTAssertEqual(transition.target, "newTarget") - XCTAssertEqual(transition.condition, "condition") - XCTAssertEqual(transition.layout, layout0) - transition.condition = "newCondition" - XCTAssertEqual(transition.source, "newSource") - XCTAssertEqual(transition.target, "newTarget") - XCTAssertEqual(transition.condition, "newCondition") - XCTAssertEqual(transition.layout, layout0) - transition.layout = layout1 - XCTAssertEqual(transition.source, "newSource") - XCTAssertEqual(transition.target, "newTarget") - XCTAssertEqual(transition.condition, "newCondition") - XCTAssertEqual(transition.layout, layout1) - } - -} diff --git a/Tests/JavascriptModelTests/VariableMappingTests.swift b/Tests/JavascriptModelTests/VariableMappingTests.swift deleted file mode 100644 index 04e5f3b..0000000 --- a/Tests/JavascriptModelTests/VariableMappingTests.swift +++ /dev/null @@ -1,86 +0,0 @@ -// VariableMappingTests.swift -// LLFSMGenerate -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. - -@testable import JavascriptModel -import XCTest - -/// Test class for ``VariableMapping``. -final class VariableMappingTests: XCTestCase { - - /// The unit under test. - var mapping = VariableMapping(source: "source", destination: "destination") - - /// Initialise the test data before every test. - override func setUp() { - mapping = VariableMapping(source: "source", destination: "destination") - } - - /// Test that the init sets the stored properties correctly. - func testInit() { - XCTAssertEqual(mapping.source, "source") - XCTAssertEqual(mapping.destination, "destination") - } - - /// Test that the setters work correctly. - func testSetters() { - mapping.source = "new source" - XCTAssertEqual(mapping.source, "new source") - XCTAssertEqual(mapping.destination, "destination") - mapping.destination = "new destination" - XCTAssertEqual(mapping.source, "new source") - XCTAssertEqual(mapping.destination, "new destination") - } - -} diff --git a/Tests/VHDLMachineTransformationsTests/ActionModelTests.swift b/Tests/VHDLMachineTransformationsTests/ActionModelTests.swift deleted file mode 100644 index f3daf6e..0000000 --- a/Tests/VHDLMachineTransformationsTests/ActionModelTests.swift +++ /dev/null @@ -1,83 +0,0 @@ -// ActionModelTests.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -import JavascriptModel -import VHDLMachines -@testable import VHDLMachineTransformations -import VHDLParsing -import XCTest - -/// Test class for ``ActionModel`` extensions. -final class ActionModelTests: XCTestCase { - - // swiftlint:disable force_unwrapping - - /// An action name to convert. - let actionName = VariableName(rawValue: "OnEntry")! - - // swiftlint:enable force_unwrapping - - /// The actions code. - let code = SynchronousBlock.statement(statement: .null) - - /// Test the conversion is correct. - func testInit() { - let model = ActionModel(name: actionName, code: code) - XCTAssertEqual(model.name, "OnEntry") - XCTAssertEqual(model.code, "null;") - } - -} diff --git a/Tests/VHDLMachineTransformationsTests/ArrangementTests.swift b/Tests/VHDLMachineTransformationsTests/ArrangementTests.swift deleted file mode 100644 index 6bc4df5..0000000 --- a/Tests/VHDLMachineTransformationsTests/ArrangementTests.swift +++ /dev/null @@ -1,137 +0,0 @@ -// ArrangementTests.swift -// LLFSMGenerate -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. - -import Foundation -import JavascriptModel -import TestHelpers -import VHDLMachines -@testable import VHDLMachineTransformations -import VHDLParsing -import XCTest - -/// Test class for `Arrangement` extensions. -final class ArrangementTests: TransformationsFileTester { - - /// A model of the arrangement. - lazy var model = ArrangementModel.pingArrangement(path: self.pingMachineDirectory) - - /// Initialise the model before every test. - override func setUp() { - super.setUp() - model = ArrangementModel.pingArrangement(path: self.pingMachineDirectory) - } - - /// Test that the arrangement is created correctly from the model. - func testArrangementCreation() { - XCTAssertEqual(Arrangement(model: model, basePath: machinesDirectory), .pingArrangement) - } - - /// Test the arrangement is still created using relative paths. - func testArrangementCreationWithRelativePath() throws { - let subdir = self.machinesDirectory.appendingPathComponent("subdir", isDirectory: true) - let pingURL = subdir.appendingPathComponent("PingMachine.machine", isDirectory: true) - try self.manager.createDirectory(at: pingURL, withIntermediateDirectories: true) - let modelURL = pingURL.appendingPathComponent("model.json", isDirectory: false) - let data = try encoder.encode(MachineModel.pingMachine) - try data.write(to: modelURL) - model.machines[0].path = "subdir/PingMachine.machine" - XCTAssertEqual(Arrangement(model: model, basePath: machinesDirectory), .pingArrangement) - } - - /// Test that the init returns nil for invalid machine references. - func testInvalidMachineReferences() throws { - let oldRef = model.machines[0] - model.machines += [model.machines[0]] - XCTAssertNil(Arrangement(model: model, basePath: machinesDirectory)) - model.machines = [oldRef] - XCTAssertNotNil(Arrangement(model: model, basePath: machinesDirectory)) - var ref = oldRef - ref.path = String(ref.path.dropLast(8)) - model.machines = [ref] - XCTAssertNil(Arrangement(model: model, basePath: machinesDirectory)) - model.machines = [oldRef] - XCTAssertNotNil(Arrangement(model: model, basePath: machinesDirectory)) - var invalidMapping = oldRef - invalidMapping.mappings[0] = JavascriptModel.VariableMapping( - source: "invalid name!", destination: "clk" - ) - model.machines = [invalidMapping] - XCTAssertNil(Arrangement(model: model, basePath: machinesDirectory)) - model.machines = [oldRef] - XCTAssertNotNil(Arrangement(model: model, basePath: machinesDirectory)) - try self.manager.removeItem( - at: self.pingMachineDirectory.appendingPathComponent("model.json", isDirectory: false) - ) - XCTAssertNil(Arrangement(model: model, basePath: machinesDirectory)) - } - - /// Test that the init returns nil for invalid variables. - func testInitReturnsNilForInvalidVariables() { - let oldModel = model - model.externalVariables += "\nsignal invalid_data!: in std_logic;" - XCTAssertNil(Arrangement(model: model, basePath: machinesDirectory)) - model = oldModel - XCTAssertNotNil(Arrangement(model: model, basePath: machinesDirectory)) - model.globalVariables += "\nsignal invalid_data!: in std_logic;" - XCTAssertNil(Arrangement(model: model, basePath: machinesDirectory)) - model = oldModel - XCTAssertNotNil(Arrangement(model: model, basePath: machinesDirectory)) - model.clocks += [ClockModel(name: "clk2", frequency: "invalid")] - XCTAssertNil(Arrangement(model: model, basePath: machinesDirectory)) - model = oldModel - XCTAssertNotNil(Arrangement(model: model, basePath: machinesDirectory)) - } - -} diff --git a/Tests/VHDLMachineTransformationsTests/ClockModelTests.swift b/Tests/VHDLMachineTransformationsTests/ClockModelTests.swift deleted file mode 100644 index 7487ecc..0000000 --- a/Tests/VHDLMachineTransformationsTests/ClockModelTests.swift +++ /dev/null @@ -1,80 +0,0 @@ -// ClockModelTests.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -import JavascriptModel -import VHDLMachines -@testable import VHDLMachineTransformations -import VHDLParsing -import XCTest - -/// Test class for ``ClockModel`` extensions. -final class ClockModelTests: XCTestCase { - - // swiftlint:disable force_unwrapping - - /// A clock test data. - let clock = Clock(name: VariableName(rawValue: "clk")!, frequency: 100, unit: .MHz) - - // swiftlint:enable force_unwrapping - - /// Test the init creates the model correctly. - func testInit() { - let clockModel = ClockModel(clock: clock) - XCTAssertEqual(clockModel.name, "clk") - XCTAssertEqual(clockModel.frequency, "100 MHz") - } - -} diff --git a/Tests/VHDLMachineTransformationsTests/ClockTests.swift b/Tests/VHDLMachineTransformationsTests/ClockTests.swift deleted file mode 100644 index 3b33fe1..0000000 --- a/Tests/VHDLMachineTransformationsTests/ClockTests.swift +++ /dev/null @@ -1,118 +0,0 @@ -// ClockTests.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -import JavascriptModel -import VHDLMachines -@testable import VHDLMachineTransformations -import VHDLParsing -import XCTest - -/// Test class for `Clock` extensions. -final class ClockTests: XCTestCase { - - /// A model to use in the tests. - var model = ClockModel(name: "clk", frequency: "100 MHz") - - /// Initialise test variables before each test. - override func setUp() { - model = ClockModel(name: "clk", frequency: "100 MHz") - } - - /// Test the init parses the model correctly. - func testModelIsParsedCorrectly() { - // swiftlint:disable:next force_unwrapping - let clk = VariableName(rawValue: "clk")! - let expected = Clock(name: clk, frequency: 100, unit: .MHz) - XCTAssertEqual(expected, Clock(model: model)) - model.frequency = "100MHz" - XCTAssertEqual(expected, Clock(model: model)) - model.frequency = "100Hz" - let expected2 = Clock(name: clk, frequency: 100, unit: .Hz) - XCTAssertEqual(expected2, Clock(model: model)) - model.frequency = "100 Hz" - XCTAssertEqual(expected2, Clock(model: model)) - model.frequency = "1Hz" - let expected3 = Clock(name: clk, frequency: 1, unit: .Hz) - XCTAssertEqual(expected3, Clock(model: model)) - model.frequency = "1 Hz" - XCTAssertEqual(expected3, Clock(model: model)) - } - - /// Test init fails for invalid name in model. - func testInvalidName() { - model.name = "c l k" - XCTAssertNil(Clock(model: model)) - model.name = "" - XCTAssertNil(Clock(model: model)) - model.name = " " - XCTAssertNil(Clock(model: model)) - } - - /// Test init fails for invalid frequency. - func testInvalidFrequency() { - model.frequency = "" - XCTAssertNil(Clock(model: model)) - model.frequency = "10" - XCTAssertNil(Clock(model: model)) - model.frequency = "Hz" - XCTAssertNil(Clock(model: model)) - model.frequency = "THz" - XCTAssertNil(Clock(model: model)) - model.frequency = "1 1" - XCTAssertNil(Clock(model: model)) - } - -} diff --git a/Tests/VHDLMachineTransformationsTests/MachineModelTests.swift b/Tests/VHDLMachineTransformationsTests/MachineModelTests.swift deleted file mode 100644 index c0fe3ad..0000000 --- a/Tests/VHDLMachineTransformationsTests/MachineModelTests.swift +++ /dev/null @@ -1,271 +0,0 @@ -// MachineModelTests.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -import JavascriptModel -import VHDLMachines -@testable import VHDLMachineTransformations -import VHDLParsing -import XCTest - -/// Test class for ``MachineModel`` extensions. -final class MachineModelTests: XCTestCase { - - // swiftlint:disable force_unwrapping - - /// The default states in the machine under test. - let states = [ - State( - name: VariableName(rawValue: "state1")!, - actions: [ - VariableName(rawValue: "OnExit")!: .statement(statement: .assignment( - name: .variable(reference: .variable(name: VariableName(rawValue: "y")!)), - value: .reference(variable: .variable( - reference: .variable(name: VariableName(rawValue: "s1_x")!) - )) - )) - ], - signals: [LocalSignal(type: .stdLogic, name: VariableName(rawValue: "s1_x")!)], - externalVariables: [VariableName(rawValue: "y")!] - ), - State( - name: VariableName(rawValue: "state2")!, - actions: [ - VariableName(rawValue: "OnEntry")!: .statement(statement: .assignment( - name: .variable(reference: .variable(name: VariableName(rawValue: "s2_x")!)), - value: .literal(value: .bit(value: .low)) - )) - ], - signals: [LocalSignal(type: .stdLogic, name: VariableName(rawValue: "s2_x")!)], - externalVariables: [] - ) - ] - - /// The state layouts. - let stateLayouts = [ - StateLayout(position: Point2D(x: 0, y: 0), dimensions: Point2D(x: 1, y: 1)), - StateLayout(position: Point2D(x: 2, y: 2), dimensions: Point2D(x: 3, y: 3)) - ] - - /// The default transitions in this machine. - let transitions = [ - Transition(condition: .conditional(condition: .literal(value: true)), source: 0, target: 1) - ] - - /// The transition layouts. - let transitionLayouts = [ - TransitionLayout(path: BezierPath( - source: Point2D(x: 1, y: 1), - target: Point2D(x: 2, y: 2), - control0: Point2D(x: 1, y: 2), - control1: Point2D(x: 2, y: 1) - )) - ] - - /// The clocks in the machine. - let clocks = [ - Clock(name: VariableName(rawValue: "clk")!, frequency: 100, unit: .MHz) - ] - - /// The expected machine. - lazy var machine = Machine( - actions: [VariableName(rawValue: "OnEntry")!, VariableName(rawValue: "OnExit")!], - includes: [ - .library(value: VariableName(rawValue: "IEEE")!), - .include( - statement: UseStatement( - nonEmptyComponents: [.module(name: VariableName(rawValue: "std_logic_1164")!), .all] - )! - ) - ], - externalSignals: [PortSignal(type: .stdLogic, name: VariableName(rawValue: "y")!, mode: .output)], - clocks: clocks, - drivingClock: 0, - machineSignals: [LocalSignal(type: .stdLogic, name: VariableName(rawValue: "x")!)], - isParameterised: false, - parameterSignals: [], - returnableSignals: [], - states: states, - transitions: transitions, - initialState: 0, - suspendedState: 1 - ) - - /// The expected model. - lazy var expected = MachineModel( - states: [ - StateModel( - name: "state1", - variables: "signal s1_x: std_logic;", - externalVariables: "y", - actions: [ - ActionModel(name: "Internal", code: ""), - ActionModel(name: "OnEntry", code: ""), - ActionModel(name: "OnExit", code: "y <= s1_x;") - ], - layout: stateLayouts[0] - ), - StateModel( - name: "state2", - variables: "signal s2_x: std_logic;", - externalVariables: "", - actions: [ActionModel(name: "OnEntry", code: "s2_x <= '0';")], - layout: stateLayouts[1] - ) - ], - externalVariables: "y: out std_logic;", - machineVariables: "signal x: std_logic;", - includes: "library IEEE;\nuse std_logic_1164.all;", - transitions: [ - TransitionModel( - source: "state1", - target: "state2", - condition: "true", - layout: transitionLayouts[0] - ) - ], - initialState: "state1", - suspendedState: "state2", - clocks: [ClockModel(name: "clk", frequency: "100 MHz")] - ) - - // swiftlint:disable function_body_length - - /// Initialise machine before every test. - override func setUp() { - machine = Machine( - actions: [VariableName(rawValue: "OnEntry")!, VariableName(rawValue: "OnExit")!], - includes: [ - .library(value: VariableName(rawValue: "IEEE")!), - .include( - statement: UseStatement( - nonEmptyComponents: [.module(name: VariableName(rawValue: "std_logic_1164")!), .all] - )! - ) - ], - externalSignals: [PortSignal(type: .stdLogic, name: VariableName(rawValue: "y")!, mode: .output)], - clocks: clocks, - drivingClock: 0, - machineSignals: [LocalSignal(type: .stdLogic, name: VariableName(rawValue: "x")!)], - isParameterised: false, - parameterSignals: [], - returnableSignals: [], - states: states, - transitions: transitions, - initialState: 0, - suspendedState: 1 - ) - expected = MachineModel( - states: [ - StateModel( - name: "state1", - variables: "signal s1_x: std_logic;", - externalVariables: "y", - actions: [ - ActionModel(name: "Internal", code: ""), - ActionModel(name: "OnEntry", code: ""), - ActionModel(name: "OnExit", code: "y <= s1_x;") - ], - layout: stateLayouts[0] - ), - StateModel( - name: "state2", - variables: "signal s2_x: std_logic;", - externalVariables: "", - actions: [ - ActionModel(name: "Internal", code: ""), - ActionModel(name: "OnEntry", code: "s2_x <= '0';"), - ActionModel(name: "OnExit", code: "") - ], - layout: stateLayouts[1] - ) - ], - externalVariables: "y: out std_logic;", - machineVariables: "signal x: std_logic;", - includes: "library IEEE;\nuse std_logic_1164.all;", - transitions: [ - TransitionModel( - source: "state1", - target: "state2", - condition: "true", - layout: transitionLayouts[0] - ) - ], - initialState: "state1", - suspendedState: "state2", - clocks: [ClockModel(name: "clk", frequency: "100 MHz")] - ) - } - - // swiftlint:enable function_body_length - - // swiftlint:enable force_unwrapping - - /// Test conversion functions correctly. - func testConversionInit() { - let model = MachineModel( - machine: machine, stateLayouts: stateLayouts, transitionLayouts: transitionLayouts - ) - XCTAssertEqual(model, expected) - } - - /// Test conversion detects incorrect number of layouts. - func testInvalidLayouts() { - XCTAssertNil(MachineModel(machine: machine, stateLayouts: [], transitionLayouts: transitionLayouts)) - XCTAssertNil(MachineModel(machine: machine, stateLayouts: stateLayouts, transitionLayouts: [])) - XCTAssertNil(MachineModel(machine: machine, stateLayouts: [], transitionLayouts: [])) - } - -} diff --git a/Tests/VHDLMachineTransformationsTests/MachineTests.swift b/Tests/VHDLMachineTransformationsTests/MachineTests.swift deleted file mode 100644 index ab8b2b1..0000000 --- a/Tests/VHDLMachineTransformationsTests/MachineTests.swift +++ /dev/null @@ -1,358 +0,0 @@ -// MachineTests.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -import JavascriptModel -import VHDLMachines -@testable import VHDLMachineTransformations -import VHDLParsing -import XCTest - -/// Test class for `Machine` extensions. -final class MachineTests: XCTestCase { - - /// The default states in the machine under test. - let states = [ - StateModel( - name: "state1", - variables: "signal s1_x: std_logic;", - externalVariables: "y", - actions: [ - ActionModel(name: "OnExit", code: "y <= s1_x;") - ], - layout: StateLayout(position: Point2D(x: 0, y: 0), dimensions: Point2D(x: 1, y: 1)) - ), - StateModel( - name: "state2", - variables: "signal s2_x: std_logic;", - externalVariables: "", - actions: [ - ActionModel(name: "OnEntry", code: "s2_x <= '0';") - ], - layout: StateLayout(position: Point2D(x: 2, y: 2), dimensions: Point2D(x: 3, y: 3)) - ) - ] - - /// The default transitions in this machine. - let transitions = [ - TransitionModel( - source: "state1", - target: "state2", - condition: "true", - layout: TransitionLayout(path: BezierPath( - source: Point2D(x: 1, y: 1), - target: Point2D(x: 2, y: 2), - control0: Point2D(x: 1, y: 2), - control1: Point2D(x: 2, y: 1) - )) - ) - ] - - /// The clocks in the machine. - let clocks = [ - ClockModel(name: "clk", frequency: "100 MHz") - ] - - /// The model under test. - lazy var model = MachineModel( - states: states, - externalVariables: "y: out std_logic;", - machineVariables: "signal x: std_logic;", - includes: "library IEEE;\nuse std_logic_1164.all;", - transitions: transitions, - initialState: "state1", - suspendedState: "state2", - clocks: clocks - ) - - // swiftlint:disable force_unwrapping - - /// The expected machine. - var expected = Machine( - actions: [ - VariableName(rawValue: "Internal")!, - VariableName(rawValue: "OnEntry")!, - VariableName(rawValue: "OnExit")! - ], - includes: [ - .library(value: VariableName(rawValue: "IEEE")!), - .include(statement: UseStatement(rawValue: "use std_logic_1164.all;")!) - ], - externalSignals: [PortSignal(type: .stdLogic, name: VariableName(rawValue: "y")!, mode: .output)], - clocks: [Clock(name: VariableName(rawValue: "clk")!, frequency: 100, unit: .MHz)], - drivingClock: 0, - machineSignals: [LocalSignal(type: .stdLogic, name: VariableName(rawValue: "x")!)], - isParameterised: false, - parameterSignals: [], - returnableSignals: [], - states: [ - State( - name: VariableName(rawValue: "state1")!, - actions: [ - VariableName(rawValue: "OnExit")!: .statement(statement: .assignment( - name: .variable(reference: .variable(name: VariableName(rawValue: "y")!)), - value: .reference(variable: .variable( - reference: .variable(name: VariableName(rawValue: "s1_x")!) - )) - )) - ], - signals: [LocalSignal(type: .stdLogic, name: VariableName(rawValue: "s1_x")!)], - externalVariables: [VariableName(rawValue: "y")!] - ), - State( - name: VariableName(rawValue: "state2")!, - actions: [ - VariableName(rawValue: "OnEntry")!: .statement(statement: .assignment( - name: .variable(reference: .variable(name: VariableName(rawValue: "s2_x")!)), - value: .literal(value: .bit(value: .low)) - )) - ], - signals: [LocalSignal(type: .stdLogic, name: VariableName(rawValue: "s2_x")!)], - externalVariables: [] - ) - ], - transitions: [ - Transition(condition: .conditional(condition: .literal(value: true)), source: 0, target: 1) - ], - initialState: 0, - suspendedState: 1 - ) - - // swiftlint:disable function_body_length - - /// Initialise the test properties before each test. - override func setUp() { - model = MachineModel( - states: states, - externalVariables: "y: out std_logic;", - machineVariables: "signal x: std_logic;", - includes: "library IEEE;\nuse std_logic_1164.all;", - transitions: transitions, - initialState: "state1", - suspendedState: "state2", - clocks: clocks - ) - expected = Machine( - actions: [ - VariableName(rawValue: "Internal")!, - VariableName(rawValue: "OnEntry")!, - VariableName(rawValue: "OnExit")! - ], - includes: [ - .library(value: VariableName(rawValue: "IEEE")!), - .include(statement: UseStatement(rawValue: "use std_logic_1164.all;")!) - ], - externalSignals: [PortSignal(type: .stdLogic, name: VariableName(rawValue: "y")!, mode: .output)], - clocks: [Clock(name: VariableName(rawValue: "clk")!, frequency: 100, unit: .MHz)], - drivingClock: 0, - machineSignals: [LocalSignal(type: .stdLogic, name: VariableName(rawValue: "x")!)], - isParameterised: false, - parameterSignals: [], - returnableSignals: [], - states: [ - State( - name: VariableName(rawValue: "state1")!, - actions: [ - VariableName(rawValue: "OnExit")!: .statement(statement: .assignment( - name: .variable(reference: .variable(name: VariableName(rawValue: "y")!)), - value: .reference(variable: .variable( - reference: .variable(name: VariableName(rawValue: "s1_x")!) - )) - )) - ], - signals: [LocalSignal(type: .stdLogic, name: VariableName(rawValue: "s1_x")!)], - externalVariables: [VariableName(rawValue: "y")!] - ), - State( - name: VariableName(rawValue: "state2")!, - actions: [ - VariableName(rawValue: "OnEntry")!: .statement(statement: .assignment( - name: .variable(reference: .variable(name: VariableName(rawValue: "s2_x")!)), - value: .literal(value: .bit(value: .low)) - )) - ], - signals: [LocalSignal(type: .stdLogic, name: VariableName(rawValue: "s2_x")!)], - externalVariables: [] - ) - ], - transitions: [ - Transition(condition: .conditional(condition: .literal(value: true)), source: 0, target: 1) - ], - initialState: 0, - suspendedState: 1 - ) - } - - // swiftlint:enable function_body_length - - // swiftlint:enable force_unwrapping - - /// Test the model is converted correctly. - func testConversionInit() { - XCTAssertEqual(Machine(model: model), expected) - } - - /// Test for incorrect actions. - func testInvalidActions() { - model.states[0].actions = [ActionModel(name: "1 2 3", code: "null;")] - XCTAssertNil(Machine(model: model)) - model.states[0].actions = [ActionModel(name: "OnExit", code: "invalid code")] - XCTAssertNil(Machine(model: model)) - } - - /// Test for invalid includes. - func testInvalidIncludes() { - model.includes += "\ninvalid code;" - XCTAssertNil(Machine(model: model)) - model.includes = "This is invalid" - XCTAssertNil(Machine(model: model)) - model.includes = "" - expected.includes = [] - XCTAssertEqual(Machine(model: model), expected) - } - - /// Test for invalid machine variables. - func testInvalidMachineVariables() { - model.machineVariables += "\ninvalid code;" - XCTAssertNil(Machine(model: model)) - model.machineVariables = "This is invalid" - XCTAssertNil(Machine(model: model)) - model.machineVariables = "" - expected.machineSignals = [] - XCTAssertEqual(Machine(model: model), expected) - } - - /// Test invalid external variables are detected. - func testInvalidExternals() { - model.externalVariables += "\ninvalid code;" - XCTAssertNil(Machine(model: model)) - model.externalVariables = "This is invalid" - XCTAssertNil(Machine(model: model)) - model.externalVariables = "" - expected.externalSignals = [] - XCTAssertEqual(Machine(model: model), expected) - } - - /// Test invalid clocks are detected. - func testInvalidClocks() { - model.clocks += [ClockModel(name: "invalid name", frequency: "100 Hz")] - XCTAssertNil(Machine(model: model)) - model.clocks = [ClockModel(name: "clk", frequency: "Invalid freq")] - XCTAssertNil(Machine(model: model)) - model.clocks = [] - XCTAssertNil(Machine(model: model)) - } - - /// Test for invalid transitions. - func testInvalidTransitions() { - model.transitions += [ - TransitionModel( - source: "state2", - target: "state1", - condition: "invalid condition", - layout: TransitionLayout(path: BezierPath( - source: Point2D(x: 2, y: 2), - target: Point2D(x: 2, y: 1), - control0: Point2D(x: 1, y: 2), - control1: Point2D(x: 1, y: 1) - )) - ) - ] - XCTAssertNil(Machine(model: model)) - model.transitions = transitions - model.transitions[0].source = "invalidState" - XCTAssertNil(Machine(model: model)) - model.transitions = [] - expected.transitions = [] - XCTAssertEqual(Machine(model: model), expected) - } - - /// Test for invalid initial and suspended states. - func testInvalidInitialSuspended() { - var invalidInitial = model - invalidInitial.states[0].name = "NotInitialState" - XCTAssertNil(Machine(model: invalidInitial)) - invalidInitial.initialState = "" - XCTAssertNil(Machine(model: invalidInitial)) - invalidInitial.initialState = "state3" - XCTAssertNil(Machine(model: invalidInitial)) - var invalidSuspended = model - invalidSuspended.states[0].name = "NotSuspendedState" - XCTAssertNil(Machine(model: invalidSuspended)) - invalidSuspended.suspendedState = "" - XCTAssertNil(Machine(model: invalidSuspended)) - invalidSuspended.suspendedState = "state3" - XCTAssertNil(Machine(model: invalidSuspended)) - model.suspendedState = nil - XCTAssertNotNil(Machine(model: model)) - model.suspendedState = "state3" - XCTAssertNil(Machine(model: model)) - } - - /// Test for unique names. - func testUniqueNames() { - model.clocks[0].name = "OnEntry" - XCTAssertNil(Machine(model: model)) - model.clocks[0].name = "x" - XCTAssertNil(Machine(model: model)) - model.clocks[0].name = "y" - XCTAssertNil(Machine(model: model)) - model.clocks[0].name = "s1_x" - XCTAssertNil(Machine(model: model)) - model.clocks[0].name = "state1" - XCTAssertNil(Machine(model: model)) - } - -} diff --git a/Tests/VHDLMachineTransformationsTests/StateModelTests.swift b/Tests/VHDLMachineTransformationsTests/StateModelTests.swift deleted file mode 100644 index 7aa248c..0000000 --- a/Tests/VHDLMachineTransformationsTests/StateModelTests.swift +++ /dev/null @@ -1,158 +0,0 @@ -// StateModelTests.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -import JavascriptModel -import VHDLMachines -@testable import VHDLMachineTransformations -import VHDLParsing -import XCTest - -/// Test class for ``StateModel`` extensions. -final class StateModelTests: XCTestCase { - - /// A layout of the state. - let layout = StateLayout(position: Point2D(x: 10, y: 20), dimensions: Point2D(x: 200, y: 100)) - - // swiftlint:disable force_unwrapping - - /// A variable called `x`. - let x = VariableName(rawValue: "x")! - - /// A variable called `y`. - let y = VariableName(rawValue: "y")! - - /// A state to convert. - lazy var state = State( - name: VariableName(rawValue: "state1")!, - actions: [ - VariableName(rawValue: "OnEntry")!: .statement( - statement: .assignment( - name: .variable(reference: .variable(name: x)), - value: .literal(value: .bit(value: .high)) - ) - ), - VariableName(rawValue: "OnExit")!: .statement( - statement: .assignment( - name: .variable(reference: .variable(name: y)), - value: .literal(value: .bit(value: .low)) - ) - ), - VariableName(rawValue: "Internal")!: .statement( - statement: .assignment( - name: .variable(reference: .variable(name: x)), - value: .literal(value: .bit(value: .low)) - ) - ) - ], - signals: [ - LocalSignal(type: .stdLogic, name: x), - LocalSignal( - type: .stdLogic, name: y, defaultValue: .literal(value: .bit(value: .high)), comment: nil - ) - ], - externalVariables: [VariableName(rawValue: "extX")!, VariableName(rawValue: "extY")!] - ) - - override func setUp() { - state = State( - name: VariableName(rawValue: "state1")!, - actions: [ - VariableName(rawValue: "OnEntry")!: .statement( - statement: .assignment( - name: .variable(reference: .variable(name: x)), - value: .literal(value: .bit(value: .high)) - ) - ), - VariableName(rawValue: "OnExit")!: .statement( - statement: .assignment( - name: .variable(reference: .variable(name: y)), - value: .literal(value: .bit(value: .low)) - ) - ), - VariableName(rawValue: "Internal")!: .statement( - statement: .assignment( - name: .variable(reference: .variable(name: x)), - value: .literal(value: .bit(value: .low)) - ) - ) - ], - signals: [ - LocalSignal(type: .stdLogic, name: x), - LocalSignal( - type: .stdLogic, name: y, defaultValue: .literal(value: .bit(value: .high)), comment: nil - ) - ], - externalVariables: [VariableName(rawValue: "extX")!, VariableName(rawValue: "extY")!] - ) - } - - // swiftlint:enable force_unwrapping - - /// Test conversion from state. - func testInit() { - let model = StateModel(state: state, layout: layout) - XCTAssertEqual(model.name, "state1") - XCTAssertEqual(model.variables, "signal x: std_logic;\nsignal y: std_logic := '1';") - XCTAssertEqual(model.externalVariables, "extX\nextY") - XCTAssertEqual(model.actions, [ - ActionModel(name: "Internal", code: "x <= '0';"), - ActionModel(name: "OnEntry", code: "x <= '1';"), - ActionModel(name: "OnExit", code: "y <= '0';") - ]) - XCTAssertEqual(model.layout, layout) - } - -} diff --git a/Tests/VHDLMachineTransformationsTests/StateTests.swift b/Tests/VHDLMachineTransformationsTests/StateTests.swift deleted file mode 100644 index dc399db..0000000 --- a/Tests/VHDLMachineTransformationsTests/StateTests.swift +++ /dev/null @@ -1,211 +0,0 @@ -// StateTests.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -import JavascriptModel -import VHDLMachines -@testable import VHDLMachineTransformations -import VHDLParsing -import XCTest - -/// Test class for `State` extensions. -final class StateTests: XCTestCase { - - /// A model to convert. - var model = StateModel( - name: "state1", - variables: "signal x: std_logic;\nsignal y: std_logic := '1';", - externalVariables: "extX\nextY", - actions: [ - ActionModel(name: "OnEntry", code: "x <= '1';"), - ActionModel(name: "OnExit", code: "y <= '0';"), - ActionModel(name: "Internal", code: "x <= '0';") - ], - layout: StateLayout(position: Point2D(x: 0, y: 0), dimensions: Point2D(x: 300, y: 200)) - ) - - // swiftlint:disable force_unwrapping - - /// A variable called `x`. - let x = VariableName(rawValue: "x")! - - /// A variable called `y`. - let y = VariableName(rawValue: "y")! - - /// The expected state after conversion. - lazy var expected = State( - name: VariableName(rawValue: "state1")!, - actions: [ - VariableName(rawValue: "OnEntry")!: .statement( - statement: .assignment( - name: .variable(reference: .variable(name: x)), - value: .literal(value: .bit(value: .high)) - ) - ), - VariableName(rawValue: "OnExit")!: .statement( - statement: .assignment( - name: .variable(reference: .variable(name: y)), - value: .literal(value: .bit(value: .low)) - ) - ), - VariableName(rawValue: "Internal")!: .statement( - statement: .assignment( - name: .variable(reference: .variable(name: x)), - value: .literal(value: .bit(value: .low)) - ) - ) - ], - signals: [ - LocalSignal(type: .stdLogic, name: x), - LocalSignal( - type: .stdLogic, name: y, defaultValue: .literal(value: .bit(value: .high)), comment: nil - ) - ], - externalVariables: [VariableName(rawValue: "extX")!, VariableName(rawValue: "extY")!] - ) - - /// Create the expected result before every test. - override func setUp() { - model = StateModel( - name: "state1", - variables: "signal x: std_logic;\nsignal y: std_logic := '1';", - externalVariables: "extX\nextY", - actions: [ - ActionModel(name: "OnEntry", code: "x <= '1';"), - ActionModel(name: "OnExit", code: "y <= '0';"), - ActionModel(name: "Internal", code: "x <= '0';") - ], - layout: StateLayout(position: Point2D(x: 0, y: 0), dimensions: Point2D(x: 300, y: 200)) - ) - expected = State( - name: VariableName(rawValue: "state1")!, - actions: [ - VariableName(rawValue: "OnEntry")!: .statement( - statement: .assignment( - name: .variable(reference: .variable(name: x)), - value: .literal(value: .bit(value: .high)) - ) - ), - VariableName(rawValue: "OnExit")!: .statement( - statement: .assignment( - name: .variable(reference: .variable(name: y)), - value: .literal(value: .bit(value: .low)) - ) - ), - VariableName(rawValue: "Internal")!: .statement( - statement: .assignment( - name: .variable(reference: .variable(name: x)), - value: .literal(value: .bit(value: .low)) - ) - ) - ], - signals: [ - LocalSignal(type: .stdLogic, name: x), - LocalSignal( - type: .stdLogic, name: y, defaultValue: .literal(value: .bit(value: .high)), comment: nil - ) - ], - externalVariables: [VariableName(rawValue: "extX")!, VariableName(rawValue: "extY")!] - ) - } - - // swiftlint:enable force_unwrapping - - /// Test the state model is correctly converted into a state. - func testStateModelConversion() { - let state = State(model: model) - XCTAssertEqual(state, expected) - } - - /// Test for invalid name in model conversion. - func testInvalidNameInModelConversion() { - model.name = "state 1" - XCTAssertNil(State(model: model)) - } - - /// Test the initialiser returns nil for invalid actions. - func testInvalidActions() { - var model2 = model - model.actions[0].code = "This is invalid" - XCTAssertNil(State(model: model)) - model2.actions[0].name = "Invalid name" - XCTAssertNil(State(model: model2)) - } - - /// Test the initialiser returns nil for invalid variables. - func testInvalidVariables() { - model.variables += "\nThis is invalid;" - XCTAssertNil(State(model: model)) - } - - /// Test invalid external variables return nil. - func testInvalidExternalVariables() { - model.externalVariables += "\nThis is invalid" - XCTAssertNil(State(model: model)) - } - - /// Check init removes empty actions. - func testInvalidAction() { - // swiftlint:disable:next force_unwrapping - let internalName = VariableName(rawValue: "Internal")! - model.actions = model.actions.dropLast() + [ - ActionModel(name: "Internal", code: "") - ] - expected.actions[internalName] = nil - let state = State(model: model) - XCTAssertEqual(state, expected) - } - -} diff --git a/Tests/VHDLMachineTransformationsTests/TransformationsFileTester.swift b/Tests/VHDLMachineTransformationsTests/TransformationsFileTester.swift deleted file mode 100644 index 3bb17f2..0000000 --- a/Tests/VHDLMachineTransformationsTests/TransformationsFileTester.swift +++ /dev/null @@ -1,107 +0,0 @@ -// TransformationsFileTester.swift -// LLFSMGenerate -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. - -import Foundation -import JavascriptModel -import TestHelpers - -/// Helper class for testing in the `VHDLMachinesTransformations` target. -class TransformationsFileTester: FileTester { - - /// The path to the `machines` folder within the `VHDLMachinesTransformationsTests` target. - var machinesDirectory: URL { - transformationsDirectory.appendingPathComponent("machines", isDirectory: true) - } - - /// The directory to the `PingMachine`. - var pingMachineDirectory: URL { - machinesDirectory.appendingPathComponent("PingMachine.machine", isDirectory: true) - } - - /// Create the machines directory before each test. - override func setUp() { - super.setUp() - if !manager.fileExists(atPath: machinesDirectory.path) { - try? manager.createDirectory( - at: machinesDirectory, withIntermediateDirectories: true, attributes: nil - ) - _ = manager.createFile( - atPath: machinesDirectory.appendingPathComponent(".gitignore", isDirectory: false).path, - contents: "*".data(using: .utf8) - ) - } - try? manager.createDirectory(at: pingMachineDirectory, withIntermediateDirectories: true) - let model = MachineModel.pingMachine - let modelDir = pingMachineDirectory.appendingPathComponent("model.json", isDirectory: false) - guard let data = try? JSONEncoder().encode(model) else { - return - } - try? data.write(to: modelDir) - } - - /// Remove the machines directory before each test. - override func tearDown() { - super.tearDown() - try? manager.removeItem(at: machinesDirectory) - try? manager.createDirectory( - at: machinesDirectory, withIntermediateDirectories: true, attributes: nil - ) - _ = manager.createFile( - atPath: machinesDirectory.appendingPathComponent(".gitignore", isDirectory: false).path, - contents: "*".data(using: .utf8) - ) - } - -} diff --git a/Tests/VHDLMachineTransformationsTests/TransitionModelTests.swift b/Tests/VHDLMachineTransformationsTests/TransitionModelTests.swift deleted file mode 100644 index 63ad78e..0000000 --- a/Tests/VHDLMachineTransformationsTests/TransitionModelTests.swift +++ /dev/null @@ -1,98 +0,0 @@ -// TransitionModelTests.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -import JavascriptModel -import VHDLMachines -@testable import VHDLMachineTransformations -import VHDLParsing -import XCTest - -/// Test class for ``TransitionModel`` extensions. -final class TransitionModelTests: XCTestCase { - - /// A transition to convert. - let transition = Transition( - condition: .conditional(condition: .literal(value: true)), source: 0, target: 1 - ) - - /// The layout of the transition. - let layout = TransitionLayout(path: BezierPath( - source: Point2D(x: 0, y: 0), - target: Point2D(x: 1, y: 1), - control0: Point2D(x: 2, y: 2), - control1: Point2D(x: 3, y: 3) - )) - - // swiftlint:disable force_unwrapping - - /// The states within the machine. - let states = [ - State(name: VariableName(rawValue: "state1")!, actions: [:], signals: [], externalVariables: []), - State(name: VariableName(rawValue: "state2")!, actions: [:], signals: [], externalVariables: []) - ] - - // swiftlint:enable force_unwrapping - - /// Test the model is correctly created from the transition. - func testInit() { - let model = TransitionModel(transition: transition, between: states, layout: layout) - XCTAssertEqual(model.source, "state1") - XCTAssertEqual(model.target, "state2") - XCTAssertEqual(model.condition, "true") - XCTAssertEqual(model.layout, layout) - } - -} diff --git a/Tests/VHDLMachineTransformationsTests/TransitionTests.swift b/Tests/VHDLMachineTransformationsTests/TransitionTests.swift deleted file mode 100644 index 248f25b..0000000 --- a/Tests/VHDLMachineTransformationsTests/TransitionTests.swift +++ /dev/null @@ -1,113 +0,0 @@ -// TransitionTests.swift -// VHDLMachineTransformations -// -// Created by Morgan McColl. -// Copyright © 2024 Morgan McColl. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this -// software must display the following acknowledgement: -// -// This product includes software developed by Morgan McColl. -// -// 4. Neither the name of the author nor the names of contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// ----------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or -// modify it under the above terms or under the terms of the GNU -// General Public License as published by the Free Software Foundation; -// either version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see http://www.gnu.org/licenses/ -// or write to the Free Software Foundation, Inc., 51 Franklin Street, -// Fifth Floor, Boston, MA 02110-1301, USA. -// - -import JavascriptModel -import VHDLMachines -@testable import VHDLMachineTransformations -import VHDLParsing -import XCTest - -/// Test class for ``Transition`` extensions. -final class TransitionTests: XCTestCase { - - /// The model to convert. - let model = TransitionModel( - source: "state1", - target: "state2", - condition: "true", - layout: TransitionLayout(path: BezierPath( - source: Point2D(x: 0, y: 0), - target: Point2D(x: 1, y: 1), - control0: Point2D(x: 2, y: 2), - control1: Point2D(x: 3, y: 3) - )) - ) - - // swiftlint:disable force_unwrapping - - /// Some states to use for the conversion. - let states = [ - State(name: VariableName(rawValue: "state1")!, actions: [:], signals: [], externalVariables: []), - State(name: VariableName(rawValue: "state2")!, actions: [:], signals: [], externalVariables: []) - ] - - // swiftlint:enable force_unwrapping - - /// Test the conversion from a model to a transition. - func testModelConversion() { - let transition = Transition(model: model, states: states) - let expected = Transition( - condition: .conditional(condition: .literal(value: true)), - source: 0, - target: 1 - ) - XCTAssertEqual(transition, expected) - } - - /// Test invalid model. - func testInvalidModel() { - var model = model - var model2 = model - var model3 = model - model.condition = "1 + 2" - XCTAssertNil(Transition(model: model, states: states)) - model2.source = "state3" - XCTAssertNil(Transition(model: model2, states: states)) - model3.target = "state 2" - XCTAssertNil(Transition(model: model3, states: states)) - } - -} diff --git a/Tests/VHDLMachineTransformationsTests/machines/.gitignore b/Tests/VHDLMachineTransformationsTests/machines/.gitignore deleted file mode 100644 index f59ec20..0000000 --- a/Tests/VHDLMachineTransformationsTests/machines/.gitignore +++ /dev/null @@ -1 +0,0 @@ -* \ No newline at end of file From 9ed7d0c7dafaa465157760d2dc2f0572630172be Mon Sep 17 00:00:00 2001 From: Morgan McColl Date: Wed, 17 Apr 2024 16:08:43 +1000 Subject: [PATCH 05/12] Removed dependencies to old targets. --- Package.swift | 6 +++++- Sources/MachineGenerator/Generate.swift | 2 +- Sources/MachineGenerator/VHDLGenerator.swift | 2 +- Tests/MachineGeneratorTests/GeneratorTests.swift | 2 +- Tests/MachineGeneratorTests/Machine0.swift | 2 +- Tests/MachineGeneratorTests/Machine0Tests.swift | 2 +- Tests/MachineGeneratorTests/MachineTester.swift | 2 +- Tests/TestHelpers/ArrangementModel+pingArrangement.swift | 2 +- Tests/TestHelpers/MachineModel+pingMachine.swift | 2 +- 9 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Package.swift b/Package.swift index ed2d7ed..51dcb57 100644 --- a/Package.swift +++ b/Package.swift @@ -54,7 +54,11 @@ let package = Package( ), .testTarget( name: "TestHelpers", - dependencies: ["VHDLMachineTransformations", "VHDLParsing", "VHDLMachines", "JavascriptModel"] + dependencies: [ + .product(name: "VHDLJSModels", package: "VHDLJSModels"), + .product(name: "VHDLMachines", package: "VHDLMachines"), + .product(name: "VHDLParsing", package: "VHDLParsing") + ] ) ] ) diff --git a/Sources/MachineGenerator/Generate.swift b/Sources/MachineGenerator/Generate.swift index d446acd..fa257f6 100644 --- a/Sources/MachineGenerator/Generate.swift +++ b/Sources/MachineGenerator/Generate.swift @@ -56,7 +56,7 @@ import ArgumentParser import Foundation -import JavascriptModel +import VHDLJSModels import VHDLMachines import VHDLMachineTransformations diff --git a/Sources/MachineGenerator/VHDLGenerator.swift b/Sources/MachineGenerator/VHDLGenerator.swift index 173092e..3fecf5e 100644 --- a/Sources/MachineGenerator/VHDLGenerator.swift +++ b/Sources/MachineGenerator/VHDLGenerator.swift @@ -56,8 +56,8 @@ import ArgumentParser import Foundation -import JavascriptModel import SwiftUtils +import VHDLJSModels import VHDLKripkeStructureGenerator import VHDLMachines import VHDLParsing diff --git a/Tests/MachineGeneratorTests/GeneratorTests.swift b/Tests/MachineGeneratorTests/GeneratorTests.swift index 0004e61..78c2ce3 100644 --- a/Tests/MachineGeneratorTests/GeneratorTests.swift +++ b/Tests/MachineGeneratorTests/GeneratorTests.swift @@ -55,8 +55,8 @@ // import Foundation -import JavascriptModel @testable import MachineGenerator +import VHDLJSModels import VHDLMachines import XCTest diff --git a/Tests/MachineGeneratorTests/Machine0.swift b/Tests/MachineGeneratorTests/Machine0.swift index 803c7c2..2e8bc20 100644 --- a/Tests/MachineGeneratorTests/Machine0.swift +++ b/Tests/MachineGeneratorTests/Machine0.swift @@ -55,7 +55,7 @@ // import Foundation -import JavascriptModel +import VHDLJSModels import VHDLMachines import VHDLParsing diff --git a/Tests/MachineGeneratorTests/Machine0Tests.swift b/Tests/MachineGeneratorTests/Machine0Tests.swift index 9983fcd..066dac1 100644 --- a/Tests/MachineGeneratorTests/Machine0Tests.swift +++ b/Tests/MachineGeneratorTests/Machine0Tests.swift @@ -54,7 +54,7 @@ // Fifth Floor, Boston, MA 02110-1301, USA. // -import JavascriptModel +import VHDLJSModels import VHDLMachines import VHDLMachineTransformations import XCTest diff --git a/Tests/MachineGeneratorTests/MachineTester.swift b/Tests/MachineGeneratorTests/MachineTester.swift index fb99307..a127654 100644 --- a/Tests/MachineGeneratorTests/MachineTester.swift +++ b/Tests/MachineGeneratorTests/MachineTester.swift @@ -55,8 +55,8 @@ // import Foundation -import JavascriptModel import TestHelpers +import VHDLJSModels import VHDLMachines import XCTest diff --git a/Tests/TestHelpers/ArrangementModel+pingArrangement.swift b/Tests/TestHelpers/ArrangementModel+pingArrangement.swift index 24ff39a..e49682c 100644 --- a/Tests/TestHelpers/ArrangementModel+pingArrangement.swift +++ b/Tests/TestHelpers/ArrangementModel+pingArrangement.swift @@ -54,7 +54,7 @@ // Fifth Floor, Boston, MA 02110-1301, USA. import Foundation -import JavascriptModel +import VHDLJSModels /// Add creation of ping arrangement. public extension ArrangementModel { diff --git a/Tests/TestHelpers/MachineModel+pingMachine.swift b/Tests/TestHelpers/MachineModel+pingMachine.swift index 432a2bf..4123f2d 100644 --- a/Tests/TestHelpers/MachineModel+pingMachine.swift +++ b/Tests/TestHelpers/MachineModel+pingMachine.swift @@ -53,7 +53,7 @@ // or write to the Free Software Foundation, Inc., 51 Franklin Street, // Fifth Floor, Boston, MA 02110-1301, USA. -import JavascriptModel +import VHDLJSModels /// Add `pingMachine`. public extension MachineModel { From 19bb941e2ff62aa9f0ec8f4ac23984b2478acde0 Mon Sep 17 00:00:00 2001 From: Morgan McColl Date: Wed, 17 Apr 2024 16:09:51 +1000 Subject: [PATCH 06/12] removed dependency to old targets. --- Package.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/Package.swift b/Package.swift index 51dcb57..a4f33a5 100644 --- a/Package.swift +++ b/Package.swift @@ -41,8 +41,6 @@ let package = Package( name: "MachineGeneratorTests", dependencies: [ .target(name: "MachineGenerator"), - .target(name: "JavascriptModel"), - .target(name: "VHDLMachineTransformations"), .product(name: "VHDLMachines", package: "VHDLMachines"), .product(name: "VHDLParsing", package: "VHDLParsing"), .product(name: "ArgumentParser", package: "swift-argument-parser"), From 103b9344bb3ca8ef2ed3cd94034a897551fc1dd2 Mon Sep 17 00:00:00 2001 From: Morgan McColl Date: Wed, 17 Apr 2024 16:12:14 +1000 Subject: [PATCH 07/12] Revert "Removed dependencies to old targets." This reverts commit 9ed7d0c7dafaa465157760d2dc2f0572630172be. --- Package.swift | 6 +----- Sources/MachineGenerator/Generate.swift | 2 +- Sources/MachineGenerator/VHDLGenerator.swift | 2 +- Tests/MachineGeneratorTests/GeneratorTests.swift | 2 +- Tests/MachineGeneratorTests/Machine0.swift | 2 +- Tests/MachineGeneratorTests/Machine0Tests.swift | 2 +- Tests/MachineGeneratorTests/MachineTester.swift | 2 +- Tests/TestHelpers/ArrangementModel+pingArrangement.swift | 2 +- Tests/TestHelpers/MachineModel+pingMachine.swift | 2 +- 9 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Package.swift b/Package.swift index a4f33a5..3da03cb 100644 --- a/Package.swift +++ b/Package.swift @@ -52,11 +52,7 @@ let package = Package( ), .testTarget( name: "TestHelpers", - dependencies: [ - .product(name: "VHDLJSModels", package: "VHDLJSModels"), - .product(name: "VHDLMachines", package: "VHDLMachines"), - .product(name: "VHDLParsing", package: "VHDLParsing") - ] + dependencies: ["VHDLMachineTransformations", "VHDLParsing", "VHDLMachines", "JavascriptModel"] ) ] ) diff --git a/Sources/MachineGenerator/Generate.swift b/Sources/MachineGenerator/Generate.swift index fa257f6..d446acd 100644 --- a/Sources/MachineGenerator/Generate.swift +++ b/Sources/MachineGenerator/Generate.swift @@ -56,7 +56,7 @@ import ArgumentParser import Foundation -import VHDLJSModels +import JavascriptModel import VHDLMachines import VHDLMachineTransformations diff --git a/Sources/MachineGenerator/VHDLGenerator.swift b/Sources/MachineGenerator/VHDLGenerator.swift index 3fecf5e..173092e 100644 --- a/Sources/MachineGenerator/VHDLGenerator.swift +++ b/Sources/MachineGenerator/VHDLGenerator.swift @@ -56,8 +56,8 @@ import ArgumentParser import Foundation +import JavascriptModel import SwiftUtils -import VHDLJSModels import VHDLKripkeStructureGenerator import VHDLMachines import VHDLParsing diff --git a/Tests/MachineGeneratorTests/GeneratorTests.swift b/Tests/MachineGeneratorTests/GeneratorTests.swift index 78c2ce3..0004e61 100644 --- a/Tests/MachineGeneratorTests/GeneratorTests.swift +++ b/Tests/MachineGeneratorTests/GeneratorTests.swift @@ -55,8 +55,8 @@ // import Foundation +import JavascriptModel @testable import MachineGenerator -import VHDLJSModels import VHDLMachines import XCTest diff --git a/Tests/MachineGeneratorTests/Machine0.swift b/Tests/MachineGeneratorTests/Machine0.swift index 2e8bc20..803c7c2 100644 --- a/Tests/MachineGeneratorTests/Machine0.swift +++ b/Tests/MachineGeneratorTests/Machine0.swift @@ -55,7 +55,7 @@ // import Foundation -import VHDLJSModels +import JavascriptModel import VHDLMachines import VHDLParsing diff --git a/Tests/MachineGeneratorTests/Machine0Tests.swift b/Tests/MachineGeneratorTests/Machine0Tests.swift index 066dac1..9983fcd 100644 --- a/Tests/MachineGeneratorTests/Machine0Tests.swift +++ b/Tests/MachineGeneratorTests/Machine0Tests.swift @@ -54,7 +54,7 @@ // Fifth Floor, Boston, MA 02110-1301, USA. // -import VHDLJSModels +import JavascriptModel import VHDLMachines import VHDLMachineTransformations import XCTest diff --git a/Tests/MachineGeneratorTests/MachineTester.swift b/Tests/MachineGeneratorTests/MachineTester.swift index a127654..fb99307 100644 --- a/Tests/MachineGeneratorTests/MachineTester.swift +++ b/Tests/MachineGeneratorTests/MachineTester.swift @@ -55,8 +55,8 @@ // import Foundation +import JavascriptModel import TestHelpers -import VHDLJSModels import VHDLMachines import XCTest diff --git a/Tests/TestHelpers/ArrangementModel+pingArrangement.swift b/Tests/TestHelpers/ArrangementModel+pingArrangement.swift index e49682c..24ff39a 100644 --- a/Tests/TestHelpers/ArrangementModel+pingArrangement.swift +++ b/Tests/TestHelpers/ArrangementModel+pingArrangement.swift @@ -54,7 +54,7 @@ // Fifth Floor, Boston, MA 02110-1301, USA. import Foundation -import VHDLJSModels +import JavascriptModel /// Add creation of ping arrangement. public extension ArrangementModel { diff --git a/Tests/TestHelpers/MachineModel+pingMachine.swift b/Tests/TestHelpers/MachineModel+pingMachine.swift index 4123f2d..432a2bf 100644 --- a/Tests/TestHelpers/MachineModel+pingMachine.swift +++ b/Tests/TestHelpers/MachineModel+pingMachine.swift @@ -53,7 +53,7 @@ // or write to the Free Software Foundation, Inc., 51 Franklin Street, // Fifth Floor, Boston, MA 02110-1301, USA. -import VHDLJSModels +import JavascriptModel /// Add `pingMachine`. public extension MachineModel { From 000b16d83ef376e17ad2c0882cea56f81f58ba3b Mon Sep 17 00:00:00 2001 From: Morgan McColl Date: Wed, 17 Apr 2024 16:14:45 +1000 Subject: [PATCH 08/12] Fixed dependencies on test target. --- Package.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 3da03cb..a43cf9d 100644 --- a/Package.swift +++ b/Package.swift @@ -52,7 +52,11 @@ let package = Package( ), .testTarget( name: "TestHelpers", - dependencies: ["VHDLMachineTransformations", "VHDLParsing", "VHDLMachines", "JavascriptModel"] + dependencies: [ + .product(name: "VHDLMachines", package: "VHDLMachines"), + .product(name: "VHDLParsing", package: "VHDLParsing"), + .product(name: "VHDLJSModels", package: "VHDLJSModels") + ] ) ] ) From 307adca96303cf1dde1481c04e91345d5d2dd6f4 Mon Sep 17 00:00:00 2001 From: Morgan McColl Date: Wed, 17 Apr 2024 16:16:25 +1000 Subject: [PATCH 09/12] Updated Machines dependency to 4.0.1. --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index a43cf9d..b1ed5c1 100644 --- a/Package.swift +++ b/Package.swift @@ -16,7 +16,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.3.0"), - .package(url: "https://github.com/mipalgu/VHDLMachines", from: "4.0.0"), + .package(url: "https://github.com/mipalgu/VHDLMachines", from: "4.0.1"), .package(url: "https://github.com/mipalgu/VHDLParsing", from: "2.4.0"), .package(url: "https://github.com/apple/swift-argument-parser", from: "1.3.0"), .package(url: "https://github.com/mipalgu/VHDLKripkeStructureGenerator.git", from: "0.2.2"), From 17b9b22c92bf1d38671493304a7d906d5d13045e Mon Sep 17 00:00:00 2001 From: Morgan McColl Date: Wed, 17 Apr 2024 16:16:39 +1000 Subject: [PATCH 10/12] Changed test data to not use duplicate instance names. --- Tests/TestHelpers/Arrangement+pingArrangement.swift | 2 +- Tests/TestHelpers/ArrangementModel+pingArrangement.swift | 2 +- Tests/TestHelpers/VariableName+testNames.swift | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Tests/TestHelpers/Arrangement+pingArrangement.swift b/Tests/TestHelpers/Arrangement+pingArrangement.swift index 089095a..6818d3d 100644 --- a/Tests/TestHelpers/Arrangement+pingArrangement.swift +++ b/Tests/TestHelpers/Arrangement+pingArrangement.swift @@ -64,7 +64,7 @@ public extension Arrangement { /// An arrangement containing the `PingMachine`. static let pingArrangement = Arrangement( mappings: [ - MachineInstance(name: .pingMachine, type: .pingMachine): MachineMapping( + MachineInstance(name: .pingMachineInst, type: .pingMachine): MachineMapping( machine: .pingMachine, with: [ VHDLMachines.VariableMapping(source: .clk, destination: .clk), diff --git a/Tests/TestHelpers/ArrangementModel+pingArrangement.swift b/Tests/TestHelpers/ArrangementModel+pingArrangement.swift index 24ff39a..9ee7a4b 100644 --- a/Tests/TestHelpers/ArrangementModel+pingArrangement.swift +++ b/Tests/TestHelpers/ArrangementModel+pingArrangement.swift @@ -68,7 +68,7 @@ public extension ArrangementModel { externalVariables: "externalPing: out std_logic; externalPong: out std_logic;", machines: [ MachineReference( - name: "PingMachine", + name: "PingMachine_inst", path: path.path, mappings: [ JavascriptModel.VariableMapping(source: "clk", destination: "clk"), diff --git a/Tests/TestHelpers/VariableName+testNames.swift b/Tests/TestHelpers/VariableName+testNames.swift index 336801b..5df9c84 100644 --- a/Tests/TestHelpers/VariableName+testNames.swift +++ b/Tests/TestHelpers/VariableName+testNames.swift @@ -87,6 +87,8 @@ public extension VariableName { static let pingMachine = VariableName(rawValue: "PingMachine")! + static let pingMachineInst = VariableName(rawValue: "PingMachine_inst")! + static let pong = VariableName(rawValue: "pong")! static let sendPing = VariableName(rawValue: "SendPing")! From a9a761114bef1c8326e9e0088e43a19eb6396348 Mon Sep 17 00:00:00 2001 From: Morgan McColl Date: Wed, 17 Apr 2024 16:17:55 +1000 Subject: [PATCH 11/12] Lowered coverage requirement. --- .github/workflows/cov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cov.yml b/.github/workflows/cov.yml index 79d9dc6..01aff73 100644 --- a/.github/workflows/cov.yml +++ b/.github/workflows/cov.yml @@ -41,7 +41,7 @@ jobs: uses: mattpolzin/swift-codecov-action@0.7.3 id: cov with: - MINIMUM_COVERAGE: 98 + MINIMUM_COVERAGE: 95 - name: Post Positive Result if: ${{ success() }} From a85809ecd2e363d2c1fb2e5a92a0ad989627868c Mon Sep 17 00:00:00 2001 From: Morgan McColl Date: Wed, 17 Apr 2024 16:22:26 +1000 Subject: [PATCH 12/12] Changed version number to 2.0.0. --- Sources/MachineGenerator/LLFSMGenerate.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/MachineGenerator/LLFSMGenerate.swift b/Sources/MachineGenerator/LLFSMGenerate.swift index 34934f2..cfc9b45 100644 --- a/Sources/MachineGenerator/LLFSMGenerate.swift +++ b/Sources/MachineGenerator/LLFSMGenerate.swift @@ -64,7 +64,7 @@ struct LLFSMGenerate: ParsableCommand { static var configuration = CommandConfiguration( commandName: "llfsmgenerate", abstract: "A utility for performing operations on LLFSM formats.", - version: "1.4.0", + version: "2.0.0", subcommands: [Generate.self, VHDLGenerator.self, CleanCommand.self, InstallCommand.self] )