summaryrefslogtreecommitdiff
path: root/tests/examplefiles/perl_misc
diff options
context:
space:
mode:
authorJon Jensen <jon@endpoint.com>2010-07-23 18:16:36 -0600
committerJon Jensen <jon@endpoint.com>2010-07-23 18:16:36 -0600
commiteb116405a7d23456589371322e52f8430a8cde0d (patch)
tree3543aa6f9f41313fe880ed438072dce35e386729 /tests/examplefiles/perl_misc
parent072d0c3194c652c88f6b2857c61eadf53d5ab167 (diff)
downloadpygments-eb116405a7d23456589371322e52f8430a8cde0d.tar.gz
Improve lexing of Perl numbers
Add support for floating point numbers (adapted from Lua lexer). Support comma-like _ in numbers. Add test file to exercise this.
Diffstat (limited to 'tests/examplefiles/perl_misc')
-rw-r--r--tests/examplefiles/perl_misc62
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/examplefiles/perl_misc b/tests/examplefiles/perl_misc
new file mode 100644
index 00000000..e6dbfb28
--- /dev/null
+++ b/tests/examplefiles/perl_misc
@@ -0,0 +1,62 @@
+#!/usr/bin/perl
+
+# from http://gist.github.com/485595
+use strict;
+use warnings;
+use Time::HiRes 'usleep';
+
+for (1..5) {
+ open my $in, '<', '/proc/sys/kernel/random/entropy_avail' or die;
+ print <$in>;
+ close $in;
+ usleep 100_000;
+}
+
+# other miscellaneous tests of numbers separated by _
+#usleep 100_000;
+100_000_000;
+my $nichts = 0.005_006;
+print "$nichts\n";
+my $nichts2 = 0.005_006_007;
+print 900_800_700.005_006_007, $/;
+
+# numbers from `man 1 perlnumber`
+my $n;
+$n = 1234; # decimal integer
+$n = 0b1110011; # binary integer
+$n = 01234; # octal integer
+$n = 0x1234; # hexadecimal integer
+$n = 12.34e-56; # exponential notation
+$n = "-12.34e56"; # number specified as a string
+$n = "1234"; # number specified as a string
+
+# other numbers
+for (
+ -9876,
+ +8765,
+ -9876.02,
+ -9876.02e+10,
+ +765_432e30,
+ 2002.,
+ .2002,
+) {
+ print $_, "\n";
+}
+
+# operators on numbers
+for (
+ $n + 300,
+ $n - 300,
+ $n / 300 + 10,
+ $n * 250 / 2.0,
+ $n == 100,
+ $n != 100,
+ $n > 100,
+ $n >= 100,
+ $n < 100,
+ $n <= 100,
+ $n % 2,
+ abs $n,
+) {
+ print $_, "\n";
+}