Home | History | Annotate | Download | only in unit
      1 #!/usr/bin/ruby
      2 # encoding: utf-8
      3 
      4 require 'antlr3'
      5 require 'test/unit'
      6 require 'spec'
      7 
      8 class TestDFA < Test::Unit::TestCase
      9   def setup
     10     @A = ANTLR3::Scope.new( :a, :b )
     11     @B = ANTLR3::Scope.new( 'count = 3' )
     12     @C = ANTLR3::Scope.new( 'a', 'b = 0', 'c = {}' )
     13   end
     14   
     15   def test_members
     16     @A.members.map( &:to_s ).should == %w( a b )
     17     @B.members.map( &:to_s ).should == %w( count )
     18     @C.members.map( &:to_s ).should == %w( a b c )
     19   end
     20   
     21   def test_defaults_without_arguments
     22     @A.new.to_a.should == [ nil, nil ]
     23     @B.new.to_a.should == [ 3 ]
     24     @C.new.to_a.should == [ nil, 0, {} ]
     25   end
     26   
     27   def test_C_defaults_with_arguments
     28     c = @C.new( Object )
     29     c.a.should == Object
     30     c.b.should == 0
     31     c.c.should == {}
     32   end
     33   
     34   def test_B_defaults_with_arguments
     35     b = @B.new( 7000 )
     36     b.count.should == 7000
     37   end
     38   
     39   def test_A_defaults_with_arguments
     40     a = @A.new( "apple", :orange )
     41     a.a.should == 'apple'
     42     a.b.should == :orange
     43   end
     44   
     45 end
     46