File Coverage

blib/lib/Language/Kemuri.pm
Criterion Covered Total %
statement 15 46 32.6
branch n/a
condition n/a
subroutine 5 6 83.3
pod 1 1 100.0
total 21 53 39.6


line stmt bran cond sub pod time code
1             package Language::Kemuri;
2 2     2   107978 use strict;
  2         5  
  2         62  
3 2     2   9 use warnings;
  2         4  
  2         46  
4 2     2   10 use Carp;
  2         8  
  2         201  
5             our $VERSION = '0.07';
6 2     2   9 use Exporter;
  2         3  
  2         104  
7             our @EXPORT_OK = qw/kemuri/;
8 2     2   48 use 5.010001;
  2         8  
  2         1778  
9              
10             sub kemuri {
11 0     0 1   my $code = shift;
12              
13 0           my @stack;
14 0           my $buf = "";
15            
16 0           for my $c ( split //, $code ) {
17 0           given ($c) {
18 0           when (q{`}) {
19 0           push @stack, unpack("C*", reverse "Hello, world!");
20             }
21 0           when (q{"}) {
22 0           my $x = pop @stack;
23 0           push @stack, $x;
24 0           push @stack, $x;
25             }
26 0           when (q{'}) {
27 0           my $x = pop @stack;
28 0           my $y = pop @stack;
29 0           my $z = pop @stack;
30 0           push @stack, $x;
31 0           push @stack, $z;
32 0           push @stack, $y;
33             }
34 0           when ('^') {
35 0           my $x = pop @stack;
36 0           my $y = pop @stack;
37 0           push @stack, $x ^ $y;
38             }
39 0           when ('~') {
40 0           my $x = pop @stack;
41 0           push @stack, -($x+1);
42             }
43 0           when ('|') {
44 0           $buf .= reverse map { chr($_ % 256) } @stack;
  0            
45             }
46 0           default {
47 0           croak "unknown kemuri token $c in $code";
48             }
49             }
50             }
51              
52 0           return $buf;
53             }
54              
55             1;
56             __END__