Sha256: 6196e50cbb339f9c54bfe7097f354a7ef601937d5eff00b02a7af0e36d1135e9

Contents?: true

Size: 938 Bytes

Versions: 27

Compression:

Stored size: 938 Bytes

Contents

# encoding: UTF-8

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

require 'spec_helper'

describe TwitterCldr::Parsers::UnicodeRegexParser::CharacterRange do
  let(:tokenizer) { TwitterCldr::Tokenizers::UnicodeRegexTokenizer.new }
  let(:parser) { TwitterCldr::Parsers::UnicodeRegexParser.new }

  def tokenize(str)
    tokenizer.tokenize(str)
  end

  def parse(tokens, options = {})
    parser.parse(tokens, options)
  end

  def char_range_from(elements)
    elements.first
  end

  describe "#to_set" do
    it "should return a range between the initial and the final values" do
      range = char_range_from(parse(tokenize("a-b")))
      expect(range.to_set.to_a(true)).to eq([97..98])
    end
  end

  describe "#codepoints" do
    it "lists all the codepoints in the range" do
      range = char_range_from(parse(tokenize("a-z")))
      expect(range.codepoints).to eq((97..122).to_a)
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
twitter_cldr-6.0.1 spec/parsers/unicode_regex/character_range_spec.rb
twitter_cldr-6.0.0 spec/parsers/unicode_regex/character_range_spec.rb
twitter_cldr-5.4.0 spec/parsers/unicode_regex/character_range_spec.rb
twitter_cldr-5.3.0 spec/parsers/unicode_regex/character_range_spec.rb
twitter_cldr-5.2.0 spec/parsers/unicode_regex/character_range_spec.rb
twitter_cldr-5.1.0 spec/parsers/unicode_regex/character_range_spec.rb
twitter_cldr-5.0.0 spec/parsers/unicode_regex/character_range_spec.rb