@@ -709,48 +709,75 @@ Assertion.addProperty('callable', function () {
709
709
}
710
710
} ) ;
711
711
712
+ /**
713
+ * @todo
714
+ */
712
715
Assertion . addProperty ( 'asyncFunction' , function ( ) {
713
716
const val = flag ( this , 'object' )
714
717
const ssfi = flag ( this , 'ssfi' )
715
- const msg = `${ flag ( this , 'message' ) } : ` || ''
718
+ const message = flag ( this , 'message' )
719
+ const msg = message ? `${ message } : ` : ''
720
+ const negate = flag ( this , 'negate' ) ;
721
+
722
+ const assertionMessage = negate ?
723
+ `${ msg } expected ${ _ . inspect ( val ) } not to be a AsyncFunction` :
724
+ `${ msg } expected ${ _ . inspect ( val ) } to be a AsyncFunction` ;
725
+
726
+ const isAsyncCallable = [ 'AsyncFunction' , 'AsyncGeneratorFunction' ] . includes ( _ . type ( val ) ) ;
716
727
717
- if ( ! [ 'AsyncFunction' , 'AsyncGeneratorFunction' ] . includes ( _ . type ( val ) ) ) {
728
+ if ( ( isAsyncCallable && negate ) || ( ! isAsyncCallable && ! negate ) ) {
718
729
throw new AssertionError (
719
- msg + 'expected ' + _ . inspect ( val ) + ' to be a AsyncFunction' ,
730
+ assertionMessage ,
720
731
undefined ,
721
732
ssfi
722
733
) ;
723
734
}
724
735
} ) ;
725
736
726
737
/**
727
- * TODO
738
+ * @todo
728
739
*/
729
740
Assertion . addProperty ( 'generatorFunction' , function ( ) {
730
741
const val = flag ( this , 'object' )
731
742
const ssfi = flag ( this , 'ssfi' )
732
- const msg = `${ flag ( this , 'message' ) } : ` || ''
743
+ const message = flag ( this , 'message' )
744
+ const msg = message ? `${ message } : ` : ''
745
+ const negate = flag ( this , 'negate' ) ;
733
746
734
- if ( ! [ 'GeneratorFunction' , 'AsyncGeneratorFunction' ] . includes ( _ . type ( val ) ) ) {
747
+ const assertionMessage = negate ?
748
+ `${ msg } expected ${ _ . inspect ( val ) } not to be a GeneratorFunction` :
749
+ `${ msg } expected ${ _ . inspect ( val ) } to be a GeneratorFunction` ;
750
+
751
+ const isGeneratorCallable = [ 'GeneratorFunction' , 'AsyncGeneratorFunction' ] . includes ( _ . type ( val ) ) ;
752
+
753
+ if ( ( isGeneratorCallable && negate ) || ( ! isGeneratorCallable && ! negate ) ) {
735
754
throw new AssertionError (
736
- msg + 'expected ' + _ . inspect ( val ) + ' to be a GeneratorFunction' ,
755
+ assertionMessage ,
737
756
undefined ,
738
757
ssfi
739
758
) ;
740
759
}
741
760
} ) ;
742
761
743
762
/**
744
- * TODO
763
+ * @todo
745
764
*/
746
765
Assertion . addProperty ( 'asyncGeneratorFunction' , function ( ) {
747
766
const val = flag ( this , 'object' )
748
767
const ssfi = flag ( this , 'ssfi' )
749
- const msg = `${ flag ( this , 'message' ) } : ` || ''
768
+ const message = flag ( this , 'message' )
769
+ const msg = message ? `${ message } : ` : ''
770
+ const negate = flag ( this , 'negate' ) ;
771
+
772
+ const assertionMessage = negate ?
773
+ `${ msg } expected ${ _ . inspect ( val ) } not to be a AsyncGeneratorFunction` :
774
+ `${ msg } expected ${ _ . inspect ( val ) } to be a AsyncGeneratorFunction` ;
750
775
751
- if ( _ . type ( val ) !== 'AsyncGeneratorFunction' ) {
776
+ const isAsyncGeneratorCallable = _ . type ( val ) === 'AsyncGeneratorFunction' ;
777
+
778
+ if ( ( isAsyncGeneratorCallable && negate ) || ( ! isAsyncGeneratorCallable && ! negate ) ) {
752
779
throw new AssertionError (
753
- msg + 'expected ' + _ . inspect ( val ) + ' to be a AsyncGeneratorFunction' ,
780
+ assertionMessage ,
754
781
undefined ,
755
782
ssfi
756
783
) ;
0 commit comments