|
| 1 | +// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop) |
| 2 | +// RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=swift-6) |
| 3 | +// RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=upcoming-swift) |
| 4 | +// RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=upcoming-swift -Xcc -std=c++14) |
| 5 | +// RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=upcoming-swift -Xcc -std=c++17) |
| 6 | +// RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=upcoming-swift -Xcc -std=c++20) |
| 7 | + |
| 8 | +// Also test this with a bridging header instead of the StdSet module. |
| 9 | +// RUN: %empty-directory(%t2) |
| 10 | +// RUN: cp %S/Inputs/std-stack.h %t2/std-stack-bridging-header.h |
| 11 | +// RUN: %target-run-simple-swift(-D BRIDGING_HEADER -import-objc-header %t2/std-stack-bridging-header.h -Xfrontend -enable-experimental-cxx-interop) |
| 12 | +// RUN: %target-run-simple-swift(-D BRIDGING_HEADER -import-objc-header %t2/std-stack-bridging-header.h -cxx-interoperability-mode=swift-6) |
| 13 | +// RUN: %target-run-simple-swift(-D BRIDGING_HEADER -import-objc-header %t2/std-stack-bridging-header.h -cxx-interoperability-mode=upcoming-swift) |
| 14 | + |
| 15 | +// REQUIRES: executable_test |
| 16 | +// |
| 17 | +// Enable this everywhere once we have a solution for modularizing other C++ stdlibs: rdar://87654514 |
| 18 | +// REQUIRES: OS=macosx || OS=linux-gnu |
| 19 | + |
| 20 | +import StdlibUnittest |
| 21 | +#if !BRIDGING_HEADER |
| 22 | +import StdStack |
| 23 | +#endif |
| 24 | +import CxxStdlib |
| 25 | + |
| 26 | +var StdStackTestSuite = TestSuite("StdStack") |
| 27 | + |
| 28 | +StdStackTestSuite.test("stack count") { |
| 29 | + let s1 = initStackOfCInt() |
| 30 | + expectEqual(s1.count, 3) |
| 31 | + |
| 32 | + let s2 = initEmtypeStackOfCInt() |
| 33 | + expectEqual(s2.count, 0) |
| 34 | +} |
| 35 | + |
| 36 | +StdStackTestSuite.test("stack isEmpty") { |
| 37 | + let s1 = initStackOfCInt() |
| 38 | + expectFalse(s1.isEmpty) |
| 39 | + |
| 40 | + let s2 = initEmtypeStackOfCInt() |
| 41 | + expectTrue(s2.isEmpty) |
| 42 | +} |
| 43 | + |
| 44 | +StdStackTestSuite.test("stack top") { |
| 45 | + let s1 = initStackOfCInt() |
| 46 | + expectEqual(s1.top(), 3) |
| 47 | +} |
| 48 | + |
| 49 | +StdStackTestSuite.test("stack push") { |
| 50 | + var s1 = initStackOfCInt() |
| 51 | + |
| 52 | + s1.push(4) |
| 53 | + expectEqual(s1.top(), 4) |
| 54 | + expectEqual(s1.count, 4) |
| 55 | + |
| 56 | + var s2 = initEmtypeStackOfCInt() |
| 57 | + |
| 58 | + s2.push(4) |
| 59 | + expectEqual(s2.top(), 4) |
| 60 | + expectEqual(s2.count, 1) |
| 61 | +} |
| 62 | + |
| 63 | +StdStackTestSuite.test("stack pop") { |
| 64 | + var s1 = initStackOfCInt() |
| 65 | + |
| 66 | + expectEqual(s1.top(), 3) |
| 67 | + |
| 68 | + s1.pop() |
| 69 | + expectEqual(s1.top(), 2) |
| 70 | + |
| 71 | + s1.pop() |
| 72 | + expectEqual(s1.top(), 1) |
| 73 | + |
| 74 | + s1.pop() |
| 75 | + expectTrue(s1.isEmpty) |
| 76 | +} |
| 77 | + |
| 78 | +runAllTests() |
0 commit comments