parser 2.0.0.beta5 → 2.0.0.beta6

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,11 +2,20 @@ require 'helper'
2
2
  require 'parser/ruby18'
3
3
 
4
4
  class TestSourceCommentAssociator < Minitest::Test
5
- def test_associate
5
+ def associate(code)
6
6
  parser = Parser::Ruby18.new
7
7
 
8
8
  buffer = Parser::Source::Buffer.new('(comments)')
9
- buffer.source = <<-END
9
+ buffer.source = code
10
+
11
+ ast, comments = parser.parse_with_comments(buffer)
12
+ associations = Parser::Source::Comment.associate(ast, comments)
13
+
14
+ [ ast, associations ]
15
+ end
16
+
17
+ def test_associate
18
+ ast, associations = associate(<<-END)
10
19
  # Class comment
11
20
  # another class comment
12
21
  class Foo
@@ -23,9 +32,6 @@ class Foo
23
32
  end
24
33
  END
25
34
 
26
- ast, comments = parser.parse_with_comments(buffer)
27
- associations = Parser::Source::Comment.associate(ast, comments)
28
-
29
35
  klass_node = ast
30
36
  attr_accessor_node = ast.children[2].children[0]
31
37
  method_node = ast.children[2].children[1]
@@ -45,4 +51,16 @@ end
45
51
  associations[intermediate_node].map(&:text)
46
52
  end
47
53
 
54
+ def test_associate_no_body
55
+ ast, associations = associate(<<-END)
56
+ # foo
57
+ class Foo
58
+ end
59
+ END
60
+
61
+ assert_equal 1, associations.size
62
+ assert_equal ['# foo'],
63
+ associations[ast].map(&:text)
64
+ end
65
+
48
66
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta5
4
+ version: 2.0.0.beta6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Zotov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-08 00:00:00.000000000 Z
11
+ date: 2013-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ast
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '1.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '1.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: slop
29
29
  requirement: !ruby/object:Gem::Requirement