parser 0.9.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -880,10 +880,10 @@ class TestLexer < MiniTest::Unit::TestCase
880
880
  end
881
881
 
882
882
  def test_identifier_equals_tilde
883
- @lex.state = :expr_fname # can only set via parser's defs
883
+ @lex.state = :expr_fname
884
884
  util_lex_token("identifier=~",
885
- :tIDENTIFIER, "identifier",
886
- :tMATCH, "=~")
885
+ :tIDENTIFIER, "identifier=",
886
+ :tTILDE, "~")
887
887
  end
888
888
 
889
889
  def test_identifier_gt
@@ -430,16 +430,16 @@ class TestParser < MiniTest::Unit::TestCase
430
430
  ALL_VERSIONS - %w(1.8))
431
431
  end
432
432
 
433
- # def test_hash_kwsplat
434
- # assert_parses(
435
- # s(:hash,
436
- # s(:pair, s(:symbol, :foo), s(:int, 2))
437
- # s(:kwsplat, s(:lvar, :bar))),
438
- # %q[{ foo: 2, **bar }],
439
- # %q{ ^^ operator (kwsplat)
440
- # | ~~~~~ expression (kwsplat)},
441
- # %w(2.0))
442
- # end
433
+ def test_hash_kwsplat
434
+ assert_parses(
435
+ s(:hash,
436
+ s(:pair, s(:sym, :foo), s(:int, 2)),
437
+ s(:kwsplat, s(:lvar, :bar))),
438
+ %q[{ foo: 2, **bar }],
439
+ %q{ ^^ operator (kwsplat)
440
+ | ~~~~~ expression (kwsplat)},
441
+ %w(2.0))
442
+ end
443
443
 
444
444
  def test_hash_no_hashrocket
445
445
  assert_parses(
@@ -447,7 +447,6 @@ class TestParser < MiniTest::Unit::TestCase
447
447
  %q[{ 1, 2 }],
448
448
  %q{^ begin
449
449
  | ^ end
450
- | ^ operator (pair)
451
450
  | ~~~~ expression (pair)
452
451
  |~~~~~~~~ expression},
453
452
  %w(1.8))
@@ -1479,23 +1478,66 @@ class TestParser < MiniTest::Unit::TestCase
1479
1478
  %q{def f(foo=1, bar=2); nil; end})
1480
1479
  end
1481
1480
 
1482
- def test_splatarg_named
1481
+ def test_restarg_named
1483
1482
  assert_parses(
1484
1483
  s(:def, :f,
1485
- s(:args, s(:splatarg, :foo)),
1484
+ s(:args, s(:restarg, :foo)),
1486
1485
  s(:nil)),
1487
1486
  %q{def f(*foo); nil; end},
1488
- %q{ ~~~ name (args.splatarg)
1489
- | ~~~~ expression (args.splatarg)})
1487
+ %q{ ~~~ name (args.restarg)
1488
+ | ~~~~ expression (args.restarg)})
1490
1489
  end
1491
1490
 
