use v6-alpha; use Test; use Perl6::Grammar; =kwid Testing self hosting rules. =cut plan 25; if !eval('("a" ~~ /a/)') { skip_rest "skipped tests - rules support appears to be missing"; } else { # Testing the parsing of verious forms of numbers is(?("1" ~~ /^$/),Bool::True,"1 is parsed as an integer"); is(?("-1" ~~ /^$/),Bool::True,"-1 is parsed as an integer"); is(?("1." ~~ /^$/),Bool::True,"1. is parsed as a Rat"); is(?("-1." ~~ /^$/),Bool::True,"-1. is parsed as a Rat"); is(?("0.1" ~~ /^$/),Bool::True,"0.1 is parsed as a Rat"); is(?("-0.1" ~~ /^$/),Bool::True,"0.1 is parsed as a Rat"); is(?(".1" ~~ /^$/),Bool::True,".1 is parsed as a Rat"); is(?("-.1" ~~ /^$/),Bool::True,".1 is parsed as a Rat"); is(?("10.01" ~~ /^$/),Bool::True,"10.01 is parsed as a decimal"); is(?("1e3" ~~ /^$/),Bool::True,"1e3 is parsed as a rational"); is(?("10.01e3" ~~ /^$/),Bool::True,"10.01e3 is parsed as a rational"); is(?("42_000" ~~ /^$/),Bool::True,"underscores are allowed"); is(?("42_127_000" ~~ /^$/),Bool::True,"Multiple undescores are allowed"); is(?("_42" ~~ /^$/),Bool::False,"Leading underscores a dissallowed"); is(?("0b100" ~~ /^$/),Bool::True,"0b100 (binary) is parsed as a binary"); is(?("0x100" ~~ /^$/),Bool::True,"0x100 (hex) is parsed as a hex"); is(?("0o100" ~~ /^$/),Bool::True,"0o100 (oct) is parsed as a oct"); is(?("Perl6" ~~ /^$/),Bool::True,"ids are parsed"); is(?("Perl6::rule" ~~ /^$/),Bool::True,"ids are parsed as fullid"); is(?("::rule" ~~ /^$/),Bool::True,"global ids are parsed as fullid"); is(?('$foo' ~~ /^$/),Bool::True,"scalars are parsed as variables"); is(?('@foo' ~~ /^$/),Bool::True,"arrays are parsed as variables"); is(?('%foo' ~~ /^$/),Bool::True,"hashes are parsed as variables"); is(?('&foo' ~~ /^$/),Bool::True,"subs are parsed as variables"); is(?('sub () {}' ~~ /^$/),Bool::True,"Anon subs parsing"); }