~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to test/rdoc/test_rdoc_ruby_lex.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2011-09-24 19:16:17 UTC
  • mfrom: (1.1.8 upstream) (13.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20110924191617-o1qz4rcmqjot8zuy
Tags: 1.9.3~rc1-1
* New upstream release: 1.9.3 RC1.
  + Includes load.c fixes. Closes: #639959.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'rubygems'
 
2
require 'minitest/autorun'
 
3
require 'rdoc/rdoc'
 
4
require 'rdoc/ruby_lex'
 
5
 
 
6
class TestRubyLex < MiniTest::Unit::TestCase
 
7
  def test_unary_minus
 
8
    ruby_lex = RDoc::RubyLex.new("-1", nil)
 
9
    assert_equal("-1", ruby_lex.token.value)
 
10
 
 
11
    ruby_lex = RDoc::RubyLex.new("a[-2]", nil)
 
12
    2.times { ruby_lex.token } # skip "a" and "["
 
13
    assert_equal("-2", ruby_lex.token.value)
 
14
 
 
15
    ruby_lex = RDoc::RubyLex.new("a[0..-12]", nil)
 
16
    4.times { ruby_lex.token } # skip "a", "[", "0", and ".."
 
17
    assert_equal("-12", ruby_lex.token.value)
 
18
 
 
19
    ruby_lex = RDoc::RubyLex.new("0+-0.1", nil)
 
20
    2.times { ruby_lex.token } # skip "0" and "+"
 
21
    assert_equal("-0.1", ruby_lex.token.value)
 
22
  end
 
23
end