1492
- def test_splatarg_unnamed
1491
+ def test_restarg_unnamed
1493
1492
  assert_parses(
1494
1493
  s(:def, :f,
1495
- s(:args, s(:splatarg)),
1494
+ s(:args, s(:restarg)),
1496
1495
  s(:nil)),
1497
1496
  %q{def f(*); nil; end},
1498
- %q{ ~ expression (args.splatarg)})
1497
+ %q{ ~ expression (args.restarg)})
1498
+ end
1499
+
1500
+ def test_kwarg
1501
+ assert_parses(
1502
+ s(:def, :f,
1503
+ s(:args, s(:kwarg, :foo)),
1504
+ s(:nil)),
1505
+ %q{def f(foo:); nil; end},
1506
+ %q{ ~~~ name (args.kwarg)
1507
+ | ~~~~ expression (args.kwarg)},
1508
+ ALL_VERSIONS - %w(1.8 1.9 2.0))
1509
+ end
1510
+
1511
+ def test_kwoptarg
1512
+ assert_parses(
1513
+ s(:def, :f,
1514
+ s(:args, s(:kwoptarg, :foo, s(:int, 1))),
1515
+ s(:nil)),
1516
+ %q{def f(foo: 1); nil; end},
1517
+ %q{ ~~~ name (args.kwoptarg)
1518
+ | ~~~~~~ expression (args.kwoptarg)},
1519
+ ALL_VERSIONS - %w(1.8 1.9))
1520
+ end
1521
+
1522
+ def test_kwrestarg_named
1523
+ assert_parses(
1524
+ s(:def, :f,
1525
+ s(:args, s(:kwrestarg, :foo)),
1526
+ s(:nil)),
1527
+ %q{def f(**foo); nil; end},
1528
+ %q{ ~~~ name (args.kwrestarg)
1529
+ | ~~~~~ expression (args.kwrestarg)},
1530
+ ALL_VERSIONS - %w(1.8 1.9))
1531
+ end
1532
+
1533
+ def test_kwrestarg_unnamed
1534
+ assert_parses(
1535
+ s(:def, :f,
1536
+ s(:args, s(:kwrestarg)),
1537
+ s(:nil)),
1538
+ %q{def f(**); nil; end},
1539
+ %q{ ~~ expression (args.kwrestarg)},
1540
+ ALL_VERSIONS - %w(1.8 1.9))
1499
1541
  end
1500
1542
 
1501
1543
  def test_blockarg
@@ -1522,7 +1564,7 @@ class TestParser < MiniTest::Unit::TestCase
1522
1564
  s(:args,
1523
1565
  s(:arg, :a),
1524
1566
  s(:optarg, :o, s(:int, 1)),
1525
- s(:splatarg, :r),
1567
+ s(:restarg, :r),
1526
1568
  s(:blockarg, :b)),
1527
1569
  %q{a, o=1, *r, &b})
1528
1570
 
@@ -1531,7 +1573,7 @@ class TestParser < MiniTest::Unit::TestCase
1531
1573
  s(:args,
1532
1574
  s(:arg, :a),
1533
1575
  s(:optarg, :o, s(:int, 1)),
1534
- s(:splatarg, :r),
1576
+ s(:restarg, :r),
1535
1577
  s(:arg, :p),
1536
1578
  s(:blockarg, :b)),
1537
1579
  %q{a, o=1, *r, p, &b},
@@ -1559,7 +1601,7 @@ class TestParser < MiniTest::Unit::TestCase
1559
1601
  assert_parses_args(
1560
1602
  s(:args,
1561
1603
  s(:arg, :a),
1562
- s(:splatarg, :r),
1604
+ s(:restarg, :r),
1563
1605
  s(:blockarg, :b)),
1564
1606
  %q{a, *r, &b})
1565
1607
 
