brakeman 3.5.0 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +15 -4
- data/bin/brakeman +6 -1
- data/bundle/load.rb +2 -2
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/Manifest.txt +5 -0
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/README.rdoc +12 -0
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/Rakefile +127 -70
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/compare/normalize.rb +146 -0
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/rp_extensions.rb +77 -0
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/rp_stringscanner.rb +64 -0
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby18_parser.rb +1637 -1646
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby18_parser.y +11 -11
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby19_parser.rb +1602 -1603
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby19_parser.y +12 -12
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby20_parser.rb +2507 -2524
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby20_parser.y +12 -26
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby21_parser.rb +1872 -1868
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby21_parser.y +12 -21
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby22_parser.rb +1758 -1754
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby22_parser.y +12 -21
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby23_parser.rb +1844 -1847
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby23_parser.y +12 -21
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby24_parser.rb +6790 -0
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby24_parser.y +2364 -0
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby_lexer.rb +12 -16
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby_lexer.rex.rb +6 -12
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby_parser.rb +86 -7
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby_parser.yy +51 -50
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby_parser_extras.rb +30 -237
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/test/test_ruby_lexer.rb +54 -41
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/test/test_ruby_parser.rb +775 -700
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/test/test_ruby_parser_extras.rb +4 -6
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/History.txt +7 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/Manifest.txt +0 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/README.txt +0 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/Rakefile +0 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/lib/composite_sexp_processor.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/lib/pt_testcase.rb +3 -1
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/lib/sexp.rb +7 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/lib/sexp_processor.rb +7 -5
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/lib/unique.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/test/test_composite_sexp_processor.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/test/test_environment.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/test/test_sexp.rb +21 -2
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/test/test_sexp_processor.rb +13 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/CHANGELOG.md +4 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/COPYING +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/Gemfile +1 -1
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/HACKING +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/README.md +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/Rakefile +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/bin/tilt +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/docs/TEMPLATES.md +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/docs/common.css +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt.rb +1 -1
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/asciidoc.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/babel.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/bluecloth.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/builder.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/coffee.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/commonmarker.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/creole.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/csv.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/dummy.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/erb.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/erubi.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/erubis.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/etanni.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/haml.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/kramdown.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/less.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/liquid.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/livescript.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/mapping.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/markaby.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/maruku.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/nokogiri.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/pandoc.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/plain.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/prawn.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/radius.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/rdiscount.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/rdoc.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/redcarpet.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/redcloth.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/rst-pandoc.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/sass.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/sigil.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/string.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/template.rb +10 -1
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/typescript.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/wikicloth.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/yajl.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/man/index.txt +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/man/tilt.1.ronn +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/markaby/locals.mab +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/markaby/markaby.mab +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/markaby/markaby_other_static.mab +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/markaby/render_twice.mab +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/markaby/scope.mab +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/markaby/yielding.mab +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/mytemplate.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/test_helper.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_asciidoctor_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_babeltemplate.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_blueclothtemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_buildertemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_cache_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_coffeescripttemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_commonmarkertemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_compilesite_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_creoletemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_csv_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_erbtemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_erubistemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_erubitemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_etannitemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_hamltemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_kramdown_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_lesstemplate_test.less +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_lesstemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_liquidtemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_livescripttemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_mapping_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_markaby_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_markdown_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_marukutemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_metadata_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_nokogiritemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_pandoctemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_prawntemplate.prawn +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_prawntemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_radiustemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_rdiscounttemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_rdoctemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_redcarpettemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_redclothtemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_rstpandoctemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_sasstemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_sigil_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_stringtemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_template_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_typescript_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_wikiclothtemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_yajltemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/tilt.gemspec +2 -2
- data/lib/brakeman.rb +4 -0
- data/lib/brakeman/checks/check_sql.rb +2 -2
- data/lib/brakeman/checks/check_xml_dos.rb +0 -6
- data/lib/brakeman/options.rb +4 -0
- data/lib/brakeman/parsers/rails3_erubis.rb +7 -0
- data/lib/brakeman/processors/alias_processor.rb +101 -0
- data/lib/brakeman/processors/controller_processor.rb +3 -1
- data/lib/brakeman/version.rb +1 -1
- metadata +125 -118
@@ -2,16 +2,16 @@
|
|
2
2
|
|
3
3
|
# ENV['VERBOSE'] = "1"
|
4
4
|
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require 'ruby_parser'
|
5
|
+
require "minitest/autorun"
|
6
|
+
require "ruby_parser"
|
8
7
|
|
9
|
-
$: << File.expand_path(
|
8
|
+
$: << File.expand_path("~/Work/p4/zss/src/sexp_processor/dev/lib")
|
10
9
|
|
11
|
-
require
|
10
|
+
require "pt_testcase"
|
12
11
|
|
13
12
|
class Sexp
|
14
13
|
alias oldeq2 ==
|
14
|
+
# TODO: push up to Sexp
|
15
15
|
def ==(obj) # :nodoc:
|
16
16
|
if obj.class == self.class then
|
17
17
|
super and
|
@@ -22,62 +22,6 @@ class Sexp
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
class RubyParserTestCase < ParseTreeTestCase
|
26
|
-
attr_accessor :result, :processor
|
27
|
-
|
28
|
-
make_my_diffs_pretty!
|
29
|
-
|
30
|
-
def self.previous key
|
31
|
-
"Ruby"
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.generate_test klass, node, data, input_name, output_name
|
35
|
-
return if node.to_s =~ /bmethod|dmethod/
|
36
|
-
return if Array === data['Ruby']
|
37
|
-
|
38
|
-
output_name = "ParseTree"
|
39
|
-
|
40
|
-
super
|
41
|
-
end
|
42
|
-
|
43
|
-
def assert_parse rb, pt
|
44
|
-
self.result = processor.parse rb
|
45
|
-
assert_equal pt, result
|
46
|
-
end
|
47
|
-
|
48
|
-
def refute_parse rb
|
49
|
-
self.result = processor.parse rb
|
50
|
-
assert_nil result
|
51
|
-
end
|
52
|
-
|
53
|
-
def assert_syntax_error rb, emsg
|
54
|
-
e = nil
|
55
|
-
assert_silent do
|
56
|
-
e = assert_raises RubyParser::SyntaxError do
|
57
|
-
processor.parse rb
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
assert_equal emsg, e.message
|
62
|
-
end
|
63
|
-
|
64
|
-
def assert_parse_error rb, emsg
|
65
|
-
e = nil
|
66
|
-
assert_silent do
|
67
|
-
e = assert_raises Racc::ParseError do
|
68
|
-
processor.parse rb
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
assert_equal emsg, e.message
|
73
|
-
end
|
74
|
-
|
75
|
-
def assert_parse_line rb, pt, line
|
76
|
-
assert_parse rb, pt
|
77
|
-
assert_equal line, result.line, "call should have line number"
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
25
|
module TestRubyParserShared
|
82
26
|
def setup
|
83
27
|
super
|
@@ -388,7 +332,7 @@ module TestRubyParserShared
|
|
388
332
|
end
|
389
333
|
|
390
334
|
def test_lasgn_env
|
391
|
-
rb =
|
335
|
+
rb = "a = 42"
|
392
336
|
pt = s(:lasgn, :a, s(:lit, 42))
|
393
337
|
expected_env = { :a => :lvar }
|
394
338
|
|
@@ -397,7 +341,7 @@ module TestRubyParserShared
|
|
397
341
|
end
|
398
342
|
|
399
343
|
def test_lasgn_ivar_env
|
400
|
-
rb =
|
344
|
+
rb = "@a = 42"
|
401
345
|
pt = s(:iasgn, :@a, s(:lit, 42))
|
402
346
|
|
403
347
|
assert_parse rb, pt
|
@@ -484,15 +428,15 @@ module TestRubyParserShared
|
|
484
428
|
assert_equal s(:str, "blah"), processor.literal_concat(lhs, rhs)
|
485
429
|
end
|
486
430
|
|
487
|
-
def
|
431
|
+
def test_logical_op_12
|
488
432
|
lhs = s(:lit, 1)
|
489
433
|
rhs = s(:lit, 2)
|
490
434
|
exp = s(:and, s(:lit, 1), s(:lit, 2))
|
491
435
|
|
492
|
-
assert_equal exp, processor.
|
436
|
+
assert_equal exp, processor.logical_op(:and, lhs, rhs)
|
493
437
|
end
|
494
438
|
|
495
|
-
def
|
439
|
+
def test_logical_op_1234_5
|
496
440
|
lhs = s(:and, s(:lit, 1), s(:and, s(:lit, 2), s(:and, s(:lit, 3), s(:lit, 4))))
|
497
441
|
rhs = s(:lit, 5)
|
498
442
|
exp = s(:and,
|
@@ -505,10 +449,10 @@ module TestRubyParserShared
|
|
505
449
|
s(:lit, 4),
|
506
450
|
s(:lit, 5)))))
|
507
451
|
|
508
|
-
assert_equal exp, processor.
|
452
|
+
assert_equal exp, processor.logical_op(:and, lhs, rhs)
|
509
453
|
end
|
510
454
|
|
511
|
-
def
|
455
|
+
def test_logical_op_123_4
|
512
456
|
lhs = s(:and, s(:lit, 1), s(:and, s(:lit, 2), s(:lit, 3)))
|
513
457
|
rhs = s(:lit, 4)
|
514
458
|
exp = s(:and,
|
@@ -519,18 +463,18 @@ module TestRubyParserShared
|
|
519
463
|
s(:lit, 3),
|
520
464
|
s(:lit, 4))))
|
521
465
|
|
522
|
-
assert_equal exp, processor.
|
466
|
+
assert_equal exp, processor.logical_op(:and, lhs, rhs)
|
523
467
|
end
|
524
468
|
|
525
|
-
def
|
469
|
+
def test_logical_op_12_3
|
526
470
|
lhs = s(:and, s(:lit, 1), s(:lit, 2))
|
527
471
|
rhs = s(:lit, 3)
|
528
472
|
exp = s(:and, s(:lit, 1), s(:and, s(:lit, 2), s(:lit, 3)))
|
529
473
|
|
530
|
-
assert_equal exp, processor.
|
474
|
+
assert_equal exp, processor.logical_op(:and, lhs, rhs)
|
531
475
|
end
|
532
476
|
|
533
|
-
def
|
477
|
+
def test_logical_op_nested_mix
|
534
478
|
lhs = s(:or, s(:call, nil, :a), s(:call, nil, :b))
|
535
479
|
rhs = s(:and, s(:call, nil, :c), s(:call, nil, :d))
|
536
480
|
exp = s(:or,
|
@@ -540,7 +484,7 @@ module TestRubyParserShared
|
|
540
484
|
lhs.paren = true
|
541
485
|
rhs.paren = true
|
542
486
|
|
543
|
-
assert_equal exp, processor.
|
487
|
+
assert_equal exp, processor.logical_op(:or, lhs, rhs)
|
544
488
|
end
|
545
489
|
|
546
490
|
def test_str_evstr
|
@@ -553,7 +497,7 @@ module TestRubyParserShared
|
|
553
497
|
def test_dsym_to_sym
|
554
498
|
pt = s(:alias, s(:lit, :<<), s(:lit, :>>))
|
555
499
|
|
556
|
-
rb =
|
500
|
+
rb = "alias :<< :>>"
|
557
501
|
assert_parse rb, pt
|
558
502
|
|
559
503
|
rb = 'alias :"<<" :">>"'
|
@@ -627,6 +571,14 @@ module TestRubyParserShared
|
|
627
571
|
assert_parse rb, pt
|
628
572
|
end
|
629
573
|
|
574
|
+
def test_str_newline_hash_line_number
|
575
|
+
rb = "\"\\n\\n\\n\\n#\"\n1"
|
576
|
+
pt = s(:block, s(:str, "\n\n\n\n#").line(1),
|
577
|
+
s(:lit, 1).line(2))
|
578
|
+
|
579
|
+
assert_parse rb, pt
|
580
|
+
end
|
581
|
+
|
630
582
|
def after_process_hook klass, node, data, input_name, output_name
|
631
583
|
assert_equal 1, @result.line, "should have proper line number"
|
632
584
|
end
|
@@ -857,6 +809,19 @@ module TestRubyParserShared
|
|
857
809
|
assert_parse_line rb, pt, 1
|
858
810
|
end
|
859
811
|
|
812
|
+
def test_parse_line_rescue
|
813
|
+
skip "not yet"
|
814
|
+
rb = "begin\n a\n rescue\n b\n rescue\n c\n end\n"
|
815
|
+
pt = s(:rescue,
|
816
|
+
s(:call, nil, :a).line(2),
|
817
|
+
s(:resbody, s(:array).line(3),
|
818
|
+
s(:call, nil, :b).line(4)).line(3),
|
819
|
+
s(:resbody, s(:array).line(5),
|
820
|
+
s(:call, nil, :c).line(6)).line(5)).line(1)
|
821
|
+
|
822
|
+
assert_parse_line rb, pt, 1
|
823
|
+
end
|
824
|
+
|
860
825
|
def test_parse_line_return
|
861
826
|
rb = <<-RUBY
|
862
827
|
def blah
|
@@ -943,27 +908,7 @@ module TestRubyParserShared
|
|
943
908
|
end
|
944
909
|
|
945
910
|
def ruby18
|
946
|
-
|
947
|
-
end
|
948
|
-
|
949
|
-
def ruby19
|
950
|
-
Ruby19Parser === self.processor
|
951
|
-
end
|
952
|
-
|
953
|
-
def ruby20
|
954
|
-
Ruby20Parser === self.processor
|
955
|
-
end
|
956
|
-
|
957
|
-
def ruby21
|
958
|
-
Ruby21Parser === self.processor
|
959
|
-
end
|
960
|
-
|
961
|
-
def ruby22
|
962
|
-
Ruby22Parser === self.processor
|
963
|
-
end
|
964
|
-
|
965
|
-
def ruby23
|
966
|
-
Ruby23Parser === self.processor
|
911
|
+
RubyParser::V18 === self.processor
|
967
912
|
end
|
968
913
|
|
969
914
|
def test_bug_comma
|
@@ -1021,10 +966,8 @@ module TestRubyParserShared
|
|
1021
966
|
rb = "not(a)"
|
1022
967
|
pt = if ruby18 then
|
1023
968
|
s(:not, s(:call, nil, :a))
|
1024
|
-
elsif ruby19 or ruby20 or ruby21 or ruby22 or ruby23 then
|
1025
|
-
s(:call, s(:call, nil, :a), :"!")
|
1026
969
|
else
|
1027
|
-
|
970
|
+
s(:call, s(:call, nil, :a), :"!")
|
1028
971
|
end
|
1029
972
|
|
1030
973
|
assert_parse rb, pt
|
@@ -1627,11 +1570,11 @@ module TestRubyParserShared
|
|
1627
1570
|
|
1628
1571
|
def test___ENCODING__
|
1629
1572
|
rb = "__ENCODING__"
|
1630
|
-
pt = if
|
1573
|
+
pt = if RubyParser::V18 === processor then
|
1631
1574
|
s(:call, nil, :__ENCODING__)
|
1632
1575
|
else
|
1633
1576
|
if defined? Encoding then
|
1634
|
-
if
|
1577
|
+
if RubyParser::V18 === processor then
|
1635
1578
|
s(:call, nil, :__ENCODING__)
|
1636
1579
|
else
|
1637
1580
|
s(:colon2, s(:const, :Encoding), :UTF_8)
|
@@ -1657,9 +1600,117 @@ module TestRubyParserShared
|
|
1657
1600
|
assert_syntax_error "def a; class B; end; end", err
|
1658
1601
|
assert_syntax_error "def a; def b; end; class B; end; end", err
|
1659
1602
|
end
|
1603
|
+
|
1604
|
+
def test_call_not
|
1605
|
+
rb = "not 42"
|
1606
|
+
pt = s(:not, s(:lit, 42))
|
1607
|
+
|
1608
|
+
assert_parse rb, pt
|
1609
|
+
end
|
1610
|
+
|
1611
|
+
def test_call_bang_command_call
|
1612
|
+
rb = "! a.b 1"
|
1613
|
+
pt = s(:not, s(:call, s(:call, nil, :a), :b, s(:lit, 1)))
|
1614
|
+
|
1615
|
+
assert_parse rb, pt
|
1616
|
+
end
|
1617
|
+
|
1618
|
+
def test_call_unary_bang
|
1619
|
+
rb = "!1"
|
1620
|
+
pt = s(:not, s(:lit, 1))
|
1621
|
+
|
1622
|
+
assert_parse rb, pt
|
1623
|
+
end
|
1624
|
+
|
1625
|
+
def test_bang_eq
|
1626
|
+
rb = "1 != 2"
|
1627
|
+
pt = s(:not, s(:call, s(:lit, 1), :"==", s(:lit, 2)))
|
1628
|
+
|
1629
|
+
assert_parse rb, pt
|
1630
|
+
end
|
1631
|
+
|
1632
|
+
def test_flip2_env_lvar
|
1633
|
+
rb = "if a..b then end"
|
1634
|
+
pt = s(:if, s(:flip2, s(:call, nil, :a), s(:call, nil, :b)), nil, nil)
|
1635
|
+
|
1636
|
+
assert_parse rb, pt
|
1637
|
+
|
1638
|
+
top_env = processor.env.env.first
|
1639
|
+
|
1640
|
+
assert_kind_of Hash, top_env
|
1641
|
+
|
1642
|
+
flip = top_env.find { |k,v| k =~ /^flip/ }
|
1643
|
+
|
1644
|
+
assert flip
|
1645
|
+
assert_equal :lvar, flip.last
|
1646
|
+
end
|
1647
|
+
|
1648
|
+
def test_parse_until_not_canonical
|
1649
|
+
rb = "until not var.nil?\n 'foo'\nend"
|
1650
|
+
|
1651
|
+
pt = s(:while,
|
1652
|
+
s(:call, s(:call, nil, :var), :nil?),
|
1653
|
+
s(:str, "foo"), true)
|
1654
|
+
|
1655
|
+
assert_parse rb, pt
|
1656
|
+
end
|
1657
|
+
|
1658
|
+
def test_parse_until_not_noncanonical
|
1659
|
+
rb = "until not var.nil?\n 'foo'\nend"
|
1660
|
+
pt = s(:until,
|
1661
|
+
s(:not, s(:call, s(:call, nil, :var), :nil?)),
|
1662
|
+
s(:str, "foo"), true)
|
1663
|
+
|
1664
|
+
processor.canonicalize_conditions = false
|
1665
|
+
|
1666
|
+
assert_parse rb, pt
|
1667
|
+
end
|
1668
|
+
|
1669
|
+
def test_parse_if_not_canonical
|
1670
|
+
rb = "if not var.nil? then 'foo' else 'bar'\nend"
|
1671
|
+
pt = s(:if,
|
1672
|
+
s(:call, s(:call, nil, :var), :nil?),
|
1673
|
+
s(:str, "bar"),
|
1674
|
+
s(:str, "foo"))
|
1675
|
+
|
1676
|
+
assert_parse rb, pt
|
1677
|
+
end
|
1678
|
+
|
1679
|
+
def test_parse_if_not_noncanonical
|
1680
|
+
rb = "if not var.nil? then 'foo' else 'bar'\nend"
|
1681
|
+
pt = s(:if,
|
1682
|
+
s(:not, s(:call, s(:call, nil, :var), :nil?)),
|
1683
|
+
s(:str, "foo"),
|
1684
|
+
s(:str, "bar"))
|
1685
|
+
|
1686
|
+
processor.canonicalize_conditions = false
|
1687
|
+
|
1688
|
+
assert_parse rb, pt
|
1689
|
+
end
|
1690
|
+
|
1691
|
+
def test_parse_while_not_canonical
|
1692
|
+
rb = "while not var.nil?\n 'foo'\nend"
|
1693
|
+
pt = s(:until,
|
1694
|
+
s(:call, s(:call, nil, :var), :nil?),
|
1695
|
+
s(:str, "foo"), true)
|
1696
|
+
|
1697
|
+
assert_parse rb, pt
|
1698
|
+
end
|
1699
|
+
|
1700
|
+
def test_parse_while_not_noncanonical
|
1701
|
+
rb = "while not var.nil?\n 'foo'\nend"
|
1702
|
+
pt = s(:while,
|
1703
|
+
s(:not, s(:call, s(:call, nil, :var), :nil?)),
|
1704
|
+
s(:str, "foo"), true)
|
1705
|
+
|
1706
|
+
processor.canonicalize_conditions = false
|
1707
|
+
|
1708
|
+
assert_parse rb, pt
|
1709
|
+
end
|
1710
|
+
|
1660
1711
|
end
|
1661
1712
|
|
1662
|
-
module
|
1713
|
+
module TestRubyParserShared19Plus
|
1663
1714
|
def test_aref_args_lit_assocs
|
1664
1715
|
rb = "[1, 2 => 3]"
|
1665
1716
|
pt = s(:array, s(:lit, 1), s(:hash, s(:lit, 2), s(:lit, 3)))
|
@@ -2223,429 +2274,66 @@ module TestRubyParserShared19to22
|
|
2223
2274
|
assert_parse "f(state: {\n})", pt
|
2224
2275
|
assert_parse "f(state:\n {\n})", pt
|
2225
2276
|
end
|
2226
|
-
end
|
2227
|
-
|
2228
|
-
module TestRubyParserShared20to22
|
2229
|
-
def test_non_interpolated_symbol_array_line_breaks
|
2230
2277
|
|
2231
|
-
|
2232
|
-
|
2278
|
+
def test_mlhs_back_splat
|
2279
|
+
rb = "a, b, c, *s = f"
|
2280
|
+
pt = s(:masgn,
|
2233
2281
|
s(:array,
|
2234
|
-
s(:
|
2235
|
-
s(:
|
2236
|
-
s(:
|
2282
|
+
s(:lasgn, :a), s(:lasgn, :b), s(:lasgn, :c),
|
2283
|
+
s(:splat, s(:lasgn, :s))),
|
2284
|
+
s(:to_ary, s(:call, nil, :f)))
|
2285
|
+
|
2237
2286
|
assert_parse rb, pt
|
2238
2287
|
end
|
2239
2288
|
|
2240
|
-
def
|
2241
|
-
|
2242
|
-
|
2243
|
-
pt = s(:block,
|
2289
|
+
def test_mlhs_back_anonsplat
|
2290
|
+
rb = "a, b, c, * = f"
|
2291
|
+
pt = s(:masgn,
|
2244
2292
|
s(:array,
|
2245
|
-
s(:
|
2246
|
-
s(:
|
2247
|
-
s(:
|
2293
|
+
s(:lasgn, :a), s(:lasgn, :b), s(:lasgn, :c),
|
2294
|
+
s(:splat)),
|
2295
|
+
s(:to_ary, s(:call, nil, :f)))
|
2296
|
+
|
2248
2297
|
assert_parse rb, pt
|
2249
2298
|
end
|
2250
2299
|
|
2251
|
-
def
|
2252
|
-
rb = "
|
2253
|
-
pt = s(:
|
2300
|
+
def test_mlhs_mid_splat
|
2301
|
+
rb = "a, b, c, *s, x, y, z = f"
|
2302
|
+
pt = s(:masgn,
|
2303
|
+
s(:array,
|
2304
|
+
s(:lasgn, :a), s(:lasgn, :b), s(:lasgn, :c),
|
2305
|
+
s(:splat, s(:lasgn, :s)),
|
2306
|
+
s(:lasgn, :x), s(:lasgn, :y), s(:lasgn, :z)),
|
2307
|
+
s(:to_ary, s(:call, nil, :f)))
|
2254
2308
|
|
2255
2309
|
assert_parse rb, pt
|
2256
2310
|
end
|
2257
2311
|
|
2258
|
-
def
|
2259
|
-
rb = "
|
2260
|
-
pt = s(:
|
2312
|
+
def test_mlhs_mid_anonsplat
|
2313
|
+
rb = "a, b, c, *, x, y, z = f"
|
2314
|
+
pt = s(:masgn,
|
2315
|
+
s(:array, s(:lasgn, :a), s(:splat), s(:lasgn, :z)),
|
2316
|
+
s(:to_ary, s(:call, nil, :f)))
|
2317
|
+
pt = s(:masgn,
|
2318
|
+
s(:array,
|
2319
|
+
s(:lasgn, :a), s(:lasgn, :b), s(:lasgn, :c),
|
2320
|
+
s(:splat),
|
2321
|
+
s(:lasgn, :x), s(:lasgn, :y), s(:lasgn, :z)),
|
2322
|
+
s(:to_ary, s(:call, nil, :f)))
|
2261
2323
|
|
2262
2324
|
assert_parse rb, pt
|
2263
2325
|
end
|
2264
2326
|
|
2265
|
-
def
|
2266
|
-
rb = "
|
2267
|
-
pt = s(:
|
2268
|
-
|
2269
|
-
|
2270
|
-
|
2271
|
-
|
2272
|
-
|
2273
|
-
|
2274
|
-
|
2275
|
-
s(:call, nil, :test_splat, s(:hash, s(:kwsplat, s(:lvar, :testing)))))
|
2276
|
-
|
2277
|
-
assert_parse rb, pt
|
2278
|
-
end
|
2279
|
-
|
2280
|
-
def test_dstr_lex_state
|
2281
|
-
rb = '"#{p:a}"'
|
2282
|
-
pt = s(:dstr, "", s(:evstr, s(:call, nil, :p, s(:lit, :a))))
|
2283
|
-
|
2284
|
-
assert_parse rb, pt
|
2285
|
-
end
|
2286
|
-
|
2287
|
-
def test_call_arg_kwsplat
|
2288
|
-
rb = "a(b, **1)"
|
2289
|
-
pt = s(:call, nil, :a, s(:call, nil, :b), s(:hash, s(:kwsplat, s(:lit, 1))))
|
2290
|
-
|
2291
|
-
assert_parse rb, pt
|
2292
|
-
end
|
2293
|
-
|
2294
|
-
def test_call_arg_assoc_kwsplat
|
2295
|
-
rb = "f(1, kw: 2, **3)"
|
2296
|
-
pt = s(:call, nil, :f,
|
2297
|
-
s(:lit, 1),
|
2298
|
-
s(:hash, s(:lit, :kw), s(:lit, 2), s(:kwsplat, s(:lit, 3))))
|
2299
|
-
|
2300
|
-
assert_parse rb, pt
|
2301
|
-
end
|
2302
|
-
|
2303
|
-
def test_call_kwsplat
|
2304
|
-
rb = "a(**1)"
|
2305
|
-
pt = s(:call, nil, :a, s(:hash, s(:kwsplat, s(:lit, 1))))
|
2306
|
-
|
2307
|
-
assert_parse rb, pt
|
2308
|
-
end
|
2309
|
-
|
2310
|
-
def test_iter_kwarg
|
2311
|
-
rb = "a { |b: 1| }"
|
2312
|
-
pt = s(:iter, s(:call, nil, :a), s(:args, s(:kwarg, :b, s(:lit, 1))))
|
2313
|
-
|
2314
|
-
assert_parse rb, pt
|
2315
|
-
end
|
2316
|
-
|
2317
|
-
def test_iter_kwarg_kwsplat
|
2318
|
-
rb = "a { |b: 1, **c| }"
|
2319
|
-
pt = s(:iter, s(:call, nil, :a), s(:args, s(:kwarg, :b, s(:lit, 1)), :"**c"))
|
2320
|
-
|
2321
|
-
assert_parse rb, pt
|
2322
|
-
end
|
2323
|
-
|
2324
|
-
def test_block_kwarg_lvar
|
2325
|
-
rb = "bl { |kw: :val| kw }"
|
2326
|
-
pt = s(:iter, s(:call, nil, :bl), s(:args, s(:kwarg, :kw, s(:lit, :val))),
|
2327
|
-
s(:lvar, :kw))
|
2328
|
-
|
2329
|
-
assert_parse rb, pt
|
2330
|
-
end
|
2331
|
-
|
2332
|
-
def test_block_kwarg_lvar_multiple
|
2333
|
-
rb = "bl { |kw: :val, kw2: :val2 | kw }"
|
2334
|
-
pt = s(:iter, s(:call, nil, :bl),
|
2335
|
-
s(:args,
|
2336
|
-
s(:kwarg, :kw, s(:lit, :val)),
|
2337
|
-
s(:kwarg, :kw2, s(:lit, :val2))),
|
2338
|
-
s(:lvar, :kw))
|
2339
|
-
|
2340
|
-
assert_parse rb, pt
|
2341
|
-
end
|
2342
|
-
end
|
2343
|
-
|
2344
|
-
class TestRubyParser < Minitest::Test
|
2345
|
-
def test_parse
|
2346
|
-
processor = RubyParser.new
|
2347
|
-
|
2348
|
-
# 1.8 only syntax
|
2349
|
-
rb = "while false : 42 end"
|
2350
|
-
pt = s(:while, s(:false), s(:lit, 42), true)
|
2351
|
-
|
2352
|
-
assert_silent do
|
2353
|
-
assert_equal pt, processor.parse(rb)
|
2354
|
-
end
|
2355
|
-
|
2356
|
-
# 1.9 only syntax
|
2357
|
-
rb = "a.()"
|
2358
|
-
pt = s(:call, s(:call, nil, :a), :call)
|
2359
|
-
|
2360
|
-
assert_equal pt, processor.parse(rb)
|
2361
|
-
|
2362
|
-
# bad syntax
|
2363
|
-
e = assert_raises Racc::ParseError do
|
2364
|
-
capture_io do
|
2365
|
-
processor.parse "a.("
|
2366
|
-
end
|
2367
|
-
end
|
2368
|
-
|
2369
|
-
msg = "(string):1 :: parse error on value \"(\" (tLPAREN2)"
|
2370
|
-
assert_equal msg, e.message.strip
|
2371
|
-
end
|
2372
|
-
end
|
2373
|
-
|
2374
|
-
class TestRuby18Parser < RubyParserTestCase
|
2375
|
-
include TestRubyParserShared
|
2376
|
-
|
2377
|
-
def setup
|
2378
|
-
super
|
2379
|
-
|
2380
|
-
self.processor = Ruby18Parser.new
|
2381
|
-
end
|
2382
|
-
|
2383
|
-
def test_call_space_before_paren_args
|
2384
|
-
rb = "a (:b, :c, :d => :e)"
|
2385
|
-
pt = s(:call, nil, :a,
|
2386
|
-
s(:lit, :b),
|
2387
|
-
s(:lit, :c),
|
2388
|
-
s(:hash, s(:lit, :d), s(:lit, :e)))
|
2389
|
-
|
2390
|
-
assert_parse rb, pt
|
2391
|
-
end
|
2392
|
-
|
2393
|
-
def test_flip2_env_lvar
|
2394
|
-
rb = "if a..b then end"
|
2395
|
-
pt = s(:if, s(:flip2, s(:call, nil, :a), s(:call, nil, :b)), nil, nil)
|
2396
|
-
|
2397
|
-
assert_parse rb, pt
|
2398
|
-
|
2399
|
-
top_env = processor.env.env.first
|
2400
|
-
|
2401
|
-
assert_kind_of Hash, top_env
|
2402
|
-
|
2403
|
-
flip = top_env.find { |k,v| k =~ /^flip/ }
|
2404
|
-
|
2405
|
-
assert flip
|
2406
|
-
assert_equal :lvar, flip.last
|
2407
|
-
end
|
2408
|
-
|
2409
|
-
def test_assoc_list_18
|
2410
|
-
rb = "{1, 2, 3, 4}"
|
2411
|
-
pt = s(:hash, s(:lit, 1), s(:lit, 2), s(:lit, 3), s(:lit, 4))
|
2412
|
-
|
2413
|
-
assert_parse rb, pt
|
2414
|
-
end
|
2415
|
-
|
2416
|
-
def test_case_then_colon_18
|
2417
|
-
rb = "case x; when Fixnum: 42; end"
|
2418
|
-
pt = s(:case,
|
2419
|
-
s(:call, nil, :x),
|
2420
|
-
s(:when, s(:array, s(:const, :Fixnum)), s(:lit, 42)),
|
2421
|
-
nil)
|
2422
|
-
|
2423
|
-
assert_parse rb, pt
|
2424
|
-
end
|
2425
|
-
|
2426
|
-
def test_do_colon_18
|
2427
|
-
rb = "while false : 42 end"
|
2428
|
-
pt = s(:while, s(:false), s(:lit, 42), true)
|
2429
|
-
|
2430
|
-
assert_parse rb, pt
|
2431
|
-
end
|
2432
|
-
|
2433
|
-
def test_parse_until_not_canonical
|
2434
|
-
rb = "until not var.nil?\n 'foo'\nend"
|
2435
|
-
|
2436
|
-
pt = s(:while,
|
2437
|
-
s(:call, s(:call, nil, :var), :nil?),
|
2438
|
-
s(:str, "foo"), true)
|
2439
|
-
|
2440
|
-
assert_parse rb, pt
|
2441
|
-
end
|
2442
|
-
|
2443
|
-
def test_parse_until_not_noncanonical
|
2444
|
-
rb = "until not var.nil?\n 'foo'\nend"
|
2445
|
-
pt = s(:until,
|
2446
|
-
s(:not, s(:call, s(:call, nil, :var), :nil?)),
|
2447
|
-
s(:str, "foo"), true)
|
2448
|
-
|
2449
|
-
processor.canonicalize_conditions = false
|
2450
|
-
|
2451
|
-
assert_parse rb, pt
|
2452
|
-
end
|
2453
|
-
|
2454
|
-
def test_parse_if_not_canonical
|
2455
|
-
rb = "if not var.nil? then 'foo' else 'bar'\nend"
|
2456
|
-
pt = s(:if,
|
2457
|
-
s(:call, s(:call, nil, :var), :nil?),
|
2458
|
-
s(:str, "bar"),
|
2459
|
-
s(:str, "foo"))
|
2460
|
-
|
2461
|
-
assert_parse rb, pt
|
2462
|
-
end
|
2463
|
-
|
2464
|
-
def test_parse_if_not_noncanonical
|
2465
|
-
rb = "if not var.nil? then 'foo' else 'bar'\nend"
|
2466
|
-
pt = s(:if,
|
2467
|
-
s(:not, s(:call, s(:call, nil, :var), :nil?)),
|
2468
|
-
s(:str, "foo"),
|
2469
|
-
s(:str, "bar"))
|
2470
|
-
|
2471
|
-
processor.canonicalize_conditions = false
|
2472
|
-
|
2473
|
-
assert_parse rb, pt
|
2474
|
-
end
|
2475
|
-
|
2476
|
-
def test_parse_while_not_canonical
|
2477
|
-
rb = "while not var.nil?\n 'foo'\nend"
|
2478
|
-
pt = s(:until,
|
2479
|
-
s(:call, s(:call, nil, :var), :nil?),
|
2480
|
-
s(:str, "foo"), true)
|
2481
|
-
|
2482
|
-
assert_parse rb, pt
|
2483
|
-
end
|
2484
|
-
|
2485
|
-
def test_parse_while_not_noncanonical
|
2486
|
-
rb = "while not var.nil?\n 'foo'\nend"
|
2487
|
-
pt = s(:while,
|
2488
|
-
s(:not, s(:call, s(:call, nil, :var), :nil?)),
|
2489
|
-
s(:str, "foo"), true)
|
2490
|
-
|
2491
|
-
processor.canonicalize_conditions = false
|
2492
|
-
|
2493
|
-
assert_parse rb, pt
|
2494
|
-
end
|
2495
|
-
|
2496
|
-
def test_double_block_error_10
|
2497
|
-
assert_syntax_error "a.b (&b) {}", BLOCK_DUP_MSG
|
2498
|
-
end
|
2499
|
-
|
2500
|
-
def test_double_block_error_11
|
2501
|
-
assert_syntax_error "a (1, &b) { }", BLOCK_DUP_MSG
|
2502
|
-
end
|
2503
|
-
|
2504
|
-
def test_double_block_error_12
|
2505
|
-
assert_syntax_error "a (1, &b) do end", BLOCK_DUP_MSG
|
2506
|
-
end
|
2507
|
-
|
2508
|
-
def test_double_block_error_13
|
2509
|
-
assert_syntax_error "m.a (1, &b) { }", BLOCK_DUP_MSG
|
2510
|
-
end
|
2511
|
-
|
2512
|
-
def test_double_block_error_14
|
2513
|
-
assert_syntax_error "m.a (1, &b) do end", BLOCK_DUP_MSG
|
2514
|
-
end
|
2515
|
-
|
2516
|
-
def test_double_block_error_15
|
2517
|
-
assert_syntax_error "m::a (1, &b) { }", BLOCK_DUP_MSG
|
2518
|
-
end
|
2519
|
-
|
2520
|
-
def test_double_block_error_16
|
2521
|
-
assert_syntax_error "m::a (1, &b) do end", BLOCK_DUP_MSG
|
2522
|
-
end
|
2523
|
-
|
2524
|
-
# In 1.8, block args with an outer set of parens are superfluous.
|
2525
|
-
# In 1.9, outer set of parens are NOT... they are an explicit extra masgn.
|
2526
|
-
|
2527
|
-
def test_iter_args_2_18
|
2528
|
-
rb = "f { |(a, b)| }"
|
2529
|
-
pt = s(:iter, s(:call, nil, :f), s(:args, :a, :b))
|
2530
|
-
|
2531
|
-
assert_parse rb, pt
|
2532
|
-
end
|
2533
|
-
|
2534
|
-
def test_bug_args__18
|
2535
|
-
rb = "f { |(a, b)| }"
|
2536
|
-
pt = s(:iter, s(:call, nil, :f),
|
2537
|
-
s(:args, :a, :b))
|
2538
|
-
|
2539
|
-
assert_parse rb, pt
|
2540
|
-
end
|
2541
|
-
|
2542
|
-
def test_bug_args_masgn_outer_parens__18
|
2543
|
-
rb = "f { |((a, b), c)| }"
|
2544
|
-
pt = s(:iter, # NOTE: same sexp as test_bug_args_masgn
|
2545
|
-
s(:call, nil, :f),
|
2546
|
-
s(:args, s(:masgn, :a, :b), :c))
|
2547
|
-
|
2548
|
-
assert_parse rb, pt.dup
|
2549
|
-
end
|
2550
|
-
|
2551
|
-
def test_call_unary_bang
|
2552
|
-
rb = "!1"
|
2553
|
-
pt = s(:not, s(:lit, 1))
|
2554
|
-
|
2555
|
-
assert_parse rb, pt
|
2556
|
-
end
|
2557
|
-
|
2558
|
-
def test_bang_eq
|
2559
|
-
rb = "1 != 2"
|
2560
|
-
pt = s(:not, s(:call, s(:lit, 1), :"==", s(:lit, 2)))
|
2561
|
-
|
2562
|
-
assert_parse rb, pt
|
2563
|
-
end
|
2564
|
-
|
2565
|
-
def test_call_not
|
2566
|
-
rb = "not 42"
|
2567
|
-
pt = s(:not, s(:lit, 42))
|
2568
|
-
|
2569
|
-
assert_parse rb, pt
|
2570
|
-
end
|
2571
|
-
|
2572
|
-
def test_call_bang_command_call
|
2573
|
-
rb = "! a.b 1"
|
2574
|
-
pt = s(:not, s(:call, s(:call, nil, :a), :b, s(:lit, 1)))
|
2575
|
-
|
2576
|
-
assert_parse rb, pt
|
2577
|
-
end
|
2578
|
-
end
|
2579
|
-
|
2580
|
-
class TestRuby19Parser < RubyParserTestCase
|
2581
|
-
include TestRubyParserShared
|
2582
|
-
include TestRubyParserShared19to22
|
2583
|
-
|
2584
|
-
def setup
|
2585
|
-
super
|
2586
|
-
|
2587
|
-
self.processor = Ruby19Parser.new
|
2588
|
-
end
|
2589
|
-
|
2590
|
-
def test_mlhs_back_splat
|
2591
|
-
rb = "a, b, c, *s = f"
|
2592
|
-
pt = s(:masgn,
|
2593
|
-
s(:array,
|
2594
|
-
s(:lasgn, :a), s(:lasgn, :b), s(:lasgn, :c),
|
2595
|
-
s(:splat, s(:lasgn, :s))),
|
2596
|
-
s(:to_ary, s(:call, nil, :f)))
|
2597
|
-
|
2598
|
-
assert_parse rb, pt
|
2599
|
-
end
|
2600
|
-
|
2601
|
-
def test_mlhs_back_anonsplat
|
2602
|
-
rb = "a, b, c, * = f"
|
2603
|
-
pt = s(:masgn,
|
2604
|
-
s(:array,
|
2605
|
-
s(:lasgn, :a), s(:lasgn, :b), s(:lasgn, :c),
|
2606
|
-
s(:splat)),
|
2607
|
-
s(:to_ary, s(:call, nil, :f)))
|
2608
|
-
|
2609
|
-
assert_parse rb, pt
|
2610
|
-
end
|
2611
|
-
|
2612
|
-
def test_mlhs_mid_splat
|
2613
|
-
rb = "a, b, c, *s, x, y, z = f"
|
2614
|
-
pt = s(:masgn,
|
2615
|
-
s(:array,
|
2616
|
-
s(:lasgn, :a), s(:lasgn, :b), s(:lasgn, :c),
|
2617
|
-
s(:splat, s(:lasgn, :s)),
|
2618
|
-
s(:lasgn, :x), s(:lasgn, :y), s(:lasgn, :z)),
|
2619
|
-
s(:to_ary, s(:call, nil, :f)))
|
2620
|
-
|
2621
|
-
assert_parse rb, pt
|
2622
|
-
end
|
2623
|
-
|
2624
|
-
def test_mlhs_mid_anonsplat
|
2625
|
-
rb = "a, b, c, *, x, y, z = f"
|
2626
|
-
pt = s(:masgn,
|
2627
|
-
s(:array, s(:lasgn, :a), s(:splat), s(:lasgn, :z)),
|
2628
|
-
s(:to_ary, s(:call, nil, :f)))
|
2629
|
-
pt = s(:masgn,
|
2630
|
-
s(:array,
|
2631
|
-
s(:lasgn, :a), s(:lasgn, :b), s(:lasgn, :c),
|
2632
|
-
s(:splat),
|
2633
|
-
s(:lasgn, :x), s(:lasgn, :y), s(:lasgn, :z)),
|
2634
|
-
s(:to_ary, s(:call, nil, :f)))
|
2635
|
-
|
2636
|
-
assert_parse rb, pt
|
2637
|
-
end
|
2638
|
-
|
2639
|
-
def test_mlhs_front_splat
|
2640
|
-
rb = "*s, x, y, z = f"
|
2641
|
-
pt = s(:masgn,
|
2642
|
-
s(:array, s(:splat, s(:lasgn, :s)), s(:lasgn, :z)),
|
2643
|
-
s(:to_ary, s(:call, nil, :f)))
|
2644
|
-
pt = s(:masgn,
|
2645
|
-
s(:array,
|
2646
|
-
s(:splat, s(:lasgn, :s)),
|
2647
|
-
s(:lasgn, :x), s(:lasgn, :y), s(:lasgn, :z)),
|
2648
|
-
s(:to_ary, s(:call, nil, :f)))
|
2327
|
+
def test_mlhs_front_splat
|
2328
|
+
rb = "*s, x, y, z = f"
|
2329
|
+
pt = s(:masgn,
|
2330
|
+
s(:array, s(:splat, s(:lasgn, :s)), s(:lasgn, :z)),
|
2331
|
+
s(:to_ary, s(:call, nil, :f)))
|
2332
|
+
pt = s(:masgn,
|
2333
|
+
s(:array,
|
2334
|
+
s(:splat, s(:lasgn, :s)),
|
2335
|
+
s(:lasgn, :x), s(:lasgn, :y), s(:lasgn, :z)),
|
2336
|
+
s(:to_ary, s(:call, nil, :f)))
|
2649
2337
|
|
2650
2338
|
assert_parse rb, pt
|
2651
2339
|
end
|
@@ -2866,7 +2554,7 @@ class TestRuby19Parser < RubyParserTestCase
|
|
2866
2554
|
assert_parse rb, pt
|
2867
2555
|
end
|
2868
2556
|
|
2869
|
-
def
|
2557
|
+
def test_block_args_opt2_2
|
2870
2558
|
rb = "f { |a, b = 42, c = 24| [a, b, c] }"
|
2871
2559
|
pt = s(:iter,
|
2872
2560
|
s(:call, nil, :f),
|
@@ -3062,144 +2750,341 @@ class TestRuby19Parser < RubyParserTestCase
|
|
3062
2750
|
assert_parse rb, pt
|
3063
2751
|
end
|
3064
2752
|
|
3065
|
-
def test_iter_args_11_1
|
3066
|
-
rb = "f { |a, b = 42, *c, d| }"
|
3067
|
-
pt = s(:iter, s(:call, nil, :f),
|
3068
|
-
s(:args, :a, s(:lasgn, :b, s(:lit, 42)), :"*c", :d))
|
2753
|
+
def test_iter_args_11_1
|
2754
|
+
rb = "f { |a, b = 42, *c, d| }"
|
2755
|
+
pt = s(:iter, s(:call, nil, :f),
|
2756
|
+
s(:args, :a, s(:lasgn, :b, s(:lit, 42)), :"*c", :d))
|
2757
|
+
|
2758
|
+
assert_parse rb, pt
|
2759
|
+
end
|
2760
|
+
|
2761
|
+
def test_iter_args_11_2
|
2762
|
+
rb = "f { |a, b = 42, *c, d, &e| }"
|
2763
|
+
pt = s(:iter, s(:call, nil, :f),
|
2764
|
+
s(:args, :a, s(:lasgn, :b, s(:lit, 42)), :"*c", :d, :"&e"))
|
2765
|
+
|
2766
|
+
assert_parse rb, pt
|
2767
|
+
end
|
2768
|
+
|
2769
|
+
def test_kill_me_6
|
2770
|
+
# | f_marg_list tCOMMA tSTAR f_norm_arg tCOMMA f_marg_list
|
2771
|
+
rb = "f { |a, (b, *c, d)| }"
|
2772
|
+
pt = s(:iter,
|
2773
|
+
s(:call, nil, :f),
|
2774
|
+
s(:args, :a, s(:masgn, :b, :"*c", :d)))
|
2775
|
+
|
2776
|
+
assert_parse rb, pt
|
2777
|
+
end
|
2778
|
+
|
2779
|
+
def test_kill_me_7
|
2780
|
+
# | f_marg_list tCOMMA tSTAR
|
2781
|
+
rb = "f { |a, (b, *)| }"
|
2782
|
+
pt = s(:iter,
|
2783
|
+
s(:call, nil, :f),
|
2784
|
+
s(:args, :a, s(:masgn, :b, :*)))
|
2785
|
+
|
2786
|
+
assert_parse rb, pt
|
2787
|
+
end
|
2788
|
+
|
2789
|
+
def test_kill_me_8
|
2790
|
+
# | f_marg_list tCOMMA tSTAR tCOMMA f_marg_list
|
2791
|
+
rb = "f { |a, (b, *, c)| }"
|
2792
|
+
pt = s(:iter,
|
2793
|
+
s(:call, nil, :f),
|
2794
|
+
s(:args, :a, s(:masgn, :b, :*, :c)))
|
2795
|
+
|
2796
|
+
assert_parse rb, pt
|
2797
|
+
end
|
2798
|
+
|
2799
|
+
def test_kill_me_9
|
2800
|
+
# | tSTAR f_norm_arg
|
2801
|
+
rb = "f { |a, (*b)| }"
|
2802
|
+
pt = s(:iter,
|
2803
|
+
s(:call, nil, :f),
|
2804
|
+
s(:args, :a, s(:masgn, :"*b")))
|
2805
|
+
|
2806
|
+
assert_parse rb, pt
|
2807
|
+
end
|
2808
|
+
|
2809
|
+
def test_kill_me_10
|
2810
|
+
# | tSTAR f_norm_arg tCOMMA f_marg_list
|
2811
|
+
rb = "f { |a, (*b, c)| }"
|
2812
|
+
pt = s(:iter,
|
2813
|
+
s(:call, nil, :f),
|
2814
|
+
s(:args, :a, s(:masgn, :"*b", :c)))
|
2815
|
+
|
2816
|
+
assert_parse rb, pt
|
2817
|
+
end
|
2818
|
+
|
2819
|
+
def test_kill_me_11
|
2820
|
+
# | tSTAR
|
2821
|
+
rb = "f { |a, (*)| }"
|
2822
|
+
pt = s(:iter,
|
2823
|
+
s(:call, nil, :f),
|
2824
|
+
s(:args, :a, s(:masgn, :*)))
|
2825
|
+
|
2826
|
+
assert_parse rb, pt
|
2827
|
+
end
|
2828
|
+
|
2829
|
+
def test_kill_me_12
|
2830
|
+
# | tSTAR tCOMMA f_marg_list
|
2831
|
+
rb = "f { |a, (*, b)| }"
|
2832
|
+
pt = s(:iter,
|
2833
|
+
s(:call, nil, :f),
|
2834
|
+
s(:args, :a, s(:masgn, :*, :b)))
|
2835
|
+
|
2836
|
+
assert_parse rb, pt
|
2837
|
+
end
|
2838
|
+
|
2839
|
+
def test_index_0
|
2840
|
+
rb = "a[] = b"
|
2841
|
+
pt = s(:attrasgn, s(:call, nil, :a), :[]=, s(:call, nil, :b))
|
2842
|
+
|
2843
|
+
assert_parse rb, pt
|
2844
|
+
end
|
2845
|
+
|
2846
|
+
def test_lambda_do_vs_brace
|
2847
|
+
pt = s(:call, nil, :f, s(:iter, s(:call, nil, :lambda), s(:args)))
|
2848
|
+
|
2849
|
+
rb = "f ->() {}"
|
2850
|
+
assert_parse rb, pt
|
2851
|
+
|
2852
|
+
rb = "f ->() do end"
|
2853
|
+
assert_parse rb, pt
|
2854
|
+
|
2855
|
+
pt = s(:call, nil, :f, s(:iter, s(:call, nil, :lambda), 0))
|
2856
|
+
|
2857
|
+
rb = "f -> {}"
|
2858
|
+
assert_parse rb, pt
|
2859
|
+
|
2860
|
+
rb = "f -> do end"
|
2861
|
+
assert_parse rb, pt
|
2862
|
+
end
|
2863
|
+
|
2864
|
+
def test_thingy
|
2865
|
+
pt = s(:call, s(:call, nil, :f), :call, s(:lit, 42))
|
2866
|
+
|
2867
|
+
rb = "f.(42)"
|
2868
|
+
assert_parse rb, pt
|
2869
|
+
|
2870
|
+
rb = "f::(42)"
|
2871
|
+
assert_parse rb, pt
|
2872
|
+
end
|
2873
|
+
|
2874
|
+
def test_unary_plus_on_literal
|
2875
|
+
rb = "+:a"
|
2876
|
+
pt = s(:call, s(:lit, :a), :+@)
|
2877
|
+
|
2878
|
+
assert_parse rb, pt
|
2879
|
+
end
|
2880
|
+
end
|
2881
|
+
|
2882
|
+
module TestRubyParserShared21Plus
|
2883
|
+
def test_f_kw
|
2884
|
+
rb = "def x k:42; end"
|
2885
|
+
pt = s(:defn, :x, s(:args, s(:kwarg, :k, s(:lit, 42))), s(:nil))
|
2886
|
+
|
2887
|
+
assert_parse rb, pt
|
2888
|
+
end
|
2889
|
+
|
2890
|
+
def test_f_kw__required
|
2891
|
+
rb = "def x k:; end"
|
2892
|
+
pt = s(:defn, :x, s(:args, s(:kwarg, :k)), s(:nil))
|
2893
|
+
|
2894
|
+
assert_parse rb, pt
|
2895
|
+
end
|
2896
|
+
|
2897
|
+
def test_block_kw
|
2898
|
+
rb = "blah { |k:42| }"
|
2899
|
+
pt = s(:iter, s(:call, nil, :blah), s(:args, s(:kwarg, :k, s(:lit, 42))))
|
2900
|
+
|
2901
|
+
assert_parse rb, pt
|
2902
|
+
|
2903
|
+
rb = "blah { |k:42| }"
|
2904
|
+
assert_parse rb, pt
|
2905
|
+
end
|
2906
|
+
|
2907
|
+
def test_block_kw__required
|
2908
|
+
rb = "blah do |k:| end"
|
2909
|
+
pt = s(:iter, s(:call, nil, :blah), s(:args, s(:kwarg, :k)))
|
2910
|
+
|
2911
|
+
assert_parse rb, pt
|
2912
|
+
|
2913
|
+
rb = "blah do |k:| end"
|
2914
|
+
assert_parse rb, pt
|
2915
|
+
end
|
2916
|
+
|
2917
|
+
def test_stabby_block_kw
|
2918
|
+
rb = "-> (k:42) { }"
|
2919
|
+
pt = s(:iter, s(:call, nil, :lambda), s(:args, s(:kwarg, :k, s(:lit, 42))))
|
2920
|
+
|
2921
|
+
assert_parse rb, pt
|
2922
|
+
end
|
2923
|
+
|
2924
|
+
def test_stabby_block_kw__required
|
2925
|
+
rb = "-> (k:) { }"
|
2926
|
+
pt = s(:iter, s(:call, nil, :lambda), s(:args, s(:kwarg, :k)))
|
3069
2927
|
|
3070
2928
|
assert_parse rb, pt
|
3071
2929
|
end
|
3072
2930
|
|
3073
|
-
def
|
3074
|
-
|
3075
|
-
|
3076
|
-
|
2931
|
+
def test_parse_line_heredoc_hardnewline
|
2932
|
+
skip "not yet"
|
2933
|
+
|
2934
|
+
rb = <<-'CODE'.gsub(/^ /, '')
|
2935
|
+
<<-EOFOO
|
2936
|
+
\n\n\n\n\n\n\n\n\n
|
2937
|
+
EOFOO
|
2938
|
+
|
2939
|
+
class Foo
|
2940
|
+
end
|
2941
|
+
CODE
|
2942
|
+
|
2943
|
+
pt = s(:block,
|
2944
|
+
s(:str, "\n\n\n\n\n\n\n\n\n\n").line(1),
|
2945
|
+
s(:class, :Foo, nil).line(5)).line(1)
|
3077
2946
|
|
3078
2947
|
assert_parse rb, pt
|
3079
2948
|
end
|
2949
|
+
end
|
3080
2950
|
|
3081
|
-
|
3082
|
-
|
3083
|
-
rb = "f { |a, (b, *c, d)| }"
|
3084
|
-
pt = s(:iter,
|
3085
|
-
s(:call, nil, :f),
|
3086
|
-
s(:args, :a, s(:masgn, :b, :"*c", :d)))
|
2951
|
+
module TestRubyParserShared20Plus
|
2952
|
+
def test_non_interpolated_symbol_array_line_breaks
|
3087
2953
|
|
2954
|
+
rb = "%i(\na\nb\n)\n1"
|
2955
|
+
pt = s(:block,
|
2956
|
+
s(:array,
|
2957
|
+
s(:lit, :a).line(2),
|
2958
|
+
s(:lit, :b).line(3)).line(1),
|
2959
|
+
s(:lit, 1).line(5))
|
3088
2960
|
assert_parse rb, pt
|
3089
2961
|
end
|
3090
2962
|
|
3091
|
-
def
|
3092
|
-
# | f_marg_list tCOMMA tSTAR
|
3093
|
-
rb = "f { |a, (b, *)| }"
|
3094
|
-
pt = s(:iter,
|
3095
|
-
s(:call, nil, :f),
|
3096
|
-
s(:args, :a, s(:masgn, :b, :*)))
|
2963
|
+
def test_interpolated_symbol_array_line_breaks
|
3097
2964
|
|
2965
|
+
rb = "%I(\na\nb\n)\n1"
|
2966
|
+
pt = s(:block,
|
2967
|
+
s(:array,
|
2968
|
+
s(:lit, :a).line(2),
|
2969
|
+
s(:lit, :b).line(3)).line(1),
|
2970
|
+
s(:lit, 1).line(5))
|
3098
2971
|
assert_parse rb, pt
|
3099
2972
|
end
|
3100
2973
|
|
3101
|
-
def
|
3102
|
-
|
3103
|
-
|
3104
|
-
pt = s(:iter,
|
3105
|
-
s(:call, nil, :f),
|
3106
|
-
s(:args, :a, s(:masgn, :b, :*, :c)))
|
2974
|
+
def test_defs_kwarg
|
2975
|
+
rb = "def self.a b: 1\nend"
|
2976
|
+
pt = s(:defs, s(:self), :a, s(:args, s(:kwarg, :b, s(:lit, 1))), s(:nil))
|
3107
2977
|
|
3108
2978
|
assert_parse rb, pt
|
3109
2979
|
end
|
3110
2980
|
|
3111
|
-
def
|
3112
|
-
|
3113
|
-
|
3114
|
-
pt = s(:iter,
|
3115
|
-
s(:call, nil, :f),
|
3116
|
-
s(:args, :a, s(:masgn, :"*b")))
|
2981
|
+
def test_defn_kwarg_kwsplat
|
2982
|
+
rb = "def a(b: 1, **c) end"
|
2983
|
+
pt = s(:defn, :a, s(:args, s(:kwarg, :b, s(:lit, 1)), :"**c"), s(:nil))
|
3117
2984
|
|
3118
2985
|
assert_parse rb, pt
|
3119
2986
|
end
|
3120
2987
|
|
3121
|
-
def
|
3122
|
-
|
3123
|
-
|
3124
|
-
pt = s(:iter,
|
3125
|
-
s(:call, nil, :f),
|
3126
|
-
s(:args, :a, s(:masgn, :"*b", :c)))
|
2988
|
+
def test_defn_kwarg_kwsplat_anon
|
2989
|
+
rb = "def a(b: 1, **) end"
|
2990
|
+
pt = s(:defn, :a, s(:args, s(:kwarg, :b, s(:lit, 1)), :"**"), s(:nil))
|
3127
2991
|
|
3128
2992
|
assert_parse rb, pt
|
3129
2993
|
end
|
3130
2994
|
|
3131
|
-
def
|
3132
|
-
|
3133
|
-
|
3134
|
-
|
3135
|
-
s(:call, nil, :f),
|
3136
|
-
s(:args, :a, s(:masgn, :*)))
|
2995
|
+
def test_defn_kwarg_env
|
2996
|
+
rb = "def test(**testing) test_splat(**testing) end"
|
2997
|
+
pt = s(:defn, :test, s(:args, :"**testing"),
|
2998
|
+
s(:call, nil, :test_splat, s(:hash, s(:kwsplat, s(:lvar, :testing)))))
|
3137
2999
|
|
3138
3000
|
assert_parse rb, pt
|
3139
3001
|
end
|
3140
3002
|
|
3141
|
-
def
|
3142
|
-
|
3143
|
-
|
3144
|
-
pt = s(:iter,
|
3145
|
-
s(:call, nil, :f),
|
3146
|
-
s(:args, :a, s(:masgn, :*, :b)))
|
3003
|
+
def test_dstr_lex_state
|
3004
|
+
rb = '"#{p:a}"'
|
3005
|
+
pt = s(:dstr, "", s(:evstr, s(:call, nil, :p, s(:lit, :a))))
|
3147
3006
|
|
3148
3007
|
assert_parse rb, pt
|
3149
3008
|
end
|
3150
3009
|
|
3151
|
-
def
|
3152
|
-
rb = "a
|
3153
|
-
pt = s(:
|
3010
|
+
def test_call_arg_kwsplat
|
3011
|
+
rb = "a(b, **1)"
|
3012
|
+
pt = s(:call, nil, :a, s(:call, nil, :b), s(:hash, s(:kwsplat, s(:lit, 1))))
|
3154
3013
|
|
3155
3014
|
assert_parse rb, pt
|
3156
3015
|
end
|
3157
3016
|
|
3158
|
-
def
|
3159
|
-
|
3017
|
+
def test_call_arg_assoc_kwsplat
|
3018
|
+
rb = "f(1, kw: 2, **3)"
|
3019
|
+
pt = s(:call, nil, :f,
|
3020
|
+
s(:lit, 1),
|
3021
|
+
s(:hash, s(:lit, :kw), s(:lit, 2), s(:kwsplat, s(:lit, 3))))
|
3160
3022
|
|
3161
|
-
rb = "f ->() {}"
|
3162
3023
|
assert_parse rb, pt
|
3024
|
+
end
|
3025
|
+
|
3026
|
+
def test_call_kwsplat
|
3027
|
+
rb = "a(**1)"
|
3028
|
+
pt = s(:call, nil, :a, s(:hash, s(:kwsplat, s(:lit, 1))))
|
3163
3029
|
|
3164
|
-
rb = "f ->() do end"
|
3165
3030
|
assert_parse rb, pt
|
3031
|
+
end
|
3166
3032
|
|
3167
|
-
|
3033
|
+
def test_iter_kwarg
|
3034
|
+
rb = "a { |b: 1| }"
|
3035
|
+
pt = s(:iter, s(:call, nil, :a), s(:args, s(:kwarg, :b, s(:lit, 1))))
|
3168
3036
|
|
3169
|
-
rb = "f -> {}"
|
3170
3037
|
assert_parse rb, pt
|
3038
|
+
end
|
3039
|
+
|
3040
|
+
def test_iter_kwarg_kwsplat
|
3041
|
+
rb = "a { |b: 1, **c| }"
|
3042
|
+
pt = s(:iter, s(:call, nil, :a), s(:args, s(:kwarg, :b, s(:lit, 1)), :"**c"))
|
3171
3043
|
|
3172
|
-
rb = "f -> do end"
|
3173
3044
|
assert_parse rb, pt
|
3174
3045
|
end
|
3175
3046
|
|
3176
|
-
def
|
3177
|
-
|
3047
|
+
def test_block_kwarg_lvar
|
3048
|
+
rb = "bl { |kw: :val| kw }"
|
3049
|
+
pt = s(:iter, s(:call, nil, :bl), s(:args, s(:kwarg, :kw, s(:lit, :val))),
|
3050
|
+
s(:lvar, :kw))
|
3178
3051
|
|
3179
|
-
rb = "f.(42)"
|
3180
3052
|
assert_parse rb, pt
|
3053
|
+
end
|
3054
|
+
|
3055
|
+
def test_block_kwarg_lvar_multiple
|
3056
|
+
rb = "bl { |kw: :val, kw2: :val2 | kw }"
|
3057
|
+
pt = s(:iter, s(:call, nil, :bl),
|
3058
|
+
s(:args,
|
3059
|
+
s(:kwarg, :kw, s(:lit, :val)),
|
3060
|
+
s(:kwarg, :kw2, s(:lit, :val2))),
|
3061
|
+
s(:lvar, :kw))
|
3181
3062
|
|
3182
|
-
rb = "f::(42)"
|
3183
3063
|
assert_parse rb, pt
|
3184
3064
|
end
|
3185
3065
|
|
3186
|
-
def
|
3187
|
-
rb = "
|
3188
|
-
pt = s(:call,
|
3066
|
+
def test_stabby_block_iter_call
|
3067
|
+
rb = "x -> () do\na.b do\nend\nend"
|
3068
|
+
pt = s(:call, nil, :x,
|
3069
|
+
s(:iter,
|
3070
|
+
s(:call, nil, :lambda),
|
3071
|
+
s(:args),
|
3072
|
+
s(:iter, s(:call, s(:call, nil, :a), :b), 0)))
|
3189
3073
|
|
3190
3074
|
assert_parse rb, pt
|
3191
3075
|
end
|
3192
|
-
end
|
3193
|
-
|
3194
|
-
class TestRuby20Parser < RubyParserTestCase
|
3195
|
-
include TestRubyParserShared
|
3196
|
-
include TestRubyParserShared20to22
|
3197
|
-
include TestRubyParserShared19to22
|
3198
3076
|
|
3199
|
-
def
|
3200
|
-
|
3077
|
+
def test_stabby_block_iter_call_no_target_with_arg
|
3078
|
+
rb = "x -> () do\na(1) do\nend\nend"
|
3079
|
+
pt = s(:call, nil, :x,
|
3080
|
+
s(:iter,
|
3081
|
+
s(:call, nil, :lambda),
|
3082
|
+
s(:args),
|
3083
|
+
s(:iter,
|
3084
|
+
s(:call, nil, :a,
|
3085
|
+
s(:lit, 1)), 0)))
|
3201
3086
|
|
3202
|
-
|
3087
|
+
assert_parse rb, pt
|
3203
3088
|
end
|
3204
3089
|
|
3205
3090
|
def test_block_call_dot_op2_brace_block
|
@@ -3345,113 +3230,17 @@ class TestRuby20Parser < RubyParserTestCase
|
|
3345
3230
|
assert_parse rb, pt
|
3346
3231
|
end
|
3347
3232
|
|
3348
|
-
def test_defn_unary_not
|
3349
|
-
rb = "def !@; true; end" # I seriously HATE this
|
3350
|
-
pt = s(:defn, :"!@", s(:args), s(:true))
|
3351
|
-
|
3352
|
-
assert_parse rb, pt
|
3353
|
-
end
|
3354
|
-
|
3355
3233
|
def test_iter_array_curly
|
3356
3234
|
rb = "f :a, [:b] { |c, d| }" # yes, this is bad code... that's their problem
|
3357
3235
|
pt = s(:iter,
|
3358
3236
|
s(:call, nil, :f, s(:lit, :a), s(:array, s(:lit, :b))),
|
3359
3237
|
s(:args, :c, :d))
|
3360
3238
|
|
3361
|
-
assert_parse rb, pt
|
3362
|
-
end
|
3363
|
-
end
|
3364
|
-
|
3365
|
-
class TestRuby21Parser < RubyParserTestCase
|
3366
|
-
include TestRubyParserShared
|
3367
|
-
include TestRubyParserShared19to22
|
3368
|
-
include TestRubyParserShared20to22
|
3369
|
-
|
3370
|
-
def setup
|
3371
|
-
super
|
3372
|
-
|
3373
|
-
self.processor = Ruby21Parser.new
|
3374
|
-
end
|
3375
|
-
|
3376
|
-
def test_f_kw
|
3377
|
-
rb = "def x k:42; end"
|
3378
|
-
pt = s(:defn, :x, s(:args, s(:kwarg, :k, s(:lit, 42))), s(:nil))
|
3379
|
-
|
3380
|
-
assert_parse rb, pt
|
3381
|
-
end
|
3382
|
-
|
3383
|
-
def test_f_kw__required
|
3384
|
-
rb = "def x k:; end"
|
3385
|
-
pt = s(:defn, :x, s(:args, s(:kwarg, :k)), s(:nil))
|
3386
|
-
|
3387
|
-
assert_parse rb, pt
|
3388
|
-
end
|
3389
|
-
|
3390
|
-
def test_block_kw
|
3391
|
-
rb = "blah { |k:42| }"
|
3392
|
-
pt = s(:iter, s(:call, nil, :blah), s(:args, s(:kwarg, :k, s(:lit, 42))))
|
3393
|
-
|
3394
|
-
assert_parse rb, pt
|
3395
|
-
|
3396
|
-
rb = "blah { |k:42| }"
|
3397
|
-
assert_parse rb, pt
|
3398
|
-
end
|
3399
|
-
|
3400
|
-
def test_block_kw__required
|
3401
|
-
rb = "blah do |k:| end"
|
3402
|
-
pt = s(:iter, s(:call, nil, :blah), s(:args, s(:kwarg, :k)))
|
3403
|
-
|
3404
|
-
assert_parse rb, pt
|
3405
|
-
|
3406
|
-
rb = "blah do |k:| end"
|
3407
|
-
assert_parse rb, pt
|
3408
|
-
end
|
3409
|
-
|
3410
|
-
def test_stabby_block_kw
|
3411
|
-
rb = "-> (k:42) { }"
|
3412
|
-
pt = s(:iter, s(:call, nil, :lambda), s(:args, s(:kwarg, :k, s(:lit, 42))))
|
3413
|
-
|
3414
|
-
assert_parse rb, pt
|
3415
|
-
end
|
3416
|
-
|
3417
|
-
def test_stabby_block_kw__required
|
3418
|
-
rb = "-> (k:) { }"
|
3419
|
-
pt = s(:iter, s(:call, nil, :lambda), s(:args, s(:kwarg, :k)))
|
3420
|
-
|
3421
|
-
assert_parse rb, pt
|
3422
|
-
end
|
3423
|
-
|
3424
|
-
def test_parse_line_heredoc_hardnewline
|
3425
|
-
skip "not yet"
|
3426
|
-
|
3427
|
-
rb = <<-'CODE'.gsub(/^ /, '')
|
3428
|
-
<<-EOFOO
|
3429
|
-
\n\n\n\n\n\n\n\n\n
|
3430
|
-
EOFOO
|
3431
|
-
|
3432
|
-
class Foo
|
3433
|
-
end
|
3434
|
-
CODE
|
3435
|
-
|
3436
|
-
pt = s(:block,
|
3437
|
-
s(:str, "\n\n\n\n\n\n\n\n\n\n").line(1),
|
3438
|
-
s(:class, :Foo, nil).line(5)).line(1)
|
3439
|
-
|
3440
|
-
assert_parse rb, pt
|
3441
|
-
end
|
3442
|
-
end
|
3443
|
-
|
3444
|
-
class TestRuby22Parser < RubyParserTestCase
|
3445
|
-
include TestRubyParserShared
|
3446
|
-
include TestRubyParserShared19to22
|
3447
|
-
include TestRubyParserShared20to22
|
3448
|
-
|
3449
|
-
def setup
|
3450
|
-
super
|
3451
|
-
|
3452
|
-
self.processor = Ruby22Parser.new
|
3239
|
+
assert_parse rb, pt
|
3453
3240
|
end
|
3241
|
+
end
|
3454
3242
|
|
3243
|
+
module TestRubyParserShared22Plus
|
3455
3244
|
def test_call_args_assoc_quoted
|
3456
3245
|
pt = s(:call, nil, :x, s(:hash, s(:lit, :k), s(:lit, 42)))
|
3457
3246
|
|
@@ -3492,17 +3281,7 @@ class TestRuby22Parser < RubyParserTestCase
|
|
3492
3281
|
end
|
3493
3282
|
end
|
3494
3283
|
|
3495
|
-
|
3496
|
-
include TestRubyParserShared
|
3497
|
-
include TestRubyParserShared19to22
|
3498
|
-
include TestRubyParserShared20to22
|
3499
|
-
|
3500
|
-
def setup
|
3501
|
-
super
|
3502
|
-
|
3503
|
-
self.processor = Ruby23Parser.new
|
3504
|
-
end
|
3505
|
-
|
3284
|
+
module TestRubyParserShared23Plus
|
3506
3285
|
def test_safe_call
|
3507
3286
|
rb = "a&.b"
|
3508
3287
|
pt = s(:safe_call, s(:call, nil, :a), :b)
|
@@ -3524,6 +3303,13 @@ class TestRuby23Parser < RubyParserTestCase
|
|
3524
3303
|
assert_parse rb, pt
|
3525
3304
|
end
|
3526
3305
|
|
3306
|
+
def test_safe_call_after_newline
|
3307
|
+
rb = "a\n&.b"
|
3308
|
+
pt = s(:safe_call, s(:call, nil, :a), :b)
|
3309
|
+
|
3310
|
+
assert_parse rb, pt
|
3311
|
+
end
|
3312
|
+
|
3527
3313
|
def test_safe_calls
|
3528
3314
|
rb = "a&.b&.c(1)"
|
3529
3315
|
pt = s(:safe_call, s(:safe_call, s(:call, nil, :a), :b), :c, s(:lit, 1))
|
@@ -3604,22 +3390,311 @@ a + b
|
|
3604
3390
|
)
|
3605
3391
|
|
3606
3392
|
pt = s(:block,
|
3607
|
-
|
3608
|
-
|
3609
|
-
|
3610
|
-
|
3393
|
+
s(:call, nil, :puts, s(:str, "hello my dear friend").line(1)).line(1),
|
3394
|
+
s(:call, s(:call, nil, :a).line(6),
|
3395
|
+
:+,
|
3396
|
+
s(:call, nil, :b).line(6)).line(6)
|
3611
3397
|
).line(1)
|
3612
3398
|
|
3613
3399
|
assert_parse rb, pt
|
3614
3400
|
end
|
3615
3401
|
end
|
3616
3402
|
|
3617
|
-
|
3403
|
+
module TestRubyParserShared24Plus
|
3404
|
+
# ...version specific tests to go here...
|
3405
|
+
end
|
3406
|
+
|
3407
|
+
class TestRubyParser < Minitest::Test
|
3408
|
+
def test_cls_version
|
3409
|
+
assert_equal 18, RubyParser::V18.version
|
3410
|
+
assert_equal 23, RubyParser::V23.version
|
3411
|
+
refute RubyParser::Parser.version
|
3412
|
+
end
|
3413
|
+
|
3414
|
+
def test_parse
|
3415
|
+
processor = RubyParser.new
|
3416
|
+
|
3417
|
+
# 1.8 only syntax
|
3418
|
+
rb = "while false : 42 end"
|
3419
|
+
pt = s(:while, s(:false), s(:lit, 42), true)
|
3420
|
+
|
3421
|
+
assert_silent do
|
3422
|
+
assert_equal pt, processor.parse(rb)
|
3423
|
+
end
|
3424
|
+
|
3425
|
+
# 1.9 only syntax
|
3426
|
+
rb = "a.()"
|
3427
|
+
pt = s(:call, s(:call, nil, :a), :call)
|
3428
|
+
|
3429
|
+
assert_equal pt, processor.parse(rb)
|
3430
|
+
|
3431
|
+
# bad syntax
|
3432
|
+
e = assert_raises Racc::ParseError do
|
3433
|
+
capture_io do
|
3434
|
+
processor.parse "a.("
|
3435
|
+
end
|
3436
|
+
end
|
3437
|
+
|
3438
|
+
msg = "(string):1 :: parse error on value \"(\" (tLPAREN2)"
|
3439
|
+
assert_equal msg, e.message.strip
|
3440
|
+
end
|
3441
|
+
end
|
3442
|
+
|
3443
|
+
class RubyParserTestCase < ParseTreeTestCase
|
3444
|
+
attr_accessor :result, :processor
|
3445
|
+
|
3446
|
+
make_my_diffs_pretty!
|
3447
|
+
|
3448
|
+
def self.previous key
|
3449
|
+
"Ruby"
|
3450
|
+
end
|
3451
|
+
|
3452
|
+
def self.generate_test klass, node, data, input_name, output_name
|
3453
|
+
return if node.to_s =~ /bmethod|dmethod/
|
3454
|
+
return if Array === data['Ruby']
|
3455
|
+
|
3456
|
+
output_name = "ParseTree"
|
3457
|
+
|
3458
|
+
super
|
3459
|
+
end
|
3460
|
+
|
3461
|
+
def assert_parse rb, pt
|
3462
|
+
self.result = processor.parse rb
|
3463
|
+
assert_equal pt, result
|
3464
|
+
end
|
3465
|
+
|
3466
|
+
def refute_parse rb
|
3467
|
+
self.result = processor.parse rb
|
3468
|
+
assert_nil result
|
3469
|
+
end
|
3470
|
+
|
3471
|
+
def assert_syntax_error rb, emsg
|
3472
|
+
e = nil
|
3473
|
+
assert_silent do
|
3474
|
+
e = assert_raises RubyParser::SyntaxError do
|
3475
|
+
processor.parse rb
|
3476
|
+
end
|
3477
|
+
end
|
3478
|
+
|
3479
|
+
assert_equal emsg, e.message
|
3480
|
+
end
|
3481
|
+
|
3482
|
+
def assert_parse_error rb, emsg
|
3483
|
+
e = nil
|
3484
|
+
assert_silent do
|
3485
|
+
e = assert_raises Racc::ParseError do
|
3486
|
+
processor.parse rb
|
3487
|
+
end
|
3488
|
+
end
|
3489
|
+
|
3490
|
+
assert_equal emsg, e.message
|
3491
|
+
end
|
3492
|
+
|
3493
|
+
def assert_parse_line rb, pt, line
|
3494
|
+
old_env = ENV["VERBOSE"]
|
3495
|
+
ENV["VERBOSE"] = "1"
|
3496
|
+
|
3497
|
+
assert_parse rb, pt
|
3498
|
+
assert_equal line, result.line, "call should have line number"
|
3499
|
+
ensure
|
3500
|
+
ENV["VERBOSE"] = old_env
|
3501
|
+
end
|
3502
|
+
end
|
3503
|
+
|
3504
|
+
class TestRubyParserV18 < RubyParserTestCase
|
3505
|
+
include TestRubyParserShared
|
3506
|
+
|
3507
|
+
def setup
|
3508
|
+
super
|
3509
|
+
|
3510
|
+
self.processor = RubyParser::V18.new
|
3511
|
+
end
|
3512
|
+
|
3513
|
+
def test_assoc_list_18
|
3514
|
+
rb = "{1, 2, 3, 4}"
|
3515
|
+
pt = s(:hash, s(:lit, 1), s(:lit, 2), s(:lit, 3), s(:lit, 4))
|
3516
|
+
|
3517
|
+
assert_parse rb, pt
|
3518
|
+
end
|
3519
|
+
|
3520
|
+
def test_case_then_colon_18
|
3521
|
+
rb = "case x; when Fixnum: 42; end"
|
3522
|
+
pt = s(:case,
|
3523
|
+
s(:call, nil, :x),
|
3524
|
+
s(:when, s(:array, s(:const, :Fixnum)), s(:lit, 42)),
|
3525
|
+
nil)
|
3526
|
+
|
3527
|
+
assert_parse rb, pt
|
3528
|
+
end
|
3529
|
+
|
3530
|
+
def test_do_colon_18
|
3531
|
+
rb = "while false : 42 end"
|
3532
|
+
pt = s(:while, s(:false), s(:lit, 42), true)
|
3533
|
+
|
3534
|
+
assert_parse rb, pt
|
3535
|
+
end
|
3536
|
+
|
3537
|
+
def test_call_space_before_paren_args_18
|
3538
|
+
rb = "a (:b, :c, :d => :e)"
|
3539
|
+
pt = s(:call, nil, :a,
|
3540
|
+
s(:lit, :b),
|
3541
|
+
s(:lit, :c),
|
3542
|
+
s(:hash, s(:lit, :d), s(:lit, :e)))
|
3543
|
+
|
3544
|
+
assert_parse rb, pt
|
3545
|
+
end
|
3546
|
+
|
3547
|
+
# In 1.8, block args with an outer set of parens are superfluous.
|
3548
|
+
# In 1.9, outer set of parens are NOT... they are an explicit extra masgn.
|
3549
|
+
|
3550
|
+
def test_iter_args_2_18
|
3551
|
+
rb = "f { |(a, b)| }"
|
3552
|
+
pt = s(:iter, s(:call, nil, :f), s(:args, :a, :b))
|
3553
|
+
|
3554
|
+
assert_parse rb, pt
|
3555
|
+
end
|
3556
|
+
|
3557
|
+
def test_bug_args__18
|
3558
|
+
rb = "f { |(a, b)| }"
|
3559
|
+
pt = s(:iter, s(:call, nil, :f),
|
3560
|
+
s(:args, :a, :b))
|
3561
|
+
|
3562
|
+
assert_parse rb, pt
|
3563
|
+
end
|
3564
|
+
|
3565
|
+
def test_bug_args_masgn_outer_parens__18
|
3566
|
+
rb = "f { |((a, b), c)| }"
|
3567
|
+
pt = s(:iter, # NOTE: same sexp as test_bug_args_masgn
|
3568
|
+
s(:call, nil, :f),
|
3569
|
+
s(:args, s(:masgn, :a, :b), :c))
|
3570
|
+
|
3571
|
+
assert_parse rb, pt.dup
|
3572
|
+
end
|
3573
|
+
|
3574
|
+
def test_double_block_error_10
|
3575
|
+
assert_syntax_error "a.b (&b) {}", BLOCK_DUP_MSG
|
3576
|
+
end
|
3577
|
+
|
3578
|
+
def test_double_block_error_11
|
3579
|
+
assert_syntax_error "a (1, &b) { }", BLOCK_DUP_MSG
|
3580
|
+
end
|
3581
|
+
|
3582
|
+
def test_double_block_error_12
|
3583
|
+
assert_syntax_error "a (1, &b) do end", BLOCK_DUP_MSG
|
3584
|
+
end
|
3585
|
+
|
3586
|
+
def test_double_block_error_13
|
3587
|
+
assert_syntax_error "m.a (1, &b) { }", BLOCK_DUP_MSG
|
3588
|
+
end
|
3589
|
+
|
3590
|
+
def test_double_block_error_14
|
3591
|
+
assert_syntax_error "m.a (1, &b) do end", BLOCK_DUP_MSG
|
3592
|
+
end
|
3593
|
+
|
3594
|
+
def test_double_block_error_15
|
3595
|
+
assert_syntax_error "m::a (1, &b) { }", BLOCK_DUP_MSG
|
3596
|
+
end
|
3597
|
+
|
3598
|
+
def test_double_block_error_16
|
3599
|
+
assert_syntax_error "m::a (1, &b) do end", BLOCK_DUP_MSG
|
3600
|
+
end
|
3601
|
+
end
|
3602
|
+
|
3603
|
+
class TestRubyParserV19 < RubyParserTestCase
|
3604
|
+
include TestRubyParserShared
|
3605
|
+
include TestRubyParserShared19Plus
|
3606
|
+
|
3607
|
+
def setup
|
3608
|
+
super
|
3609
|
+
|
3610
|
+
self.processor = RubyParser::V19.new
|
3611
|
+
end
|
3612
|
+
end
|
3613
|
+
|
3614
|
+
class TestRubyParserV20 < RubyParserTestCase
|
3615
|
+
include TestRubyParserShared
|
3616
|
+
include TestRubyParserShared19Plus
|
3617
|
+
include TestRubyParserShared20Plus
|
3618
|
+
|
3619
|
+
def setup
|
3620
|
+
super
|
3621
|
+
|
3622
|
+
self.processor = RubyParser::V20.new
|
3623
|
+
end
|
3624
|
+
|
3625
|
+
def test_defn_unary_not
|
3626
|
+
rb = "def !@; true; end" # I seriously HATE this
|
3627
|
+
pt = s(:defn, :"!@", s(:args), s(:true))
|
3628
|
+
|
3629
|
+
assert_parse rb, pt
|
3630
|
+
end
|
3631
|
+
end
|
3632
|
+
|
3633
|
+
class TestRubyParserV21 < RubyParserTestCase
|
3634
|
+
include TestRubyParserShared
|
3635
|
+
include TestRubyParserShared19Plus
|
3636
|
+
include TestRubyParserShared20Plus
|
3637
|
+
include TestRubyParserShared21Plus
|
3638
|
+
|
3639
|
+
def setup
|
3640
|
+
super
|
3641
|
+
|
3642
|
+
self.processor = RubyParser::V21.new
|
3643
|
+
end
|
3644
|
+
end
|
3645
|
+
|
3646
|
+
class TestRubyParserV22 < RubyParserTestCase
|
3647
|
+
include TestRubyParserShared
|
3648
|
+
include TestRubyParserShared19Plus
|
3649
|
+
include TestRubyParserShared20Plus
|
3650
|
+
include TestRubyParserShared21Plus
|
3651
|
+
include TestRubyParserShared22Plus
|
3652
|
+
|
3653
|
+
def setup
|
3654
|
+
super
|
3655
|
+
|
3656
|
+
self.processor = RubyParser::V22.new
|
3657
|
+
end
|
3658
|
+
end
|
3659
|
+
|
3660
|
+
class TestRubyParserV23 < RubyParserTestCase
|
3661
|
+
include TestRubyParserShared
|
3662
|
+
include TestRubyParserShared19Plus
|
3663
|
+
include TestRubyParserShared20Plus
|
3664
|
+
include TestRubyParserShared21Plus
|
3665
|
+
include TestRubyParserShared22Plus
|
3666
|
+
include TestRubyParserShared23Plus
|
3667
|
+
|
3668
|
+
def setup
|
3669
|
+
super
|
3670
|
+
|
3671
|
+
self.processor = RubyParser::V23.new
|
3672
|
+
end
|
3673
|
+
end
|
3674
|
+
|
3675
|
+
class TestRubyParserV24 < RubyParserTestCase
|
3676
|
+
include TestRubyParserShared
|
3677
|
+
include TestRubyParserShared19Plus
|
3678
|
+
include TestRubyParserShared20Plus
|
3679
|
+
include TestRubyParserShared21Plus
|
3680
|
+
include TestRubyParserShared22Plus
|
3681
|
+
include TestRubyParserShared23Plus
|
3682
|
+
include TestRubyParserShared24Plus
|
3683
|
+
|
3684
|
+
def setup
|
3685
|
+
super
|
3686
|
+
|
3687
|
+
self.processor = RubyParser::V24.new
|
3688
|
+
end
|
3689
|
+
end
|
3690
|
+
|
3691
|
+
RubyParser::VERSIONS.each do |klass|
|
3692
|
+
v = klass.version
|
3618
3693
|
describe "block args arity #{v}" do
|
3619
3694
|
attr_accessor :parser
|
3620
3695
|
|
3621
3696
|
before do
|
3622
|
-
self.parser =
|
3697
|
+
self.parser = RubyParser.const_get("V#{v}").new
|
3623
3698
|
end
|
3624
3699
|
|
3625
3700
|
{
|