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
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/twitter_cldr-4.4.5/spec/parsers/unicode_regex/literal_spec.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/twitter_cldr-4.4.5/spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-4.4.5 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-4.4.4 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-4.4.3 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-4.4.2 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-4.4.1 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-4.4.0 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-4.3.1 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-4.3.0 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-4.2.0 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-4.1.0 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-4.0.0 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-3.6.0 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-3.5.0 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-3.4.0 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-3.3.0 spec/parsers/unicode_regex/literal_spec.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/twitter_cldr-3.2.1/spec/parsers/unicode_regex/literal_spec.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/twitter_cldr-3.2.1/spec/parsers/unicode_regex/literal_spec.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/twitter_cldr-3.1.2/spec/parsers/unicode_regex/literal_spec.rb