[cfe-commits] [libcxxabi] r149436 - in /libcxxabi/trunk/test: testit unwind_01.cpp unwind_02.cpp unwind_03.cpp unwind_04.cpp unwind_05.cpp

Howard Hinnant hhinnant at apple.com
Tue Jan 31 13:58:58 PST 2012


Author: hhinnant
Date: Tue Jan 31 15:58:58 2012
New Revision: 149436

URL: http://llvm.org/viewvc/llvm-project?rev=149436&view=rev
Log:
Some unwinding test cases

Added:
    libcxxabi/trunk/test/unwind_01.cpp
    libcxxabi/trunk/test/unwind_02.cpp
    libcxxabi/trunk/test/unwind_03.cpp
    libcxxabi/trunk/test/unwind_04.cpp
    libcxxabi/trunk/test/unwind_05.cpp
Modified:
    libcxxabi/trunk/test/testit

Modified: libcxxabi/trunk/test/testit
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/testit?rev=149436&r1=149435&r2=149436&view=diff
==============================================================================
--- libcxxabi/trunk/test/testit (original)
+++ libcxxabi/trunk/test/testit Tue Jan 31 15:58:58 2012
@@ -8,8 +8,6 @@
 # //
 # //===--------------------------------------------------------------------===//
 
-export DYLD_LIBRARY_PATH=/Users/hhinnant/Development/libcxxabi/lib:/Users/hhinnant/Development/temp_libcxx/lib
-
 if [ -z $CC ]
 then
 	CC=clang++

Added: libcxxabi/trunk/test/unwind_01.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/unwind_01.cpp?rev=149436&view=auto
==============================================================================
--- libcxxabi/trunk/test/unwind_01.cpp (added)
+++ libcxxabi/trunk/test/unwind_01.cpp Tue Jan 31 15:58:58 2012
@@ -0,0 +1,96 @@
+//===------------------------- unwind_01.cpp ------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <assert.h>
+
+struct A
+{
+    static int count;
+    int id_;
+    A() : id_(++count) {}
+    ~A() {assert(id_ == count--);}
+
+private:
+    A(const A&);
+    A& operator=(const A&);
+};
+
+int A::count = 0;
+
+struct B
+{
+    static int count;
+    int id_;
+    B() : id_(++count) {}
+    ~B() {assert(id_ == count--);}
+
+private:
+    B(const B&);
+    B& operator=(const B&);
+};
+
+int B::count = 0;
+
+struct C
+{
+    static int count;
+    int id_;
+    C() : id_(++count) {}
+    ~C() {assert(id_ == count--);}
+
+private:
+    C(const C&);
+    C& operator=(const C&);
+};
+
+int C::count = 0;
+
+void f2()
+{
+    C c;
+    A a;
+    throw 55;
+    B b;
+}
+
+void f1()
+{
+    A a;
+    B b;
+    f2();
+    C c;
+}
+
+int main()
+{
+    try
+    {
+        f1();
+        assert(false);
+    }
+    catch (int* i)
+    {
+        assert(false);
+    }
+    catch (long i)
+    {
+        assert(false);
+    }
+    catch (int i)
+    {
+        assert(i == 55);
+    }
+    catch (...)
+    {
+        assert(false);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+    assert(C::count == 0);
+}

Added: libcxxabi/trunk/test/unwind_02.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/unwind_02.cpp?rev=149436&view=auto
==============================================================================
--- libcxxabi/trunk/test/unwind_02.cpp (added)
+++ libcxxabi/trunk/test/unwind_02.cpp Tue Jan 31 15:58:58 2012
@@ -0,0 +1,96 @@
+//===------------------------- unwind_02.cpp ------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <assert.h>
+
+struct A
+{
+    static int count;
+    int id_;
+    A() : id_(++count) {}
+    ~A() {assert(id_ == count--);}
+
+private:
+    A(const A&);
+    A& operator=(const A&);
+};
+
+int A::count = 0;
+
+struct B
+{
+    static int count;
+    int id_;
+    B() : id_(++count) {}
+    ~B() {assert(id_ == count--);}
+
+private:
+    B(const B&);
+    B& operator=(const B&);
+};
+
+int B::count = 0;
+
+struct C
+{
+    static int count;
+    int id_;
+    C() : id_(++count) {}
+    ~C() {assert(id_ == count--);}
+
+private:
+    C(const C&);
+    C& operator=(const C&);
+};
+
+int C::count = 0;
+
+void f2()
+{
+    C c;
+    A a;
+    throw 55;
+    B b;
+}
+
+void f1() throw (long, char, int, double)
+{
+    A a;
+    B b;
+    f2();
+    C c;
+}
+
+int main()
+{
+    try
+    {
+        f1();
+        assert(false);
+    }
+    catch (int* i)
+    {
+        assert(false);
+    }
+    catch (long i)
+    {
+        assert(false);
+    }
+    catch (int i)
+    {
+        assert(i == 55);
+    }
+    catch (...)
+    {
+        assert(false);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+    assert(C::count == 0);
+}

Added: libcxxabi/trunk/test/unwind_03.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/unwind_03.cpp?rev=149436&view=auto
==============================================================================
--- libcxxabi/trunk/test/unwind_03.cpp (added)
+++ libcxxabi/trunk/test/unwind_03.cpp Tue Jan 31 15:58:58 2012
@@ -0,0 +1,102 @@
+//===------------------------- unwind_03.cpp ------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <exception>
+#include <stdlib.h>
+#include <assert.h>
+
+struct A
+{
+    static int count;
+    int id_;
+    A() : id_(++count) {}
+    ~A() {assert(id_ == count--);}
+
+private:
+    A(const A&);
+    A& operator=(const A&);
+};
+
+int A::count = 0;
+
+struct B
+{
+    static int count;
+    int id_;
+    B() : id_(++count) {}
+    ~B() {assert(id_ == count--);}
+
+private:
+    B(const B&);
+    B& operator=(const B&);
+};
+
+int B::count = 0;
+
+struct C
+{
+    static int count;
+    int id_;
+    C() : id_(++count) {}
+    ~C() {assert(id_ == count--);}
+
+private:
+    C(const C&);
+    C& operator=(const C&);
+};
+
+int C::count = 0;
+
+void f2()
+{
+    C c;
+    A a;
+    throw 55;
+    B b;
+}
+
+void f1() throw (long, char, double)
+{
+    A a;
+    B b;
+    f2();
+    C c;
+}
+
+void u_handler()
+{
+    exit(0);
+}
+
+int main()
+{
+    std::set_unexpected(u_handler);
+    try
+    {
+        f1();
+        assert(false);
+    }
+    catch (int* i)
+    {
+        assert(false);
+    }
+    catch (long i)
+    {
+        assert(false);
+    }
+    catch (int i)
+    {
+        assert(i == 55);
+    }
+    catch (...)
+    {
+        assert(false);
+    }
+    assert(false);
+}

Added: libcxxabi/trunk/test/unwind_04.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/unwind_04.cpp?rev=149436&view=auto
==============================================================================
--- libcxxabi/trunk/test/unwind_04.cpp (added)
+++ libcxxabi/trunk/test/unwind_04.cpp Tue Jan 31 15:58:58 2012
@@ -0,0 +1,108 @@
+//===------------------------- unwind_04.cpp ------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <exception>
+#include <stdlib.h>
+#include <assert.h>
+
+struct A
+{
+    static int count;
+    int id_;
+    A() : id_(++count) {}
+    ~A() {assert(id_ == count--);}
+
+private:
+    A(const A&);
+    A& operator=(const A&);
+};
+
+int A::count = 0;
+
+struct B
+{
+    static int count;
+    int id_;
+    B() : id_(++count) {}
+    ~B() {assert(id_ == count--);}
+
+private:
+    B(const B&);
+    B& operator=(const B&);
+};
+
+int B::count = 0;
+
+struct C
+{
+    static int count;
+    int id_;
+    C() : id_(++count) {}
+    ~C() {assert(id_ == count--);}
+
+private:
+    C(const C&);
+    C& operator=(const C&);
+};
+
+int C::count = 0;
+
+void f2()
+{
+    C c;
+    A a;
+    throw 55;
+    B b;
+}
+
+void f1() throw (long, char, double)
+{
+    A a;
+    B b;
+    f2();
+    C c;
+}
+
+void u_handler()
+{
+    throw 'a';
+}
+
+int main()
+{
+    std::set_unexpected(u_handler);
+    try
+    {
+        f1();
+        assert(false);
+    }
+    catch (int* i)
+    {
+        assert(false);
+    }
+    catch (long i)
+    {
+        assert(false);
+    }
+    catch (int i)
+    {
+        assert(false);
+    }
+    catch (char c)
+    {
+        assert(c == 'a');
+    }
+    catch (...)
+    {
+        assert(false);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+    assert(C::count == 0);
+}

Added: libcxxabi/trunk/test/unwind_05.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/unwind_05.cpp?rev=149436&view=auto
==============================================================================
--- libcxxabi/trunk/test/unwind_05.cpp (added)
+++ libcxxabi/trunk/test/unwind_05.cpp Tue Jan 31 15:58:58 2012
@@ -0,0 +1,112 @@
+//===------------------------- unwind_05.cpp ------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <exception>
+#include <stdlib.h>
+#include <assert.h>
+
+struct A
+{
+    static int count;
+    int id_;
+    A() : id_(++count) {}
+    ~A() {assert(id_ == count--);}
+
+private:
+    A(const A&);
+    A& operator=(const A&);
+};
+
+int A::count = 0;
+
+struct B
+{
+    static int count;
+    int id_;
+    B() : id_(++count) {}
+    ~B() {assert(id_ == count--);}
+
+private:
+    B(const B&);
+    B& operator=(const B&);
+};
+
+int B::count = 0;
+
+struct C
+{
+    static int count;
+    int id_;
+    C() : id_(++count) {}
+    ~C() {assert(id_ == count--);}
+
+private:
+    C(const C&);
+    C& operator=(const C&);
+};
+
+int C::count = 0;
+
+void f2()
+{
+    C c;
+    A a;
+    throw 55;
+    B b;
+}
+
+void f1() throw (long, char, double, std::bad_exception)
+{
+    A a;
+    B b;
+    f2();
+    C c;
+}
+
+void u_handler()
+{
+    throw;
+}
+
+int main()
+{
+    std::set_unexpected(u_handler);
+    try
+    {
+        f1();
+        assert(false);
+    }
+    catch (int* i)
+    {
+        assert(false);
+    }
+    catch (long i)
+    {
+        assert(false);
+    }
+    catch (int i)
+    {
+        assert(false);
+    }
+    catch (char c)
+    {
+        assert(false);
+    }
+    catch (const std::bad_exception& e)
+    {
+        assert(true);
+    }
+    catch (...)
+    {
+        assert(false);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+    assert(C::count == 0);
+}





More information about the cfe-commits mailing list