@@ -611,3 +611,55 @@ tape( 'the function compares a function and a corresponding return annotation',
611611 return x ;
612612 }
613613} ) ;
614+
615+ tape ( 'the function detects a mismatch when an actual array element is a primitive and the expected array element is an array' , function test ( t ) {
616+ var expected ;
617+ var actual ;
618+ var msg ;
619+
620+ actual = [ 300 , 700 ] ;
621+ expected = '[[ 300, 700 ]]' ;
622+ msg = 'Displayed return value is `[[ 300, 700 ]]`, but expected `[ 300, 700 ]` instead' ;
623+ t . strictEqual ( compareValues ( actual , expected ) , msg , 'returns expected message' ) ;
624+
625+ t . end ( ) ;
626+ } ) ;
627+
628+ tape ( 'the function detects a mismatch when an actual array element is a primitive and the expected array element is an object' , function test ( t ) {
629+ var expected ;
630+ var actual ;
631+ var msg ;
632+
633+ actual = [ 1 ] ;
634+ expected = '[ {} ]' ;
635+ msg = 'Displayed return value is `[ {} ]`, but expected `[ 1 ]` instead' ;
636+ t . strictEqual ( compareValues ( actual , expected ) , msg , 'returns expected message' ) ;
637+
638+ t . end ( ) ;
639+ } ) ;
640+
641+ tape ( 'the function detects a mismatch when an actual array element is a primitive and the expected array element is a RegExp' , function test ( t ) {
642+ var expected ;
643+ var actual ;
644+ var msg ;
645+
646+ actual = [ 1 ] ;
647+ expected = '[ /abc/ ]' ;
648+ msg = 'Displayed return value is `[ /abc/ ]`, but expected `[ 1 ]` instead' ;
649+ t . strictEqual ( compareValues ( actual , expected ) , msg , 'returns expected message' ) ;
650+
651+ t . end ( ) ;
652+ } ) ;
653+
654+ tape ( 'the function detects a mismatch in a mixed array where a primitive corresponds to an array' , function test ( t ) {
655+ var expected ;
656+ var actual ;
657+ var msg ;
658+
659+ actual = [ 1 , 2 ] ;
660+ expected = '[ 1, [ 2 ] ]' ;
661+ msg = 'Displayed return value is `[ 1, [ 2 ] ]`, but expected `[ 1, 2 ]` instead' ;
662+ t . strictEqual ( compareValues ( actual , expected ) , msg , 'returns expected message' ) ;
663+
664+ t . end ( ) ;
665+ } ) ;
0 commit comments