Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 50 lines (38 sloc) 1.141 kb
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 44 45 46 47 48 49
use v6;
use Test;

plan 8;

# +---- UTF8 non-breaking space here!
# |
# V
# L<S03/Changes to Perl 5 operators/list assignment operator now parses on the right>


# very simple assignment

{
    my $foo = 'FOO';
    is $foo, 'FOO', 'Can assign string to scalar 1';
    my $bar = 'BAR';
    is $foo, 'FOO', 'Can assign string to scalar 2';

    $foo = $bar;
    is $foo, 'BAR', 'Can assign scalar to scalar';

    $foo = 'FOO';
    is $bar, 'BAR', "Assignment didn't create a binding";
}

# test that assignment from arrays to scalars doesn't create a binding:

{
    my @array = 23, 42;
    is @array[0], 23, 'Could assign first element';
    is @array[1], 42, 'Could assign second element';
    my $temp = @array[0];
    is $temp, 23, 'Could retrieve first element to a scalar';
    #rakudo skip 'Broken in ng1'
    # {
    # @array[0] = @array[1];
    # is $temp, 23, "Assignment to scalar didn't create a binding"
    # }
}

{
    my $a = 42;
    my @list = ($a);
    $a = 24;
    is @list[0], 42, "Assignment to scalar didn't create a binding";
}

# vim: ft=perl6
Something went wrong with that request. Please try again.