Indented here document (<<~) is Ruby 2.3 feature

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2019-01-19 07:49:47 +00:00
parent 405940234e
commit e90d826de7

View File

@ -28,20 +28,20 @@ tests = [
[ 'getlocal *, 1', %q{ x = true; -> { x }.call }, ], [ 'getlocal *, 1', %q{ x = true; -> { x }.call }, ],
[ 'getlocal', %q{ x = true; -> { -> { x }.() }.() }, ], [ 'getlocal', %q{ x = true; -> { -> { x }.() }.() }, ],
[ 'setblockparam', <<~'},', ], # { [ 'setblockparam', <<-'},', ], # {
def m&b def m&b
b = # here b = # here
proc { true } proc { true }
end end
m { false }.call m { false }.call
}, },
[ 'getblockparam', <<~'},', ], # { [ 'getblockparam', <<-'},', ], # {
def m&b def m&b
b # here b # here
end end
m { true }.call m { true }.call
}, },
[ 'getblockparamproxy', <<~'},', ], # { [ 'getblockparamproxy', <<-'},', ], # {
def m&b def m&b
b # here b # here
.call .call
@ -101,11 +101,11 @@ tests = [
[ 'expandarray', %q{ y = [ true, false, nil ]; x, *z, w = y; x }, ], [ 'expandarray', %q{ y = [ true, false, nil ]; x, *z, w = y; x }, ],
[ 'splatarray', %q{ x, = *(y = true), false; x }, ], [ 'splatarray', %q{ x, = *(y = true), false; x }, ],
[ 'concatarray', %q{ ["t", "r", *x = "u", "e"].join }, ], [ 'concatarray', %q{ ["t", "r", *x = "u", "e"].join }, ],
[ 'concatarray', <<~'},', ], # { [ 'concatarray', <<-'},', ], # {
class X; def to_a; ['u']; end; end class X; def to_a; ['u']; end; end
['t', 'r', *X.new, 'e'].join ['t', 'r', *X.new, 'e'].join
}, },
[ 'concatarray', <<~'},', ], # { [ 'concatarray', <<-'},', ], # {
r = false r = false
t = [true, nil] t = [true, nil]
q, w, e = r, *t # here q, w, e = r, *t # here
@ -122,7 +122,7 @@ tests = [
[ 'dup', %q{ x = y = true; x }, ], [ 'dup', %q{ x = y = true; x }, ],
[ 'dupn', %q{ Object::X ||= true }, ], [ 'dupn', %q{ Object::X ||= true }, ],
[ 'reverse', %q{ q, (w, e), r = 1, [2, 3], 4; e == 3 }, ], [ 'reverse', %q{ q, (w, e), r = 1, [2, 3], 4; e == 3 }, ],
[ 'swap', <<~'},', ], # { [ 'swap', <<-'},', ], # {
x = [[false, true]] x = [[false, true]]
for i, j in x # here for i, j in x # here
; ;
@ -137,7 +137,7 @@ tests = [
[ 'defined', %q{ !defined?(x) }, ], [ 'defined', %q{ !defined?(x) }, ],
[ 'checkkeyword', %q{ def x x:rand;x end; x x: true }, ], [ 'checkkeyword', %q{ def x x:rand;x end; x x: true }, ],
[ 'checktype', %q{ x = true; "#{x}" }, ], [ 'checktype', %q{ x = true; "#{x}" }, ],
[ 'checkmatch', <<~'},', ], # { [ 'checkmatch', <<-'},', ], # {
x = y = true x = y = true
case x case x
when false when false
@ -147,7 +147,7 @@ tests = [
end end
y == nil y == nil
}, },
[ 'checkmatch', <<~'},', ], # { [ 'checkmatch', <<-'},', ], # {
x, y = true, [false] x, y = true, [false]
case x case x
when *y # here when *y # here
@ -157,7 +157,7 @@ tests = [
end end
z z
}, },
[ 'checkmatch', <<~'},', ], # { [ 'checkmatch', <<-'},', ], # {
x = false x = false
begin begin
raise raise
@ -173,7 +173,7 @@ tests = [
[ 'defineclass', %q{ X = Class.new; class X; true end }, ], [ 'defineclass', %q{ X = Class.new; class X; true end }, ],
[ 'defineclass', %q{ X = Class.new; class Y < X; true end }, ], [ 'defineclass', %q{ X = Class.new; class Y < X; true end }, ],
[ 'defineclass', %q{ X = Class.new; class << X; true end }, ], [ 'defineclass', %q{ X = Class.new; class << X; true end }, ],
[ 'defineclass', <<~'},', ], # { [ 'defineclass', <<-'},', ], # {
X = Class.new X = Class.new
Y = Class.new(X) Y = Class.new(X)
class Y < X class Y < X
@ -184,7 +184,7 @@ tests = [
[ 'opt_send_without_block', %q{ true.to_s }, ], [ 'opt_send_without_block', %q{ true.to_s }, ],
[ 'send', %q{ true.tap {|i| i.to_s } }, ], [ 'send', %q{ true.tap {|i| i.to_s } }, ],
[ 'leave', %q{ def x; true; end; x }, ], [ 'leave', %q{ def x; true; end; x }, ],
[ 'invokesuper', <<~'},', ], # { [ 'invokesuper', <<-'},', ], # {
class X < String class X < String
def empty? def empty?
super # here super # here
@ -192,7 +192,7 @@ tests = [
end end
X.new.empty? X.new.empty?
}, },
[ 'invokeblock', <<~'},', ], # { [ 'invokeblock', <<-'},', ], # {
def x def x
return yield self # here return yield self # here
end end
@ -203,7 +203,7 @@ tests = [
[ 'opt_str_freeze', %q{ 'true'.freeze }, ], [ 'opt_str_freeze', %q{ 'true'.freeze }, ],
[ 'opt_str_uminus', %q{ -'true' }, ], [ 'opt_str_uminus', %q{ -'true' }, ],
[ 'opt_str_freeze', <<~'},', ], # { [ 'opt_str_freeze', <<-'},', ], # {
class String class String
def freeze def freeze
true true
@ -214,7 +214,7 @@ tests = [
[ 'opt_newarray_max', %q{ [ ].max.nil? }, ], [ 'opt_newarray_max', %q{ [ ].max.nil? }, ],
[ 'opt_newarray_max', %q{ [1, x = 2, 3].max == 3 }, ], [ 'opt_newarray_max', %q{ [1, x = 2, 3].max == 3 }, ],
[ 'opt_newarray_max', <<~'},', ], # { [ 'opt_newarray_max', <<-'},', ], # {
class Array class Array
def max def max
true true
@ -224,7 +224,7 @@ tests = [
}, },
[ 'opt_newarray_min', %q{ [ ].min.nil? }, ], [ 'opt_newarray_min', %q{ [ ].min.nil? }, ],
[ 'opt_newarray_min', %q{ [3, x = 2, 1].min == 1 }, ], [ 'opt_newarray_min', %q{ [3, x = 2, 1].min == 1 }, ],
[ 'opt_newarray_min', <<~'},', ], # { [ 'opt_newarray_min', <<-'},', ], # {
class Array class Array
def min def min
true true
@ -240,12 +240,12 @@ tests = [
[ 'branchunless', %q{ x = nil; x &&= true; x.nil? }, ], [ 'branchunless', %q{ x = nil; x &&= true; x.nil? }, ],
[ 'branchnil', %q{ x = true; x&.to_s }, ], [ 'branchnil', %q{ x = true; x&.to_s }, ],
[ 'branchnil', %q{ x = nil; (x&.to_s).nil? }, ], [ 'branchnil', %q{ x = nil; (x&.to_s).nil? }, ],
[ 'jump', <<~'},', ], # { [ 'jump', <<-'},', ], # {
y = 1 y = 1
x = if y == 0 then nil elsif y == 1 then true else nil end x = if y == 0 then nil elsif y == 1 then true else nil end
x x
}, },
[ 'jump', <<~'},', ], # { [ 'jump', <<-'},', ], # {
# ultra complicated situation: this ||= assignment only generates # ultra complicated situation: this ||= assignment only generates
# 15 instructions, not including the class definition. # 15 instructions, not including the class definition.
class X; attr_accessor :x; end class X; attr_accessor :x; end
@ -254,14 +254,14 @@ tests = [
}, },
[ 'once', %q{ /#{true}/o =~ "true" && $~ }, ], [ 'once', %q{ /#{true}/o =~ "true" && $~ }, ],
[ 'once', <<~'},', ], # { [ 'once', <<-'},', ], # {
def once expr def once expr
return /#{expr}/o # here return /#{expr}/o # here
end end
x = once(true); x = once(false); x = once(nil); x = once(true); x = once(false); x = once(nil);
x =~ "true" && $~ x =~ "true" && $~
}, },
[ 'once', <<~'},', ], # { [ 'once', <<-'},', ], # {
# recursive once # recursive once
def once n def once n
return %r/#{ return %r/#{
@ -275,7 +275,7 @@ tests = [
x = once(128); x = once(7); x = once(16); x = once(128); x = once(7); x = once(16);
x =~ "true" && $~ x =~ "true" && $~
}, },
[ 'once', <<~'},', ], # { [ 'once', <<-'},', ], # {
# inter-thread lockup situation # inter-thread lockup situation
def once n def once n
return Thread.start n do |m| return Thread.start n do |m|
@ -323,12 +323,12 @@ tests = [
[ 'opt_mod', %q{ '%s' % [ true ] }, ], [ 'opt_mod', %q{ '%s' % [ true ] }, ],
[ 'opt_eq', %q{ 1 == 1 }, ], [ 'opt_eq', %q{ 1 == 1 }, ],
[ 'opt_eq', <<~'},', ], # { [ 'opt_eq', <<-'},', ], # {
class X; def == other; true; end; end class X; def == other; true; end; end
X.new == true X.new == true
}, },
[ 'opt_neq', %q{ 1 != 0 }, ], [ 'opt_neq', %q{ 1 != 0 }, ],
[ 'opt_neq', <<~'},', ], # { [ 'opt_neq', <<-'},', ], # {
class X; def != other; true; end; end class X; def != other; true; end; end
X.new != true X.new != true
}, },
@ -360,7 +360,7 @@ tests = [
[ 'opt_aset', %q{ [][0] = true }, ], [ 'opt_aset', %q{ [][0] = true }, ],
[ 'opt_aset', %q{ {}[0] = true }, ], [ 'opt_aset', %q{ {}[0] = true }, ],
[ 'opt_aset', %q{ x = 'frue'; x[0] = 't'; x }, ], [ 'opt_aset', %q{ x = 'frue'; x[0] = 't'; x }, ],
[ 'opt_aset', <<~'},', ], # { [ 'opt_aset', <<-'},', ], # {
# opt_aref / opt_aset mixup situation # opt_aref / opt_aset mixup situation
class X; def x; {}; end; end class X; def x; {}; end; end
x = X.new x = X.new
@ -393,18 +393,18 @@ tests = [
[ 'opt_succ', %q{ x = Time.at(0); x.succ == Time.at(1) }, ], [ 'opt_succ', %q{ x = Time.at(0); x.succ == Time.at(1) }, ],
[ 'opt_not', %q{ ! false }, ], [ 'opt_not', %q{ ! false }, ],
[ 'opt_neq', <<~'},', ], # { [ 'opt_neq', <<-'},', ], # {
class X; def !; true; end; end class X; def !; true; end; end
! X.new ! X.new
}, },
[ 'opt_regexpmatch1', %q{ /true/ =~ 'true' && $~ }, ], [ 'opt_regexpmatch1', %q{ /true/ =~ 'true' && $~ }, ],
[ 'opt_regexpmatch1', <<~'},', ], # { [ 'opt_regexpmatch1', <<-'},', ], # {
class Regexp; def =~ other; true; end; end class Regexp; def =~ other; true; end; end
/true/ =~ 'true' /true/ =~ 'true'
}, },
[ 'opt_regexpmatch2', %q{ 'true' =~ /true/ && $~ }, ], [ 'opt_regexpmatch2', %q{ 'true' =~ /true/ && $~ }, ],
[ 'opt_regexpmatch2', <<~'},', ], # { [ 'opt_regexpmatch2', <<-'},', ], # {
class String; def =~ other; true; end; end class String; def =~ other; true; end; end
'true' =~ /true/ 'true' =~ /true/
}, },