Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

First cut of StaticRegistries - separate from Context

Commit
1091ca81e6ea63b4153d7c456ec16a7ab588210e
Author
Phil Nash ·
Parents
5234b15ff49a

Files · Download .tar.gz

Changes

 include/catch.hpp                                  |  2 +
 include/catch_runner.hpp                           |  8 +--
 include/internal/catch_capture.hpp                 | 35 ++--------
 include/internal/catch_context.h                   | 11 ---
 include/internal/catch_context_impl.hpp            | 20 +-----
 .../catch_exception_translator_registry.hpp        |  8 +--
 include/internal/catch_impl.hpp                    | 25 +++----
 include/internal/catch_interfaces_exception.h      |  4 +-
 include/internal/catch_interfaces_reporter.h       |  1 -
 .../internal/catch_interfaces_static_registries.h  | 52 +++++++++++---
 include/internal/catch_interfaces_testcase.h       |  3 +-
 include/internal/catch_list.hpp                    |  9 ++-
 include/internal/catch_notimplemented_exception.h  | 41 ++++++++---
 .../internal/catch_notimplemented_exception.hpp    | 38 ++++++++---
 include/internal/catch_objc.hpp                    |  2 +-
 include/internal/catch_reporter_registrars.hpp     |  4 +-
 include/internal/catch_runner_impl.hpp             |  6 +-
 include/internal/catch_static_registries_impl.hpp  | 79 +++++++++++++++++++---
 include/internal/catch_test_case_registry_impl.hpp |  4 +-
 projects/SelfTest/catch_self_test.hpp              |  3 +-
 .../CatchSelfTest.xcodeproj/project.pbxproj        | 10 +++
 21 files changed, 223 insertions(+), 142 deletions(-)

diff --git a/include/catch.hpp b/include/catch.hpp
index 59d1d35f..f0dd7c9e 100644
--- a/include/catch.hpp
+++ b/include/catch.hpp
@@ -9,6 +9,7 @@
 #ifndef TWOBLUECUBES_CATCH_HPP_INCLUDED
 #define TWOBLUECUBES_CATCH_HPP_INCLUDED
 
+#include "internal/catch_notimplemented_exception.h"
 #include "internal/catch_context.h"
 #include "internal/catch_test_registry.hpp"
 #include "internal/catch_capture.hpp"
@@ -29,6 +30,7 @@
 
 #if defined( CATCH_CONFIG_MAIN ) || defined( CATCH_CONFIG_RUNNER )
 #include "catch_runner.hpp"
+#include "internal/catch_impl.hpp"
 #endif
 
 #ifdef CATCH_CONFIG_MAIN
diff --git a/include/catch_runner.hpp b/include/catch_runner.hpp
index ca1aa635..cda98164 100644
--- a/include/catch_runner.hpp
+++ b/include/catch_runner.hpp
@@ -34,7 +34,7 @@ namespace Catch {
             
         ReporterConfig reporterConfig( config.getName(), config.stream(), config.includeSuccessfulResults() );
         
-        Ptr<IReporter> reporter = getCurrentContext().getReporterRegistry().create( reporterName, reporterConfig );
+        Ptr<IReporter> reporter = getStatics().getReporterRegistry().create( reporterName, reporterConfig );
 
         if( !reporter )
         {
@@ -87,7 +87,7 @@ namespace Catch {
             }
             result = static_cast<int>( runner.getTotals().assertions.failed );
         }
-        Catch::Context::cleanUp();
+        Catch::cleanUp();
         return result;
     }
 
@@ -124,7 +124,7 @@ namespace Catch {
                     cmd.raiseError( "Does not accept arguments" );
 
                 showHelp( argv[0] );
-                Catch::Context::cleanUp();        
+                Catch::cleanUp();        
                 return 0;
             }
         
@@ -133,7 +133,7 @@ namespace Catch {
         catch( std::exception& ex ) {
             std::cerr << ex.what() << "\n\nUsage: ...\n\n";
             showUsage( std::cerr );
-            Catch::Context::cleanUp();
+            Catch::cleanUp();
             return (std::numeric_limits<int>::max)();
         }
                 
diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp
index edb75101..62018929 100644
--- a/include/internal/catch_capture.hpp
+++ b/include/internal/catch_capture.hpp
@@ -19,30 +19,6 @@ namespace Catch {
 
 struct TestFailureException{};
 
-class NotImplementedException : public std::exception
-{
-public:
-    NotImplementedException( const SourceLineInfo& lineInfo )
-    :   m_lineInfo( lineInfo ) {
-        std::ostringstream oss;
-        oss << lineInfo << "function ";
-        if( !lineInfo.function.empty() )
-            oss << lineInfo.function << " ";
-        oss << "not implemented";
-        m_what = oss.str();
-    }
-    
-    virtual ~NotImplementedException() throw() {}
-    
-    virtual const char* what() const throw() {
-        return m_what.c_str();
-    }
-    
-private:
-    std::string m_what;
-    SourceLineInfo m_lineInfo;
-};
-
 class ScopedInfo {
 public:
     ScopedInfo() : m_oss() {
@@ -88,7 +64,7 @@ inline bool isTrue( bool value ){ return value; }
     } catch( Catch::TestFailureException& ) { \
         throw; \
     } catch( ... ) { \
-        INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::getCurrentContext().getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false, expr ); \
+        INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::getStatics().getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false, expr ); \
         throw; \
     } } while( Catch::isTrue( false ) )
 
@@ -109,7 +85,7 @@ inline bool isTrue( bool value ){ return value; }
         INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ).setResultType( Catch::ResultWas::Ok ), stopOnFailure, false ); \
     } \
     catch( ... ) { \
-        INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::getCurrentContext().getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure, false ); \
+        INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::getStatics().getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure, false ); \
     }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -131,7 +107,7 @@ inline bool isTrue( bool value ){ return value; }
 #define INTERNAL_CATCH_THROWS_AS( expr, exceptionType, stopOnFailure, macroName ) \
     INTERNAL_CATCH_THROWS( expr, exceptionType, stopOnFailure, macroName ) \
     catch( ... ) { \
-        INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::getCurrentContext().getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure, false ); \
+        INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::getStatics().getExceptionTranslatorRegistry() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure, false ); \
     }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -150,11 +126,8 @@ inline bool isTrue( bool value ){ return value; }
     } catch( Catch::TestFailureException& ) { \
         throw; \
     } catch( ... ) { \
-        INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #arg " " #matcher ) << Catch::getCurrentContext().getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false, false ); \
+        INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #arg " " #matcher ) << Catch::getStatics().getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false, false ); \
         throw; \
     }}while( Catch::isTrue( false ) )
 
-///////////////////////////////////////////////////////////////////////////////
-#define CATCH_NOT_IMPLEMENTED throw Catch::NotImplementedException( CATCH_INTERNAL_LINEINFO )
-
 #endif // TWOBLUECUBES_CATCH_CAPTURE_HPP_INCLUDED
