line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dallycot::AST::Unique; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:JSMITH'; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# ABSTRACT: Test that all values are unique |
5
|
|
|
|
|
|
|
|
6
|
23
|
|
|
23
|
|
12008
|
use strict; |
|
23
|
|
|
|
|
39
|
|
|
23
|
|
|
|
|
735
|
|
7
|
23
|
|
|
23
|
|
88
|
use warnings; |
|
23
|
|
|
|
|
33
|
|
|
23
|
|
|
|
|
444
|
|
8
|
|
|
|
|
|
|
|
9
|
23
|
|
|
23
|
|
87
|
use utf8; |
|
23
|
|
|
|
|
31
|
|
|
23
|
|
|
|
|
105
|
|
10
|
23
|
|
|
23
|
|
519
|
use parent 'Dallycot::AST'; |
|
23
|
|
|
|
|
33
|
|
|
23
|
|
|
|
|
104
|
|
11
|
|
|
|
|
|
|
|
12
|
23
|
|
|
23
|
|
1165
|
use Promises qw(deferred); |
|
23
|
|
|
|
|
34
|
|
|
23
|
|
|
|
|
125
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub to_string { |
15
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
16
|
0
|
|
|
|
|
|
return join( " <> ", map { $_->to_string } @{$self} ); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub to_rdf { |
20
|
0
|
|
|
0
|
0
|
|
my($self, $model) = @_; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# |
23
|
|
|
|
|
|
|
# node -> expression_set -> [ ... ] |
24
|
|
|
|
|
|
|
# |
25
|
0
|
|
|
|
|
|
return $model -> apply( |
26
|
|
|
|
|
|
|
$model -> meta_uri('loc:all-unique'), |
27
|
|
|
|
|
|
|
[ @$self ] |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub execute { |
32
|
0
|
|
|
0
|
0
|
|
my ( $self, $engine ) = @_; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
return $engine->collect(@$self)->then( |
35
|
|
|
|
|
|
|
sub { |
36
|
0
|
|
|
0
|
|
|
my (@values) = map {@$_} @_; |
|
0
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my @types = map { $_->type } @values; |
|
0
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
return $engine->coerce( @values, \@types )->then( |
40
|
|
|
|
|
|
|
sub { |
41
|
0
|
|
|
|
|
|
my (@new_values) = @_; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# now make sure values are all different |
44
|
0
|
|
|
|
|
|
my %seen; |
45
|
0
|
|
|
|
|
|
my @unique = grep { !$seen{ $_->id }++ } @new_values; |
|
0
|
|
|
|
|
|
|
46
|
0
|
0
|
|
|
|
|
if ( @unique != @new_values ) { |
47
|
0
|
|
|
|
|
|
return $engine->FALSE; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
else { |
50
|
0
|
|
|
|
|
|
return $engine->TRUE; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
0
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
} |
55
|
0
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |