rcodetools 0.5.0.0 → 0.7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. data/CHANGES +14 -0
  2. data/README +63 -0
  3. data/README.TDC +158 -0
  4. data/README.ja +84 -0
  5. data/README.vim +11 -0
  6. data/Rakefile +15 -2
  7. data/THANKS +5 -0
  8. data/bin/rct-complete +4 -2
  9. data/bin/rct-doc +4 -2
  10. data/bin/rct-meth-args +1 -1
  11. data/bin/xmpfilter +7 -1
  12. data/icicles-rcodetools.el +2 -1
  13. data/lib/rcodetools/completion.rb +36 -18
  14. data/lib/rcodetools/doc.rb +3 -0
  15. data/lib/rcodetools/fork.rb +222 -0
  16. data/lib/rcodetools/fork_config.rb +26 -0
  17. data/lib/rcodetools/options.rb +34 -1
  18. data/lib/rcodetools/xmpfilter.rb +106 -18
  19. data/lib/rcodetools/xmptestunitfilter.rb +116 -55
  20. data/lib/ruby_toggle_file.rb +99 -0
  21. data/rcodetools.el +64 -9
  22. data/rcodetools.vim +41 -6
  23. data/test/data/completion_class_info-input.rb +1 -0
  24. data/test/data/completion_class_info-output.rb +10 -0
  25. data/test/data/completion_class_info_no_candidates-input.rb +1 -0
  26. data/test/data/completion_class_info_no_candidates-output.rb +1 -0
  27. data/test/data/completion_detect_rbtest-input.rb +7 -0
  28. data/test/data/completion_detect_rbtest-output.rb +2 -0
  29. data/test/data/completion_detect_rbtest2-input.rb +1 -0
  30. data/test/data/completion_detect_rbtest2-output.rb +2 -0
  31. data/test/data/completion_in_method-input.rb +3 -0
  32. data/test/data/completion_in_method-output.rb +1 -0
  33. data/test/data/completion_in_method-test.rb +6 -0
  34. data/test/data/completion_rbtest-input.rb +7 -0
  35. data/test/data/completion_rbtest-output.rb +2 -0
  36. data/test/data/doc_detect_rbtest-input.rb +1 -0
  37. data/test/data/doc_detect_rbtest-output.rb +1 -0
  38. data/test/data/doc_detect_rbtest2-input.rb +7 -0
  39. data/test/data/doc_detect_rbtest2-output.rb +1 -0
  40. data/test/data/doc_rbtest-input.rb +7 -0
  41. data/test/data/doc_rbtest-output.rb +1 -0
  42. data/test/data/rspec-input.rb +9 -9
  43. data/test/data/rspec-output.rb +21 -21
  44. data/test/data/rspec_poetry-input.rb +9 -9
  45. data/test/data/rspec_poetry-output.rb +21 -21
  46. data/test/data/sample_test_script.rb +9 -0
  47. data/test/data/unit_test_detect_rbtest-input.rb +50 -0
  48. data/test/data/unit_test_detect_rbtest-output.rb +52 -0
  49. data/test/data/unit_test_detect_rbtest2-input.rb +6 -0
  50. data/test/data/unit_test_detect_rbtest2-output.rb +6 -0
  51. data/test/data/unit_test_rbtest-input.rb +6 -0
  52. data/test/data/unit_test_rbtest-output.rb +6 -0
  53. data/test/test_completion.rb +37 -3
  54. data/test/test_doc.rb +2 -0
  55. data/test/test_functional.rb +75 -14
  56. data/test/test_options.rb +1 -0
  57. data/test/test_ruby_toggle_file.rb +125 -0
  58. data/test/test_run.rb +7 -3
  59. data/test/test_xmpfilter.rb +132 -5
  60. data/test/test_xmptestunitfilter.rb +1 -0
  61. metadata +76 -43
@@ -7,6 +7,9 @@ require 'rcodetools/options'
7
7
  require 'stringio'
8
8
 
9
9
  class TestRun < Test::Unit::TestCase
