From d81f3dc4b93b1a7e883fbf1c2c8bab8143ed6994 Mon Sep 17 00:00:00 2001 From: Marco Poletti Date: Sun, 4 Mar 2018 10:50:42 +0000 Subject: Make Fruit injectors accessible concurrently from multiple threads. This commit is probably backwards-incompatible on some platforms (e.g. OS X), so I expect CI errors in some configurations. I'll add a CMake flag to allow switching this off in a separate commit. --- tests/test_eager_injection.py | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test_eager_injection.py b/tests/test_eager_injection.py index 4812039..60a914b 100644 --- a/tests/test_eager_injection.py +++ b/tests/test_eager_injection.py @@ -52,6 +52,37 @@ COMMON_DEFINITIONS = ''' bool Z::constructed = false; ''' +def test_eager_injection_deprecated(): + source = ''' + fruit::Component getComponent() { + return fruit::createComponent() + .addMultibindingProvider([](){return new Y();}) + .registerConstructor(); + } + + int main() { + + fruit::Injector injector(getComponent); + + Assert(!X::constructed); + Assert(!Y::constructed); + Assert(!Z::constructed); + + injector.eagerlyInjectAll(); + + Assert(X::constructed); + Assert(Y::constructed); + // Z still not constructed, it's not reachable from Injector. + Assert(!Z::constructed); + + return 0; + } + ''' + expect_generic_compile_error( + 'deprecation|deprecated', + COMMON_DEFINITIONS, + source) + def test_eager_injection(): source = ''' fruit::Component getComponent() { @@ -81,7 +112,8 @@ def test_eager_injection(): expect_success( COMMON_DEFINITIONS, source, - locals()) + locals(), + ignore_deprecation_warnings=True) if __name__== '__main__': main(__file__) -- cgit v1.2.3