-
-
Notifications
You must be signed in to change notification settings - Fork 159
[Swift 6]: Port log-lines #828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
meatball133
wants to merge
2
commits into
exercism:main
Choose a base branch
from
meatball133:update-log-lines
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
// swift-tools-version:5.3 | ||
// swift-tools-version:6.0 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "LogLines", | ||
products: [ | ||
// Products define the executables and libraries a package produces, and make them visible to other packages. | ||
.library( | ||
name: "LogLines", | ||
targets: ["LogLines"]), | ||
], | ||
dependencies: [ | ||
// Dependencies declare other packages that this package depends on. | ||
// .package(url: /* package url */, from: "1.0.0"), | ||
], | ||
targets: [ | ||
// Targets are the basic building blocks of a package. A target can define a module or a test suite. | ||
// Targets can depend on other targets in this package, and on products in packages this package depends on. | ||
.target( | ||
name: "LogLines", | ||
dependencies: []), | ||
.testTarget( | ||
name: "LogLinesTests", | ||
dependencies: ["LogLines"]), | ||
] | ||
name: "LogLines", | ||
products: [ | ||
// Products define the executables and libraries a package produces, and make them visible to other packages. | ||
.library( | ||
name: "LogLines", | ||
targets: ["LogLines"]) | ||
], | ||
dependencies: [ | ||
// Dependencies declare other packages that this package depends on. | ||
// .package(url: /* package url */, from: "1.0.0"), | ||
], | ||
targets: [ | ||
// Targets are the basic building blocks of a package. A target can define a module or a test suite. | ||
// Targets can depend on other targets in this package, and on products in packages this package depends on. | ||
.target( | ||
name: "LogLines", | ||
dependencies: []), | ||
.testTarget( | ||
name: "LogLinesTests", | ||
dependencies: ["LogLines"]), | ||
] | ||
) |
98 changes: 50 additions & 48 deletions
98
exercises/concept/log-lines/Tests/LogLinesTests/LogLinesTests.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,100 @@ | ||
import XCTest | ||
import Foundation | ||
import Testing | ||
|
||
@testable import LogLines | ||
|
||
final class LogLinesTests: XCTestCase { | ||
let runAll = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false | ||
let RUNALL = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false | ||
|
||
@Suite struct LogLinesTests { | ||
@Test("init trace") | ||
func testInitTrace() { | ||
let line = "[TRC]: Line 84 - Console.WriteLine('Hello World');" | ||
XCTAssertEqual(LogLevel(line), LogLevel.trace) | ||
#expect(LogLevel(line) == LogLevel.trace) | ||
} | ||
|
||
func testInitDebug() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
@Test("init debug", .enabled(if: RUNALL)) | ||
func testInitDebug() { | ||
let line = "[DBG]: ; expected" | ||
XCTAssertEqual(LogLevel(line), LogLevel.debug) | ||
#expect(LogLevel(line) == LogLevel.debug) | ||
} | ||
|
||
func testInitInfo() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
@Test("init info", .enabled(if: RUNALL)) | ||
func testInitInfo() { | ||
let line = "[INF]: Timezone changed" | ||
XCTAssertEqual(LogLevel(line), LogLevel.info) | ||
#expect(LogLevel(line) == LogLevel.info) | ||
} | ||
|
||
func testInitWarning() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
@Test("init warning", .enabled(if: RUNALL)) | ||
func testInitWarning() { | ||
let line = "[WRN]: Timezone not set" | ||
XCTAssertEqual(LogLevel(line), LogLevel.warning) | ||
#expect(LogLevel(line) == LogLevel.warning) | ||
} | ||
|
||
func testInitError() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
@Test("init error", .enabled(if: RUNALL)) | ||
func testInitError() { | ||
let line = "[ERR]: Disk full" | ||
XCTAssertEqual(LogLevel(line), LogLevel.error) | ||
#expect(LogLevel(line) == LogLevel.error) | ||
} | ||
|
||
func testInitFatal() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
@Test("init fatal", .enabled(if: RUNALL)) | ||
func testInitFatal() { | ||
let line = "[FTL]: Not enough memory" | ||
XCTAssertEqual(LogLevel(line), LogLevel.fatal) | ||
#expect(LogLevel(line) == LogLevel.fatal) | ||
} | ||
|
||
func testInitUnknownEmpty() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
@Test("init unknown empty", .enabled(if: RUNALL)) | ||
func testInitUnknownEmpty() { | ||
let line = "Something terrible has happened!" | ||
XCTAssertEqual(LogLevel(line), LogLevel.unknown) | ||
#expect(LogLevel(line) == LogLevel.unknown) | ||
} | ||
|
||
func testInitUnknownNonStandard() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
@Test("init unknown non-standard", .enabled(if: RUNALL)) | ||
func testInitUnknownNonStandard() { | ||
let line = "[XYZ]: Gibberish message.. beep boop.." | ||
XCTAssertEqual(LogLevel(line), LogLevel.unknown) | ||
#expect(LogLevel(line) == LogLevel.unknown) | ||
} | ||
|
||
func testShortTrace() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
@Test("short trace", .enabled(if: RUNALL)) | ||
func testShortTrace() { | ||
let message = "Line 13 - int myNum = 42;" | ||
XCTAssertEqual(LogLevel.trace.shortFormat(message: message), "0:Line 13 - int myNum = 42;") | ||
#expect(LogLevel.trace.shortFormat(message: message) == "0:Line 13 - int myNum = 42;") | ||
} | ||
|
||
func testShortDebug() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
@Test("short debug", .enabled(if: RUNALL)) | ||
func testShortDebug() { | ||
let message = "The name 'LogLevel' does not exist in the current context" | ||
XCTAssertEqual( | ||
LogLevel.debug.shortFormat(message: message), | ||
"1:The name 'LogLevel' does not exist in the current context") | ||
#expect( | ||
LogLevel.debug.shortFormat(message: message) | ||
== "1:The name 'LogLevel' does not exist in the current context") | ||
} | ||
|
||
func testShortInfo() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
@Test("short info", .enabled(if: RUNALL)) | ||
func testShortInfo() { | ||
let message = "File moved" | ||
XCTAssertEqual(LogLevel.info.shortFormat(message: message), "4:File moved") | ||
#expect(LogLevel.info.shortFormat(message: message) == "4:File moved") | ||
} | ||
|
||
func testShortWarning() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
@Test("short warning", .enabled(if: RUNALL)) | ||
func testShortWarning() { | ||
let message = "Unsafe password" | ||
XCTAssertEqual(LogLevel.warning.shortFormat(message: message), "5:Unsafe password") | ||
#expect(LogLevel.warning.shortFormat(message: message) == "5:Unsafe password") | ||
} | ||
|
||
func testShortError() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
@Test("short error", .enabled(if: RUNALL)) | ||
func testShortError() { | ||
let message = "Stack overflow" | ||
XCTAssertEqual(LogLevel.error.shortFormat(message: message), "6:Stack overflow") | ||
#expect(LogLevel.error.shortFormat(message: message) == "6:Stack overflow") | ||
} | ||
|
||
func testShortFatal() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
@Test("short fatal", .enabled(if: RUNALL)) | ||
func testShortFatal() { | ||
let message = "Dumping all files" | ||
XCTAssertEqual(LogLevel.fatal.shortFormat(message: message), "7:Dumping all files") | ||
#expect(LogLevel.fatal.shortFormat(message: message) == "7:Dumping all files") | ||
} | ||
|
||
func testShortUnknownEmpty() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
@Test("short unknown empty", .enabled(if: RUNALL)) | ||
func testShortUnknownEmpty() { | ||
let message = "Wha happon?" | ||
XCTAssertEqual(LogLevel.unknown.shortFormat(message: message), "42:Wha happon?") | ||
#expect(LogLevel.unknown.shortFormat(message: message) == "42:Wha happon?") | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not consistent with other PRs