File: iterator-boolean.t

package info (click to toggle)
librdf-trine-perl 1.019-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,200 kB
  • sloc: perl: 17,601; sql: 20; makefile: 8; sh: 1
file content (42 lines) | stat: -rw-r--r-- 1,107 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env perl
use strict;
use warnings;
no warnings 'redefine';
use URI::file;
use Test::More tests => 8;
use Test::Exception;
use JSON 2.0;

use Data::Dumper;
use RDF::Trine;
use RDF::Trine::Iterator qw(sgrep smap swatch);
use RDF::Trine::Iterator::Boolean;
use RDF::Trine::Statement;

{
	my $stream	= RDF::Trine::Iterator::Boolean->new([1]);
	isa_ok( $stream, 'RDF::Trine::Iterator::Boolean' );
	ok( $stream->is_boolean, 'is_boolean' );
	ok( $stream->get_boolean, 'boolean value' );
}

{
	my $stream	= RDF::Trine::Iterator::Boolean->new([0]);
	isa_ok( $stream, 'RDF::Trine::Iterator::Boolean' );
	ok( $stream->is_boolean, 'is_boolean' );
	ok( not($stream->get_boolean), 'boolean value' );
}

{
	my $stream	= RDF::Trine::Iterator::Boolean->new( [1] );
	my $xml		= $stream->as_xml;
	like( $xml, qr#<boolean>true</boolean>#sm, 'boolean iterator as_xml' );
}

{
	my $stream	= RDF::Trine::Iterator::Boolean->new( [0] );
	my $json	= $stream->as_json;
	my $expect	= from_json('{"boolean":false,"head":{"vars":[]}}');
	my $got		= from_json($json);
	is_deeply( $got, $expect, 'boolean iterator as_json' );
}