Ticket/InsdepUI/plugin/highlight-9.9.0/test/api/number.js

(完整代码) 890B

'use strict';

let _       = require('lodash');
let hljs    = require('../../build');
let utility = require('../utility');

const pattern      = new RegExp(`${hljs.NUMBER_RE}$`);
let numberToString = utility.numberToString;

describe('.NUMBER_RE', function() {
  it('should match regular numbers and decimals', function() {
    const number        = _.map(_.range(0, 1001), numberToString);
    const decimal       = _.map(_.range(0, 1.001, 0.001), numberToString);
    const noLeadingZero = ['.1234', '.5206', '.0002', '.9998'];

    const numbers = [].concat(number, decimal, noLeadingZero);

    numbers.should.matchEach(pattern);
  });

  it('should not match hex or binary numbers', function() {
    const numbers = [ '0xbada55', '0xfa1755', '0x45362e'
                    , '0b0101'  , '0b1100'  , '0b1001'
                    ];

    numbers.should.not.matchEach(pattern);
  });
});

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。