Sha256: 36b84bd71770004cd4997f88769e66edfac5ef84519fb25956af1ca578654c11

Contents?: true

Size: 1.43 KB

Versions: 4

Compression:

Stored size: 1.43 KB

Contents

// Copyright 2012 Twitter, Inc
// http://www.apache.org/licenses/LICENSE-2.0

var TwitterCldr = require('../../../../lib/assets/javascripts/twitter_cldr/core.js');
var data = require('../../../../lib/assets/javascripts/twitter_cldr/en.js');

describe("Literal", function() {
  beforeEach(function() {
    TwitterCldr.set_data(data);
  });

  describe("#to_set", function() {
    it("should set an array of tokens", function() {
      var literal = new TwitterCldr.Literal ("a");
      expect(literal.to_set().to_array(true)).toEqual([97]);
    });
    it("should return escaped characters with no special meaning as codepoints", function() {
      var literal = new TwitterCldr.Literal ("\\a");
      expect(literal.to_set().to_array(true)).toEqual([97]);
    });
    it("should convert special regex switches to their range equivalents", function() {
      var literal = new TwitterCldr.Literal ("\\d"); // digit
      expect(literal.to_set()).toEqualRangeSet(new TwitterCldr.RangeSet([new TwitterCldr.Range(48,57)]));
    });
    it("should convert negated special regex switches to their range equivalents", function() {
      var literal = new TwitterCldr.Literal ("\\D"); // NOT digit
      expect(literal.to_set()).toEqualRangeSet(new TwitterCldr.RangeSet([
        new TwitterCldr.Range(0, 1),
        new TwitterCldr.Range(8, 47),
        new TwitterCldr.Range(58, 55295),
        new TwitterCldr.Range(57344, 65535),//1114111),
      ]));
    });
  });
});

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
twitter_cldr_js-3.3.0 spec/js/parsers/unicode_regex/literal.spec.js
twitter_cldr_js-3.2.0 spec/js/parsers/unicode_regex/literal.spec.js
twitter_cldr_js-3.1.1 spec/js/parsers/unicode_regex/literal.spec.js
twitter_cldr_js-3.1.0 spec/js/parsers/unicode_regex/literal.spec.js