aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarco Poletti <poletti.marco@gmail.com>2018-03-04 10:50:42 +0000
committerMarco Poletti <poletti.marco@gmail.com>2018-03-04 10:50:42 +0000
commitd81f3dc4b93b1a7e883fbf1c2c8bab8143ed6994 (patch)
treef239c52dbbc709a9f85f6575dd20fe370217aff5 /tests
parent567a17e8603f4ba27231ba50bc06f05eefec8fe0 (diff)
downloadgoogle-fruit-d81f3dc4b93b1a7e883fbf1c2c8bab8143ed6994.tar.gz
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_eager_injection.py34
1 files changed, 33 insertions, 1 deletions
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<X> getComponent() {
+ return fruit::createComponent()
+ .addMultibindingProvider([](){return new Y();})
+ .registerConstructor<Z()>();
+ }
+
+ int main() {
+
+ fruit::Injector<X> 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<X>.
+ Assert(!Z::constructed);
+
+ return 0;
+ }
+ '''
+ expect_generic_compile_error(
+ 'deprecation|deprecated',
+ COMMON_DEFINITIONS,
+ source)
+
def test_eager_injection():
source = '''
fruit::Component<X> 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__)