Permalink
Browse files

Switched .autotest to new API.

       Split out lib/ruby_parser_extras.rb so lexer is standalone.
       Added lexer tests for &, &&, &&=, &=, |, |=, ||, ||=, +@, +, +=, -@, -, -=, .., ..., ., ?a, ), ?\M-\C-a, ], floats, }, ::, /, /=, /regexp/, ^, ^=, ",", ~, ~@, %, %=, >=, >>, >>=, >, a?b:c, (, [, def [], def []=, {, =>, !, !=, !~, # comments, =begin coments, consts, ;, =, ==, ===, $_, identifiers, 42, 4_2, 0x2a, 0d42, 052, 0b101010, 1e10, *, **, **=, *=, and probably more.

[git-p4: depot-paths = "//src/ruby_parser/dev/": change = 3805]
  • Loading branch information...
1 parent 2749468 commit 864444855f03fdcbeeb66b888586d48a6428c686 @zenspider zenspider committed Feb 3, 2008
Showing with 1,528 additions and 1,152 deletions.
  1. +11 −1 .autotest
  2. +27 −5 Rakefile
  3. +8 −915 lib/ruby_lexer.rb
  4. +903 −0 lib/ruby_parser_extras.rb
  5. +402 −231 test/test_ruby_lexer.rb
  6. +177 −0 test/test_ruby_parser_extras.rb
View
@@ -3,7 +3,9 @@
Autotest.add_hook :initialize do |at|
at.extra_files << "../../ParseTree/dev/test/pt_testcase.rb"
at.libs << ":../../ParseTree/dev/lib:../../ParseTree/dev/test"
- at.exceptions << 'unit'
+ at.add_exception 'unit'
+ at.add_exception 'coverage'
+ at.add_exception 'coverage.info'
at.unit_diff = "unit_diff -u -b"
@@ -14,8 +16,16 @@ Autotest.add_hook :initialize do |at|
at.add_mapping(/pt_testcase.rb/) do |f, _|
at.files_matching(/^test.*rb$/)
end
+
+ %w(TestEnvironment TestStackState).each do |klass|
+ at.extra_class_map[klass] = "test/test_ruby_parser_extras.rb"
+ end
end
Autotest.add_hook :run_command do |at|
system "rake parser"
end
+
+Autotest.add_hook :all_good do |at|
+ system "rake rcov_info PATTERN=test/test_ruby_lexer.rb"
+end
View
@@ -2,7 +2,7 @@
require 'rubygems'
require 'hoe'
-require './lib/ruby_lexer.rb'
+require './lib/ruby_parser_extras.rb'
hoe = Hoe.new('ruby_parser', RubyParser::VERSION) do |p|
p.rubyforge_name = 'parsetree'
@@ -48,9 +48,31 @@ task :clean do
Dir["lib/*.output"])
end
-# require 'rcov/rcovtask'
-# Rcov::RcovTask.new do |t|
-# t.test_files = FileList['test/test_ruby_lexer.rb']
-# end
+begin
+ require 'rcov/rcovtask'
+ Rcov::RcovTask.new do |t|
+ pattern = ENV['PATTERN'] || 'test/test_ruby_*.rb'
+
+ t.test_files = FileList[pattern]
+ t.verbose = true
+ t.rcov_opts << "--threshold 80"
+ t.rcov_opts << "--no-color"
+ end
+rescue LoadError
+ # skip
+end
+
+task :rcov_info => :parser do
+ pattern = ENV['PATTERN'] || "test/test_*.rb"
+ ruby "-Ilib -S rcov --text-report --save coverage.info #{pattern}"
+end
+
+task :rcov_overlay do
+ rcov, eol = Marshal.load(File.read("coverage.info")).last[ENV["FILE"]], 1
+ puts rcov[:lines].zip(rcov[:coverage]).map { |line, coverage|
+ bol, eol = eol, eol + line.length
+ [bol, eol, "#ffcccc"] unless coverage
+ }.compact.inspect
+end
# vim: syntax=Ruby
Oops, something went wrong.

0 comments on commit 8644448

Please sign in to comment.