10
+ include Rcodetools
11
+ DIR = File.expand_path(File.dirname(__FILE__))
12
+
10
13
  tests = {
11
14
  :simple_annotation => {:klass => XMPFilter},
12
15
  :unit_test => {:klass => XMPTestUnitFilter},
@@ -20,6 +23,8 @@ class TestRun < Test::Unit::TestCase
20
23
  :completion => {:klass => XMPCompletionFilter, :lineno => 1},
21
24
  :completion_emacs => {:klass => XMPCompletionEmacsFilter, :lineno => 1},
22
25
  :completion_emacs_icicles => {:klass => XMPCompletionEmacsIciclesFilter, :lineno => 1},
26
+ :completion_class_info => {:klass => XMPCompletionClassInfoFilter, :lineno => 1},
27
+ :completion_class_info_no_candidates => {:klass => XMPCompletionClassInfoFilter, :lineno => 1},
23
28
 
24
29
  :doc => {:klass => XMPDocFilter, :lineno => 1},
25
30
  :refe => {:klass => XMPReFeFilter, :lineno => 1},
@@ -30,9 +35,8 @@ class TestRun < Test::Unit::TestCase
30
35
  }
31
36
  tests.each_pair do |test, opts|
32
37
  define_method("test_#{test}") do
33
- dir = File.expand_path(File.dirname(__FILE__))
34
- inputfile = "#{dir}/data/#{test}-input.rb"
35
- outputfile = "#{dir}/data/#{test}-output.rb"
38
+ inputfile = "#{DIR}/data/#{test}-input.rb"
39
+ outputfile = "#{DIR}/data/#{test}-output.rb"
36
40
  sio = StringIO.new
37
41
  sio.puts opts[:klass].run(File.read(inputfile), DEFAULT_OPTIONS.merge(opts))
38
42
  assert_equal(File.read(outputfile), sio.string)
@@ -1,12 +1,14 @@
1
1
 
2
2
  require 'test/unit'
3
- $: << ".." << "../lib[s]"
3
+ $: << ".." << "../lib"
4
4
  require "rcodetools/xmpfilter"
5
5
 
6
6
  class TestXMPFilter < Test::Unit::TestCase
7
+ include Rcodetools
7
8
  def setup
8
9
  @xmp = XMPFilter.new
9
10
  @marker = XMPFilter::MARKER
11
+ @testdir = File.dirname(__FILE__)
10
12
  end
11
13
 
12
14
  def test_extract_data
@@ -25,12 +27,137 @@ class TestXMPFilter < Test::Unit::TestCase
25
27
  assert_equal([[2, ["some exception"]]], data.exceptions.sort)
26
28
  assert_equal([[1, ["var", "var2"]], [4, ["var3"]]], data.bindings.sort)
27
29
  end
28
- end
29
30
 
30
- class TestXMPAddMarkers < Test::Unit::TestCase
31
-
31
+ def test_interpreter_command
32
+ xmp = XMPFilter.new(:interpreter=>"ruby", :detect_rct_fork => false)
33
+ assert_equal(%w[ruby -w], xmp.interpreter_command)
34
+ end
35
+
36
+ def test_interpreter_command_detect_rct_fork
37
+ begin
38
+ def Fork::run?() true end
39
+ xmp = XMPFilter.new(:interpreter=>"ruby", :detect_rct_fork => true)
40
+ assert_equal(%w[ruby -S rct-fork-client], xmp.interpreter_command)
41
+ ensure
42
+ def Fork::run?() false end
43
+ end
44
+ end
45
+
46
+ def test_interpreter_command_use_rbtest
47
+ xmp = XMPFilter.new(:interpreter=>"ruby", :use_rbtest => true)
48
+ assert_equal(%w[ruby -S rbtest], xmp.interpreter_command)
49
+ end
50
+
51
+ def test_initialize__test_script_1
52
+ @xmp = XMPFilter.new(:test_script=>"/path/to/test/test_ruby_toggle_file.rb",
53
+ :test_method=>"test_implementation_file_file_exist",
54
+ :filename=>"/path/to/lib/ruby_toggle_file.rb")
55
+
56
+ evals_expected = [
57
+ %q!$LOADED_FEATURES << "ruby_toggle_file.rb"!,
58
+ %q!require 'test/unit'!,
59
+ %q!load "/path/to/test/test_ruby_toggle_file.rb"!,
60
+ %q!Test::Unit::AutoRunner.run(false, nil, ["-n", "test_implementation_file_file_exist"])!
61
+ ]
62
+ assert_equal evals_expected, @xmp.instance_variable_get(:@evals)
63
+ end
64
+
65
+ def test_initialize__test_script_2
66
+ @xmp = XMPFilter.new(:test_script=>"/path/to/test_ruby_toggle_file.rb",
67
+ :test_method=>"test_implementation_file_file_exist",
68
+ :filename=>"/path/to/ruby_toggle_file.rb")
69
+
70
+ evals_expected = [
71
+ %q!$LOADED_FEATURES << "ruby_toggle_file.rb"!,
72
+ %q!require 'test/unit'!,
73
+ %q!load "/path/to/test_ruby_toggle_file.rb"!,
74
+ %q!Test::Unit::AutoRunner.run(false, nil, ["-n", "test_implementation_file_file_exist"])!
75
+ ]
76
+ assert_equal evals_expected, @xmp.instance_variable_get(:@evals)
77
+ end
78
+
79
+ def test_initialize__test_script_3
80
+ test_script = File.join(@testdir, "data/sample_test_script.rb")
81
+ filename = File.join(@testdir, "data/sample.rb")
82
+ @xmp = XMPFilter.new(:test_script=>test_script, :test_method=>"4", :filename=>filename)
83
+
84
+ evals_expected = [
85
+ %q!$LOADED_FEATURES << "sample.rb"!,
86
+ %q!require 'test/unit'!,
87
+ %Q!load #{test_script.dump}!,
88
+ %q!Test::Unit::AutoRunner.run(false, nil, ["-n", "test_sample0"])!
89
+ ]
90
+ assert_equal evals_expected, @xmp.instance_variable_get(:@evals)
91
+ end
32
92
 
