1#!./parrot
2# Copyright (C) 2007-2014, Parrot Foundation.
3
4=head1 NAME
5
6t/pmc/object.t - test the Object PMC
7
8=head1 SYNOPSIS
9
10    % prove t/pmc/object.t
11
12=head1 DESCRIPTION
13
14Tests the Object PMC.
15
16=cut
17
18# L<PDD15/Object PMC API>
19## TODO add more tests as this is documented and implemented
20
21.sub main :main
22    .include 'test_more.pir'
23
24    plan(4)
25
26    test_new()
27    test_isa()
28    test_subclass_object()
29.end
30
31.sub test_new
32    throws_substring(<<'CODE', 'Object must be created by a class', 'new Object fails')
33    .sub main
34        new $P0, ['Object']
35    .end
36CODE
37    throws_substring(<<'CODE', 'Object must be created by a class', 'new(pmc) Object fails')
38    .sub main
39        new $P0, ['String']
40        new $P1, ['Object'], $P0
41    .end
42CODE
43.end
44
45.sub test_isa
46    $P0 = new ['String']
47    null $P1
48    $I0 = isa $P0, $P1
49    is($I0, 0, 'isa null pmc')
50.end
51
52.sub test_subclass_object
53    $P0 = subclass "Object", "Foo"
54    push_eh error
55    $P1 = new $P0
56    ok(1, 'subclass from Object')
57    .return()
58
59  error:
60    # Object must be created by a class
61    todo(0, 'subclass from Object', 'GH #1010 allow normal Object instantiaton')
62    pop_eh
63.end
64
65# Local Variables:
66#   mode: pir
67#   fill-column: 100
68# End:
69# vim: expandtab shiftwidth=4 ft=pir:
70