jruby-parser 0.5.1 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,4 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0ff10f0bf92834272246c617b94993f1918c804e
4
- data.tar.gz: e2e3475e078e7839f2f413bc42ebfbba4e9f4e6b
5
2
  SHA512:
6
- metadata.gz: 1f9484ea74a7d2c0d9bcbbec9079b34ff2ffbdba23e2b5a55f3e394c17134defee652feb799bade91f6366fc7268c373b451c1b1a9af0097d796b52b568659e9
7
- data.tar.gz: b65f06c640f489f153e54fe2b3a7c035ea33703543a965dd18fa644f8e9d049f995ac9d06e6be613af64186aa103a849b783fd8a2aff2d9872740435ea736ced
3
+ metadata.gz: 2ca4259137ed311d1d5fdd1ca3ac17d68aa66fc744772a68292e5c81fec7bf4919704698b884b4d5f29212fa000374fe82d28668c2a1d178fa549eb39c700fef
4
+ data.tar.gz: 53ac91b3351fcffc09565ae374b97cbc3c570b451307d9cda48632135921aa9e7e2e3dcd2adf94d00e8ff39bdd45cd123511c7bd2041f1060d46ef296a87413a
Binary file
@@ -1,3 +1,3 @@
1
1
  module JRubyParser
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.4"
3
3
  end
@@ -1,9 +1,9 @@
1
- require_relative '../helpers'
1
+ require_relative '../../helpers'
2
2
 
3
- describe Parser do
3
+ describe org.jrubyparser.ast.AliasNode do
4
4
  VERSIONS.each do |v|
5
5
  it "Should parse alias node of symbols" do
6
- parse("alias :new_name :old_name", v).find_node(:alias).tap do |a|
6
+ rparse("alias :new_name :old_name", v).find_node(:alias).tap do |a|
7
7
  a.new_name_string.should == "new_name"
8
8
  a.old_name_string.should == "old_name"
9
9
  a.new_name.should have_position(0, 0, 6, 15)
@@ -12,7 +12,7 @@ describe Parser do
12
12
  end
13
13
 
14
14
  it "Should parse alias node of CONSTANTS" do
15
- parse("alias NEW OLD", v).find_node(:alias).tap do |a|
15
+ rparse("alias NEW OLD", v).find_node(:alias).tap do |a|
16
16
  a.new_name_string.should == "NEW"
17
17
  a.old_name_string.should == "OLD"
18
18
  a.new_name.should have_position(0, 0, 6, 9)
@@ -0,0 +1,61 @@
1
+ require_relative '../../helpers'
2
+
3
+ describe org.jrubyparser.ast.CallNode do
4
+ VERSIONS.each do |v|
5
+ it "parses a 0-arg object.method call without parens [#{v}]" do
6
+ rparse("Array.new", v).find_node(:call).tap do |call|
7
+ call.should have_name_and_position("new", 0, 0, 0, 9)
8
+ call.receiver_node.should have_name_and_position("Array", 0, 0, 0, 5)
9
+ call.args_node.size.should == 0
10
+ end
11
+ end
12
+
13
+ it "parses a 0-arg object.method call with parens [#{v}]" do
14
+ rparse("Array.new()", v).find_node(:call).tap do |call|
15
+ call.should have_name_and_position("new", 0, 0, 0, 11)
16
+ call.receiver_node.should have_name_and_position("Array", 0, 0, 0, 5)
17
+ call.args_node.size.should == 0
18
+ end
19
+ end
20
+
21
+ it "parses a 1-arg object.method call without parens [#{v}]" do
22
+ rparse("Array.new 1", v).find_node(:call).tap do |call|
23
+ call.should have_name_and_position("new", 0, 0, 0, 11)
24
+ call.receiver_node.should have_name_and_position("Array", 0, 0, 0, 5)
25
+ call.args_node.size.should == 1
26
+ end
27
+ end
28
+
29
+ it "parses a 1-arg object.method call with parens [#{v}]" do
30
+ rparse("Array.new(1)", v).find_node(:call).tap do |call|
31
+ call.should have_name_and_position("new", 0, 0, 0, 12)
32
+ call.receiver_node.should have_name_and_position("Array", 0, 0, 0, 5)
33
+ call.args_node.size.should == 1
34
+ end
35
+ end
36
+
37
+ it "parses a 1-arg infix method [#{v}]" do
38
+ rparse("4 + 5", v).find_node(:call).tap do |call|
39
+ call.should have_name_and_position("+", 0, 0, 0, 5)
40
+ call.receiver_node.should have_position(0, 0, 0, 1)
41
+ call.args_node.size.should == 1
42
+ end
43
+ end
44
+
45
+ it "parses a 1-arg object.method call with infix operator as arg [#{v}]" do
46
+ rparse("Array.new 4 + 5", v).find_node(:call).tap do |call|
47
+ call.should have_name_and_position("new", 0, 0, 0, 15)
48
+ call.receiver_node.should have_name_and_position("Array", 0, 0, 0, 5)
49
+ call.args_node.size.should == 1
50
+ end
51
+ end
52
+
53
+ if v != 1.8 # In 1.8 this is a NotNode (see not_spec.rb)
54
+ it "parses unary ! call with parenthesis [#{v}]" do
55
+ rparse("!(x < 5)", v).find_node(:call).tap do |call|
56
+ call.should have_name_and_position("!", 0, 0, 0, 8)
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,76 @@
1
+ require_relative '../../helpers'
2
+
3
+ describe org.jrubyparser.ast.FCallNode do
4
+ VERSIONS.each do |v|
5
+ it "parses a 0-arg method call sans parens +extra line [#{v}]" do
6
+ rparse("\nblock_given?\n", v).find_node(:fcall).tap do |call|
7
+ call.should have_name_and_position("block_given?", 1, 1, 1, 13)
8
+ end
9
+ end
10
+
11
+ it "parses a 0-arg method call with parens [#{v}]" do
12
+ rparse("puts()", v).find_node(:fcall).tap do |call|
13
+ call.should have_name_and_position("puts", 0, 0, 0, 6)
14
+ call.args_node.size.should == 0
15
+ end
16
+ end
17
+
18
+ it "parses a 1-arg method call with parens [#{v}]" do
19
+ rparse("puts(1)", v).find_node(:fcall).tap do |call|
20
+ call.should have_name_and_position("puts", 0, 0, 0, 7)
21
+ call.args_node.size.should == 1
22
+ end
23
+ end
24
+
25
+ it "parses a 1-arg method call without parens [#{v}]" do
26
+ rparse("puts 1", v).find_node(:fcall).tap do |call|
27
+ call.should have_name_and_position("puts", 0, 0, 0, 6)
28
+ call.args_node.size.should == 1
29
+ end
30
+ end
31
+
32
+ it "parses a 2-arg method call with parens [#{v}]" do
33
+ rparse("puts(1,2)", v).find_node(:fcall).tap do |call|
34
+ call.should have_name_and_position("puts", 0, 0, 0, 9)
35
+ call.args_node.size.should == 2
36
+ end
37
+ end
38
+
39
+ it "parses a 2-arg method call without parens [#{v}]" do
40
+ rparse("puts 1, 2", v).find_node(:fcall).tap do |call|
41
+ call.should have_name_and_position("puts", 0, 0, 0, 9)
42
+ call.args_node.size.should == 2
43
+ end
44
+ end
45
+
46
+ it "parses an empty method with a block({}) [#{v}]" do
47
+ parse("foo() {}", v).find_node(:fcall).tap do |call|
48
+ call.should have_name_and_position("foo", 0, 0, 0, 8)
49
+ call.iter_node.should have_position(0, 0, 6, 8)
50
+ end
51
+ end
52
+
53
+ it "parses an empty method with a block(do...end) [#{v}]" do
54
+ parse("foo() do\nend\n", v).find_node(:fcall).tap do |call|
55
+ call.should have_name_and_position("foo", 0, 1, 0, 12)
56
+ call.iter_node.should have_position(0, 1, 6, 12)
57
+ end
58
+ end
59
+
60
+ it "parses an empty method with a block({}) +1 arg [#{v}]" do
61
+ parse("foo() { |a| }", v).find_node(:fcall).tap do |call|
62
+ call.should have_name_and_position("foo", 0, 0, 0, 13)
63
+ call.iter_node.should have_position(0, 0, 6, 13)
64
+ # FIXME: Need arg tests
65
+ end
66
+ end
67
+
68
+ it "parses an empty method with a block(do...end) [#{v}]" do
69
+ parse("foo() do |a|\nend\n", v).find_node(:fcall).tap do |call|
70
+ call.should have_name_and_position("foo", 0, 1, 0, 16)
71
+ call.iter_node.should have_position(0, 1, 6, 16)
72
+ # FIXME: Need arg tests
73
+ end
74
+ end
75
+ end
76
+ end
@@ -65,6 +65,17 @@ describe org.jrubyparser.ast.Node do
65
65
  caret_nodes.first.occurrences.to_a.should =~ caret_nodes
66
66
  end
67
67
  end
68
+
69
+ if v == 1.8
70
+ carets_parse("proc { |^a| proc { |^a| ^a } }", v).tap do |_, caret_nodes|
71
+ caret_nodes.last.occurrences.to_a.should =~ caret_nodes
72
+ end
73
+ else
74
+ carets_parse("proc { |a| proc { |^a| ^a } }", v).tap do |_, caret_nodes|
75
+ caret_nodes.last.occurrences.to_a.should =~ caret_nodes
76
+ end
77
+ end
78
+
68
79
  carets_parse("proc { |^a| ^a }", v).tap do |_, caret_nodes|
69
80
  caret_nodes.first.occurrences.to_a.should =~ caret_nodes
70
81
  end
@@ -0,0 +1,33 @@
1
+ require_relative '../../helpers'
2
+
3
+ describe org.jrubyparser.ast.AliasNode do
4
+ VERSIONS.each do |v|
5
+ it "should parse a hash literal (a=>b) [#{v}]" do
6
+ rparse("{:one => 1, :two => 2}", v).find_node(:hash).tap do |hash|
7
+ hash.should have_position(0, 0, 0, 22)
8
+ end
9
+ end
10
+
11
+ if v == 1.8
12
+ it "should parse a hash literal (a,b) [#{v}]" do
13
+ rparse("{:one, 1, :two, 2}", v).find_node(:hash).tap do |hash|
14
+ hash.should have_position(0, 0, 0, 18)
15
+ end
16
+
17
+ rparse("call :one => 2", v).find_node(:hash).tap do |hash|
18
+ hash.should have_position(0, 0, 5, 14)
19
+ end
20
+ end
21
+ else
22
+ it "should parse a hash literal (a: b) [#{v}]" do
23
+ rparse("{one: 1, two: 2}", v).find_node(:hash).tap do |hash|
24
+ hash.should have_position(0, 0, 0, 16)
25
+ end
26
+
27
+ rparse("call one: 2", v).find_node(:hash).tap do |hash|
28
+ hash.should have_position(0, 0, 5, 11)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -28,6 +28,14 @@ describe org.jrubyparser.ast.Node do
28
28
  caret_node.block_parameter?.should == false
29
29
  end
30
30
 
31
+ caret_parse("proc { |c; ^d| }", v).tap do |root, caret_node|
32
+ caret_node.block_parameter?.should == true
33
+ end
34
+
35
+ caret_parse("proc { |c; d, ^e| }", v).tap do |root, caret_node|
36
+ caret_node.block_parameter?.should == true
37
+ end
38
+
31
39
  end
32
40
  end
33
41
  end
@@ -0,0 +1,13 @@
1
+ require_relative '../../helpers'
2
+
3
+ describe org.jrubyparser.ast.NotNode do
4
+ VERSIONS.each do |v|
5
+ if v == 1.8
6
+ it "parses unary ! call with parenthesis [#{v}]" do
7
+ rparse("!(x < 5)", v).find_node(:not).tap do |call|
8
+ call.should have_position(0, 0, 0, 8)
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ require_relative '../../helpers'
2
+
3
+ describe org.jrubyparser.ast.VCallNode do
4
+ VERSIONS.each do |v|
5
+ it "parses a 0-arg method call sans parens +extra line [#{v}]" do
6
+ rparse("\nputs\n", v).find_node(:vcall).tap do |call|
7
+ call.should have_name_and_position("puts", 1, 1, 1, 5)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require_relative '../../helpers'
2
+
3
+ describe org.jrubyparser.ast.WhileNode do
4
+ VERSIONS.each do |v|
5
+ it "can have an empty body [#{v}]" do
6
+ rparse("while true\n;end\n", v).find_node(:while).tap do |b|
7
+ b.should have_position(0, 1, 0, 15)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,46 @@
1
+ require_relative '../helpers'
2
+
3
+ import org.jrubyparser.util.MethodDefVisitor
4
+
5
+ def modules_in(code)
6
+ find_modules(parse(code))
7
+ end
8
+
9
+ def find_modules(node)
10
+ node.child_nodes.inject([]) do |modules, n|
11
+ modules << n if n.kind_of? org.jrubyparser.ast.IModuleScope
12
+ modules.concat find_modules(n)
13
+ end
14
+ end
15
+
16
+ describe MethodDefVisitor do
17
+ it 'should find no methods defined in a class' do
18
+ modules_in("class Example\nend").first.method_defs.should == []
19
+ end
20
+
21
+ it 'should find a method defined in a class' do
22
+ modz = modules_in("class Example\ndef hello\nend\nend")
23
+ modz.first.method_defs.map(&:name).should =~ %w{hello}
24
+ end
25
+
26
+ it 'should find methods defined in a class' do
27
+ modz = modules_in("class Example\ndef hello\nend;def world; end\nend")
28
+ modz.first.method_defs.map(&:name).should =~ %w{hello world}
29
+ end
30
+
31
+ it 'should not find a method defined on an inner class' do
32
+ modz = modules_in("module Ex\nclass Example\ndef hello\nend\nend\nend")
33
+ modz.first.method_defs.size.should == 0
34
+ end
35
+
36
+ it 'should not find a method defined inside a method' do
37
+ modz = modules_in("class Example\ndef hello\ndef hello_too\nend\nend\nend")
38
+ modz.first.method_defs.size.should == 1
39
+ end
40
+
41
+ it 'should find a method defined in block scope in module body' do
42
+ modz = modules_in("module Ex\nloop do\ndef hello\nend\nend\nend")
43
+ modz.first.method_defs.size.should == 1
44
+ end
45
+ end
46
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jruby-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas E. Enebo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-13 00:00:00.000000000 Z
11
+ date: 2014-05-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A Gem for syntactically correct parse trees of Ruby source
14
14
  email: tom.enebo@gmail.com
@@ -16,6 +16,7 @@ executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
+ - lib/jruby-parser.jar
19
20
  - lib/jruby-parser.rb
20
21
  - lib/jruby-parser/core_ext/array.rb
21
22
  - lib/jruby-parser/core_ext/attr_assign_node.rb
@@ -33,21 +34,28 @@ files:
33
34
  - lib/jruby-parser/version.rb
34
35
  - lib/yydebug.jar
35
36
  - sample/simple.rb
37
+ - spec/ast/node/alias_spec.rb
36
38
  - spec/ast/node/array_spec.rb
37
39
  - spec/ast/node/break_spec.rb
40
+ - spec/ast/node/call_spec.rb
38
41
  - spec/ast/node/comments_spec.rb
42
+ - spec/ast/node/fcall_spec.rb
39
43
  - spec/ast/node/find_scopes_spec.rb
40
44
  - spec/ast/node/get_declaration_spec.rb
41
45
  - spec/ast/node/get_defined_scope_spec.rb
