binaryNumber.js 702 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. let hljs = require('../../build');
  3. const pattern = new RegExp(`${hljs.BINARY_NUMBER_RE}$`);
  4. describe('.BINARY_NUMBER_RE', function() {
  5. it('should match binary numbers', function() {
  6. const numbers = [ '0b0101', '0b1100', '0b1001'
  7. , '0b11110101', '0b11001111'
  8. , '0b1010111111000001'
  9. ];
  10. numbers.should.matchEach(pattern);
  11. });
  12. it('should not match binary numbers greater than 2', function() {
  13. const numbers = [ '0b2101', '0b1130', '0b1041'
  14. , '0b11150101', '0b11061111'
  15. , '0b1010111117000001'
  16. ];
  17. numbers.should.not.matchEach(pattern);
  18. });
  19. });