File: rexp-emptyenvironment.t

package info (click to toggle)
libstatistics-r-io-perl 1.0002-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 5,824 kB
  • sloc: perl: 10,895; makefile: 2
file content (43 lines) | stat: -rw-r--r-- 1,372 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!perl -T
use 5.010;
use strict;
use warnings FATAL => 'all';

use Test::More tests => 12;
use Test::Fatal;

use Statistics::R::REXP::EmptyEnvironment;

my $env = new_ok('Statistics::R::REXP::EmptyEnvironment', [], 'new EmptyEnv');

is($env, $env, 'self equality');

my $env_2 = Statistics::R::REXP::EmptyEnvironment->new;
is($env, $env_2, 'null equality');
isnt($env, 'null', 'null inequality');

## cannot set enclosure or attributes on the empty environment
like(exception {
         Statistics::R::REXP::EmptyEnvironment->new(frame => { })
     }, qr/Nothing can be assigned to the empty environment/, 'setting empty env contents');
like(exception {
         Statistics::R::REXP::EmptyEnvironment->new(enclosure => $env_2)
     }, qr/Empty environment has no enclosure/, 'setting empty env enclosure');
like(exception {
         Statistics::R::REXP::EmptyEnvironment->new(attributes => { foo => 'bar', x => 42 })
     }, qr/Empty environment has no attributes/, 'setting empty env attributes');

ok(!$env->is_null, 'is not null');
ok(!$env->is_vector, 'is not vector');

is($env .'',
   'environment R_EmptyEnv', 'text representation');

## attributes
is_deeply($env->attributes, undef, 'default attributes');

## Perl representation
like(exception {
         $env->to_pl
     }, qr/Environments do not have a native Perl representation/,
     'Perl representation');