@@ -1567,7 +1609,7 @@ class TestParser < MiniTest::Unit::TestCase
1567
1609
  assert_parses_args(
1568
1610
  s(:args,
1569
1611
  s(:arg, :a),
1570
- s(:splatarg, :r),
1612
+ s(:restarg, :r),
1571
1613
  s(:arg, :p),
1572
1614
  s(:blockarg, :b)),
1573
1615
  %q{a, *r, p, &b},
@@ -1584,7 +1626,7 @@ class TestParser < MiniTest::Unit::TestCase
1584
1626
  assert_parses_args(
1585
1627
  s(:args,
1586
1628
  s(:optarg, :o, s(:int, 1)),
1587
- s(:splatarg, :r),
1629
+ s(:restarg, :r),
1588
1630
  s(:blockarg, :b)),
1589
1631
  %q{o=1, *r, &b})
1590
1632
 
@@ -1592,7 +1634,7 @@ class TestParser < MiniTest::Unit::TestCase
1592
1634
  assert_parses_args(
1593
1635
  s(:args,
1594
1636
  s(:optarg, :o, s(:int, 1)),
1595
- s(:splatarg, :r),
1637
+ s(:restarg, :r),
1596
1638
  s(:arg, :p),
1597
1639
  s(:blockarg, :b)),
1598
1640
  %q{o=1, *r, p, &b},
@@ -1617,14 +1659,14 @@ class TestParser < MiniTest::Unit::TestCase
1617
1659
  # f_rest_arg opt_f_block_arg
1618
1660
  assert_parses_args(
1619
1661
  s(:args,
1620
- s(:splatarg, :r),
1662
+ s(:restarg, :r),
1621
1663
  s(:blockarg, :b)),
1622
1664
  %q{*r, &b})
1623
1665
 
1624
1666
  # f_rest_arg tCOMMA f_arg opt_f_block_arg
1625
1667
  assert_parses_args(
1626
1668
  s(:args,
1627
- s(:splatarg, :r),
1669
+ s(:restarg, :r),
1628
1670
  s(:arg, :p),
1629
1671
  s(:blockarg, :b)),
1630
1672
  %q{*r, p, &b},
@@ -1642,6 +1684,34 @@ class TestParser < MiniTest::Unit::TestCase
1642
1684
  %q{})
1643
1685
  end
1644
1686
 
1687
+ def test_kwarg_combinations
1688
+ # f_kwarg tCOMMA f_kwrest opt_f_block_arg
1689
+ assert_parses_args(
1690
+ s(:args,
1691
+ s(:kwoptarg, :foo, s(:int, 1)),
1692
+ s(:kwoptarg, :bar, s(:int, 2)),
1693
+ s(:kwrestarg, :baz),
1694
+ s(:blockarg, :b)),
1695
+ %q{(foo: 1, bar: 2, **baz, &b)},
1696
+ ALL_VERSIONS - %w(1.8 1.9))
1697
+
1698
+ # f_kwarg opt_f_block_arg
1699
+ assert_parses_args(
1700
+ s(:args,
1701
+ s(:kwoptarg, :foo, s(:int, 1)),
1702
+ s(:blockarg, :b)),
1703
+ %q{(foo: 1, &b)},
1704
+ ALL_VERSIONS - %w(1.8 1.9))
1705
+
1706
+ # f_kwrest opt_f_block_arg
1707
+ assert_parses_args(
1708
+ s(:args,
1709
+ s(:kwrestarg, :baz),
1710
+ s(:blockarg, :b)),
1711
+ %q{**baz, &b},
1712
+ ALL_VERSIONS - %w(1.8 1.9))
1713
+ end
1714
+
1645
1715
  def assert_parses_margs(ast, code, versions=ALL_VERSIONS - %w(1.8))
1646
1716
  assert_parses_args(
1647
1717
  s(:args, ast),
@@ -1663,42 +1733,42 @@ class TestParser < MiniTest::Unit::TestCase
1663
1733
 
1664
1734
  # f_marg_list tCOMMA tSTAR f_norm_arg
1665
1735
  assert_parses_margs(
1666
- s(:mlhs, s(:arg, :a), s(:splatarg, :s)),
1667
- %q{(a, *s)})
1736
+ s(:mlhs, s(:arg, :a), s(:restarg, :r)),
1737
+ %q{(a, *r)})
1668
1738
 
1669
1739
  # f_marg_list tCOMMA tSTAR f_norm_arg tCOMMA f_marg_list
1670
1740
  assert_parses_margs(
1671
- s(:mlhs, s(:arg, :a), s(:splatarg, :s), s(:arg, :p)),
1672
- %q{(a, *s, p)})
1741
+ s(:mlhs, s(:arg, :a), s(:restarg, :r), s(:arg, :p)),
1742
+ %q{(a, *r, p)})
1673
1743
 
1674
1744
  # f_marg_list tCOMMA tSTAR
1675
1745
  assert_parses_margs(
1676
- s(:mlhs, s(:arg, :a), s(:splatarg)),
1746
+ s(:mlhs, s(:arg, :a), s(:restarg)),
1677
1747
  %q{(a, *)})
1678
1748
 
1679
1749
  # f_marg_list tCOMMA tSTAR tCOMMA f_marg_list
1680
1750
  assert_parses_margs(
1681
- s(:mlhs, s(:arg, :a), s(:splatarg), s(:arg, :p)),
1751
+ s(:mlhs, s(:arg, :a), s(:restarg), s(:arg, :p)),
1682
1752
  %q{(a, *, p)})
1683
1753
 
1684
1754
  # tSTAR f_norm_arg
1685
1755
  assert_parses_margs(
1686
- s(:mlhs, s(:splatarg, :s)),
1687
- %q{(*s)})
1756
+ s(:mlhs, s(:restarg, :r)),
1757
+ %q{(*r)})
1688
1758
 