42
46
  - spec/ast/node/get_node_at_spec.rb
43
47
  - spec/ast/node/get_occurences_spec.rb
48
+ - spec/ast/node/hash_spec.rb
44
49
  - spec/ast/node/is_block_parameter_spec.rb
45
50
  - spec/ast/node/is_method_parameter_spec.rb
46
51
  - spec/ast/node/next_spec.rb
52
+ - spec/ast/node/not_spec.rb
47
53
  - spec/ast/node/op_element_asgn_and_spec.rb
48
54
  - spec/ast/node/op_element_asgn_or_spec.rb
49
55
  - spec/ast/node/op_element_asgn_spec.rb
50
56
  - spec/ast/node/return_spec.rb
57
+ - spec/ast/node/vcall_spec.rb
58
+ - spec/ast/node/while_spec.rb
51
59
  - spec/ast/node_path.rb
52
60
  - spec/helpers.rb
53
61
  - spec/helpers/node_helpers.rb
@@ -59,18 +67,15 @@ files:
59
67
  - spec/parser/alias_spec.rb
60
68
  - spec/parser/broken_spec.rb
61
69
  - spec/parser/calls_spec.rb
62
- - spec/positions/alias_spec.rb
63
70
  - spec/positions/arg_spec.rb
64
71
  - spec/positions/attr_asgn_spec.rb
65
- - spec/positions/call_spec.rb
66
72
  - spec/positions/conditionals_spec.rb
67
- - spec/positions/hash_spec.rb
68
73
  - spec/positions/heredoc_spec.rb
69
74
  - spec/positions/name_spec.rb
70
75
  - spec/positions/op_asgn_or_spec.rb
71
76
  - spec/positions/str_spec.rb
77
+ - spec/util/method_def_visitor_spec.rb
72
78
  - spec/util/node_diff_spec.rb
73
- - lib/jruby-parser.jar
74
79
  homepage: http://github.com/jruby/jruby-parser
75
80
  licenses: []
76
81
  metadata: {}
@@ -80,36 +85,43 @@ require_paths:
80
85
  - lib
81
86
  required_ruby_version: !ruby/object:Gem::Requirement
82
87
  requirements:
83
- - - '>='
88
+ - - ">="
84
89
  - !ruby/object:Gem::Version
85
90
  version: '0'
86
91
  required_rubygems_version: !ruby/object:Gem::Requirement
87
92
  requirements:
88
- - - '>='
93
+ - - ">="
89
94
  - !ruby/object:Gem::Version
90
95
  version: '0'
91
96
  requirements: []
92
97
  rubyforge_project: jruby-parser
93
- rubygems_version: 2.1.2
98
+ rubygems_version: 2.2.2
94
99
  signing_key:
95
100
  specification_version: 4
96
101
  summary: A Gem for syntactically correct parse trees of Ruby source
97
102
  test_files:
103
+ - spec/ast/node/alias_spec.rb
98
104
  - spec/ast/node/array_spec.rb
99
105
  - spec/ast/node/break_spec.rb
106
+ - spec/ast/node/call_spec.rb
100
107
  - spec/ast/node/comments_spec.rb
108
+ - spec/ast/node/fcall_spec.rb
101
109
  - spec/ast/node/find_scopes_spec.rb
102
110
  - spec/ast/node/get_declaration_spec.rb
103
111
  - spec/ast/node/get_defined_scope_spec.rb
104
112
  - spec/ast/node/get_node_at_spec.rb
105
113
  - spec/ast/node/get_occurences_spec.rb
114
+ - spec/ast/node/hash_spec.rb
106
115
  - spec/ast/node/is_block_parameter_spec.rb
107
116
  - spec/ast/node/is_method_parameter_spec.rb
108
117
  - spec/ast/node/next_spec.rb
118
+ - spec/ast/node/not_spec.rb
109
119
  - spec/ast/node/op_element_asgn_and_spec.rb
110
120
  - spec/ast/node/op_element_asgn_or_spec.rb
111
121
  - spec/ast/node/op_element_asgn_spec.rb
