Data-Path-XS

 view release on metacpan or  search on metacpan

t/lvalue.t  view on Meta::CPAN

use strict;
use warnings;
use Test::More;
use Data::Path::XS qw(path_get path_set patha_get pathc_get path_compile);
use Data::Path::XS ':keywords';

# path_get / patha_get / pathc_get / pathget all return rvalues.
# Trying to use them as lvalues must fail at compile time, and assigning
# to a returned ref must NOT silently cascade into the original structure.

subtest 'path_get is not lvalue' => sub {
    eval q{ my $d = { x => 1 }; path_get($d, '/x') = 99 };
    ok($@, 'path_get(...) = ... is rejected') or diag "no error";
    like($@, qr/lvalue|modify|read.?only|left side/i,
         'compile-time rejection mentions lvalue/readonly')
        or diag "got: $@";
};

subtest 'pathget keyword is not lvalue' => sub {



( run in 2.088 seconds using v1.01-cache-2.11-cpan-9581c071862 )