parser 2.0.0.beta6 → 2.0.0.beta7
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +15 -0
- data/CHANGELOG.md +12 -0
- data/README.md +1 -1
- data/Rakefile +15 -0
- data/lib/parser.rb +39 -39
- data/lib/parser/base.rb +2 -5
- data/lib/parser/builders/default.rb +25 -5
- data/lib/parser/lexer/explanation.rb +1 -1
- data/lib/parser/ruby18.y +4 -9
- data/lib/parser/ruby19.y +4 -9
- data/lib/parser/ruby20.y +4 -9
- data/lib/parser/ruby21.y +4 -9
- data/lib/parser/runner.rb +7 -2
- data/lib/parser/runner/ruby_parse.rb +3 -3
- data/lib/parser/runner/ruby_rewrite.rb +1 -1
- data/lib/parser/source/buffer.rb +11 -9
- data/lib/parser/source/rewriter.rb +1 -1
- data/lib/parser/source/rewriter/action.rb +2 -2
- data/lib/parser/version.rb +1 -1
- data/test/helper.rb +2 -2
- data/test/parse_helper.rb +5 -5
- data/test/test_diagnostic.rb +7 -7
- data/test/test_diagnostic_engine.rb +5 -5
- data/test/test_encoding.rb +7 -7
- data/test/test_lexer.rb +2 -2
- data/test/test_parse_helper.rb +2 -2
- data/test/test_parser.rb +89 -56
- data/test/test_source_buffer.rb +6 -6
- data/test/test_source_range.rb +3 -3
- data/test/test_source_rewriter.rb +1 -1
- data/test/test_source_rewriter_action.rb +8 -8
- metadata +2 -2
data/test/test_source_buffer.rb
CHANGED
@@ -67,24 +67,24 @@ class TestSourceBuffer < Minitest::Test
|
|
67
67
|
def test_line
|
68
68
|
@buffer.source = "1\nfoo\nbar"
|
69
69
|
|
70
|
-
assert_equal
|
71
|
-
assert_equal
|
70
|
+
assert_equal '1', @buffer.source_line(1)
|
71
|
+
assert_equal 'foo', @buffer.source_line(2)
|
72
72
|
end
|
73
73
|
|
74
74
|
def test_line_mutate
|
75
75
|
@buffer.source = "1\nfoo\nbar"
|
76
76
|
|
77
|
-
assert_equal
|
77
|
+
assert_equal '1', @buffer.source_line(1)
|
78
78
|
|
79
79
|
@buffer.source_line(1)[0] = '2'
|
80
|
-
assert_equal
|
80
|
+
assert_equal '1', @buffer.source_line(1)
|
81
81
|
end
|
82
82
|
|
83
83
|
def test_line_mapped
|
84
84
|
@buffer = Parser::Source::Buffer.new('(string)', 5)
|
85
85
|
@buffer.source = "1\nfoo\nbar"
|
86
86
|
|
87
|
-
assert_equal
|
88
|
-
assert_equal
|
87
|
+
assert_equal '1', @buffer.source_line(5)
|
88
|
+
assert_equal 'foo', @buffer.source_line(6)
|
89
89
|
end
|
90
90
|
end
|
data/test/test_source_range.rb
CHANGED
@@ -34,7 +34,7 @@ class TestSourceRange < Minitest::Test
|
|
34
34
|
|
35
35
|
def test_source_line
|
36
36
|
sr = Parser::Source::Range.new(@buf, 7, 8)
|
37
|
-
assert_equal
|
37
|
+
assert_equal 'baz', sr.source_line
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_columns
|
@@ -58,7 +58,7 @@ class TestSourceRange < Minitest::Test
|
|
58
58
|
|
59
59
|
def test_source
|
60
60
|
sr = Parser::Source::Range.new(@buf, 0, 3)
|
61
|
-
assert_equal
|
61
|
+
assert_equal 'foo', sr.source
|
62
62
|
|
63
63
|
sr_multi = Parser::Source::Range.new(@buf, 0, 10)
|
64
64
|
assert_equal "foobar\nbaz", sr_multi.source
|
@@ -72,6 +72,6 @@ class TestSourceRange < Minitest::Test
|
|
72
72
|
|
73
73
|
def test_to_s
|
74
74
|
sr = Parser::Source::Range.new(@buf, 8, 9)
|
75
|
-
assert_equal
|
75
|
+
assert_equal '(string):2:2', sr.to_s
|
76
76
|
end
|
77
77
|
end
|
@@ -69,7 +69,7 @@ class TestSourceRewriter < Minitest::Test
|
|
69
69
|
assert_equal 2, diagnostics.count
|
70
70
|
|
71
71
|
assert_equal :error, diagnostics.first.level
|
72
|
-
assert_equal
|
72
|
+
assert_equal 'cannot remove 1 character(s)',
|
73
73
|
diagnostics.first.message
|
74
74
|
assert_equal range(3, 1), diagnostics.first.location
|
75
75
|
|
@@ -15,30 +15,30 @@ class TestSourceRewriterAction < Minitest::Test
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_accessors
|
18
|
-
action = action(range(1, 10),
|
18
|
+
action = action(range(1, 10), 'foo')
|
19
19
|
|
20
20
|
assert action.frozen?
|
21
21
|
assert_equal range(1, 10), action.range
|
22
|
-
assert_equal
|
22
|
+
assert_equal 'foo', action.replacement
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_to_s_replace
|
26
|
-
action = action(range(3, 1),
|
26
|
+
action = action(range(3, 1), 'foo')
|
27
27
|
assert_equal "replace 1 character(s) with \"foo\"", action.to_s
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_to_s_insert
|
31
|
-
action = action(range(3, 0),
|
31
|
+
action = action(range(3, 0), 'foo')
|
32
32
|
assert_equal "insert \"foo\"", action.to_s
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_to_s_remove
|
36
|
-
action = action(range(3, 2),
|
37
|
-
assert_equal
|
36
|
+
action = action(range(3, 2), '')
|
37
|
+
assert_equal 'remove 2 character(s)', action.to_s
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_to_s_nop
|
41
|
-
action = action(range(3, 0),
|
42
|
-
assert_equal
|
41
|
+
action = action(range(3, 0), '')
|
42
|
+
assert_equal 'do nothing', action.to_s
|
43
43
|
end
|
44
44
|
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.
|
4
|
+
version: 2.0.0.beta7
|
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-
|
11
|
+
date: 2013-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ast
|