6 use Test::More tests => 5 + 18 + 12;
10 ok(defined &Tikz, 'main::Tikz constant is defined');
11 is(prototype('Tikz'), '', 'main::Tikz is actually a constant');
14 package LaTeX::TikZ::TestAPI1;
17 LaTeX::TikZ->import(as => ':)');
19 ::like($@, qr/^Invalid name/, 'invalid name');
23 package LaTeX::TikZ::TestAPI2;
25 use LaTeX::TikZ as => 'T';
27 ::ok(defined &T, 'LaTeX::TikZ::TestAPI2::T constant is defined');
28 ::is(prototype('T'), '', 'LaTeX::TikZ::TestAPI2::T is actually a constant');
34 point line polyline closed_polyline rectangle circle arc arrow
37 width color fill pattern
41 ok(Tikz->can($_), "Tikz evaluates to something that ->can($_)");
44 require LaTeX::TikZ::Interface;
46 for my $name (undef, ':)') {
48 LaTeX::TikZ::Interface->import(
52 like $@, qr/^Invalid interface name/, 'invalid interface name';
56 LaTeX::TikZ::Interface->import(
60 like $@, qr/^'raw' is already defined/, 'already defined';
62 for my $code (undef, [ ]) {
64 LaTeX::TikZ::Interface->import(
68 like $@, qr/^Invalid code reference/, 'invalid code';
72 LaTeX::TikZ::Interface->import(
76 is $@, '', 'registering foo doesn\'t croak';
77 ok(Tikz->can('foo'), 'Tikz evaluates to something that ->can(foo)');
78 is_deeply [ Tikz->foo('hello') ], [ Tikz, 'hello' ], 'Tikz->foo works';
81 LaTeX::TikZ::Interface->import(
86 like $@, qr/^Invalid code reference/, 'baz is invalid code';
87 ok(!Tikz->can('baz'), 'baz was not defined');
88 ok(Tikz->can('bar'), 'but bar was defined');
89 is_deeply [ Tikz->bar('bonjour') ], [ Tikz, 'bonjour' ], 'Tikz->bar works';