Sha256: f60ecd9ad00a85f6a77dbe3ee899ea3aed044e5141fe9ef6aeb0b0b8302bbccc

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 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")
      literal.to_set.to_a(true).should == [97]
    end

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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
twitter_cldr-3.0.1 spec/parsers/unicode_regex/literal_spec.rb
twitter_cldr-3.0.0 spec/parsers/unicode_regex/literal_spec.rb