add some extra commit ids to the overload/tie fixes
[p5sagit/p5-mst-13.2.git] / dist / base / t / compile-time.t
CommitLineData
d19d8ad3 1#!/usr/bin/perl -w
2
3use strict;
4use Test::More tests => 3;
5
6my $Has_PH = $] < 5.009;
7my $Field = $Has_PH ? "pseudo-hash field" : "class field";
8
9{
10 package Parent;
11 use fields qw(this that);
12 sub new { fields::new(shift) }
13}
14
15{
16 package Child;
17 use base qw(Parent);
18}
19
20my Child $obj = Child->new;
21
22eval q(return; my Child $obj3 = $obj; $obj3->{notthere} = "");
23like $@,
24 qr/^No such .*field "notthere" in variable \$obj3 of type Child/,
25 "Compile failure of undeclared fields (helem)";
26
27# Slices
28# We should get compile time failures field name typos
29SKIP: {
30 skip("Pseudo-hashes do not support compile-time slice checks", 2)
31 if $Has_PH;
32
33 eval q(return; my Child $obj3 = $obj; my $k; @$obj3{$k,'notthere'} = ());
34 like $@,
35 qr/^No such .*field "notthere" in variable \$obj3 of type Child/,
36 "Compile failure of undeclared fields (hslice)";
37
38 eval q(return; my Child $obj3 = $obj; my $k; @{$obj3}{$k,'notthere'} = ());
39 like
40 $@, qr/^No such .*field "notthere" in variable \$obj3 of type Child/,
41 "Compile failure of undeclared fields (hslice (block form))";
42}