Sha256: f364872782552bc76a902afedf84730bc0735e7b43239cb4ad055c31dd7b0ea1

Contents?: true

Size: 1.84 KB

Versions: 11

Compression:

Stored size: 1.84 KB

Contents

# encoding: UTF-8

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

require 'spec_helper'

include TwitterCldr::Tokenizers

describe NumberTokenizer do
  describe "#full_path" do
    it "should fill in the type and return the full path to the requested format" do
      tokenizer = NumberTokenizer.new
      tokenizer.type = :default
      tokenizer.format = :default
      tokenizer.send(:full_path).should == [:numbers, :formats, :decimal, :patterns, :default]
    end
  end

  describe "#tokens" do
    it "gets tokens for a latin language (i.e. Portuguese)" do
      tokenizer = NumberTokenizer.new(:locale => :pt)
      got = tokenizer.tokens
      expected = [{ :value => "", :type => :pattern },
                  { :value => "#,##0.###", :type => :pattern }]
      check_token_list(got, expected)
    end

    it "gets tokens for a non-latin language (i.e. Russian)" do
      tokenizer = NumberTokenizer.new(:locale => :ru)
      got = tokenizer.tokens
      expected = [{ :value => "", :type => :pattern },
                  { :value => "#,##0.###", :type => :pattern }]
      check_token_list(got, expected)
    end

    it "correctly parses suffixes (i.e. Russian currency)" do
      tokenizer = NumberTokenizer.new(:locale => :ru)
      got = tokenizer.tokens(:type => :currency)
      expected = [{ :value => "", :type => :pattern },
                  { :value => "#,##0.00", :type => :pattern },
                  { :value => " ¤", :type => :pattern }]
      check_token_list(got, expected)
    end

    it "correctly parses prefixes (i.e. Italian currency)" do
      tokenizer = NumberTokenizer.new(:locale => :it)
      got = tokenizer.tokens(:type => :currency)
      expected = [{ :value => "¤ ", :type => :pattern },
                  { :value => "#,##0.00", :type => :pattern }]
      check_token_list(got, expected)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
twitter_cldr-2.4.3 spec/tokenizers/numbers/number_tokenizer_spec.rb
twitter_cldr-3.0.0.beta1 spec/tokenizers/numbers/number_tokenizer_spec.rb
twitter_cldr-2.4.2 spec/tokenizers/numbers/number_tokenizer_spec.rb
twitter_cldr-2.4.1 spec/tokenizers/numbers/number_tokenizer_spec.rb
twitter_cldr-2.4.0 spec/tokenizers/numbers/number_tokenizer_spec.rb
twitter_cldr-2.2.0 spec/tokenizers/numbers/number_tokenizer_spec.rb
twitter_cldr-2.1.1 spec/tokenizers/numbers/number_tokenizer_spec.rb
twitter_cldr-2.1.0 spec/tokenizers/numbers/number_tokenizer_spec.rb
twitter_cldr-2.0.2 spec/tokenizers/numbers/number_tokenizer_spec.rb
twitter_cldr-2.0.1 spec/tokenizers/numbers/number_tokenizer_spec.rb
twitter_cldr-2.0.0 spec/tokenizers/numbers/number_tokenizer_spec.rb