Permalink
Browse files

Ensure singletonPattern and transientPattern are mutually exclusive

  • Loading branch information...
1 parent e51fa7f commit 4b6e5b75fccae0c503843e36b462e70bd5aa16ac @seancorfield committed Dec 11, 2012
Showing with 15 additions and 0 deletions.
  1. +5 −0 ioc.cfc
  2. +10 −0 tests/singletonPattern.cfc
View
@@ -527,6 +527,11 @@ component {
variables.transients[ transientFolder ] = true;
}
}
+
+ if ( structKeyExists( variables.config, 'singletonPattern' ) &&
+ structKeyExists( variables.config, 'transientPattern' ) ) {
+ throw 'singletonPattern and transientPattern are mutually exclusive';
+ }
variables.config.version = '0.4.1';
}
View
@@ -26,4 +26,14 @@ component extends="mxunit.framework.TestCase" {
instanceB = variables.factory.getBean( arguments.beanname );
assertNotSame( instanceA, instanceB );
}
+
+ function checkPatternsAreExclusive() {
+ try {
+ var bad = new ioc( '', { singletonPattern = '', transientPattern = '' } );
+ fail( 'Both arguments were allowed' );
+ } catch ( any e ) {
+ assertEquals( 'singletonPattern and transientPattern are mutually exclusive', e.message );
+ }
+ }
+
}

0 comments on commit 4b6e5b7

Please sign in to comment.