Files
swift-mirror/test/Interpreter/availability_host_os.swift
Jordan Rose 23f25e1de7 In immediate mode, detect the host OS version on Apple platforms.
This allows script mode to pick up the current version of macOS
instead of defaulting to 10.9, making it unnecessary to write #available.
A -target flag can still override this if you're trying to write a
portable script.

The logic is a little tortured to avoid having to actually link to
Foundation.framework or libobjc.

Finishes rdar://problem/29433205.
2016-12-22 17:01:33 -08:00

17 lines
801 B
Swift

// Note: This deliberately uses the script interpreter rather than build/run.
// RUN: %swift_driver -import-objc-header %S/Inputs/availability_host_os.h -DFAIL -Xfrontend -verify %s
// RUN: %swift_driver -import-objc-header %S/Inputs/availability_host_os.h %s | %FileCheck %s
// RUN: not %swift -typecheck -import-objc-header %S/Inputs/availability_host_os.h %s 2>&1 | %FileCheck -check-prefix=CHECK-NOT-INFERRED %s
// REQUIRES: OS=macosx
// REQUIRES: executable_test
print(mavericks()) // CHECK: {{^9$}}
print(yosemite()) // CHECK-NEXT: {{^10$}}
// CHECK-NOT-INFERRED: 'yosemite()' is only available on OS X 10.10 or newer
#if FAIL
print(todosSantos()) // expected-error {{'todosSantos()' is only available on OS X 10.99 or newer}}
// expected-note@-1 {{add 'if #available' version check}}
#endif