@@ -213,6 +213,17 @@ def i arg
2132131 ..for i in [ 1 , 2 , 3 ] do break i if i == 2 ; end
2142141 ...for i in [ 1 , 2 , 3 ] do break i if i == 2 ; end
21521510 / for i in [ 1 , 2 , 3 ] do break i if i == 2 ; end
216+ [ for i in [ 1 , 2 , 3 ] do break i if i == 2 end ]
217+ [ for i in [ 1 , 2 , 3 ] do break i if i == 2 end , for i in [ 1 , 2 , 3 ] do break i if i == 3 end ]
218+ { for i in [ 1 , 2 , 3 ] do break i if i == 2 end => 1 }
219+ { for i in [ 1 , 2 , 3 ] do break i if i == 2 end => 1 }
220+ { foo : for i in [ 1 , 2 , 3 ] do break i if i == 2 end }
221+ { foo : for i in [ 1 , 2 , 3 ] do break i if i == 2 end , bar : for i in [ 1 , 2 , 3 ] do break i if i == 3 end }
222+ { :foo => for i in [ 1 , 2 , 3 ] do break i if i == 2 end }
223+ { :foo => for i in [ 1 , 2 , 3 ] do break i if i == 2 end , :bar => for i in [ 1 , 2 , 3 ] do break i if i == 3 end }
224+ ( for i in [ 1 , 2 , 3 ] do break i if i == 2 end )
225+ ( for i in [ 1 , 2 , 3 ] do break i if i == 2 end )
226+
216227#you cant use do-end blocks inside in statement
217228for i in 3 . times . map do 1 end do puts i ; end # shouldn't work
218229for? i in [ 1 , 2 , 3 ] # shouldn't work
@@ -267,6 +278,16 @@ def i arg
267278while false do [ 1 , 2 , 3 ] . each do |e | puts e end ; end
268279while false do [ ( 0 ..10 ) , ( 10 ..20 ) ] . each do |r | puts r . end end end
269280while false do puts end? ; puts end! end
281+ [ while i < 10 do break i if i == 5 ; i += 1 ; end ]
282+ [ while i < 10 do break i if i == 5 ; i += 1 end , while i < 10 do break i if i == 6 ; i += 1 end ]
283+ { while i < 10 do break i if i == 5 ; i += 1 end => 1 }
284+ { while i < 10 do break i if i == 5 ; i += 1 end => 1 }
285+ { foo : while i < 10 do break i if i == 5 ; i += 1 end }
286+ { foo : while i < 10 do break i if i == 5 ; i += 1 end , bar :while i < 10 do break i if i == 6 ; i += 1 end }
287+ { :foo => while i < 10 do break i if i == 5 ; i += 1 end }
288+ { :foo => while i < 10 do break i if i == 5 ; i += 1 end , :bar => while i < 10 do break i if i == 6 ; i += 1 end }
289+ ( while i < 10 do break i if i == 5 ; i += 1 end )
290+ ( while i < 10 do break i if i == 5 ; i += 1 end )
270291
271292# singleline modifier
272293foo ::while false # shouldn't work
@@ -346,6 +367,16 @@ def i arg
346367a = /hello/ ; if true then 1 else 2 end
347368if true then puts ( 1 ..10 ) . end else puts ( 1 ..20 ) . end end
348369if true then puts end? else puts end! end
370+ [ if true then 1 else 2 end ]
371+ [ if true then 1 else 2 end , if true then 2 else 3 end ]
372+ { if true then :foo else :bar end => 1 }
373+ { if true then :foo else :bar end => 1 }
374+ { foo : if true then 1 else 2 end }
375+ { foo : if true then 1 else 2 end , bar : if true then 2 else 3 end }
376+ { :foo => if true then 1 else 2 end }
377+ { :foo => if true then 1 else 2 end , :bar => if true then 2 else 3 end }
378+ ( if true then 1 else 2 end )
379+ ( if true then 1 else 2 end )
349380
350381# singleline modifier
351382foo ::if something # shouldn't work
@@ -412,6 +443,16 @@ def i arg
4124431 ...case 15 when 0 ..50 then 10 when 51 ..100 then 20 else 30 end
413444case x = rand ( 1 ..100 ) when 0 ..50 then puts ( 1 ..10 ) . end when 51 ..100 then puts ( 1 ..20 ) . end end
414445case x = rand ( 1 ..100 ) when 0 ..50 then puts end? when 51 ..100 then puts end! end
446+ [ case x = rand ( 1 ..100 ) when 0 ..50 then ( 1 ..10 ) . end when 51 ..100 then ( 1 ..20 ) . end end ]
447+ [ case x = rand ( 1 ..100 ) when 0 ..50 then ( 1 ..10 ) . end when 51 ..100 then ( 1 ..20 ) . end end , case x = rand ( 1 ..100 ) when 0 ..50 then ( 1 ..10 ) . end when 51 ..100 then ( 1 ..20 ) . end end ]
448+ { case x = rand ( 1 ..100 ) when 0 ..50 then ( 1 ..10 ) . end when 51 ..100 then ( 1 ..20 ) . end end => 1 }
449+ { case x = rand ( 1 ..100 ) when 0 ..50 then ( 1 ..10 ) . end when 51 ..100 then ( 1 ..20 ) . end end => 1 }
450+ { foo : case x = rand ( 1 ..100 ) when 0 ..50 then ( 1 ..10 ) . end when 51 ..100 then ( 1 ..20 ) . end end }
451+ { foo : case x = rand ( 1 ..100 ) when 0 ..50 then ( 1 ..10 ) . end when 51 ..100 then ( 1 ..20 ) . end end , bar : case x = rand ( 1 ..100 ) when 0 ..50 then ( 1 ..10 ) . end when 51 ..100 then ( 1 ..20 ) . end end }
452+ { :foo => case x = rand ( 1 ..100 ) when 0 ..50 then ( 1 ..10 ) . end when 51 ..100 then ( 1 ..20 ) . end end }
453+ { :foo => case x = rand ( 1 ..100 ) when 0 ..50 then ( 1 ..10 ) . end when 51 ..100 then ( 1 ..20 ) . end end , :bar => case x = rand ( 1 ..100 ) when 0 ..50 then ( 1 ..10 ) . end when 51 ..100 then ( 1 ..20 ) . end end }
454+ ( case x = rand ( 1 ..100 ) when 0 ..50 then ( 1 ..10 ) . end when 51 ..100 then ( 1 ..20 ) . end end )
455+ ( case x = rand ( 1 ..100 ) when 0 ..50 then ( 1 ..10 ) . end when 51 ..100 then ( 1 ..20 ) . end end )
415456
416457self . case 15 when 0 ..50 then "foo" when 51 ..100 then "bar" else "baz" end # shouldn't work
417458self ::case 15 when 0 ..50 then "foo" when 51 ..100 then "bar" else "baz" end # shouldn't work
0 commit comments