File tree 1 file changed +9
-1
lines changed
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 2
2
3
3
var test = require ( 'tape' ) ;
4
4
var isRegex = require ( './' ) ;
5
+ var hasToStringTag = typeof Symbol === 'function' && typeof Symbol . toStringTag === 'symbol' ;
5
6
6
7
test ( 'not regexes' , function ( t ) {
7
8
t . notOk ( isRegex ( ) , 'undefined is not regex' ) ;
@@ -16,9 +17,16 @@ test('not regexes', function (t) {
16
17
t . end ( ) ;
17
18
} ) ;
18
19
20
+ test ( '@@toStringTag' , { skip : ! hasToStringTag } , function ( t ) {
21
+ var regex = / a / g;
22
+ var fakeRegex = { valueOf : function ( ) { return regex ; } , toString : function ( ) { return String ( regex ) ; } } ;
23
+ fakeRegex [ Symbol . toStringTag ] = function ( ) { return 'RegExp' ; } ;
24
+ t . notOk ( isRegex ( fakeRegex ) , 'fake RegExp with @@toStringTag "RegExp" is not regex' ) ;
25
+ t . end ( ) ;
26
+ } ) ;
27
+
19
28
test ( 'regexes' , function ( t ) {
20
29
t . ok ( isRegex ( / a / g) , 'regex literal is regex' ) ;
21
30
t . ok ( isRegex ( new RegExp ( 'a' , 'g' ) ) , 'regex object is regex' ) ;
22
31
t . end ( ) ;
23
32
} ) ;
24
-
You can’t perform that action at this time.
0 commit comments