Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

basic tests for sigilless params

  • Loading branch information...
commit 12f1b31878b6dd1702a3c7e2afbdb79f2adfffb1 1 parent 73f0563
Moritz Lenz authored August 19, 2012
46  S06-signature/sigilless.t
... ...
@@ -0,0 +1,46 @@
  1
+use v6;
  2
+use Test;
  3
+
  4
+plan 10;
  5
+
  6
+# test \term
  7
+{
  8
+    sub identity(\x) { x }
  9
+
  10
+    sub count(\x) {
  11
+        my $c = 0;
  12
+        ++$c for x;
  13
+        $c
  14
+    }
  15
+
  16
+    sub swap(\x, \y) {
  17
+        my $z = y;
  18
+        y = x;
  19
+        x = $z;
  20
+    }
  21
+
  22
+    is identity('foo'), 'foo',
  23
+       'basic passing of an argument to backslashed identifier';
  24
+    is count((1, 2, 3)), 3, 'passing of flattening arguments ';
  25
+    is count([1, 2, 3]), 1, 'passing of non-flatteing arguments';
  26
+
  27
+    my $a = 5;
  28
+    my $b = 3;
  29
+    lives_ok { eval 'swap($a, $b)' }, 'backslash does not make read-only';
  30
+    is "$a|$b", '3|5', 'swapping worked';
  31
+    dies_ok { eval 'swap(42, $a)' }, 'no additional writable containers involved';
  32
+}
  33
+
  34
+# test |term
  35
+{
  36
+    sub pass-on(&c, |args) { c(|args) }
  37
+    sub join-em(|args)     { args.list.join('|') }
  38
+
  39
+    is pass-on(-> $a, $b { $a + $b }, 2, 3),  5,        '|args sanity (1)';
  40
+    is join-em('foo', 42),                    'foo|42', '|args sanity (2)';
  41
+    is join-em(pass-on(-> $a, $b { $a + $b }, 2, 3), 42),
  42
+       '5|42', 'combined sanity';
  43
+
  44
+    is pass-on({ $:l~ $:w }, :w<6>, :l<p>), 'p6', 'named arguments';
  45
+
  46
+}
13  S32-exceptions/misc.t
@@ -9,7 +9,8 @@ throws_like 'pack("B",  1)',       X::Buf::Pack, directive => 'B';
9 9
 throws_like 'Buf.new.unpack("B")', X::Buf::Pack, directive => 'B';
10 10
 throws_like 'pack "A1", "mÄ"',     X::Buf::Pack::NonASCII, char => 'Ä';
11 11
 throws_like 'my class Foo { method a() { $!bar } }', X::Attribute::Undeclared,
12  
-            name => '$!bar', package-name => 'Foo';
  12
+            symbol => '$!bar', package-name => 'Foo', package-kind => 'class',
  13
+            what => 'attribute';
13 14
 throws_like 'sub f() { $^x }', X::Signature::Placeholder,
14 15
             line => 1;
15 16
 
@@ -27,8 +28,8 @@ throws_like '@_',            X::Placeholder::Mainline, placeholder => '@_';
27 28
 throws_like '"foo".{ say $^a }', X::Placeholder::Mainline;
28 29
 
29 30
 
30  
-throws_like 'sub f(*@a = 2) { }', X::Parameter::Default, how => 'slurpy';
31  
-throws_like 'sub f($x! = 3) { }', X::Parameter::Default, how => 'required';
  31
+throws_like 'sub f(*@ = 2) { }', X::Parameter::Default, how => 'slurpy', parameter => *.not;
  32
+throws_like 'sub f($x! = 3) { }', X::Parameter::Default, how => 'required', parameter => '$x';
32 33
 throws_like 'sub f(:$x! = 3) { }', X::Parameter::Default, how => 'required';
33 34
 throws_like 'sub f($:x) { }',  X::Parameter::Placeholder,
34 35
         parameter => '$:x',
@@ -138,7 +139,7 @@ throws_like '$.a', X::Syntax::NoSelf, variable => '$.a';
138 139
 throws_like 'my class B0Rk { $.a }',  X::Syntax::NoSelf, variable => '$.a';
139 140
 
140 141
 throws_like 'has $.x', X::Attribute::NoPackage;
141  
-throws_like 'my module A { has $.x }', X::Attribute::Package, package-type => 'module';
  142
+throws_like 'my module A { has $.x }', X::Attribute::Package, package-kind => 'module';
142 143
 
143 144
 throws_like 'has sub a() { }', X::Declaration::Scope, scope => 'has', declaration => 'sub';
144 145
 throws_like 'has package a { }', X::Declaration::Scope, scope => 'has', declaration => 'package';
@@ -146,9 +147,9 @@ throws_like 'our multi a() { }', X::Declaration::Scope::Multi, scope => 'our';
146 147
 throws_like 'multi sub () { }', X::Anon::Multi, multiness => 'multi';
147 148
 throws_like 'proto sub () { }', X::Anon::Multi, multiness => 'proto';
148 149
 throws_like 'class { multi method () { }}', X::Anon::Multi, routine-type => 'method';
149  
-throws_like 'use MONKEY_TYPING; augment class { }', X::Anon::Augment, package-type => 'class';
  150
+throws_like 'use MONKEY_TYPING; augment class { }', X::Anon::Augment, package-kind => 'class';
150 151
 throws_like 'use MONKEY_TYPING; augment class NoSuchClass { }', X::Augment::NoSuchType,
151  
-    package-type => 'class',
  152
+    package-kind => 'class',
152 153
     package => 'NoSuchClass';
153 154
 throws_like 'use MONKEY_TYPING; augment class No::Such::Class { }', X::Augment::NoSuchType,
154 155
     package => 'No::Such::Class';

0 notes on commit 12f1b31

Please sign in to comment.
Something went wrong with that request. Please try again.