1689
1759
  # tSTAR f_norm_arg tCOMMA f_marg_list
1690
1760
  assert_parses_margs(
1691
- s(:mlhs, s(:splatarg, :s), s(:arg, :p)),
1692
- %q{(*s, p)})
1761
+ s(:mlhs, s(:restarg, :r), s(:arg, :p)),
1762
+ %q{(*r, p)})
1693
1763
 
1694
1764
  # tSTAR
1695
1765
  assert_parses_margs(
1696
- s(:mlhs, s(:splatarg)),
1766
+ s(:mlhs, s(:restarg)),
1697
1767
  %q{(*)})
1698
1768
 
1699
1769
  # tSTAR tCOMMA f_marg_list
1700
1770
  assert_parses_margs(
1701
- s(:mlhs, s(:splatarg), s(:arg, :p)),
1771
+ s(:mlhs, s(:restarg), s(:arg, :p)),
1702
1772
  %q{(*, p)})
1703
1773
  end
1704
1774
 
@@ -1776,39 +1846,39 @@ class TestParser < MiniTest::Unit::TestCase
1776
1846
  # block_par tCOMMA tSTAR
1777
1847
  # f_arg tCOMMA f_rest_arg opt_f_block_arg
1778
1848
  assert_parses_blockargs(
1779
- s(:args, s(:arg, :a), s(:splatarg, :s), s(:blockarg, :b)),
1849
+ s(:args, s(:arg, :a), s(:restarg, :s), s(:blockarg, :b)),
1780
1850
  %q{|a, *s, &b|})
1781
1851
 
1782
1852
  assert_parses_blockargs(
1783
1853
  s(:args, s(:arg, :a),
1784
- s(:splatarg_expr, s(:ivasgn, :@s)),
1854
+ s(:restarg_expr, s(:ivasgn, :@s)),
1785
1855
  s(:blockarg_expr, s(:ivasgn, :@b))),
1786
1856
  %q{|a, *@s, &@b|},
1787
1857
  %w(1.8))
1788
1858
 
1789
1859
  assert_parses_blockargs(
1790
- s(:args, s(:arg, :a), s(:splatarg), s(:blockarg, :b)),
1860
+ s(:args, s(:arg, :a), s(:restarg), s(:blockarg, :b)),
1791
1861
  %q{|a, *, &b|})
1792
1862
 
1793
1863
  assert_parses_blockargs(
1794
1864
  s(:args, s(:arg, :a),
1795
- s(:splatarg),
1865
+ s(:restarg),
1796
1866
  s(:blockarg_expr, s(:ivasgn, :@b))),
1797
1867
  %q{|a, *, &@b|},
1798
1868
  %w(1.8))
1799
1869
 
1800
1870
  assert_parses_blockargs(
1801
- s(:args, s(:arg, :a), s(:splatarg, :s)),
1871
+ s(:args, s(:arg, :a), s(:restarg, :s)),
1802
1872
  %q{|a, *s|})
1803
1873
 
1804
1874
  assert_parses_blockargs(
1805
1875
  s(:args, s(:arg, :a),
1806
- s(:splatarg_expr, s(:ivasgn, :@s))),
1876
+ s(:restarg_expr, s(:ivasgn, :@s))),
1807
1877
  %q{|a, *@s|},
1808
1878
  %w(1.8))
