underscoreIdent.js 887 B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. let hljs = require('../../build');
  3. const pattern = new RegExp(`^${hljs.UNDERSCORE_IDENT_RE}$`);
  4. describe('.UNDERSCORE_IDENT_RE', function() {
  5. it('should match any word starting without numbers', function() {
  6. const words = [ 'foo' , 'bar' , 'baz'
  7. , 'Foo' , 'Bar' , 'Baz'
  8. , '_foo' , '_bar' , '_baz'
  9. , '_Foo' , '_Bar' , '_Baz'
  10. , '_f_oo', '_ba_r', '_baz_'
  11. , '_F_oo', '_Ba_r', '_Baz_'
  12. ];
  13. words.should.matchEach(pattern);
  14. });
  15. it('should not match any word starting with numbers', function() {
  16. const words = [ '1foo' , '6bar' , '0baz'
  17. , '2Foo' , '7Bar' , '1Baz'
  18. , '3f_oo', '8ba_r', '2baz_'
  19. , '4F_oo', '9Ba_r', '3Baz_'
  20. ];
  21. words.should.not.matchEach(pattern);
  22. });
  23. });