33
- def test_
93
+ def test_initialize__test_script__filename_eq_test_script
94
+ test_script = File.join(@testdir, "data/sample_test_script.rb")
95
+ filename = test_script
96
+ @xmp = XMPFilter.new(:test_script=>test_script, :test_method=>"4", :filename=>filename)
34
97
 
98
+ evals_expected = [
99
+ %q!Test::Unit::AutoRunner.run(false, nil, ["-n", "test_sample0"])!
100
+ ]
101
+ assert_equal evals_expected, @xmp.instance_variable_get(:@evals)
35
102
  end
103
+
104
+ def test_get_test_method_from_lineno
105
+ file = File.join(@testdir, "data/sample_test_script.rb")
106
+ assert_equal("test_sample0", @xmp.get_test_method_from_lineno(file, 4))
107
+ assert_equal("test_sample1", @xmp.get_test_method_from_lineno(file, 7))
108
+ assert_equal("test_sample1", @xmp.get_test_method_from_lineno(file, 8))
109
+ assert_equal(nil, @xmp.get_test_method_from_lineno(file, 1))
110
+ end
111
+
112
+ def test_s_detect_rbtest
113
+ # Use variable to avoid confusing syntax highlighting
114
+ beg = "=begin"
115
+ ed = "=end"
116
+
117
+ rbtest_script_1 = <<XXX
118
+ #{beg} test_0
119
+ assert f(10)
120
+ #{ed}
121
+ def f(x) x*100 end
122
+ XXX
123
+
124
+ opts = {:detect_rbtest => true}
125
+ assert_equal true, XMPFilter.detect_rbtest(rbtest_script_1, opts)
126
+ assert_equal true, opts[:use_rbtest]
127
+ opts = {:detect_rbtest => false}
128
+ assert_equal false, XMPFilter.detect_rbtest(rbtest_script_1, opts)
129
+ assert_equal false, opts[:use_rbtest]
130
+ opts = {:detect_rbtest => false, :use_rbtest => true}
131
+ assert_equal true, XMPFilter.detect_rbtest(rbtest_script_1, opts)
132
+ assert_equal true, opts[:use_rbtest]
133
+
134
+
135
+
136
+ rbtest_script_2 = <<XXX
137
+ def f(x) x*100 end
138
+ #{beg} test_0
139
+ assert f(10)
140
+ #{ed}
141
+ XXX
142
+ opts = {:detect_rbtest => true}
143
+ assert_equal true, XMPFilter.detect_rbtest(rbtest_script_2, opts)
144
+ assert_equal true, opts[:use_rbtest]
145
+ opts = {:detect_rbtest => false}
146
+ assert_equal false, XMPFilter.detect_rbtest(rbtest_script_2, opts)
147
+ assert_equal false, opts[:use_rbtest]
148
+
149
+
150
+ no_rbtest_script = <<XXX
151
+ def f(x) x*100 end
152
+ XXX
153
+
154
+ opts = {:detect_rbtest => true}
155
+ assert_equal false, XMPFilter.detect_rbtest(no_rbtest_script, opts)
156
+ assert_equal false, opts[:use_rbtest]
157
+ opts = {:detect_rbtest => false}
158
+ assert_equal false, XMPFilter.detect_rbtest(no_rbtest_script, opts)
159
+ assert_equal false, opts[:use_rbtest]
160
+ end
161
+
36
162
  end
