File: datetime.t

package info (click to toggle)
libtangram-perl 2.07-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 644 kB
  • ctags: 533
  • sloc: perl: 6,027; makefile: 41
file content (86 lines) | stat: -rw-r--r-- 2,049 bytes parent folder | download
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/perl

use strict;
use lib 't';
use Springfield;
BEGIN {
    eval "use Date::Manip qw(ParseDate);";
    if ($@) {
	eval 'use Test::More skip_all => "Date::Manip not installed";';
    } else {
	eval 'use Test::More tests => 11;';
    }
}

tests_for_dialect(qw( mysql Pg ));

#$Tangram::TRACE = \*STDOUT;

my %ids;

{
	my $storage = Springfield::connect_empty;

	my $jll = NaturalPerson->new
		(
		 firstName => 'Jean-Louis',
		 birthDate => '1963-8-13',
		 birthTime => '11:34:17',
		 birth => '1963-8-13 11:34:17',
		 incarnation => ParseDate('1963-8-13 11:34:17'),
  		);

	$ids{jll} = $storage->insert($jll);

	my $chloe = NaturalPerson->new
		(
		 firstName => 'Chlo',
		 birth => '1993-7-28 13:10:00',
		 incarnation => ParseDate('1993-7-28 13:10:00'),
  		);

   $ids{chloe} = $storage->insert($chloe);

   $storage->disconnect;
}

is(leaked, 0, "leaktest");

{
    my $storage = Springfield::connect;

    my $jll = $storage->load( $ids{jll} );

    like($jll->{birthTime}, qr/11/, "load of Date::Manip object [1]");
    like($jll->{birthTime}, qr/34/, "load of Date::Manip object [2]");
    like($jll->{birthTime}, qr/17/, "load of Date::Manip object [3]");

    like($jll->{birthDate}, qr/1963/, "load of Date::Manip object [1]");
    like($jll->{birthDate}, qr/13/, "load of Date::Manip object [2]");
    like($jll->{birthDate}, qr/8/, "load of Date::Manip object [3]");

    my $rp = $storage->remote(qw( NaturalPerson ));
    my @results = $storage->select( $rp, $rp->{birth} > '1990-1-1' );

    is(@results, 1, "Select by date compare");
    is($storage->id( $results[0] ), $ids{chloe},
       "got right object back" );

    like( $results[0]->{incarnation}, qr/^\d{10}:\d\d:\d\d$/,
	  "Dates returned in ISO9601 form" );

# 	if (optional_tests('epoch; no Time::Local',
# 					   eval { require 'Time::Local' }, 1)) {

# 		Springfield::test($jll->{birthDate} =~ /1963/
# 						  && $jll->{birthDate} =~ /13/
# 						  && $jll->{birthDate} =~ /8/
# 						 );
# 	}

    $storage->disconnect;
}

is(leaked, 0, "leaktest");

1;