1use strict;
2use Test::More tests => 14;
3
4BEGIN {
5    use_ok('Graphics::Primitive::Path');
6    use_ok('Geometry::Primitive::Rectangle');
7};
8
9my $path = Graphics::Primitive::Path->new;
10cmp_ok($path->primitive_count, '==', 0, 'primitive count');
11
12my $start = Geometry::Primitive::Point->new(x => 0, y => 0);
13$path->current_point($start);
14ok($path->current_point->equal_to($start), 'current_point');
15
16# Add A Line
17my $line_end = Geometry::Primitive::Point->new(x => 10, y => 0);
18$path->line_to($line_end);
19ok($path->current_point->equal_to($line_end), 'line set current_point');
20cmp_ok($path->primitive_count, '==', 1, 'primitive count');
21
22# Move to, no primitives
23my $mover = Geometry::Primitive::Point->new(x => 10, y => 10);
24$path->move_to($mover);
25ok($path->current_point->equal_to($mover), 'move_to set current_point');
26cmp_ok($path->primitive_count, '==', 1, 'primitive count after move_to');
27
28# Move to again, no primitive
29$path->move_to(12, 12);
30cmp_ok($path->current_point->x, '==', 12, 'move to with scalars');
31
32$path->rel_move_to(5, 4);
33my $chkpt = Geometry::Primitive::Point->new(x => 17, y => 16);
34ok($path->current_point->equal_to($chkpt), 'rel_move_to');
35
36$path->close_path;
37my $line = $path->get_primitive($path->primitive_count - 1);
38isa_ok($line, 'Geometry::Primitive::Line');
39$chkpt->x(0); $chkpt->y(0);
40ok($line->point_end->equal_to($chkpt), 'close path');
41
42$path->arc(5, 0, 1.7);
43my $a_line = $path->get_primitive($path->primitive_count - 2);
44my $arc = $path->get_primitive($path->primitive_count - 1);
45
46ok($path->current_point->equal_to($arc->point_end), 'post arc current_point');
47isa_ok($line, 'Geometry::Primitive::Line');
48