1809
1879
 
1810
1880
  assert_parses_blockargs(
1811
- s(:args, s(:arg, :a), s(:splatarg)),
1881
+ s(:args, s(:arg, :a), s(:restarg)),
1812
1882
  %q{|a, *|})
1813
1883
 
1814
1884
  # tSTAR lhs tCOMMA tAMPER lhs
@@ -1817,39 +1887,39 @@ class TestParser < MiniTest::Unit::TestCase
1817
1887
  # tSTAR tCOMMA tAMPER lhs
1818
1888
  # f_rest_arg opt_f_block_arg
1819
1889
  assert_parses_blockargs(
1820
- s(:args, s(:splatarg, :s), s(:blockarg, :b)),
1890
+ s(:args, s(:restarg, :s), s(:blockarg, :b)),
1821
1891
  %q{|*s, &b|})
1822
1892
 
1823
1893
  assert_parses_blockargs(
1824
1894
  s(:args,
1825
- s(:splatarg_expr, s(:ivasgn, :@s)),
1895
+ s(:restarg_expr, s(:ivasgn, :@s)),
1826
1896
  s(:blockarg_expr, s(:ivasgn, :@b))),
1827
1897
  %q{|*@s, &@b|},
1828
1898
  %w(1.8))
1829
1899
 
1830
1900
  assert_parses_blockargs(
1831
- s(:args, s(:splatarg), s(:blockarg, :b)),
1901
+ s(:args, s(:restarg), s(:blockarg, :b)),
1832
1902
  %q{|*, &b|})
1833
1903
 
1834
1904
  assert_parses_blockargs(
1835
1905
  s(:args,
1836
- s(:splatarg),
1906
+ s(:restarg),
1837
1907
  s(:blockarg_expr, s(:ivasgn, :@b))),
1838
1908
  %q{|*, &@b|},
1839
1909
  %w(1.8))
1840
1910
 
1841
1911
  assert_parses_blockargs(
1842
- s(:args, s(:splatarg, :s)),
1912
+ s(:args, s(:restarg, :s)),
1843
1913
  %q{|*s|})
1844
1914
 
1845
1915
  assert_parses_blockargs(
1846
1916
  s(:args,
1847
- s(:splatarg_expr, s(:ivasgn, :@s))),
1917
+ s(:restarg_expr, s(:ivasgn, :@s))),
1848
1918
  %q{|*@s|},
1849
1919
  %w(1.8))
1850
1920
 
1851
1921
  assert_parses_blockargs(
1852
- s(:args, s(:splatarg)),
1922
+ s(:args, s(:restarg)),
1853
1923
  %q{|*|})
1854
1924
 
1855
1925
  # tAMPER lhs
@@ -1870,7 +1940,7 @@ class TestParser < MiniTest::Unit::TestCase
1870
1940
  s(:arg, :a),
1871
1941
  s(:optarg, :o, s(:int, 1)),
1872
1942
  s(:optarg, :o1, s(:int, 2)),
1873
- s(:splatarg, :r),
1943
+ s(:restarg, :r),
1874
1944
  s(:blockarg, :b)),
1875
1945
  %q{|a, o=1, o1=2, *r, &b|},
1876
1946
  ALL_VERSIONS - %w(1.8))
@@ -1880,7 +1950,7 @@ class TestParser < MiniTest::Unit::TestCase
1880
1950
  s(:args,
1881
1951
  s(:arg, :a),
1882
1952
  s(:optarg, :o, s(:int, 1)),
1883
- s(:splatarg, :r),
1953
+ s(:restarg, :r),
1884
1954
  s(:arg, :p),
1885
1955
  s(:blockarg, :b)),
1886
1956
  %q{|a, o=1, *r, p, &b|},
