Skip to content
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

Add swift-testing integration #175

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions Tests/MarkdownTests/Parsing/BlockDirectiveParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,8 @@ class BlockDirectiveArgumentParserTests: XCTestCase {
"""
)
}


#if !(compiler(>=6.0) && canImport(Testing))
// FIXME: swift-testing macro for specifying the relationship between a bug and a test
// Uncomment the following code when we integrate swift-testing
// @Test("Directive MultiLine WithoutContent Parsing", .bug("#152", relationship: .verifiesFix))
Expand All @@ -1228,7 +1229,7 @@ class BlockDirectiveArgumentParserTests: XCTestCase {
"""

let document = Document(parsing: source, options: .parseBlockDirectives)
_ = try XCTUnwrap(document.child(at: 0) as? BlockDirective)
XCTAssertTrue(document.child(at: 0) is BlockDirective)
let expected = #"""
Document @1:1-4:2
└─ BlockDirective @1:1-4:2 name: "Image"
Expand All @@ -1238,4 +1239,34 @@ class BlockDirectiveArgumentParserTests: XCTestCase {
"""#
XCTAssertEqual(expected, document.debugDescription(options: .printSourceLocations))
}
#endif
}

#if compiler(>=6.0) && canImport(Testing)
import Testing

struct _BlockDirectiveArgumentParserTests {
@Test(
"Directive MultiLine WithoutContent Parsing",
.bug("https://github.com/swiftlang/swift-markdown/issues/152" ,id: "#152", "Verify fix of #152")
)
func directiveMultiLineWithoutContentParsing() throws {
let source = #"""
@Image(
source: "example.png",
alt: "Example image"
)
"""#
let document = Document(parsing: source, options: .parseBlockDirectives)
#expect(document.child(at: 0) is BlockDirective)
let expected = #"""
Document @1:1-4:2
└─ BlockDirective @1:1-4:2 name: "Image"
├─ Argument text segments:
| @2:1-2:25: " source: \"example.png\","
| @3:1-3:23: " alt: \"Example image\""
"""#
#expect(document.debugDescription(options: .printSourceLocations) == expected)
}
}
#endif