Sha256: a86aa184a72c4c60919c2f74dde16cdfd9daa5cff7ed4d1cc30b142a2291bb73

Contents?: true

Size: 1.63 KB

Versions: 1

Compression:

Stored size: 1.63 KB

Contents

# encoding: utf-8
require 'jldrill/model/items/edict/GrammarType'

module JLDrill

	describe GrammarType do
	
	    it "should have a list of grammar markings" do
	        GrammarType.types.should_not be_nil
	        GrammarType.types.keys.size.should be(106)
	    end
	    
	    it "should be able to look up the types" do
	        GrammarType.exists?("fun").should be(false)
	        GrammarType.types.keys.each do |tag|
	            GrammarType.exists?(tag).should be(true)
	        end
	    end
	    
	    it "should be able to look up the special language tags" do
	        GrammarType.exists?("fr:").should be(true)
	    end
	    
	    it "should be able to parse a string of types" do
	        string = "(n)"
	        types = GrammarType.create(string)
	        types.size.should be(1)
	        types[0].should be_eql("n")

	        string = "(n,P)"
	        types = GrammarType.create(string)
	        types.size.should be(2)
	        types[0].should be_eql("n")
	        types[1].should be_eql("P")
	    end
	    
	    it "should be able to reject non-types" do
	        string = "(usually)"
	        types = GrammarType.create(string)
	        types.size.should be(0)
	    end

#       For profiling.  Want to make sure 100000 can be done in less than 3 sec	    
#	    it "should be fast" do
#	        startTime = Time::now
#	        0.upto(1000) do
#    	        GrammarType.types.keys.each do |tag|
#    	            GrammarType.create("(" + tag + ")")
#    	        end
#	        end
#	        endTime = Time::now
#	        duration = endTime - startTime
#	        print duration.to_s + "\n"
#	        (duration < 3.0).should be(true)
#        end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jldrill-0.6.0.1 spec/jldrill/model/Edict/GrammarType_spec.rb