@@ -1909,7 +1979,7 @@ class TestParser < MiniTest::Unit::TestCase
1909
1979
  assert_parses_blockargs(
1910
1980
  s(:args,
1911
1981
  s(:arg, :a),
1912
- s(:splatarg, :r),
1982
+ s(:restarg, :r),
1913
1983
  s(:arg, :p),
1914
1984
  s(:blockarg, :b)),
1915
1985
  %q{|a, *r, p, &b|},
@@ -1919,7 +1989,7 @@ class TestParser < MiniTest::Unit::TestCase
1919
1989
  assert_parses_blockargs(
1920
1990
  s(:args,
1921
1991
  s(:optarg, :o, s(:int, 1)),
1922
- s(:splatarg, :r),
1992
+ s(:restarg, :r),
1923
1993
  s(:blockarg, :b)),
1924
1994
  %q{|o=1, *r, &b|},
1925
1995
  ALL_VERSIONS - %w(1.8))
@@ -1928,7 +1998,7 @@ class TestParser < MiniTest::Unit::TestCase
1928
1998
  assert_parses_blockargs(
1929
1999
  s(:args,
1930
2000
  s(:optarg, :o, s(:int, 1)),
1931
- s(:splatarg, :r),
2001
+ s(:restarg, :r),
1932
2002
  s(:arg, :p),
1933
2003
  s(:blockarg, :b)),
1934
2004
  %q{|o=1, *r, p, &b|},
@@ -1954,13 +2024,41 @@ class TestParser < MiniTest::Unit::TestCase
1954
2024
  # f_rest_arg tCOMMA f_arg opt_f_block_arg
1955
2025
  assert_parses_blockargs(
1956
2026
  s(:args,
1957
- s(:splatarg, :r),
2027
+ s(:restarg, :r),
1958
2028
  s(:arg, :p),
1959
2029
  s(:blockarg, :b)),
1960
2030
  %q{|*r, p, &b|},
1961
2031
  ALL_VERSIONS - %w(1.8))
1962
2032
  end
1963
2033
 
2034
+ def test_block_kwarg_combinations
2035
+ # f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
2036
+ assert_parses_blockargs(
2037
+ s(:args,
2038
+ s(:kwoptarg, :foo, s(:int, 1)),
2039
+ s(:kwoptarg, :bar, s(:int, 2)),
2040
+ s(:kwrestarg, :baz),
2041
+ s(:blockarg, :b)),
2042
+ %q{|foo: 1, bar: 2, **baz, &b|},
2043
+ ALL_VERSIONS - %w(1.8 1.9))
2044
+
2045
+ # f_block_kwarg opt_f_block_arg
2046
+ assert_parses_blockargs(
2047
+ s(:args,
2048
+ s(:kwoptarg, :foo, s(:int, 1)),
2049
+ s(:blockarg, :b)),
2050
+ %q{|foo: 1, &b|},
2051
+ ALL_VERSIONS - %w(1.8 1.9))
2052
+
2053
+ # f_kwrest opt_f_block_arg
2054
+ assert_parses_blockargs(
2055
+ s(:args,
2056
+ s(:kwrestarg, :baz),
2057
+ s(:blockarg, :b)),
2058
+ %q{|**baz, &b|},
2059
+ ALL_VERSIONS - %w(1.8 1.9))
2060
+ end
2061
+
1964
2062
  def test_arg_invalid
1965
2063
  assert_diagnoses(
1966
2064
  [:error, :argument_const],
@@ -1983,6 +2081,20 @@ class TestParser < MiniTest::Unit::TestCase
1983
2081
  %q{ ~~~~~ location})
1984
2082
  end
1985
2083
 
2084
+ def test_kwarg_invalid
2085
+ assert_diagnoses(
2086
+ [:error, :argument_const],
2087
+ %q{def foo(Abc: 1); end},
2088
+ %q{ ~~~~ location},
2089
+ ALL_VERSIONS - %w(1.8 1.9))
2090
+
2091
+ assert_diagnoses(
2092
+ [:error, :argument_const],
2093
+ %q{def foo(Abc:); end},
2094
+ %q{ ~~~~ location},
2095
+ ALL_VERSIONS - %w(1.8 1.9 2.0))
2096
+ end
2097
+
1986
2098
  def test_arg_label
1987
2099
  assert_parses(
1988
2100
  s(:def, :foo, s(:args),
@@ -2009,18 +2121,6 @@ class TestParser < MiniTest::Unit::TestCase
2009
2121
  ALL_VERSIONS - %w(1.8))
2010
2122
  end
2011
2123
 
2012
- # def test_kwoptarg
2013
- # flunk
2014
- # end
2015
-
2016
- # def test_kwsplat_named
2017
- # flunk
2018
- # end
2019
-
2020
- # def test_kwsplat_unnamed
2021
- # flunk
2022
- # end
2023
-
2024
2124
  #
2025
2125
  # Sends
2026
2126
  #
@@ -2116,6 +2216,34 @@ class TestParser < MiniTest::Unit::TestCase
2116
2216
  |~~~~~~~~~~~~ expression})
2117
2217
  end
2118
2218
 
2219
+ def test_send_plain_cmd_ambiguous_prefix
2220
+ assert_diagnoses(
2221
+ [:warning, :ambiguous_prefix, { :prefix => '+' }],
2222
+ %q{m +foo},
2223
+ %q{ ^ location})
2224
+
2225
+ assert_diagnoses(
2226
+ [:warning, :ambiguous_prefix, { :prefix => '-' }],
2227
+ %q{m -foo},
2228
+ %q{ ^ location})
2229
+
2230
+ assert_diagnoses(
2231
+ [:warning, :ambiguous_prefix, { :prefix => '&' }],
2232
+ %q{m &foo},
2233
+ %q{ ^ location})
2234
+
2235
+ assert_diagnoses(
2236
+ [:warning, :ambiguous_prefix, { :prefix => '*' }],
2237
+ %q{m *foo},
2238
+ %q{ ^ location})
2239
+
2240
+ assert_diagnoses(
2241
+ [:warning, :ambiguous_prefix, { :prefix => '**' }],
2242
+ %q{m **foo},
2243
+ %q{ ^^ location},
2244
+ ALL_VERSIONS - %w(1.8 1.9))
2245
+ end
2246
+
2119
2247
  def test_send_block_chain_cmd
2120
2248
  assert_parses(
2121
2249
  s(:send,
@@ -2160,6 +2288,42 @@ class TestParser < MiniTest::Unit::TestCase
2160
2288
  | ^ begin
2161
2289
  | ^ end
2162
2290
  |~~~~~~~~~~~~~~~~~~~~~~~ expression})
2291
+
2292
+ assert_parses(
2293
+ s(:block,
2294
+ s(:send,
2295
+ s(:block,
2296
+ s(:send, nil, :meth, s(:int, 1)),
2297
+ s(:args), s(:nil)),
2298
+ :fun, s(:lvar, :bar)),
2299
+ s(:args), s(:nil)),
2300
+ %q{meth 1 do end.fun bar do end},
2301
+ %q{},
2302
+ ALL_VERSIONS - %w(1.8 1.9))
2303
+
2304
+ assert_parses(
2305
+ s(:block,
2306
+ s(:send,
2307
+ s(:block,
2308
+ s(:send, nil, :meth, s(:int, 1)),
2309
+ s(:args), s(:nil)),
2310
+ :fun, s(:lvar, :bar)),
2311
+ s(:args), s(:nil)),
2312
+ %q{meth 1 do end.fun(bar) {}},
2313
+ %q{},
2314
+ ALL_VERSIONS - %w(1.8 1.9))
2315
+
2316
+ assert_parses(
2317
+ s(:block,
2318
+ s(:send,
2319
+ s(:block,
2320
+ s(:send, nil, :meth, s(:int, 1)),
2321
+ s(:args), s(:nil)),
2322
+ :fun),
2323
+ s(:args), s(:nil)),
2324
+ %q{meth 1 do end.fun {}},
2325
+ %q{},
2326
+ ALL_VERSIONS - %w(1.8 1.9))
2163
2327
  end
2164
2328
 
2165
2329
  def test_send_paren_block_cmd