Sha256: 78f425b1e254cbff9bc4c93379875bebccd7c1530338cea394aea5a2777a375a

Contents?: true

Size: 1.04 KB

Versions: 34

Compression:

Stored size: 1.04 KB

Contents

# encoding: UTF-8

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

require 'spec_helper'

include TwitterCldr::Parsers

describe UnicodeRegexParser::Literal do
  describe "#to_set" do
    it "should return literal characters as codepoints" do
      literal = UnicodeRegexParser::Literal.new("a")
      expect(literal.to_set.to_a(true)).to eq([97])
    end

    it "should return escaped characters with no special meaning as codepoints" do
      literal = UnicodeRegexParser::Literal.new("\\a")
      expect(literal.to_set.to_a(true)).to eq([97])
    end

    it "should convert special regex switches to their range equivalents" do
      literal = UnicodeRegexParser::Literal.new("\\d")  # digit
      expect(literal.to_set.to_a(true)).to eq([48..57])
    end

    it "should convert negated special regex switches to their range equivalents" do
      literal = UnicodeRegexParser::Literal.new("\\D")  # NOT digit
      expect(literal.to_set.to_a(true)).to eq([
        0..1, 8..47, 58..55295, 57344..1114111
      ])
    end
  end
end

Version data entries

34 entries across 34 versions & 3 rubygems

Version Path
twitter_cldr-3.2.1 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-3.2.0 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-3.1.2 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-3.1.1 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-3.1.0 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-3.0.10 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-3.0.9 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-3.0.8 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-3.0.7 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-3.0.6 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-3.0.5 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-3.0.4 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-3.0.3 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-3.0.2 spec/parsers/unicode_regex/literal_spec.rb