ident.js 756 B

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