Files
swift-mirror/test/Interop/Cxx/stdlib/use-std-function.swift
Egor Zhdan 1be7230876 [cxx-interop] Use C++17 standard by default
Clang is using C++17 standard version by default since Clang 16.

Swift’s ClangImporter should do the same, to make sure that clients who run clang and then swiftc without explicit std version see consistent behavior.

rdar://125777068
2024-04-02 16:23:32 +01:00

34 lines
1.1 KiB
Swift

// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop)
// RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=swift-6)
// RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=upcoming-swift)
// RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=upcoming-swift -Xcc -std=c++14)
// RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=upcoming-swift -Xcc -std=c++17)
// RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=upcoming-swift -Xcc -std=c++20)
// REQUIRES: executable_test
import StdlibUnittest
import StdFunction
var StdFunctionTestSuite = TestSuite("StdFunction")
StdFunctionTestSuite.test("init empty") {
let f = FunctionIntToInt()
expectTrue(isEmptyFunction(f))
let copied = f
expectTrue(isEmptyFunction(copied))
}
StdFunctionTestSuite.test("call") {
let f = getIdentityFunction()
expectEqual(123, f(123))
}
StdFunctionTestSuite.test("retrieve and pass back as parameter") {
let res = invokeFunction(getIdentityFunction(), 456)
expectEqual(456, res)
}
runAllTests()