Skip to content

Commit

Permalink
Simple tests for @_package attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
stevapple committed Feb 4, 2023
1 parent 5ee31ce commit 0f4cfba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Tests/SwiftParserTest/AttributeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -540,4 +540,9 @@ final class AttributeTests: XCTestCase {
AssertParse("func takeRepeater(_ f: @MainActor @Sendable @escaping () -> Int) {}")
AssertParse("takeRepesater { @MainActor @Sendable () -> Int in 0 }")
}

func testPackageAttribute() {
AssertParse(#"@_package(path: "../my-package") import A"#)
AssertParse(#"@_package(url: "https://example.com/package.git", from: "0.0.1") @_exported import A"#)
}
}
11 changes: 11 additions & 0 deletions Tests/SwiftSyntaxBuilderTest/ImportTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,15 @@ final class ImportTests: XCTestCase {

AssertBuildResult(importDecl, "␣import SwiftSyntax")
}

func testPackageAttribute() {
let builder = ImportDeclSyntax("""
@_package(url: "https://github.com/apple/swift-log.git", "1.0.0"..<"2.0.0")
import Logging
""")
AssertBuildResult(builder, """
@_package(url: "https://github.com/apple/swift-log.git", "1.0.0" ..< "2.0.0")
import Logging
""")
}
}

0 comments on commit 0f4cfba

Please sign in to comment.