rcodetools 0.4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/CHANGES +18 -0
  2. data/README +34 -0
  3. data/README.emacs +54 -0
  4. data/README.method_analysis +13 -0
  5. data/README.vim +84 -0
  6. data/README.xmpfilter +202 -0
  7. data/Rakefile +123 -0
  8. data/Rakefile.method_analysis +30 -0
  9. data/THANKS +6 -0
  10. data/bin/rct-complete +37 -0
  11. data/bin/rct-doc +50 -0
  12. data/bin/rct-meth-args +392 -0
  13. data/bin/xmpfilter +75 -0
  14. data/icicles-rcodetools.el +31 -0
  15. data/lib/method_analyzer.rb +107 -0
  16. data/lib/rcodetools/completion.rb +282 -0
  17. data/lib/rcodetools/doc.rb +176 -0
  18. data/lib/rcodetools/options.rb +83 -0
  19. data/lib/rcodetools/xmpfilter.rb +208 -0
  20. data/lib/rcodetools/xmptestunitfilter.rb +197 -0
  21. data/rcodetools.el +162 -0
  22. data/rcodetools.vim +118 -0
  23. data/setup.rb +1585 -0
  24. data/test/data/add_markers-input.rb +2 -0
  25. data/test/data/add_markers-output.rb +2 -0
  26. data/test/data/bindings-input.rb +26 -0
  27. data/test/data/bindings-output.rb +31 -0
  28. data/test/data/completion-input.rb +1 -0
  29. data/test/data/completion-output.rb +2 -0
  30. data/test/data/completion_emacs-input.rb +1 -0
  31. data/test/data/completion_emacs-output.rb +5 -0
  32. data/test/data/completion_emacs_icicles-input.rb +1 -0
  33. data/test/data/completion_emacs_icicles-output.rb +5 -0
  34. data/test/data/doc-input.rb +1 -0
  35. data/test/data/doc-output.rb +1 -0
  36. data/test/data/method_analyzer-data.rb +33 -0
  37. data/test/data/method_args.data.rb +106 -0
  38. data/test/data/no_warnings-input.rb +3 -0
  39. data/test/data/no_warnings-output.rb +4 -0
  40. data/test/data/refe-input.rb +1 -0
  41. data/test/data/refe-output.rb +1 -0
  42. data/test/data/ri-input.rb +1 -0
  43. data/test/data/ri-output.rb +1 -0
  44. data/test/data/ri_emacs-input.rb +1 -0
  45. data/test/data/ri_emacs-output.rb +1 -0
  46. data/test/data/ri_vim-input.rb +1 -0
  47. data/test/data/ri_vim-output.rb +1 -0
  48. data/test/data/rspec-input.rb +48 -0
  49. data/test/data/rspec-output.rb +52 -0
  50. data/test/data/rspec_poetry-input.rb +48 -0
  51. data/test/data/rspec_poetry-output.rb +52 -0
  52. data/test/data/simple_annotation-input.rb +8 -0
  53. data/test/data/simple_annotation-output.rb +8 -0
  54. data/test/data/unit_test-input.rb +50 -0
  55. data/test/data/unit_test-output.rb +52 -0
  56. data/test/data/unit_test_poetry-input.rb +50 -0
  57. data/test/data/unit_test_poetry-output.rb +52 -0
  58. data/test/test_completion.rb +467 -0
  59. data/test/test_doc.rb +403 -0
  60. data/test/test_functional.rb +18 -0
  61. data/test/test_method_analyzer.rb +99 -0
  62. data/test/test_method_args.rb +134 -0
  63. data/test/test_run.rb +41 -0
  64. data/test/test_xmpfilter.rb +36 -0
  65. data/test/test_xmptestunitfilter.rb +84 -0
  66. metadata +139 -0