163
+
@@ -4,6 +4,7 @@ $: << ".." << "../lib"
4
4
  require "rcodetools/xmptestunitfilter"
5
5
 
6
6
  class TestXMPTestUnitFilter < Test::Unit::TestCase
7
+ include Rcodetools
7
8
  def setup
8
9
  @xmp = XMPTestUnitFilter.new
9
10
  end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
2
+ rubygems_version: 0.9.1
3
3
  specification_version: 1
4
4
  name: rcodetools
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.5.0.0
7
- date: 2007-01-28 00:00:00 +01:00
6
+ version: 0.7.0.0
7
+ date: 2007-06-22 00:00:00 +02:00
8
8
  summary: rcodetools is a collection of Ruby code manipulation tools
9
9
  require_paths:
10
10
  - lib
@@ -50,18 +50,23 @@ files:
50
50
  - bin/xmpfilter
51
51
  - bin/rct-meth-args
52
52
  - lib/method_analyzer.rb
53
- - lib/rcodetools/completion.rb
54
- - lib/rcodetools/doc.rb
53
+ - lib/ruby_toggle_file.rb
54
+ - lib/rcodetools/xmpfilter.rb
55
+ - lib/rcodetools/fork.rb
55
56
  - lib/rcodetools/options.rb
57
+ - lib/rcodetools/doc.rb
58
+ - lib/rcodetools/completion.rb
59
+ - lib/rcodetools/fork_config.rb
56
60
  - lib/rcodetools/xmptestunitfilter.rb
57
- - lib/rcodetools/xmpfilter.rb
58
61
  - CHANGES
59
- - rcodetools.vim
60
62
  - rcodetools.el
63
+ - rcodetools.vim
61
64
  - icicles-rcodetools.el
62
65
  - README
66
+ - README.ja
63
67
  - README.emacs
64
68
  - README.vim
69
+ - README.TDC
65
70
  - README.xmpfilter
66
71
  - README.method_analysis
67
72
  - THANKS
@@ -69,58 +74,86 @@ files:
69
74
  - Rakefile.method_analysis
70
75
  - setup.rb
71
76
  - test/test_functional.rb
72
- - test/test_xmpfilter.rb
73
- - test/test_xmptestunitfilter.rb
77
+ - test/test_options.rb
74
78
  - test/test_doc.rb
79
+ - test/test_run.rb
80
+ - test/test_method_analyzer.rb
75
81
  - test/test_completion.rb
76
82
  - test/test_method_args.rb
77
- - test/test_method_analyzer.rb
78
- - test/test_run.rb
79
- - test/test_options.rb
80
- - test/data/simple_annotation-input.rb
83
+ - test/test_xmptestunitfilter.rb
84
+ - test/test_xmpfilter.rb
85
+ - test/test_ruby_toggle_file.rb
86
+ - test/data/completion_class_info-output.rb
87
+ - test/data/completion_in_method-test.rb
88
+ - test/data/bindings-output.rb
89
+ - test/data/completion_rbtest-output.rb
90
+ - test/data/ri_vim-output.rb
91
+ - test/data/method_args.data.rb
92
+ - test/data/doc_rbtest-output.rb
93
+ - test/data/method_analyzer-data.rb
94
+ - test/data/ri_vim-input.rb
95
+ - test/data/completion_in_method-output.rb
96
+ - test/data/rspec-output.rb
81
97
  - test/data/unit_test-input.rb
82
- - test/data/rspec-input.rb
98
+ - test/data/bindings-input.rb
99
+ - test/data/doc_detect_rbtest2-input.rb
83
100
  - test/data/simple_annotation-output.rb
