File Coverage

blib/lib/Language/Befunge/Vector/XS.pm
Criterion Covered Total %
statement 14 14 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 20 20 100.0


line stmt bran cond sub pod time code
1             #
2             # This file is part of Language::Befunge::Vector::XS.
3             # Copyright (c) 2008 Jerome Quelin, all rights reserved.
4             #
5             # This program is free software; you can redistribute it and/or modify
6             # it under the same terms as Perl itself.
7             #
8             #
9              
10             package Language::Befunge::Vector::XS;
11              
12 3     3   61580 use strict;
  3         6  
  3         104  
13 3     3   16 use warnings;
  3         5  
  3         331  
14              
15             use overload
16 3         41 '=' => \©,
17             '+' => \&_add,
18             '-' => \&_substract,
19             'neg' => \&_invert,
20             '+=' => \&_add_inplace,
21             '-=' => \&_substract_inplace,
22             '<=>' => \&_compare,
23             'eq' => \&_compare_string,
24 3     3   3262 '""' => \&as_string;
  3         2814  
25              
26             our $VERSION = '1.1.1';
27              
28             require XSLoader;
29             XSLoader::load('Language::Befunge::Vector::XS', $VERSION);
30              
31             # Preloaded methods go here.
32              
33             sub as_string {
34 128     128 1 73693 my $self = shift;
35 128         210 local $" = ',';
36 128         938 return "(@$self)";
37             }
38              
39             #
40             # my $bool = $v->_compare($string);
41             # my $bool = $v eq $string;
42             #
43             # Check whether the vector stringifies to $string.
44             #
45             sub _compare_string {
46 54     54   2393 my ($self, $str) = @_;
47 54         117 return $self->as_string eq $str;
48             }
49              
50              
51             1;
52             __END__