112
122
  - spec/ast/node/return_spec.rb
123
+ - spec/ast/node/vcall_spec.rb
124
+ - spec/ast/node/while_spec.rb
113
125
  - spec/ast/node_path.rb
114
126
  - spec/helpers.rb
115
127
  - spec/helpers/node_helpers.rb
@@ -121,14 +133,12 @@ test_files:
121
133
  - spec/parser/alias_spec.rb
122
134
  - spec/parser/broken_spec.rb
123
135
  - spec/parser/calls_spec.rb
124
- - spec/positions/alias_spec.rb
125
136
  - spec/positions/arg_spec.rb
126
137
  - spec/positions/attr_asgn_spec.rb
127
- - spec/positions/call_spec.rb
128
138
  - spec/positions/conditionals_spec.rb
129
- - spec/positions/hash_spec.rb
130
139
  - spec/positions/heredoc_spec.rb
131
140
  - spec/positions/name_spec.rb
132
141
  - spec/positions/op_asgn_or_spec.rb
133
142
  - spec/positions/str_spec.rb
143
+ - spec/util/method_def_visitor_spec.rb
134
144
  - spec/util/node_diff_spec.rb
@@ -1,130 +0,0 @@
1
- require_relative '../helpers'
2
-
3
- describe Parser do
4
- VERSIONS.each do |v|
5
- it "parses a 0-arg method call sans parens +extra line [#{v}]" do
6
- parse("\nblock_given?\n", v).find_node(:fcall).tap do |call|
7
- call.should have_name_and_position("block_given?", 1, 1, 1, 13)
8
- end
9
- end
10
-
11
- it "parses a 0-arg method call sans parens +extra line [#{v}]" do
12
- parse("\nputs\n", v).find_node(:vcall).tap do |call|
13
- call.should have_name_and_position("puts", 1, 1, 1, 5)
14
- end
15
- end
16
-
17
- it "parses a 0-arg method call with parens [#{v}]" do
18
- parse("puts()", v).find_node(:fcall).tap do |call|
19
- call.should have_name_and_position("puts", 0, 0, 0, 6)
20
- call.args_node.size.should == 0
21
- end
22
- end
23
-
24
- it "parses a 1-arg method call with parens [#{v}]" do
25
- parse("puts(1)", v).find_node(:fcall).tap do |call|
26
- call.should have_name_and_position("puts", 0, 0, 0, 7)
27
- call.args_node.size.should == 1
28
- end
29
- end
30
-
31
- it "parses a 1-arg method call without parens [#{v}]" do
32
- parse("puts 1", v).find_node(:fcall).tap do |call|
33
- call.should have_name_and_position("puts", 0, 0, 0, 6)
34
- call.args_node.size.should == 1
35
- end
36
- end
37
-
38
- it "parses a 2-arg method call with parens [#{v}]" do
39
- parse("puts(1,2)", v).find_node(:fcall).tap do |call|
40
- call.should have_name_and_position("puts", 0, 0, 0, 9)
41
- call.args_node.size.should == 2
42
- end
43
- end
44
-
45
- it "parses a 2-arg method call without parens [#{v}]" do
46
- parse("puts 1, 2", v).find_node(:fcall).tap do |call|
47
- call.should have_name_and_position("puts", 0, 0, 0, 9)
48
- call.args_node.size.should == 2
49
- end
50
- end
51
-
52
- it "parses a 0-arg object.method call without parens [#{v}]" do
53
- parse("Array.new", v).find_node(:call).tap do |call|
54
- call.should have_name_and_position("new", 0, 0, 0, 9)
55
- call.receiver_node.should have_name_and_position("Array", 0, 0, 0, 5)
56
- call.args_node.size.should == 0
57
- end
58
- end
59
-
60
- it "parses a 0-arg object.method call with parens [#{v}]" do
61
- parse("Array.new()", v).find_node(:call).tap do |call|
62
- call.should have_name_and_position("new", 0, 0, 0, 11)
63
- call.receiver_node.should have_name_and_position("Array", 0, 0, 0, 5)
64
- call.args_node.size.should == 0
65
- end
66
- end
67
-
68
- it "parses a 1-arg object.method call without parens [#{v}]" do
69
- parse("Array.new 1", v).find_node(:call).tap do |call|
70
- call.should have_name_and_position("new", 0, 0, 0, 11)
71
- call.receiver_node.should have_name_and_position("Array", 0, 0, 0, 5)
72
- call.args_node.size.should == 1
73
- end
74
- end
75
-
76
- it "parses a 1-arg object.method call with parens [#{v}]" do
77
- parse("Array.new(1)", v).find_node(:call).tap do |call|
78
- call.should have_name_and_position("new", 0, 0, 0, 12)
79
- call.receiver_node.should have_name_and_position("Array", 0, 0, 0, 5)
80
- call.args_node.size.should == 1
81
- end
82
- end
83
-
84
- it "parses a 1-arg infix method [#{v}]" do
85
- parse("4 + 5", v).find_node(:call).tap do |call|
86
- call.should have_name_and_position("+", 0, 0, 0, 5)
87
- call.receiver_node.should have_position(0, 0, 0, 1)
88
- call.args_node.size.should == 1
89
- end
90
- end
91
-
92
- it "parses a 1-arg object.method call with infix operator as arg [#{v}]" do
93
- parse("Array.new 4 + 5", v).find_node(:call).tap do |call|
94
- call.should have_name_and_position("new", 0, 0, 0, 15)
95
- call.receiver_node.should have_name_and_position("Array", 0, 0, 0, 5)
96
- call.args_node.size.should == 1
97
- end
98
- end
99
-
100
- it "parses an empty method with a block({}) [#{v}]" do
101
- parse("foo() {}", v).find_node(:fcall).tap do |call|
102
- call.should have_name_and_position("foo", 0, 0, 0, 8)
103
- call.iter_node.should have_position(0, 0, 6, 8)
104
- end
105
- end
106
-
107
- it "parses an empty method with a block(do...end) [#{v}]" do
108
- parse("foo() do\nend\n", v).find_node(:fcall).tap do |call|
109
- call.should have_name_and_position("foo", 0, 1, 0, 12)
110
- call.iter_node.should have_position(0, 1, 6, 12)
111
- end
112
- end
113
-
114
- it "parses an empty method with a block({}) +1 arg [#{v}]" do
115
- parse("foo() { |a| }", v).find_node(:fcall).tap do |call|
116
- call.should have_name_and_position("foo", 0, 0, 0, 13)
117
- call.iter_node.should have_position(0, 0, 6, 13)
118
- # FIXME: Need arg tests
119
- end
120
- end
121
-
122
- it "parses an empty method with a block(do...end) [#{v}]" do
123
- parse("foo() do |a|\nend\n", v).find_node(:fcall).tap do |call|
124
- call.should have_name_and_position("foo", 0, 1, 0, 16)
125
- call.iter_node.should have_position(0, 1, 6, 16)
126
- # FIXME: Need arg tests
127
- end
128
- end
129
- end
130
- end
@@ -1,21 +0,0 @@
1
- require_relative '../helpers'
2
-
3
- describe Parser do
4
- VERSIONS.each do |v|
5
- it "should parse a hash literal (a=>b) [#{v}]" do
6
- parse("{:one => 1, :two => 2}", v).find_node(:hash).tap do |hash|
7
- hash.should have_position(0, 0, 0, 22)
8
- end
9
- end
10
- end
11
-
12
- it "should parse a hash literal (a,b) [1.8]" do
13
- parse("{:one, 1, :two, 2}", 1.8).find_node(:hash).tap do |hash|
14
- hash.should have_position(0, 0, 0, 18)
15
- end
16
- end
17
-
18
- it "should parse a hash literal (a: b) [1.9]" do
19
- parse("{one: 1, two: 2}", 1.9).find_node(:hash).should have_position(0, 0, 0, 16)
20
- end
21
- end