84
- - test/data/unit_test-output.rb
101
+ - test/data/doc_detect_rbtest-input.rb
102
+ - test/data/ri-input.rb
103
+ - test/data/rspec_poetry-output.rb
104
+ - test/data/ri_emacs-input.rb
105
+ - test/data/ri-output.rb
106
+ - test/data/refe-input.rb
107
+ - test/data/rspec-input.rb
108
+ - test/data/unit_test_poetry-output.rb
109
+ - test/data/unit_test_detect_rbtest2-output.rb
110
+ - test/data/doc_detect_rbtest-output.rb
111
+ - test/data/doc-input.rb
112
+ - test/data/completion-input.rb
113
+ - test/data/unit_test_detect_rbtest-input.rb
114
+ - test/data/unit_test_detect_rbtest-output.rb
115
+ - test/data/completion_class_info_no_candidates-input.rb
116
+ - test/data/completion_detect_rbtest2-output.rb
85
117
  - test/data/no_warnings-input.rb
118
+ - test/data/completion-output.rb
86
119
  - test/data/no_warnings-output.rb
87
- - test/data/rspec-output.rb
88
- - test/data/bindings-input.rb
89
- - test/data/bindings-output.rb
90
- - test/data/method_analyzer-data.rb
91
- - test/data/add_markers-input.rb
120
+ - test/data/completion_emacs_icicles-input.rb
121
+ - test/data/completion_in_method-input.rb
92
122
  - test/data/add_markers-output.rb
93
- - test/data/completion-input.rb
94
- - test/data/completion-output.rb
95
- - test/data/completion_emacs-input.rb
123
+ - test/data/completion_detect_rbtest-output.rb
124
+ - test/data/completion_class_info-input.rb
125
+ - test/data/unit_test_poetry-input.rb
126
+ - test/data/doc_detect_rbtest2-output.rb
127
+ - test/data/completion_detect_rbtest-input.rb
128
+ - test/data/unit_test_rbtest-input.rb
129
+ - test/data/rspec_poetry-input.rb
96
130
  - test/data/completion_emacs-output.rb
97
- - test/data/doc-input.rb
98
- - test/data/doc-output.rb
99
- - test/data/refe-input.rb
131
+ - test/data/completion_rbtest-input.rb
132
+ - test/data/completion_class_info_no_candidates-output.rb
133
+ - test/data/unit_test_rbtest-output.rb
100
134
  - test/data/refe-output.rb
101
- - test/data/ri-input.rb
102
- - test/data/ri-output.rb
103
- - test/data/ri_emacs-input.rb
104
- - test/data/ri_emacs-output.rb
105
- - test/data/ri_vim-input.rb
106
- - test/data/ri_vim-output.rb
107
- - test/data/rspec_poetry-input.rb
108
- - test/data/rspec_poetry-output.rb
109
- - test/data/unit_test_poetry-input.rb
110
- - test/data/unit_test_poetry-output.rb
111
- - test/data/method_args.data.rb
112
- - test/data/completion_emacs_icicles-input.rb
135
+ - test/data/sample_test_script.rb
136
+ - test/data/unit_test-output.rb
137
+ - test/data/completion_detect_rbtest2-input.rb
138
+ - test/data/simple_annotation-input.rb
139
+ - test/data/completion_emacs-input.rb
140
+ - test/data/unit_test_detect_rbtest2-input.rb
141
+ - test/data/doc_rbtest-input.rb
113
142
  - test/data/completion_emacs_icicles-output.rb
143
+ - test/data/ri_emacs-output.rb
144
+ - test/data/doc-output.rb
145
+ - test/data/add_markers-input.rb
114
146
  test_files:
115
147
  - test/test_functional.rb
116
- - test/test_xmpfilter.rb
117
- - test/test_xmptestunitfilter.rb
148
+ - test/test_options.rb
118
149
  - test/test_doc.rb
150
+ - test/test_run.rb
151
+ - test/test_method_analyzer.rb
119
152
  - test/test_completion.rb
120
153
  - test/test_method_args.rb
121
- - test/test_method_analyzer.rb
122
- - test/test_run.rb
123
- - test/test_options.rb
154
+ - test/test_xmptestunitfilter.rb
155
+ - test/test_xmpfilter.rb
156
+ - test/test_ruby_toggle_file.rb
124
157
  rdoc_options:
125
158
  - --main
126
159
  - README