Skip to content

Commit

Permalink
Fix %h = { a => 1 } confusion
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Jul 2, 2014
1 parent 78d2df3 commit 6620326
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion S02-lexical-conventions/minimal-whitespace.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plan 9;
my @arr = <1 2 3 4 5>;
eval_dies_ok('@arr [0]', 'array with space before opening brackets does not work');

my %hash = {a => 1, b => 2};
my %hash = a => 1, b => 2;
eval_dies_ok('%hash <a>', 'hash with space before opening brackets does not work (1)');
eval_dies_ok('%hash {"a"}', 'hash with space before opening braces does not work (2)');

Expand Down
2 changes: 1 addition & 1 deletion S02-literals/hash-interpolation.t
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ plan 10;

{
# L<S02/Arrays/In order to interpolate an entire hash>
my %hash = { b => 2 };
my %hash = b => 2;
#?niecza 2 todo 'zen hash slice'
is "%hash{}", "b\t2", 'interpolation with curly braces';
is "%hash<>", "b\t2", 'interpolation with angle brackets';
Expand Down
3 changes: 2 additions & 1 deletion S02-types/assigning-refs.t
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ plan 18;

{
my $hashref = {:a(1), :b(2), :c(3)};
my %hash = ($hashref);
my %hash;
try { %hash = ($hashref) };

#?rakudo todo 'non-flattening hash refs'
#?pugs todo 'non-flattening hash refs'
Expand Down
2 changes: 1 addition & 1 deletion S02-types/hash.t
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ lives_ok { Hash.new("a" => "b") }, 'Hash.new($pair) lives';

# Whatever/Zen slices work on hashes too
{
my %h = { a => 1, b => 2, c => 3};
my %h = a => 1, b => 2, c => 3;
#?pugs todo
is %h{*}.join('|'), %h.values.join('|'), '{*} whatever slice';
is %h{}.join('|'), %h.join('|'), '{} zen slice';
Expand Down
2 changes: 1 addition & 1 deletion S02-types/sigils-and-types.t
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ok EVAL('Capture').does(Positional), "Capture does Positional";
my %hash;
#?pugs todo 'feature'
ok %hash.does(Associative), 'uninitialized %var does Associative';
%hash = {};
%hash = a => 1;
ok %hash.does(Associative), 'value in %var does Associative';

#?niecza todo
Expand Down
4 changes: 2 additions & 2 deletions S05-metasyntax/angle-brackets.t
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ character classes), and those are referenced at the correct spot.
#?rakudo todo '<%hash> not implemented'
#?niecza skip 'Sigil % is not allowed for regex assertions'
{
my %first = {'<alpha>' => '', 'b' => '', 'c' => ''};
my %first = '<alpha>' => '', 'b' => '', 'c' => '';
ok('aeiou' ~~ /<%first>/, 'strings are treated as a subrule in <%foo>');

my %second = {rx/\.**2/ => '', rx/'.**2'/ => ''};
my %second = rx/\.**2/ => '', rx/'.**2'/ => '';
ok('abc.**2def' ~~ /<%second>/, 'Regexes are left alone in <%foo> subrule');
}

Expand Down
4 changes: 2 additions & 2 deletions S06-signature/tree-node-parameters.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ plan 20;
is($right, %top<right>, "right value is correct: $desc");
}

my %hash = {left => 'abc', right => 'def'};
my %hash = left => 'abc', right => 'def';
traverse_hash(%hash, 'basic hash');
traverse_hash({%hash, a => 0, b => 1, c => 2}, 'hash with extra values');

Expand All @@ -29,7 +29,7 @@ plan 20;
is($west, %top<west>, "west value is correct: $desc");
}

my %hash = {east => 'abc', west => 'def'};
my %hash = east => 'abc', west => 'def';
traverse_hash(%hash, 'custom hash values work');
traverse_hash({%hash, a => 0, b => 1}, 'custom hash, extra values');

Expand Down
4 changes: 2 additions & 2 deletions S12-attributes/clone.t
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ is($val2, 42, '... cloned object has proper attr value');
is_deeply $a1.array, ['a', 'b'], 'original object has its original array';
is_deeply $a2.array, ['c', 'd'], 'cloned object has the newly-provided array';

my $b1 = HshTest.new(hash=>{'a' => 'b'});
my $b2 = $b1.clone(hash=>{'c' => 'd'});
my $b1 = HshTest.new(hash=> 'a' => 'b' );
my $b2 = $b1.clone(hash=> 'c' => 'd' );
#?rakudo todo "clone currently messes up original"
is_deeply $b1.hash, {'a' => 'b'}, 'original object has its original hash';
is_deeply $b2.hash, {'c' => 'd'}, 'cloned object has the newly-provided hash';
Expand Down
6 changes: 3 additions & 3 deletions S12-attributes/instance.t
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,10 @@ is Foo7e.new.attr, 42, "default attribute value (1)";
#?niecza skip "Unable to resolve method of in class Hash"
#?pugs skip '.of'
ok $o.h.of === Int, 'hash attribute is typed';
lives_ok {$o.h = { a => 1, b => 2 } }, 'assign to typed hash attrib';
lives_ok {$o.h<c> = 3}, 'insertion into typed hash attrib';
lives_ok {$o.h = a => 1, b => 2 }, 'assign to typed hash attrib';
lives_ok {$o.h<c> = 3}, 'insertion into typed hash attrib';
#?pugs todo
lives_ok {$o.h.push: (d => 4) }, 'pushing onto typed hash attrib';
lives_ok {$o.h.push: (d => 4) }, 'pushing onto typed hash attrib';

#?pugs todo
is_deeply $o.h<a b c d>, (1, 2, 3, 4), '... all of them worked';
Expand Down
2 changes: 1 addition & 1 deletion S12-construction/construction.t
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ is Foo.new("a string").a, 'a string', "our own 'new' was called";

my $a = RT64116.CREATE;

lives_ok { $a.env = { foo => "bar" } }, 'assign to attr of .CREATEd class';
lives_ok { $a.env = foo => "bar" }, 'assign to attr of .CREATEd class';
is $a.env<foo>, 'bar', 'assignment works';
}

Expand Down
4 changes: 2 additions & 2 deletions S26-documentation/10-doc-cli.t
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Some Text
=end pod
POD
is_run :compiler-args['--doc'], $POD, {
is_run :compiler-args['--doc'], $POD, %(
out => rx/'Some Heading'/ & rx/'Some Text'/, err => '',
}, 'basic --doc sanity';
), 'basic --doc sanity';

my $POD2 = $POD ~ Q:to<CODE>;
Expand Down
4 changes: 2 additions & 2 deletions integration/advent2011-day10.t
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ my $expected-pod = rx/'A Heading!'
.*? "class Sheep" .*? "it's a sheep! really!"
.*? "method bark" .*? "produces a funny sound"/;
is_run( $main, { out => $expected-pod,
err => ''}, :compiler-args['--doc'], '--doc');
is_run( $main, %( out => $expected-pod,
err => ''), :compiler-args['--doc'], '--doc');

my $main2 = $main ~ q:to"END";
Expand Down

0 comments on commit 6620326

Please sign in to comment.