Skip to content

Commit d7aa440

Browse files
authored
Declare Hashable conformance for ArgumentVisibility (#481)
In addition to being useful, this allows us to drop the `@testable` annotation for the ArgumentParser import in ArgumentParserTestHelpers, which resolves #463.
1 parent 0bac2cc commit d7aa440

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

Sources/ArgumentParser/Parsable Properties/ArgumentVisibility.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//===----------------------------------------------------------------------===//
1111

1212
/// Visibility level of an argument's help.
13-
public struct ArgumentVisibility {
13+
public struct ArgumentVisibility: Hashable {
1414
/// Internal implementation of `ArgumentVisibility` to allow for easier API
1515
/// evolution.
1616
internal enum Representation {

Sources/ArgumentParserTestHelpers/TestHelpers.swift

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//
1010
//===----------------------------------------------------------------------===//
1111

12-
@testable import ArgumentParser
12+
import ArgumentParser
1313
import ArgumentParserToolInfo
1414
import XCTest
1515

@@ -122,15 +122,18 @@ public func AssertHelp<T: ParsableArguments>(
122122
let flag: String
123123
let includeHidden: Bool
124124

125-
switch visibility.base {
125+
switch visibility {
126126
case .default:
127127
flag = "--help"
128128
includeHidden = false
129129
case .hidden:
130130
flag = "--help-hidden"
131131
includeHidden = true
132132
case .private:
133-
XCTFail("Should not be called.")
133+
XCTFail("Should not be called.", file: file, line: line)
134+
return
135+
default:
136+
XCTFail("Unrecognized visibility.", file: file, line: line)
134137
return
135138
}
136139

@@ -158,13 +161,16 @@ public func AssertHelp<T: ParsableCommand, U: ParsableCommand>(
158161
) {
159162
let includeHidden: Bool
160163

161-
switch visibility.base {
164+
switch visibility {
162165
case .default:
163166
includeHidden = false
164167
case .hidden:
165168
includeHidden = true
166169
case .private:
167-
XCTFail("Should not be called.")
170+
XCTFail("Should not be called.", file: file, line: line)
171+
return
172+
default:
173+
XCTFail("Unrecognized visibility.", file: file, line: line)
168174
return
169175
}
170176

0 commit comments

Comments
 (0)