]> git.vpit.fr Git - perl/modules/Scope-Context.git/blob - t/14-cmp.t
Initial commit
[perl/modules/Scope-Context.git] / t / 14-cmp.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 5;
7
8 use Scope::Context;
9
10 {
11  my $sc = Scope::Context->new;
12  {
13   my $block = Scope::Context->new;
14   my $up = $block->up;
15   cmp_ok $up,    '==', $sc, '$up == $sc';
16   cmp_ok $block, '!=', $sc, '$block != $sc';
17  }
18 }
19
20 {
21  my @scs;
22  for (1, 2) {
23   push @scs, Scope::Context->new;
24  }
25  cmp_ok $scs[0], '!=', $scs[1], 'different iterations, different contextes';
26 }
27
28 {
29  my $here = Scope::Context->new;
30  my $dummy = bless [], 'Scope::Context::Test::DummyClass';
31  for my $rhs ($here->cxt, $dummy) {
32   local $@;
33   eval { my $res = $here == $rhs };
34   my $line = __LINE__-1;
35   like $@, qr/^Cannot compare a Scope::Context object with something else at \Q$0\E line $line/, "Scope::Context == overload does not compare with $rhs";
36  }
37 }