Files
swift-mirror/test/Sema/exhaustive_switch_testable.swift
Jordan Rose 797901fc41 Enable @unknown default warnings by default in Swift 5 mode (#16045)
Note that I said "warnings"; we're going to be more cautious about
rollout and just make this a warning in Swift 5 mode, with /no/
diagnostics in Swift 3 and 4. Users are still free to use `@unknown
default` in these modes, and they'll get a fatal run-time error if
they don't and an unexpected case actually shows up.

rdar://problem/29324688
2018-04-20 17:04:31 -07:00

26 lines
842 B
Swift

// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -swift-version 5 -enable-resilience -enable-testing %S/Inputs/exhaustive_switch_testable_helper.swift -emit-module -o %t
// RUN: %target-swift-frontend -typecheck %s -swift-version 5 -I %t -DTESTABLE -verify
// RUN: %target-swift-frontend -typecheck %s -swift-version 5 -I %t 2>&1 | %FileCheck -check-prefix=VERIFY-NON-FROZEN %s
#if TESTABLE
@testable import exhaustive_switch_testable_helper
#else
import exhaustive_switch_testable_helper
#endif
func testFrozen(_ e: FrozenEnum) -> Int {
switch e {
case .a: return 1
case .b, .c: return 2
}
}
func testNonFrozen(_ e: NonFrozenEnum) -> Int {
// VERIFY-NON-FROZEN: exhaustive_switch_testable.swift:[[@LINE+1]]:{{[0-9]+}}: warning: switch must be exhaustive
switch e {
case .a: return 1
case .b, .c: return 2
}
}