1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More;
7use Test::Fatal;
8
9use Bread::Board;
10
11is(exception { container 'MyApp' => sub { "dummy" } }, undef, 'container sugar does not throw exception');
12is(exception { as { "Dummy" } }, undef, 'as sugar does not throw exception');
13is(exception {
14    container 'MyApp' => as { service 'service1' => 'foo' };
15}, undef, 'as service sugar does not throw exception');
16is(exception {
17    container 'MyApp' => as {
18        service 'service1' => 'foo';
19        service 'service2' => (
20            block => sub { "dummy" },
21            dependencies => wire_names 'service1'
22        );
23    }
24}, undef, 'container, service and wire_names sugar does not throw exception');
25is(exception {
26    container 'MyApp' => as {
27        service 'service1' => 'foo';
28        service 'service2' => (
29            block => sub { "dummy" },
30            dependencies => {
31                service1 => depends_on 'service1'
32            }
33        );
34    }
35}, undef, 'container, service, and depends_on sugar does not throw exception');
36
37no Bread::Board;
38
39like(exception { container() },
40     qr/^Undefined subroutine &main::container called/, 'container function does not exist without Bread::Board');
41like(exception { as() },
42     qr/^Undefined subroutine &main::as called/, 'as function does not exist without Bread::Board');
43like(exception { service() },
44     qr/^Undefined subroutine &main::service called/, 'service function does not exist without Bread::Board');
45like(exception { depends_on() },
46     qr/^Undefined subroutine &main::depends_on called/, 'depends_on function does not exist without Bread::Board');
47like(exception { wire_names() },
48     qr/^Undefined subroutine &main::wire_names called/, 'wire_names function does not exist without Bread::Board');
49
50done_testing;
51