@@ -0,0 +1,2 @@
1
+ 1+1
2
+ 2+3
@@ -0,0 +1,2 @@
1
+ 1+1 # =>
2
+ 2+3 # =>
@@ -0,0 +1,26 @@
1
+
2
+ require 'test/unit'
3
+
4
+ class TestFoo < Test::Unit::TestCase
5
+ def setup
6
+ @o = []
7
+ end
8
+
9
+ def test_foo
10
+ a = 1
11
+ b = a
12
+ b # =>
13
+ end
14
+
15
+ def test_arr
16
+ last = 1
17
+ @o << last
18
+ @o.last # =>
19
+ end
20
+
21
+ def test_bar
22
+ a = b = c = 1
23
+ d = a
24
+ d # =>
25
+ end
26
+ end
@@ -0,0 +1,31 @@
1
+
2
+ require 'test/unit'
3
+
4
+ class TestFoo < Test::Unit::TestCase
5
+ def setup
6
+ @o = []
7
+ end
8
+
9
+ def test_foo
10
+ a = 1
11
+ b = a
12
+ assert_equal a, b
13
+ assert_equal 1, b
14
+ end
15
+
16
+ def test_arr
17
+ last = 1
18
+ @o << last
19
+ assert_equal last, @o.last
20
+ assert_equal 1, @o.last
21
+ end
22
+
23
+ def test_bar
24
+ a = b = c = 1
25
+ d = a
26
+ assert_equal a, d
27
+ assert_equal b, d
28
+ assert_equal c, d
29
+ assert_equal 1, d
30
+ end
31
+ end
@@ -0,0 +1 @@
1
+ Array.new(3).uni
@@ -0,0 +1,2 @@
1
+ uniq
2
+ uniq!
@@ -0,0 +1 @@
1
+ Array.new(3).uni
@@ -0,0 +1,5 @@
1
+ (progn
2
+ (setq rct-method-completion-table '(("uniq") ("uniq!") ))
3
+ (setq pattern "uni")
4
+ (try-completion pattern rct-method-completion-table nil)
5
+ )
@@ -0,0 +1 @@
1
+ Array.new(3).uni
@@ -0,0 +1,5 @@
1
+ (progn
2
+ (setq rct-method-completion-table '(("uniq") ("uniq!") ))
3
+ (setq pattern "uni")
4
+ (setq klass "Array")
5
+ )
@@ -0,0 +1 @@
1
+ [].length
@@ -0,0 +1 @@
1
+ Array#length
@@ -0,0 +1,33 @@
1
+
2
+ class A
3
+ def A.foo
4
+ 1
5
+ end
6
+
7
+ def a
8
+ 1+1
9
+ end
10
+ end
11
+ class B < A
12
+ def initialize
13
+ end
14
+ attr_accessor :bb
15
+
16
+ def b
17
+ "a".length
18
+ end
19
+ end
20
+ tm = Time.now
21
+ [tm.year, tm.month, tm.day] << 0
22
+ a = A.new
23
+ a.a
24
+ b = B.new
25
+ b.a
26
+ b.b
27
+ [b.a,b.b]
28
+ z = b.a + b.b
29
+ A.foo
30
+ B.foo
31
+ b.bb=1
32
+ b.bb
33
+
@@ -0,0 +1,106 @@
1
+ # method_args.data.rb
2
+ class FixedArgsMethods
3
+ def self.singleton(a1) end
4
+ def initialize(arg) end
5
+ def f(a1) end
6
+ def b(a1,&block) end
7
+ define_method(:defmethod) {|a1|}
8
+ attr_accessor :by_attr_accessor
9
+ attr :by_attr_false
10
+ attr :by_attr_true, true
11
+ attr_reader :by_attr_reader_1, :by_attr_reader_2
12
+ attr_writer :by_attr_writer
13
+ def private_meth(x) end
14
+ private :private_meth
15
+ class << self
16
+ attr_accessor :singleton_attr_accessor
17
+ define_method(:singleton_defmethod){|a2|}
18
+ end
19
+ end
20
+
21
+ module VariableArgsMethods
22
+ def s(a1,*splat) end
23
+ def sb(a1,*splat, &block) end
24
+ def d(a1,default=nil) end
25
+ def ds(a1,default=nil,*splat) end
26
+ def dsb(a1,default=nil,*splat,&block) end
27
+ def db(a1,default=nil,&block) end
28
+ end
29
+
30
+ class Fixnum
31
+ def method_in_Fixnum(arg1, arg2) end
32
+ def self.singleton_method_in_Fixnum(arg1, arg2) end
33
+ end
34
+ class Bignum
35
+ def method_in_Bignum(arg1, arg2) end
36
+ end
37
+ class Float
38
+ def method_in_Float(arg1, arg2) end
39
+ end
40
+ class Symbol
41
+ def method_in_Symbol(arg1, arg2) end
42
+ end
43
+ class Binding
44
+ def method_in_Binding(arg1, arg2) end
45
+ end
46
+ class UnboundMethod
47
+ def method_in_UnboundMethod(arg1, arg2) end
48
+ end
49
+ class Method
50
+ def method_in_Method(arg1, arg2) end
51
+ end
52
+ class Proc
53
+ def method_in_Proc(arg1, arg2) end
54
+ end
55
+ class Continuation
56
+ def method_in_Continuation(arg1, arg2) end
57
+ end
58
+ class Thread
59
+ def method_in_Thread(arg1, arg2) end
60
+ end
61
+ # FIXME mysterious
62
+ # class FalseClass
63
+ # def method_in_FalseClass(arg1, arg2) end
64
+ # end
65
+ class TrueClass
66
+ def method_in_TrueClass(arg1, arg2) end
67
+ end
68
+ class NilClass
69
+ def method_in_NilClass(arg1, arg2) end
70
+ end
71
+ class Struct
72
+ def method_in_Struct(arg1, arg2) end
73
+ end
74
+
75
+ require 'digest'
76
+ class Digest::Base
77
+ def method_in_Digest_Base(arg1, arg2) end
78
+ end
79
+
80
+ class AnAbstractClass
81
+ $__method_args_off = true
82
+ def self.allocate
83
+ raise NotImplementedError, "#{self} is an abstract class."
84
+ end
85
+ $__method_args_off = false
86
+
87
+ def method_in_AnAbstractClass(arg1, arg2)
88
+ end
89
+
90
+ end
91
+
92
+ class AClass
93
+ include VariableArgsMethods
94
+ extend VariableArgsMethods
95
+ end
96
+
97
+ class ASubClass < AClass
98
+ end
99
+
100
+ StructA = Struct.new :a, :b
101
+ class SubclassOfStructA < StructA
102
+ attr :method_in_b
103
+ end
104
+ class StructSubclass < Struct.new(:c)
105
+ attr :method_in_c
106
+ end
@@ -0,0 +1,3 @@
1
+ A = 1
2
+ A = 1
3
+ p (1)
@@ -0,0 +1,4 @@
1
+ A = 1
2
+ A = 1
3
+ p (1)
4
+ # >> 1
@@ -0,0 +1 @@
1
+ [].length
@@ -0,0 +1 @@
1
+ refe 'Array#length'
@@ -0,0 +1 @@
1
+ [].length
@@ -0,0 +1 @@
1
+ ri 'Array#length'
@@ -0,0 +1 @@
1
+ [].length
@@ -0,0 +1 @@
1
+ (rct-find-tag-or-ri "Array#length")
@@ -0,0 +1 @@
1
+ [].length
@@ -0,0 +1 @@
1
+ call RCT_find_tag_or_ri("Array#length")
@@ -0,0 +1,48 @@
1
+
2
+ class X
3
+ Y = Struct.new(:a)
4
+ def foo(b); b ? Y.new(2) : 2 end
5
+ def bar; raise "No good" end
6
+ def baz; nil end
7
+ def fubar(x); x ** 2.0 + 1 end
8
+ def babar; [1,2] end
9
+ A = 1
10
+ A = 1
11
+ end
12
+
13
+
14
+ context "Testing xmpfilter's expectation expansion" do
15
+ setup do
16
+ @o = X.new
17
+ end
18
+
19
+ specify "Should expand should_equal expectations" do
20
+ @o.foo(true) # =>
21
+ @o.foo(true).a # =>
22
+ @o.foo(false) # =>
23
+ end
24
+
25
+ specify "Should expand should_raise expectations" do
26
+ @o.bar # =>
27
+ end
28
+
29
+ specify "Should expand should_be_nil expectations" do
30
+ @o.baz # =>
31
+ end
32
+
33
+ specify "Should expand correct expectations for complex values" do
34
+ @o.babar # =>
35
+ end
36
+
37
+ specify "Should expand should_be_close expectations" do
38
+ @o.fubar(10) # =>
39
+ end
40
+ end
41
+
42
+ context "Testing binding" do
43
+ specify "Should expand should_equal expectations" do
44
+ a = b = c = 1
45
+ d = a
46
+ d # =>
47
+ end
48
+ end
@@ -0,0 +1,52 @@
1
+
2
+ class X
3
+ Y = Struct.new(:a)
4
+ def foo(b); b ? Y.new(2) : 2 end
5
+ def bar; raise "No good" end
6
+ def baz; nil end
7
+ def fubar(x); x ** 2.0 + 1 end
8
+ def babar; [1,2] end
9
+ A = 1
10
+ A = 1 # !> already initialized constant A
11
+ end
12
+
13
+
14
+ context "Testing xmpfilter's expectation expansion" do
15
+ setup do
16
+ @o = X.new
17
+ end
18
+
19
+ specify "Should expand should_equal expectations" do
20
+ (@o.foo(true)).should_be_a_kind_of X::Y
21
+ (@o.foo(true).inspect).should_equal "#<struct X::Y a=2>"
22
+ (@o.foo(true).a).should_equal 2
23
+ (@o.foo(false)).should_equal 2
24
+ end
25
+
26
+ specify "Should expand should_raise expectations" do
27
+ lambda{@o.bar}.should_raise RuntimeError
28
+ end
29
+
30
+ specify "Should expand should_be_nil expectations" do
31
+ (@o.baz).should_be_nil
32
+ end
33
+
34
+ specify "Should expand correct expectations for complex values" do
35
+ (@o.babar).should_equal [1, 2]
36
+ end
37
+
38
+ specify "Should expand should_be_close expectations" do
39
+ (@o.fubar(10)).should_be_close 101.0, 0.0001
40
+ end
41
+ end
42
+
43
+ context "Testing binding" do
44
+ specify "Should expand should_equal expectations" do
45
+ a = b = c = 1
46
+ d = a
47
+ (d).should_equal a
48
+ (d).should_equal b
49
+ (d).should_equal c
50
+ (d).should_equal 1
51
+ end
52
+ end
@@ -0,0 +1,48 @@
1
+
2
+ class X
3
+ Y = Struct.new(:a)
4
+ def foo(b); b ? Y.new(2) : 2 end
5
+ def bar; raise "No good" end
6
+ def baz; nil end
7
+ def fubar(x); x ** 2.0 + 1 end
8
+ def babar; [1,2] end
9
+ A = 1
10
+ A = 1
11
+ end
12
+
13
+
14
+ context "Testing xmpfilter's expectation expansion" do
15
+ setup do
16
+ @o = X.new
17
+ end
18
+
19
+ specify "Should expand should_equal expectations" do
20
+ @o.foo(true) # =>
21
+ @o.foo(true).a # =>
22
+ @o.foo(false) # =>
23
+ end
24
+
25
+ specify "Should expand should_raise expectations" do
26
+ @o.bar # =>
27
+ end
28
+
29
+ specify "Should expand should_be_nil expectations" do
30
+ @o.baz # =>
31
+ end
32
+
33
+ specify "Should expand correct expectations for complex values" do
34
+ @o.babar # =>
35
+ end
36
+
37
+ specify "Should expand should_be_close expectations" do
38
+ @o.fubar(10) # =>
39
+ end
40
+ end
41
+
42
+ context "Testing binding" do
43
+ specify "Should expand should_equal expectations" do
44
+ a = b = c = 1
45
+ d = a
46
+ d # =>
47
+ end
48
+ end
@@ -0,0 +1,52 @@
1
+
2
+ class X
3
+ Y = Struct.new(:a)
4
+ def foo(b); b ? Y.new(2) : 2 end
5
+ def bar; raise "No good" end
6
+ def baz; nil end
7
+ def fubar(x); x ** 2.0 + 1 end
8
+ def babar; [1,2] end
9
+ A = 1
10
+ A = 1 # !> already initialized constant A
11
+ end
12
+
13
+
14
+ context "Testing xmpfilter's expectation expansion" do
15
+ setup do
16
+ @o = X.new
17
+ end
18
+
19
+ specify "Should expand should_equal expectations" do
20
+ @o.foo(true).should_be_a_kind_of X::Y
21
+ @o.foo(true).inspect.should_equal "#<struct X::Y a=2>"
22
+ @o.foo(true).a.should_equal 2
23
+ @o.foo(false).should_equal 2
24
+ end
25
+
26
+ specify "Should expand should_raise expectations" do
27
+ lambda{@o.bar}.should_raise RuntimeError
28
+ end
29
+
30
+ specify "Should expand should_be_nil expectations" do
31
+ @o.baz.should_be_nil
32
+ end
33
+
34
+ specify "Should expand correct expectations for complex values" do
35
+ @o.babar.should_equal [1, 2]
36
+ end
37
+
38
+ specify "Should expand should_be_close expectations" do
39
+ @o.fubar(10).should_be_close 101.0, 0.0001
40
+ end
41
+ end
42
+
43
+ context "Testing binding" do
44
+ specify "Should expand should_equal expectations" do
45
+ a = b = c = 1
46
+ d = a
47
+ d.should_equal a
48
+ d.should_equal b
49
+ d.should_equal c
50
+ d.should_equal 1
51
+ end
52
+ end