Upgrade to Test-Simple-0.82.
[p5sagit/p5-mst-13.2.git] / lib / Test / Simple / t / new_ok.t
CommitLineData
ccbd73a4 1#!/usr/bin/perl -w
2
3use strict;
4
5use Test::More tests => 13;
6
7{
8 package Bar;
9
10 sub new {
11 my $class = shift;
12 return bless {@_}, $class;
13 }
14
15
16 package Foo;
17 our @ISA = qw(Bar);
18}
19
20{
21 my $obj = new_ok("Foo");
22 is_deeply $obj, {};
23 isa_ok $obj, "Foo";
24
25 $obj = new_ok("Bar");
26 is_deeply $obj, {};
27 isa_ok $obj, "Bar";
28
29 $obj = new_ok("Foo", [this => 42]);
30 is_deeply $obj, { this => 42 };
31 isa_ok $obj, "Foo";
32
33 $obj = new_ok("Foo", [], "Foo");
34 is_deeply $obj, {};
35 isa_ok $obj, "Foo";
36}
37
38# And what if we give it nothing?
39eval {
40 new_ok();
41};
42is $@, sprintf "new_ok() must be given at least a class at %s line %d.\n", $0, __LINE__ - 2;