Skip to content

Commit ac18e06

Browse files
committed
libc++abi: move tests back
These are apparently related to libc++'s unwind personality handler and not unwind core. Move them back to the correct location. llvm-svn: 235765
1 parent 14a384b commit ac18e06

File tree

6 files changed

+771
-0
lines changed

6 files changed

+771
-0
lines changed

libcxxabi/test/unwind_01.pass.cpp

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
//===------------------------- unwind_01.cpp ------------------------------===//
2+
//
3+
// The LLVM Compiler Infrastructure
4+
//
5+
// This file is dual licensed under the MIT and the University of Illinois Open
6+
// Source Licenses. See LICENSE.TXT for details.
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#include <assert.h>
11+
12+
struct A
13+
{
14+
static int count;
15+
int id_;
16+
A() : id_(++count) {}
17+
~A() {assert(id_ == count--);}
18+
19+
private:
20+
A(const A&);
21+
A& operator=(const A&);
22+
};
23+
24+
int A::count = 0;
25+
26+
struct B
27+
{
28+
static int count;
29+
int id_;
30+
B() : id_(++count) {}
31+
~B() {assert(id_ == count--);}
32+
33+
private:
34+
B(const B&);
35+
B& operator=(const B&);
36+
};
37+
38+
int B::count = 0;
39+
40+
struct C
41+
{
42+
static int count;
43+
int id_;
44+
C() : id_(++count) {}
45+
~C() {assert(id_ == count--);}
46+
47+
private:
48+
C(const C&);
49+
C& operator=(const C&);
50+
};
51+
52+
int C::count = 0;
53+
54+
void f2()
55+
{
56+
C c;
57+
A a;
58+
throw 55;
59+
B b;
60+
}
61+
62+
void f1()
63+
{
64+
A a;
65+
B b;
66+
f2();
67+
C c;
68+
}
69+
70+
int main()
71+
{
72+
try
73+
{
74+
f1();
75+
assert(false);
76+
}
77+
catch (int* i)
78+
{
79+
assert(false);
80+
}
81+
catch (long i)
82+
{
83+
assert(false);
84+
}
85+
catch (int i)
86+
{
87+
assert(i == 55);
88+
}
89+
catch (...)
90+
{
91+
assert(false);
92+
}
93+
assert(A::count == 0);
94+
assert(B::count == 0);
95+
assert(C::count == 0);
96+
}

libcxxabi/test/unwind_02.pass.cpp

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
//===------------------------- unwind_02.cpp ------------------------------===//
2+
//
3+
// The LLVM Compiler Infrastructure
4+
//
5+
// This file is dual licensed under the MIT and the University of Illinois Open
6+
// Source Licenses. See LICENSE.TXT for details.
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#include <assert.h>
11+
12+
struct A
13+
{
14+
static int count;
15+
int id_;
16+
A() : id_(++count) {}
17+
~A() {assert(id_ == count--);}
18+
19+
private:
20+
A(const A&);
21+
A& operator=(const A&);
22+
};
23+
24+
int A::count = 0;
25+
26+
struct B
27+
{
28+
static int count;
29+
int id_;
30+
B() : id_(++count) {}
31+
~B() {assert(id_ == count--);}
32+
33+
private:
34+
B(const B&);
35+
B& operator=(const B&);
36+
};
37+
38+
int B::count = 0;
39+
40+
struct C
41+
{
42+
static int count;
43+
int id_;
44+
C() : id_(++count) {}
45+
~C() {assert(id_ == count--);}
46+
47+
private:
48+
C(const C&);
49+
C& operator=(const C&);
50+
};
51+
52+
int C::count = 0;
53+
54+
void f2()
55+
{
56+
C c;
57+
A a;
58+
throw 55;
59+
B b;
60+
}
61+
62+
void f1() throw (long, char, int, double)
63+
{
64+
A a;
65+
B b;
66+
f2();
67+
C c;
68+
}
69+
70+
int main()
71+
{
72+
try
73+
{
74+
f1();
75+
assert(false);
76+
}
77+
catch (int* i)
78+
{
79+
assert(false);
80+
}
81+
catch (long i)
82+
{
83+
assert(false);
84+
}
85+
catch (int i)
86+
{
87+
assert(i == 55);
88+
}
89+
catch (...)
90+
{
91+
assert(false);
92+
}
93+
assert(A::count == 0);
94+
assert(B::count == 0);
95+
assert(C::count == 0);
96+
}

libcxxabi/test/unwind_03.pass.cpp

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
//===------------------------- unwind_03.cpp ------------------------------===//
2+
//
3+
// The LLVM Compiler Infrastructure
4+
//
5+
// This file is dual licensed under the MIT and the University of Illinois Open
6+
// Source Licenses. See LICENSE.TXT for details.
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#include <exception>
11+
#include <stdlib.h>
12+
#include <assert.h>
13+
14+
struct A
15+
{
16+
static int count;
17+
int id_;
18+
A() : id_(++count) {}
19+
~A() {assert(id_ == count--);}
20+
21+
private:
22+
A(const A&);
23+
A& operator=(const A&);
24+
};
25+
26+
int A::count = 0;
27+
28+
struct B
29+
{
30+
static int count;
31+
int id_;
32+
B() : id_(++count) {}
33+
~B() {assert(id_ == count--);}
34+
35+
private:
36+
B(const B&);
37+
B& operator=(const B&);
38+
};
39+
40+
int B::count = 0;
41+
42+
struct C
43+
{
44+
static int count;
45+
int id_;
46+
C() : id_(++count) {}
47+
~C() {assert(id_ == count--);}
48+
49+
private:
50+
C(const C&);
51+
C& operator=(const C&);
52+
};
53+
54+
int C::count = 0;
55+
56+
void f2()
57+
{
58+
C c;
59+
A a;
60+
throw 55;
61+
B b;
62+
}
63+
64+
void f1() throw (long, char, double)
65+
{
66+
A a;
67+
B b;
68+
f2();
69+
C c;
70+
}
71+
72+
void u_handler()
73+
{
74+
exit(0);
75+
}
76+
77+
int main()
78+
{
79+
std::set_unexpected(u_handler);
80+
try
81+
{
82+
f1();
83+
assert(false);
84+
}
85+
catch (int* i)
86+
{
87+
assert(false);
88+
}
89+
catch (long i)
90+
{
91+
assert(false);
92+
}
93+
catch (int i)
94+
{
95+
assert(i == 55);
96+
}
97+
catch (...)
98+
{
99+
assert(false);
100+
}
101+
assert(false);
102+
}

0 commit comments

Comments
 (0)