Skip to content

tests: correct availability checks in Interpreter/runtime_name_local_class_opaque_type.swift #34161

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

Merged
merged 1 commit into from
Oct 3, 2020
Merged
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
25 changes: 17 additions & 8 deletions test/Interpreter/runtime_name_local_class_opaque_type.swift
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
// RUN: %empty-directory(%t)
// RUN: %target-build-swift -Xfrontend -disable-availability-checking %s -o %t/a.out
// RUN: %target-build-swift %s -o %t/a.out
// RUN: %target-run %t/a.out | %FileCheck %s

// REQUIRES: executable_test
// REQUIRES: objc_interop

protocol MyProtocol {}

@available(iOS 13, macOS 10.15, tvOS 13, watchOS 6, *)
func returnsClass1() -> some MyProtocol {
class MyClass1: MyProtocol {}
return MyClass1()
}

var returnsClass2: some MyProtocol {
class MyClass2: MyProtocol {}
return MyClass2()
@available(iOS 13, macOS 10.15, tvOS 13, watchOS 6, *)
struct Outer {
static var returnsClass2: some MyProtocol {
class MyClass2: MyProtocol {}
return MyClass2()
}
}

print(returnsClass1())
// CHECK: a.(unknown context at ${{[0-9a-z]+}}).(unknown context at ${{[0-9a-z]+}}).MyClass1

print(returnsClass2)
// CHECK: a.(unknown context at ${{[0-9a-z]+}}).(unknown context at ${{[0-9a-z]+}}).MyClass2
// CHECK: a.Outer.(unknown context at ${{[0-9a-z]+}}).(unknown context at ${{[0-9a-z]+}}).MyClass2
if #available(iOS 13, macOS 10.15, tvOS 13, watchOS 6, *) {
print(returnsClass1())
print(Outer.returnsClass2)
} else {
// Make FileCheck happy if this test runs on an older OS.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a good opportunity to port this to use StdlibUnittest instead?

print("a.(unknown context at $0).(unknown context at $0).MyClass1")
print("a.Outer.(unknown context at $0).(unknown context at $0).MyClass2")
}