### ----------------------------------------------------
### -- Format::Lisp
### -- Licenses: Artistic-2.0
### -- Authors: Jeffrey Goff
### -- File: t/01-parse-text.rakutest
### ----------------------------------------------------
### -- Chunk 2 of 2
{A ~@_A ~@_A ~@_A ~@_A ~@_},
		Q{A ~@_A ~@_A ~@_A ~@_},
		Q{A ~_A ~_A ~_A ~_A ~_A ~_A ~_A ~_A ~_A ~_},
		Q{A ~_A ~_A ~_A ~_A ~_},
		Q{A ~_A ~_A ~_A ~_},
		Q{A ~_A ~_A ~_A ~_~%A ~_A ~_A ~_A ~_},
		Q{AAAA ~:@_},
		Q{AAAA ~_},
		Q{B ~_},
		Q{D ~_},
		Q{~%A~@_},
		Q{~W~W~:_~W~W~:_~W~W~:_~W~W~:_~W~W~:_},
	;
	for @options -> $str {
		ok $fl._match( $str ), $str;
	}
}, '_';

# XXX No {" tests?

subtest {
	my @options =
		Q{~0|},
		Q{~V|},
		Q{~|},
		Q{~~~D|},
	;
	for @options -> $str {
		ok $fl._match( $str ), $str;
	}
}, '|';

subtest {
	my @options =
		Q{~#:@{A~:}},
		Q{~#:{~A~}},
		Q{~#@{~A~}},
		Q{~#{~A~}},
		Q{~#{~}},
		Q{~0:@{~A~:}},
		Q{~0:{XYZ~}},
		Q{~0@{~A~^~A~}},
		Q{~0{FOO~:}},
		Q{~0{~A~^~A~}},
		Q{~0{~}},
		Q{~1@{FOO~}},
		Q{~1@{~A~^~A~}},
		Q{~1{FOO~:}},
		Q{~1{~A~^~A~}},
		Q{~1{~}},
		Q{~2:{XYZ~}},
		Q{~2:{~A~}},
		Q{~2{FOO~:}},
		Q{~2{FOO~}},
		Q{~3{~}},
		Q{~:@{(~A ~A)~}},
		Q{~:@{~#,#,#:^~A~}},
		Q{~:@{~#,#,#^~A~}},
		Q{~:@{~#,#,2:^~A~}},
		Q{~:@{~#,#,3^~A~}},
		Q{~:@{~#,#:^~A~}},
		Q{~:@{~#,#^~A~}},
		Q{~:@{~#,1:^~A~}},
		Q{~:@{~#,1^~A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{~{~[X~;Y~;Z~:;~0^~]~}},
		Q{~{~[X~;Y~;Z~;~0^~]~}},
		Q{~{~v,'X^~A~}},
		Q{~{~v,1,v^~A~}},
		Q{~{~v,v,v^~A~}},
		Q{~{~v,v^~A~}},
		Q{~{~{~A~}~}},
		Q{~{~}},
		Q{~:@{~A ~A~}},
		Q{~:{~A~}},
		Q{~{~A~}},
		Q{~:@{~A~}},
		Q{~:{~A~}},
		Q{~{~A~}},
	;
	for @options -> $str {
		ok $fl._match( $str ), $str;
	}
}, '}';

subtest {
	my @options =
		Q{~#~},
		Q{~v~},
		Q{~~},
		Q{~~~D~~},
	;
	for @options -> $str {
		ok $fl._match( $str ), $str;
	}
}, '~';

subtest {
	my @options =
		Q{1~<X~<Y~:>Z~>2},
		Q{~:<foo~;~A~;bar~A~:>},
		Q{~:<foo~@;~A~;bar~A~:>},
		Q{~:<foo~A~;~A~:>},
		Q{~:<foo~A~;~A~;bar~:>},
		Q{~:<foo~A~@;~A~:>},
		Q{~:<foo~A~@;~A~;bar~:>},
		Q{~:<~;~A~;bar~A~:>},
		Q{~:<~@;~A~;bar~A~:>},
		Q{~< ~W ~>},
		Q{~< ~_ ~>},
		Q{~< ~i ~>},
		Q{~<X~:;Y~>~I},
		Q{~<X~:;Y~>~W},
		Q{~<X~:;Y~>~_},
		Q{~<foo~;~A~;bar~A~:>},
		Q{~<foo~@;~A~;bar~A~:>},
		Q{~<foo~A~;~A~:>},
		Q{~<foo~A~;~A~;bar~:>},
		Q{~<foo~A~@;~A~:>},
		Q{~<foo~A~@;~A~;bar~:>},
		Q{~<~:;~>~<~:>},
		Q{~<~:>~<~:;~>},
		Q{~<~;~A~;bar~A~:>},
		Q{~<~@;~A~;bar~A~:>},
		Q{~@<foo~;~A~;bar~A~:>},
		Q{~@<foo~@;~A~;bar~A~:>},
		Q{~@<foo~A~;~A~:>},
		Q{~@<foo~A~;~A~;bar~:>},
		Q{~@<foo~A~@;~A~:>},
		Q{~@<foo~A~@;~A~;bar~:>},
		Q{~@<~;~A~;bar~A~:>},
		Q{~@<~@;~A~;bar~A~:>},
		Q{~_~<X~:;Y~>},
		Q{~i~<X~:;Y~>},
		Q{~w~<X~:;Y~>},
	;
	for @options -> $str {
		ok $fl._match( $str ), $str;
	}
}, '>';

subtest {
	my @options =
		Q{AAAA~1,1:TBBB~<XXX~:;YYY~>ZZZ},
		Q{~<XXX~1,1:TYYY~>},
		Q{~<XXX~:;YYY~>ZZZ~4,5:tWWW},
	;
	for @options -> $str {
		ok $fl._match( $str ), $str;
	}
}, 'Z';

#`(
subtest {
	my @options =
		qq{~\n   X},
		qq{A~:\n X},
		qq{A~@\n X},
	;
	for @options -> $str {
		ok $fl._match( $str ), $str;
	}
}, 'newline';
)

subtest {
	my @failing-options =
		Q[~{],
		Q[~}],
		Q[~(],
		Q[~)],
		Q[~<],
		Q[~>],
#		Q[~;], # tilde-Semi outside balanced block
	;
	for @failing-options -> $str {
		nok $fl._match( $str ), $str;
	}
}, 'failing';

done-testing;

# vim: ft=perl6