diff --git a/include/internal/catch_context.h b/include/internal/catch_context.h
index 7b015983..0fb42dd2 100644
--- a/include/internal/catch_context.h
+++ b/include/internal/catch_context.h
@@ -19,9 +19,7 @@ namespace Catch {
 
     class TestCaseInfo;
     struct IResultCapture;
-    struct ITestCaseRegistry;
     struct IRunner;
-    struct IExceptionTranslatorRegistry;
     class GeneratorsForTest;
 
     class StreamBufBase : public std::streambuf{};
@@ -32,9 +30,6 @@ namespace Catch {
         
         virtual IResultCapture& getResultCapture() = 0;
         virtual IRunner& getRunner() = 0;
-        virtual IReporterRegistry& getReporterRegistry() = 0;
-        virtual ITestCaseRegistry& getTestCaseRegistry() = 0;
-        virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() = 0;
         virtual size_t getGeneratorIndex( const std::string& fileInfo, size_t totalSize ) = 0;
         virtual bool advanceGeneratorsForCurrentTest() = 0;
         virtual const IConfig* getConfig() const = 0;
@@ -59,9 +54,6 @@ namespace Catch {
     public: // IContext
         virtual IResultCapture& getResultCapture();
         virtual IRunner& getRunner();
-        virtual IReporterRegistry& getReporterRegistry();
-        virtual ITestCaseRegistry& getTestCaseRegistry();
-        virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry();
         virtual size_t getGeneratorIndex( const std::string& fileInfo, size_t totalSize );
         virtual bool advanceGeneratorsForCurrentTest();
         virtual const IConfig* getConfig() const;
@@ -82,9 +74,6 @@ namespace Catch {
         GeneratorsForTest& getGeneratorsForCurrentTest();
 
     private:        
-        std::auto_ptr<IReporterRegistry> m_reporterRegistry;
-        std::auto_ptr<ITestCaseRegistry> m_testCaseRegistry;
-        std::auto_ptr<IExceptionTranslatorRegistry> m_exceptionTranslatorRegistry;
         IRunner* m_runner;
         IResultCapture* m_resultCapture;
         const IConfig* m_config;
diff --git a/include/internal/catch_context_impl.hpp b/include/internal/catch_context_impl.hpp
index cf4f3697..097ae1df 100644
--- a/include/internal/catch_context_impl.hpp
+++ b/include/internal/catch_context_impl.hpp
@@ -5,14 +5,11 @@
  *  Distributed under the Boost Software License, Version 1.0. (See accompanying
  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  */
-#include "catch_test_case_registry_impl.hpp"
 #include "catch_runner_impl.hpp"
 #include "catch_generators_impl.hpp"
 #include "catch_console_colour_impl.hpp"
 
-#include "catch_exception_translator_registry.hpp"
 #include "catch_context.h"
-#include "catch_reporter_registry.hpp"
 #include "catch_stream.hpp"
 
 namespace Catch {
@@ -30,10 +27,7 @@ namespace Catch {
     }
  
     Context::Context()
-    :   m_reporterRegistry( new ReporterRegistry ),
-        m_testCaseRegistry( new TestRegistry ),
-        m_exceptionTranslatorRegistry( new ExceptionTranslatorRegistry ),
-        m_config( NULL )
+    :   m_config( NULL )
     {}
 
     void Context::cleanUp() {
@@ -64,18 +58,6 @@ namespace Catch {
         return *m_runner;
     }
     
-    IReporterRegistry& Context::getReporterRegistry() {
-        return *m_reporterRegistry.get();
-    }
-
-    ITestCaseRegistry& Context::getTestCaseRegistry() {
-        return *m_testCaseRegistry.get();
-    }
-    
-    IExceptionTranslatorRegistry& Context::getExceptionTranslatorRegistry() {
-        return *m_exceptionTranslatorRegistry.get();
-    }
-    
     std::streambuf* Context::createStreamBuf( const std::string& streamName ) {
         if( streamName == "stdout" ) return std::cout.rdbuf();
         if( streamName == "stderr" ) return std::cerr.rdbuf();
diff --git a/include/internal/catch_exception_translator_registry.hpp b/include/internal/catch_exception_translator_registry.hpp
index 55a20713..a6102ef9 100644
--- a/include/internal/catch_exception_translator_registry.hpp
+++ b/include/internal/catch_exception_translator_registry.hpp
@@ -17,12 +17,12 @@
 namespace Catch {
 
     class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry {
-
+    public:
         ~ExceptionTranslatorRegistry() {
             deleteAll( m_translators );
         }
 
-        virtual void registerTranslator( IExceptionTranslator* translator ) {
+        virtual void registerTranslator( const IExceptionTranslator* translator ) {
             m_translators.push_back( translator );
         }
         
@@ -54,7 +54,7 @@ namespace Catch {
             }
         }
         
-        std::string tryTranslators( std::vector<IExceptionTranslator*>::const_iterator it ) const {
+        std::string tryTranslators( std::vector<const IExceptionTranslator*>::const_iterator it ) const {
             if( it == m_translators.end() )
                 return "Unknown exception";
             
@@ -67,7 +67,7 @@ namespace Catch {
         }
         
     private:
-        std::vector<IExceptionTranslator*> m_translators;
+        std::vector<const IExceptionTranslator*> m_translators;
     };
 }
 
diff --git a/include/internal/catch_impl.hpp b/include/internal/catch_impl.hpp
index 6491a1a3..256846ce 100644
--- a/include/internal/catch_impl.hpp
+++ b/include/internal/catch_impl.hpp
@@ -1,14 +1,11 @@
-//
-//  catch_impl.hpp
-//  CatchSelfTest
-//
-//  Created by Phil Nash on 05/08/2012.
-//
-//
-
-#ifndef CatchSelfTest_catch_impl_hpp
-#define CatchSelfTest_catch_impl_hpp
-
-
-
-#endif
+/*
+ *  Created by Phil on 5/8/2012.
+ *  Copyright 2012 Two Blue Cubes Ltd. All rights reserved.
+ *
+ *  Distributed under the Boost Software License, Version 1.0. (See accompanying
+ *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#include "catch_static_registries_impl.hpp"
+#include "catch_notimplemented_exception.hpp"
+// !TBD... migrate all impl headers here
diff --git a/include/internal/catch_interfaces_exception.h b/include/internal/catch_interfaces_exception.h
index 3bb23ebd..15023ca5 100644
--- a/include/internal/catch_interfaces_exception.h
+++ b/include/internal/catch_interfaces_exception.h
@@ -9,6 +9,7 @@
 #define TWOBLUECUBES_CATCH_INTERFACES_EXCEPTIONS_H_INCLUDED
 
 #include <string>
+#include "catch_interfaces_static_registries.h"
                                               
 namespace Catch {
     
@@ -22,7 +23,6 @@ namespace Catch {
     struct IExceptionTranslatorRegistry {
         virtual ~IExceptionTranslatorRegistry(){}
         
-        virtual void registerTranslator( IExceptionTranslator* translator ) = 0;
         virtual std::string translateActiveException() const = 0;
     };
 
@@ -51,7 +51,7 @@ namespace Catch {
     public:
         template<typename T>
         ExceptionTranslatorRegistrar( std::string(*translateFunction)( T& ) ) {
-            getCurrentContext().getExceptionTranslatorRegistry().registerTranslator
+            getStaticRegistries().registerTranslator
                 ( new ExceptionTranslator<T>( translateFunction ) );
         }
     };
diff --git a/include/internal/catch_interfaces_reporter.h b/include/internal/catch_interfaces_reporter.h
index 7d10f407..dddba174 100644
--- a/include/internal/catch_interfaces_reporter.h
+++ b/include/internal/catch_interfaces_reporter.h
@@ -62,7 +62,6 @@ namespace Catch
 
         virtual ~IReporterRegistry() {}
         virtual IReporter* create( const std::string& name, const ReporterConfig& config ) const = 0;        
-        virtual void registerReporter( const std::string& name, IReporterFactory* factory ) = 0;        
         virtual const FactoryMap& getFactories() const = 0;
     };
     
diff --git a/include/internal/catch_interfaces_static_registries.h b/include/internal/catch_interfaces_static_registries.h
index 997de71e..c7212073 100644
--- a/include/internal/catch_interfaces_static_registries.h
+++ b/include/internal/catch_interfaces_static_registries.h
@@ -1,14 +1,46 @@
-//
-//  catch_static_registries.h
-//  CatchSelfTest
-//
-//  Created by Phil Nash on 05/08/2012.
-//
-//
+/*
+ *  Created by Phil on 5/8/2012.
+ *  Copyright 2012 Two Blue Cubes Ltd. All rights reserved.
+ *
+ *  Distributed under the Boost Software License, Version 1.0. (See accompanying
+ *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+#ifndef TWOBLUECUBES_CATCH_STATIC_REGISTRIES_H_INCLUDED
+#define TWOBLUECUBES_CATCH_STATIC_REGISTRIES_H_INCLUDED
 
-#ifndef CatchSelfTest_catch_static_registries_h
-#define CatchSelfTest_catch_static_registries_h
+#include "catch_interfaces_reporter.h"
+#include "catch_interfaces_config.h"
 
+#include <memory>
+#include <vector>
+#include <stdlib.h>
 
+namespace Catch {
 
-#endif
+    class TestCaseInfo;
+    struct IResultCapture;
+    struct ITestCaseRegistry;
+    struct IExceptionTranslatorRegistry;
+    struct IExceptionTranslator;
+
+    struct IStatics {
+        virtual ~IStatics(){}
+
+        virtual const IReporterRegistry& getReporterRegistry() const = 0;
+        virtual const ITestCaseRegistry& getTestCaseRegistry() const = 0;
+        virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() = 0;
+    };
+
+    struct IStaticRegistries {
+        virtual ~IStaticRegistries(){}
+        virtual void registerReporter( const std::string& name, IReporterFactory* factory ) = 0;
+        virtual void registerTest( const TestCaseInfo& testInfo ) = 0;
+        virtual void registerTranslator( const IExceptionTranslator* translator ) = 0;
+    };
+
+    IStatics& getStatics();
+    IStaticRegistries& getStaticRegistries();
+    void cleanUp();
+}
+
+#endif // TWOBLUECUBES_CATCH_STATIC_REGISTRIES_H_INCLUDED
diff --git a/include/internal/catch_interfaces_testcase.h b/include/internal/catch_interfaces_testcase.h
index 666aec05..f4ba5621 100644
--- a/include/internal/catch_interfaces_testcase.h
+++ b/include/internal/catch_interfaces_testcase.h
@@ -23,9 +23,8 @@ namespace Catch {
 
     struct ITestCaseRegistry {
         virtual ~ITestCaseRegistry(){}
-        virtual void registerTest( const TestCaseInfo& testInfo ) = 0;        
         virtual const std::vector<TestCaseInfo>& getAllTests() const = 0;
-        virtual std::vector<TestCaseInfo> getMatchingTestCases( const std::string& rawTestSpec ) = 0;
+        virtual std::vector<TestCaseInfo> getMatchingTestCases( const std::string& rawTestSpec ) const = 0;
     };
 }
 
diff --git a/include/internal/catch_list.hpp b/include/internal/catch_list.hpp
index b68fd6a2..a18914c1 100644
--- a/include/internal/catch_list.hpp
+++ b/include/internal/catch_list.hpp
@@ -14,11 +14,10 @@
 namespace Catch {
     inline int List( Config& config ) {
         
-        IContext& context = getCurrentContext();
         if( config.listWhat() & List::Reports ) {
             std::cout << "Available reports:\n";
-            IReporterRegistry::FactoryMap::const_iterator it = context.getReporterRegistry().getFactories().begin();
-            IReporterRegistry::FactoryMap::const_iterator itEnd = context.getReporterRegistry().getFactories().end();
+            IReporterRegistry::FactoryMap::const_iterator it = getStatics().getReporterRegistry().getFactories().begin();
+            IReporterRegistry::FactoryMap::const_iterator itEnd = getStatics().getReporterRegistry().getFactories().end();
             for(; it != itEnd; ++it ) {
                 // !TBD: consider listAs()
                 std::cout << "\t" << it->first << "\n\t\t'" << it->second->getDescription() << "'\n";
@@ -28,8 +27,8 @@ namespace Catch {
         
         if( config.listWhat() & List::Tests ) {
             std::cout << "Available tests:\n";
-            std::vector<TestCaseInfo>::const_iterator it = context.getTestCaseRegistry().getAllTests().begin();
-            std::vector<TestCaseInfo>::const_iterator itEnd = context.getTestCaseRegistry().getAllTests().end();
+            std::vector<TestCaseInfo>::const_iterator it = getStatics().getTestCaseRegistry().getAllTests().begin();
+            std::vector<TestCaseInfo>::const_iterator itEnd = getStatics().getTestCaseRegistry().getAllTests().end();
             for(; it != itEnd; ++it ) {
                 // !TBD: consider listAs()
                 std::cout << "\t" << it->getName() << "\n\t\t '" << it->getDescription() << "'\n";
diff --git a/include/internal/catch_notimplemented_exception.h b/include/internal/catch_notimplemented_exception.h
index 1497b5b0..5aa25e0d 100644
--- a/include/internal/catch_notimplemented_exception.h
+++ b/include/internal/catch_notimplemented_exception.h
@@ -1,14 +1,35 @@
-//
-//  catch_notimplemented_exception.h
-//  CatchSelfTest
-//
-//  Created by Phil Nash on 05/08/2012.
-//
-//
+/*
+ *  Created by Phil on 5/8/2012.
+ *  Copyright 2012 Two Blue Cubes Ltd. All rights reserved.
+ *
+ *  Distributed under the Boost Software License, Version 1.0. (See accompanying
+ *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+#ifndef TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_H_INCLUDED
+#define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_H_INCLUDED
 
-#ifndef CatchSelfTest_catch_notimplemented_exception_h
-#define CatchSelfTest_catch_notimplemented_exception_h
+#include "catch_common.h"
+#include <ostream>
 
+namespace Catch {
 
+    class NotImplementedException : public std::exception
+    {
+    public:
+        NotImplementedException( const SourceLineInfo& lineInfo );
 
-#endif
+        virtual ~NotImplementedException() throw() {}
+
+        virtual const char* what() const throw();
+
+    private:
+        std::string m_what;
+        SourceLineInfo m_lineInfo;
+    };
+
+} // end namespace Catch
+
+///////////////////////////////////////////////////////////////////////////////
+#define CATCH_NOT_IMPLEMENTED throw Catch::NotImplementedException( CATCH_INTERNAL_LINEINFO )
+
+#endif // TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_H_INCLUDED
diff --git a/include/internal/catch_notimplemented_exception.hpp b/include/internal/catch_notimplemented_exception.hpp
index 485ab45d..d819cc49 100644
--- a/include/internal/catch_notimplemented_exception.hpp
+++ b/include/internal/catch_notimplemented_exception.hpp
@@ -1,14 +1,32 @@
-//
-//  catch_notimplemented_exception.hpp
-//  CatchSelfTest
-//
-//  Created by Phil Nash on 05/08/2012.
-//
-//
+/*
+ *  Created by Phil on 5/8/2012.
+ *  Copyright 2012 Two Blue Cubes Ltd. All rights reserved.
+ *
+ *  Distributed under the Boost Software License, Version 1.0. (See accompanying
+ *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+#ifndef TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_HPP_INCLUDED
+#define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_HPP_INCLUDED
 
-#ifndef CatchSelfTest_catch_notimplemented_exception_hpp
-#define CatchSelfTest_catch_notimplemented_exception_hpp
+#include "catch_notimplemented_exception.h"
+#include <ostream>
 
+namespace Catch {
 
+    NotImplementedException::NotImplementedException( const SourceLineInfo& lineInfo )
+    :   m_lineInfo( lineInfo ) {
+        std::ostringstream oss;
+        oss << lineInfo << "function ";
+        if( !lineInfo.function.empty() )
+            oss << lineInfo.function << " ";
+        oss << "not implemented";
+        m_what = oss.str();
+    }
 
-#endif
+    const char* NotImplementedException::what() const throw() {
+        return m_what.c_str();
+    }
+    
+} // end namespace Catch
+
+#endif // TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_H_INCLUDED
diff --git a/include/internal/catch_objc.hpp b/include/internal/catch_objc.hpp
index d4709acf..843c891b 100644
--- a/include/internal/catch_objc.hpp
+++ b/include/internal/catch_objc.hpp
@@ -106,7 +106,7 @@ namespace Catch {
                         std::string name = Detail::getAnnotation( cls, "Name", testCaseName );
                         std::string desc = Detail::getAnnotation( cls, "Description", testCaseName );
                         
-                        getCurrentContext().getTestCaseRegistry().registerTest( TestCaseInfo( new OcMethod( cls, selector ), name.c_str(), desc.c_str(), SourceLineInfo() ) );
+                        getStaticRegisteries().registerTest( TestCaseInfo( new OcMethod( cls, selector ), name.c_str(), desc.c_str(), SourceLineInfo() ) );
                         noTestMethods++;
                     }
                 }
diff --git a/include/internal/catch_reporter_registrars.hpp b/include/internal/catch_reporter_registrars.hpp
index 033f433a..8d36827f 100644
--- a/include/internal/catch_reporter_registrars.hpp
+++ b/include/internal/catch_reporter_registrars.hpp
@@ -8,7 +8,7 @@
 #ifndef TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
 #define TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
 
-#include "catch_context.h"
+#include "catch_interfaces_static_registries.h"
 
 namespace Catch {    
 
@@ -29,7 +29,7 @@ namespace Catch {
     public:
 
         ReporterRegistrar( const std::string& name ) {
-            getCurrentContext().getReporterRegistry().registerReporter( name, new ReporterFactory() );
+            getStaticRegistries().registerReporter( name, new ReporterFactory() );
         }
     }; 
 }
diff --git a/include/internal/catch_runner_impl.hpp b/include/internal/catch_runner_impl.hpp
index 44ccab83..d4fc1fa6 100644
--- a/include/internal/catch_runner_impl.hpp
+++ b/include/internal/catch_runner_impl.hpp
@@ -80,7 +80,7 @@ namespace Catch {
         
         virtual void runAll( bool runHiddenTests = false ) {
             m_reporter->StartGroup( "" );
-            const std::vector<TestCaseInfo>& allTests = getCurrentContext().getTestCaseRegistry().getAllTests();
+            const std::vector<TestCaseInfo>& allTests = getStatics().getTestCaseRegistry().getAllTests();
             for( std::size_t i=0; i < allTests.size(); ++i ) {
                 if( runHiddenTests || !allTests[i].isHidden() ) {
                     if( aborting() ) {
@@ -100,7 +100,7 @@ namespace Catch {
 
             TestSpec testSpec( rawTestSpec );
             
-            const std::vector<TestCaseInfo>& allTests = getCurrentContext().getTestCaseRegistry().getAllTests();
+            const std::vector<TestCaseInfo>& allTests = getStatics().getTestCaseRegistry().getAllTests();
             std::size_t testsRun = 0;
             for( std::size_t i=0; i < allTests.size(); ++i ) {
                 if( testSpec.matches( allTests[i].getName() ) ) {
@@ -282,7 +282,7 @@ namespace Catch {
                 // This just means the test was aborted due to failure
             }
             catch(...) {
-                acceptMessage( getCurrentContext().getExceptionTranslatorRegistry().translateActiveException() );
+                acceptMessage( getStatics().getExceptionTranslatorRegistry().translateActiveException() );
                 acceptResult( ResultWas::ThrewException );
             }
             m_info.clear();
diff --git a/include/internal/catch_static_registries_impl.hpp b/include/internal/catch_static_registries_impl.hpp
index a2942681..fb8ec552 100644
--- a/include/internal/catch_static_registries_impl.hpp
+++ b/include/internal/catch_static_registries_impl.hpp
@@ -1,14 +1,73 @@
-//
-//  catch_static_registries.hpp
-//  CatchSelfTest
-//
-//  Created by Phil Nash on 05/08/2012.
-//
-//
+/*
+ *  Created by Phil on 5/8/2012.
+ *  Copyright 2012 Two Blue Cubes Ltd. All rights reserved.
+ *
+ *  Distributed under the Boost Software License, Version 1.0. (See accompanying
+ *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+#include "catch_interfaces_static_registries.h"
 
-#ifndef CatchSelfTest_catch_static_registries_hpp
-#define CatchSelfTest_catch_static_registries_hpp
+#include "catch_test_case_registry_impl.hpp"
+#include "catch_reporter_registry.hpp"
+#include "catch_exception_translator_registry.hpp"
 
+namespace Catch {
 
+    namespace {
+        
+        class StaticRegistries : public IStatics, public IStaticRegistries {
 
-#endif
+            StaticRegistries( const StaticRegistries& );
+            void operator=( const StaticRegistries& );
+
+        public: // IStatics
+            StaticRegistries() {
+            }
+            virtual const IReporterRegistry& getReporterRegistry() const {
+                return m_reporterRegistry;
+            }
+            virtual const ITestCaseRegistry& getTestCaseRegistry() const {
+                return m_testCaseRegistry;
+            }
+            virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() {
+                return m_exceptionTranslatorRegistry;
+            }
+
+        public: // IStaticRegistries
+            virtual void registerReporter( const std::string& name, IReporterFactory* factory ) {
+                m_reporterRegistry.registerReporter( name, factory );
+            }
+            virtual void registerTest( const TestCaseInfo& testInfo ) {
+                m_testCaseRegistry.registerTest( testInfo );
+            }
+            virtual void registerTranslator( const IExceptionTranslator* translator ) {
+                m_exceptionTranslatorRegistry.registerTranslator( translator );
+            }
+
+        private:
+            TestRegistry m_testCaseRegistry;
+            ReporterRegistry m_reporterRegistry;
+            ExceptionTranslatorRegistry m_exceptionTranslatorRegistry;
+        };
+
+        inline StaticRegistries*& getTheStaticRegistries() {
+            static StaticRegistries* registries = NULL;
+            if( !registries )
+                registries = new StaticRegistries();
+            return registries;
+        }
+    }
+
+    IStatics& getStatics() {
+        return *getTheStaticRegistries();
+    }
+    IStaticRegistries& getStaticRegistries() {
+        return *getTheStaticRegistries();
+    }
+    void cleanUp() {
+        delete getTheStaticRegistries();
+        getTheStaticRegistries() = NULL;
+        Context::cleanUp();
+    }
+
+} // end namespace Catch
diff --git a/include/internal/catch_test_case_registry_impl.hpp b/include/internal/catch_test_case_registry_impl.hpp
index cd0e0f16..2c22d237 100644
--- a/include/internal/catch_test_case_registry_impl.hpp
+++ b/include/internal/catch_test_case_registry_impl.hpp
@@ -44,7 +44,7 @@ namespace Catch {
             return m_functionsInOrder;
         }
 
-        virtual std::vector<TestCaseInfo> getMatchingTestCases( const std::string& rawTestSpec ) {
+        virtual std::vector<TestCaseInfo> getMatchingTestCases( const std::string& rawTestSpec ) const {
             TestSpec testSpec( rawTestSpec );
             
             std::vector<TestCaseInfo> testList;
@@ -109,7 +109,7 @@ namespace Catch {
                                     const char* name, 
                                     const char* description,
                                     const SourceLineInfo& lineInfo ) {
-        getCurrentContext().getTestCaseRegistry().registerTest( TestCaseInfo( testCase, name, description, lineInfo ) );
+        getStaticRegistries().registerTest( TestCaseInfo( testCase, name, description, lineInfo ) );
     }
     
 } // end namespace Catch
diff --git a/projects/SelfTest/catch_self_test.hpp b/projects/SelfTest/catch_self_test.hpp
index 9d37e833..40ed50d1 100644
--- a/projects/SelfTest/catch_self_test.hpp
+++ b/projects/SelfTest/catch_self_test.hpp
@@ -9,6 +9,7 @@
 #define TWOBLUECUBES_CATCH_SELF_TEST_HPP_INCLUDED
 
 #include "catch.hpp"
+#include "catch_interfaces_static_registries.h"
 
 #include "set"
 
@@ -145,7 +146,7 @@ namespace Catch {
         
         static void runMatching(    const std::string& testSpec, 
                                     Expected::Result expectedResult ) {
-            forEach(    getCurrentContext().getTestCaseRegistry().getMatchingTestCases( testSpec ), 
+            forEach(    getStatics().getTestCaseRegistry().getMatchingTestCases( testSpec ), 
                         MetaTestRunner( expectedResult ) );
         }
         
diff --git a/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj b/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj
index a3f0aeb0..4026fdb0 100644
--- a/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj
+++ b/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj
@@ -35,6 +35,11 @@
 
 /* Begin PBXFileReference section */
 		4A3D7DD01503869D005F9203 /* catch_matchers.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_matchers.hpp; sourceTree = "<group>"; };
+		4A4B0F9715CE6CFB00AE2392 /* catch_static_registries_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_static_registries_impl.hpp; sourceTree = "<group>"; };
+		4A4B0F9915CE6EC100AE2392 /* catch_interfaces_static_registries.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_static_registries.h; sourceTree = "<group>"; };
+		4A4B0F9A15CEF84800AE2392 /* catch_notimplemented_exception.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_notimplemented_exception.h; sourceTree = "<group>"; };
+		4A4B0F9B15CEF8C400AE2392 /* catch_notimplemented_exception.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_notimplemented_exception.hpp; sourceTree = "<group>"; };
+		4A4B0F9C15CEFA8300AE2392 /* catch_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_impl.hpp; sourceTree = "<group>"; };
 		4A6D0C20149B3D3B00DB3EAA /* CatchSelfTest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = CatchSelfTest; sourceTree = BUILT_PRODUCTS_DIR; };
 		4A6D0C26149B3D3B00DB3EAA /* CatchSelfTest.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = CatchSelfTest.1; sourceTree = "<group>"; };
 		4A6D0C2D149B3D9E00DB3EAA /* ApproxTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ApproxTests.cpp; path = ../../../SelfTest/ApproxTests.cpp; sourceTree = "<group>"; };
@@ -196,11 +201,14 @@
 		4AC91CB4155B9EBF00DC5117 /* impl */ = {
 			isa = PBXGroup;
 			children = (
+				4A4B0F9715CE6CFB00AE2392 /* catch_static_registries_impl.hpp */,
 				4A6D0C50149B3E3D00DB3EAA /* catch_generators_impl.hpp */,
 				4A6D0C52149B3E3D00DB3EAA /* catch_context_impl.hpp */,
 				4A6D0C5E149B3E3D00DB3EAA /* catch_runner_impl.hpp */,
 				4A6D0C62149B3E3D00DB3EAA /* catch_test_case_registry_impl.hpp */,
 				4AB1C73514F97BDA00F31DF7 /* catch_console_colour_impl.hpp */,
+				4A4B0F9B15CEF8C400AE2392 /* catch_notimplemented_exception.hpp */,
+				4A4B0F9C15CEFA8300AE2392 /* catch_impl.hpp */,
 			);
 			name = impl;
 			sourceTree = "<group>";
@@ -220,6 +228,7 @@
 				4A6D0C47149B3E3D00DB3EAA /* catch_capture.hpp */,
 				4AC91CCE155CF02800DC5117 /* catch_expression.hpp */,
 				4AC91CD0155D8DA600DC5117 /* catch_expression_builder.hpp */,
+				4A4B0F9A15CEF84800AE2392 /* catch_notimplemented_exception.h */,
 			);
 			name = Assertions;
 			sourceTree = "<group>";
@@ -261,6 +270,7 @@
 		4AC91CC1155C387400DC5117 /* Interfaces */ = {
 			isa = PBXGroup;
 			children = (
+				4A4B0F9915CE6EC100AE2392 /* catch_interfaces_static_registries.h */,
 				4A6D0C53149B3E3D00DB3EAA /* catch_interfaces_capture.h */,
 				4A6D0C54149B3E3D00DB3EAA /* catch_interfaces_exception.h */,
 				4A6D0C55149B3E3D00DB3EAA /* catch_interfaces_reporter.h */,