summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorthatch <thatch@localhost>2008-08-14 23:31:37 -0700
committerthatch <thatch@localhost>2008-08-14 23:31:37 -0700
commit38891c2e075c084240de252f219f5c7e7c40ca51 (patch)
tree99f7eca610faf79d43a29f37b7da9b31bf0278eb /tests
parent97643e86f08377bb6d42f69f3175a74364cb2694 (diff)
downloadpygments-git-38891c2e075c084240de252f219f5c7e7c40ca51.tar.gz
Support more delimiters for perl regular expressions, as discussed in #258
Diffstat (limited to 'tests')
-rw-r--r--tests/examplefiles/regex-delims.pl120
1 files changed, 120 insertions, 0 deletions
diff --git a/tests/examplefiles/regex-delims.pl b/tests/examplefiles/regex-delims.pl
new file mode 100644
index 00000000..6da5298d
--- /dev/null
+++ b/tests/examplefiles/regex-delims.pl
@@ -0,0 +1,120 @@
+#! /usr/bin/env perl
+
+use strict;
+use warnings;
+
+# common delimiters
+print "a: ";
+my $a = "foo";
+print $a, " - ";
+$a =~ s/foo/bar/;
+print $a, "\n";
+
+print "b: ";
+my $b = "foo";
+print $b, " - ";
+$b =~ s!foo!bar!;
+print $b, "\n";
+
+print "c: ";
+my $c = "foo";
+print $c, " - ";
+$c =~ s@foo@bar@;
+print $c, "\n";
+
+print "d: ";
+my $d = "foo";
+print $d, " - ";
+$d =~ s\foo\bar\;
+print $d, "\n";
+
+print "\n";
+
+# balanced delimiters
+print "e: ";
+my $e = "foo";
+print $e, " - ";
+$e =~ s{foo}{bar};
+print $e, "\n";
+
+print "f: ";
+my $f = "foo";
+print $f, " - ";
+$f =~ s(foo)(bar);
+print $f, "\n";
+
+print "g: ";
+my $g = "foo";
+print $g, " - ";
+$g =~ s<foo><bar>;
+print $g, "\n";
+
+print "h: ";
+my $h = "foo";
+print $h, " - ";
+$h =~ s[foo][bar];
+print $h, "\n";
+
+print "\n";
+
+# balanced delimiters with whitespace
+print "i: ";
+my $i = "foo";
+print $i, " - ";
+$i =~ s{foo} {bar};
+print $i, "\n";
+
+print "j: ";
+my $j = "foo";
+print $j, " - ";
+$j =~ s<foo> <bar>;
+print $j, "\n";
+
+print "k: ";
+my $k = "foo";
+print $k, " - ";
+$k =~
+ s(foo)
+
+ (bar);
+print $k, "\n";
+
+print "\n";
+
+# mixed delimiters
+print "l: ";
+my $l = "foo";
+print $l, " - ";
+$l =~ s{foo} <bar>;
+print $l, "\n";
+
+print "m: ";
+my $m = "foo";
+print $m, " - ";
+$m =~ s(foo) !bar!;
+print $m, "\n";
+
+print "n: ";
+my $n = "foo";
+print $n, " - ";
+$n =~ s[foo] $bar$;
+print $n, "\n";
+
+print "\n";
+
+# /x modifier
+print "o: ";
+my $o = "foo";
+print $o, " - ";
+$o =~ s{
+ foo
+ } {bar}x;
+print $o, "\n";
+
+print "p: ";
+my $p = "foo";
+print $p, " - ";
+$p =~ s%
+ foo
+ %bar%x;
+print $p, "\n";