File tree 2 files changed +33
-1
lines changed
2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 8
8
"test:aliases" : " mocha tests/aliases-test.js" ,
9
9
"test:languages" : " mocha tests/run.js" ,
10
10
"test:plugins" : " mocha tests/plugins/**/*.js" ,
11
+ "test:regex" : " mocha tests/regex-tests.js" ,
11
12
"test:runner" : " mocha tests/testrunner-tests.js" ,
12
- "test" : " npm run test:runner && npm run test:languages && npm run test:plugins && npm run test:aliases"
13
+ "test" : " npm run test:runner && npm run test:languages && npm run test:plugins && npm run test:aliases && npm run test:regex "
13
14
},
14
15
"repository" : {
15
16
"type" : " git" ,
Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+
3
+ const { assert } = require ( "chai" ) ;
4
+ const PrismLoader = require ( './helper/prism-loader' ) ;
5
+ const { languages } = require ( '../components' ) ;
6
+
7
+ for ( const lang in languages ) {
8
+ if ( lang === 'meta' ) {
9
+ continue ;
10
+ }
11
+
12
+ describe ( `Testing regular expressions of '${ lang } '` , function ( ) {
13
+
14
+ const Prism = PrismLoader . createInstance ( lang ) ;
15
+
16
+ it ( '- should not match the empty string' , function ( ) {
17
+ let lastToken = '<unknown>' ;
18
+
19
+ Prism . languages . DFS ( Prism . languages , function ( name , value ) {
20
+ if ( typeof this === 'object' && ! Array . isArray ( this ) && name !== 'pattern' ) {
21
+ lastToken = name ;
22
+ }
23
+
24
+ if ( Prism . util . type ( value ) === 'RegExp' ) {
25
+ assert . notMatch ( '' , value , `Token '${ lastToken } ': ${ value } should not match the empty string.` ) ;
26
+ }
27
+ } ) ;
28
+
29
+ } ) ;
30
+ } ) ;
31
+ }
You can’t perform that action at this time.
0 commit comments