ruby-changes:57733
From: Nobuyoshi <ko1@a...>
Date: Fri, 13 Sep 2019 19:49:13 +0900 (JST)
Subject: [ruby-changes:57733] 7e0f56fb3d (master): Name dynamically defined methods with line numbers
https://git.ruby-lang.org/ruby.git/commit/?id=7e0f56fb3d From 7e0f56fb3dfcbc1b48f40c6c3b2c23c8e46a2341 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Fri, 13 Sep 2019 19:48:44 +0900 Subject: Name dynamically defined methods with line numbers diff --git a/test/ripper/test_sexp.rb b/test/ripper/test_sexp.rb index 93e40f3..d6c7d60 100644 --- a/test/ripper/test_sexp.rb +++ b/test/ripper/test_sexp.rb @@ -142,12 +142,12 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L142 end pattern_matching_data = { - %q{ case 0; in 0; end } => + [__LINE__, %q{ case 0; in 0; end }] => [:case, [:@int, "0", [1, 5]], [:in, [:@int, "0", [1, 11]], [[:void_stmt]], nil]], - %q{ case 0; in 0 if a; end } => + [__LINE__, %q{ case 0; in 0 if a; end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -155,7 +155,7 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L155 [[:void_stmt]], nil]], - %q{ case 0; in 0 unless a; end } => + [__LINE__, %q{ case 0; in 0 unless a; end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -163,12 +163,12 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L163 [[:void_stmt]], nil]], - %q{ case 0; in a; end } => + [__LINE__, %q{ case 0; in a; end }] => [:case, [:@int, "0", [1, 5]], [:in, [:var_field, [:@ident, "a", [1, 11]]], [[:void_stmt]], nil]], - %q{ case 0; in a,; end } => + [__LINE__, %q{ case 0; in a,; end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -180,7 +180,7 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L180 [[:void_stmt]], nil]], - %q{ case 0; in a,b; end } => + [__LINE__, %q{ case 0; in a,b; end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -193,7 +193,7 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L193 [[:void_stmt]], nil]], - %q{ case 0; in *a; end } => + [__LINE__, %q{ case 0; in *a; end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -201,7 +201,7 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L201 [[:void_stmt]], nil]], - %q{ case 0; in *a,b; end } => + [__LINE__, %q{ case 0; in *a,b; end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -213,7 +213,7 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L213 [[:void_stmt]], nil]], - %q{ case 0; in *a,b,c; end } => + [__LINE__, %q{ case 0; in *a,b,c; end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -226,12 +226,12 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L226 [[:void_stmt]], nil]], - %q{ case 0; in *; end } => + [__LINE__, %q{ case 0; in *; end }] => [:case, [:@int, "0", [1, 5]], [:in, [:aryptn, nil, nil, [:var_field, nil], nil], [[:void_stmt]], nil]], - %q{ case 0; in *,a; end } => + [__LINE__, %q{ case 0; in *,a; end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -243,7 +243,7 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L243 [[:void_stmt]], nil]], - %q{ case 0; in a:,**b; end } => + [__LINE__, %q{ case 0; in a:,**b; end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -254,7 +254,7 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L254 [[:void_stmt]], nil]], - %q{ case 0; in **a; end } => + [__LINE__, %q{ case 0; in **a; end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -262,12 +262,12 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L262 [[:void_stmt]], nil]], - %q{ case 0; in **; end } => + [__LINE__, %q{ case 0; in **; end }] => [:case, [:@int, "0", [1, 5]], [:in, [:hshptn, nil, [], nil], [[:void_stmt]], nil]], - %q{ case 0; in a: 0; end } => + [__LINE__, %q{ case 0; in a: 0; end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -275,7 +275,7 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L275 [[:void_stmt]], nil]], - %q{ case 0; in a:; end } => + [__LINE__, %q{ case 0; in a:; end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -283,7 +283,7 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L283 [[:void_stmt]], nil]], - %q{ case 0; in "a": 0; end } => + [__LINE__, %q{ case 0; in "a": 0; end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -295,7 +295,7 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L295 [[:void_stmt]], nil]], - %q{ case 0; in "a":; end } => + [__LINE__, %q{ case 0; in "a":; end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -306,7 +306,7 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L306 [[:void_stmt]], nil]], - %q{ case 0; in a: 0, b: 0; end } => + [__LINE__, %q{ case 0; in a: 0, b: 0; end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -318,7 +318,7 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L318 [[:void_stmt]], nil]], - %q{ case 0; in 0 => a; end } => + [__LINE__, %q{ case 0; in 0 => a; end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -329,7 +329,7 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L329 [[:void_stmt]], nil]], - %q{ case 0; in 0 | 1; end } => + [__LINE__, %q{ case 0; in 0 | 1; end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -337,7 +337,7 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L337 [[:void_stmt]], nil]], - %q{ case 0; in A(0); end } => + [__LINE__, %q{ case 0; in A(0); end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -349,7 +349,7 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L349 [[:void_stmt]], nil]], - %q{ case 0; in A(a:); end } => + [__LINE__, %q{ case 0; in A(a:); end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -360,7 +360,7 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L360 [[:void_stmt]], nil]], - %q{ case 0; in A(); end } => + [__LINE__, %q{ case 0; in A(); end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -368,7 +368,7 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L368 [[:void_stmt]], nil]], - %q{ case 0; in A[a]; end } => + [__LINE__, %q{ case 0; in A[a]; end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -380,7 +380,7 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L380 [[:void_stmt]], nil]], - %q{ case 0; in A[a:]; end } => + [__LINE__, %q{ case 0; in A[a:]; end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -391,7 +391,7 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L391 [[:void_stmt]], nil]], - %q{ case 0; in A[]; end } => + [__LINE__, %q{ case 0; in A[]; end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -399,7 +399,7 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L399 [[:void_stmt]], nil]], - %q{ case 0; in [a]; end } => + [__LINE__, %q{ case 0; in [a]; end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -407,12 +407,12 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L407 [[:void_stmt]], nil]], - %q{ case 0; in []; end } => + [__LINE__, %q{ case 0; in []; end }] => [:case, [:@int, "0", [1, 5]], [:in, [:aryptn, nil, nil, nil, nil], [[:void_stmt]], nil]], - %q{ case 0; in {a: 0}; end } => + [__LINE__, %q{ case 0; in {a: 0}; end }] => [:case, [:@int, "0", [1, 5]], [:in, @@ -420,23 +420,23 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L420 [[:void_stmt]], nil]], - %q{ case 0; in {}; end } => + [__LINE__, %q{ case 0; in {}; end }] => [:case, [:@int, "0", [1, 5]], [:in, [:hshptn, nil, nil, nil], [[:void_stmt]], nil]], - %q{ case 0; in (0); end } => + [__LINE__, %q{ case 0; in (0); end }] => [:case, [:@int, "0", [1, 5]], [:in, [:@int, "0", [1, 12]], [[:void_stmt]], nil]], - %q{ case 0; in a:, a:; end } => + [__LINE__, %q{ case 0; in a:, a:; end }] => nil, - %q{ case 0; in a?:; end } => + [__LINE__, %q{ case 0; in a?:; end }] => nil, } - pattern_matching_data.each_with_index do |(src, expected), i| + pattern_matching_data.each do |(i, src), expected| define_method(:"test_pattern_matching_#{i}") do sexp = Ripper.sexp(src.strip) assert_equal expected, sexp && sexp[1][0], src -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/