Sha256: 049e8db976052ebeca4f6f74f47faf70f455bf60de457b7b89e66230e0d47e62

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

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.5.1.7 spec/jldrill/model/Edict/GrammarType_spec.rb