diff --git a/.swift-version b/.swift-version new file mode 100644 index 0000000..39ee137 --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +6.3.1 \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..8b9142b --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,44 @@ +{ + "configurations": [ + { + "type": "swift", + "request": "launch", + "args": [], + "cwd": "${workspaceFolder:swiftlyfox}", + "name": "Debug swiftyfox", + "target": "swiftyfox", + "configuration": "debug", + "preLaunchTask": "swift: Build Debug swiftyfox" + }, + { + "type": "swift", + "request": "launch", + "args": [], + "cwd": "${workspaceFolder:swiftlyfox}", + "name": "Release swiftyfox", + "target": "swiftyfox", + "configuration": "release", + "preLaunchTask": "swift: Build Release swiftyfox" + }, + { + "type": "swift", + "request": "launch", + "args": [], + "cwd": "${workspaceFolder:swiftlyfox}", + "name": "Debug swiftlyfox", + "target": "swiftlyfox", + "configuration": "debug", + "preLaunchTask": "swift: Build Debug swiftlyfox" + }, + { + "type": "swift", + "request": "launch", + "args": [], + "cwd": "${workspaceFolder:swiftlyfox}", + "name": "Release swiftlyfox", + "target": "swiftlyfox", + "configuration": "release", + "preLaunchTask": "swift: Build Release swiftlyfox" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..880bda0 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,20 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "swift: Build swiftlyfox", + "type": "shell", + "command": "swift", + "args": [ + "build", + "--swift-sdk", + "swift-6.3.1-RELEASE_wasm", + "--product", + "swiftlyfox" + ], + "group": "build", + "problemMatcher": [], + "detail": "Custom build for WASM target" + } + ] +} \ No newline at end of file diff --git a/Package.resolved b/Package.resolved deleted file mode 100644 index 987a005..0000000 --- a/Package.resolved +++ /dev/null @@ -1,15 +0,0 @@ -{ - "originHash" : "f3097f72511ac559eeb33298fe5d1aac2e73e26e2133181df5c213b8394d0ab0", - "pins" : [ - { - "identity" : "swift-argument-parser", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-argument-parser", - "state" : { - "revision" : "cdd0ef3755280949551dc26dee5de9ddeda89f54", - "version" : "1.6.2" - } - } - ], - "version" : 3 -} diff --git a/Package.swift b/Package.swift index 8d53745..9a22bcd 100644 --- a/Package.swift +++ b/Package.swift @@ -1,23 +1,23 @@ -// swift-tools-version: 6.2 +// swift-tools-version: 6.3 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( - name: "swiftyfox", - dependencies: [ - // other dependencies - .package(url: "https://github.com/apple/swift-argument-parser", from: "1.3.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. - .executableTarget( - name: "swiftyfox", - dependencies: [ - // other dependencies - .product(name: "ArgumentParser", package: "swift-argument-parser"), - ]), - - ] + name: "swiftlyfox", + dependencies: [ + // other dependencies + ], + 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. + .executableTarget( + name: "swiftlyfox", + ), + .testTarget( + name: "swiftlyfoxTests", + dependencies: ["swiftlyfox"] + ), + ], + swiftLanguageModes: [.v6] ) diff --git a/Sources/swiftlyfox/swiftlyfox.swift b/Sources/swiftlyfox/swiftlyfox.swift new file mode 100644 index 0000000..0c8b282 --- /dev/null +++ b/Sources/swiftlyfox/swiftlyfox.swift @@ -0,0 +1,6 @@ +@main +struct swiftlyfox { + static func main() { + print("Hello, world!") + } +} diff --git a/Sources/swiftyfox/swiftyfox.swift b/Sources/swiftyfox/swiftyfox.swift deleted file mode 100644 index a851b6d..0000000 --- a/Sources/swiftyfox/swiftyfox.swift +++ /dev/null @@ -1,10 +0,0 @@ -import ArgumentParser - -@main -struct swiftyfox: ParsableCommand { - @Flag var verbose = false - - static func main() { - print("Hello, world!") - } -} diff --git a/SwiftyFox.playground/Contents.swift b/SwiftyFox.playground/Contents.swift index 0017f4a..a3fcf4b 100644 --- a/SwiftyFox.playground/Contents.swift +++ b/SwiftyFox.playground/Contents.swift @@ -27,13 +27,68 @@ func calcStats(scores: [Int]) -> (min: Int, max: Int, sum: Int) { let stats = calcStats(scores: [5, 3, 100, 3, 9]) let sum = stats.sum // 120 -class Shape { +class NamedShape { var numberOfSides = 0 + var name: String + + init(name: String = "Heptagon") { + self.name = name + } + func simpleDescription() -> String { return "A shape with \(numberOfSides) sides." } } -var shape = Shape() +class Square: NamedShape { + var sideLength: Double + + init(sideLength: Double, name: String = "Square") { + self.sideLength = sideLength + super.init(name: name) + } + + func area() -> Double { + return sideLength * sideLength + } + + override func simpleDescription() -> String { + return "A Square with \(numberOfSides) sides." + } +} + +class EquilateralTriangle: NamedShape { + var sideLength: Double + + var perimeter: Double { + get { + return 3.0 * sideLength + } + + set { + sideLength = newValue / 3.0 + } + } + + init(sideLength: Double, name: String = "Square") { + self.sideLength = sideLength + super.init(name: name) + numberOfSides = 3 + } + + func area() -> Double { + return sideLength * sideLength + } + + override func simpleDescription() -> String { + return "A Equilateral Triangle with \(numberOfSides) sides." + } +} + +var shape = NamedShape() shape.numberOfSides = 7 -var shapeDesc = shape.simpleDescription() +shape.simpleDescription() + +var square = Square(sideLength: 5.2) +square.area() +square.simpleDescription() diff --git a/Tests/swiftlyfoxTests/swiftlyfoxTests.swift b/Tests/swiftlyfoxTests/swiftlyfoxTests.swift new file mode 100644 index 0000000..81434fd --- /dev/null +++ b/Tests/swiftlyfoxTests/swiftlyfoxTests.swift @@ -0,0 +1,8 @@ +import Testing +@testable import swiftlyfox + +@Test func example() async throws { + // Write your test here and use APIs like `#expect(...)` to check expected conditions. + // Swift Testing Documentation + // https://developer.apple.com/documentation/testing +}