Permalink
Browse files

[t/spec] Fudge state.t for forthcoming Rakudo commit; we can pass hal…

…f of it (of the missing ten tests, six we can't do yet due to other missing features, four a probably bugs in the first cut of state).

git-svn-id: http://svn.pugscode.org/pugs@25865 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
1 parent a29ae0f commit a2694178fcc80b2a6304c3eeae5d9f849e22fca6 jnthn committed Mar 17, 2009
Showing with 18 additions and 13 deletions.
  1. +18 −13 S04-declarations/state.t
@@ -52,6 +52,7 @@ plan 20;
# state will first {...}
#?pugs eval "parse error"
+#?rakudo todo 'will first { ... }'
{
my ($a, $b);
my $gen = {
@@ -66,6 +67,7 @@ plan 20;
}
# Return of a reference to a state() var
+#?rakudo skip 'references'
{
my $gen = {
state $svar = 42;
@@ -83,6 +85,7 @@ plan 20;
# Anonymous state vars
# L<http://groups.google.de/group/perl.perl6.language/msg/07aefb88f5fc8429>
#?pugs todo 'anonymous state vars'
+#?rakudo skip 'references and anonymous state vars'
{
# XXX -- currently this is parsed as \&state()
my $gen = eval '{ try { \state } }';
@@ -112,6 +115,7 @@ plan 20;
}
# state() inside regular expressions
+#?rakudo skip 'embedded closures in regexen'
{
my $str = "abc";
@@ -130,14 +134,13 @@ plan 20;
}
# state() inside subs, chained declaration
+#?rakudo skip 'state bug'
{
sub step () {
state $svar = state $svar2 = 42;
- try {
- $svar++;
- $svar2--;
- return (+$svar, +$svar2);
- }
+ $svar++;
+ $svar2--;
+ return (+$svar, +$svar2);
};
is(step().perl, "(43, 41)", "chained state (#1)");
@@ -158,24 +161,26 @@ plan 20;
}
# recursive state with list assignment initialization happens only first time
+#?rakudo skip 'recurses infinitely'
{
my $seensize;
- my sub fib (UInt $n) {
- state @seen = 0,1,1;
- $seensize = +@seen;
- @seen[$n] //= fib($n-1) + fib($n-2);
+ my sub fib (Int $n) {
+ state @seen = 0,1,1;
+ $seensize = +@seen;
+ @seen[$n] //= fib($n-1) + fib($n-2);
}
is fib(10), 55, "fib 1 works";
is $seensize, 11, "list assignment state in fib memoizes";
}
# recursive state with [list] assignment initialization happens only first time
+#?rakudo skip '@$foo syntax'
{
my $seensize;
- my sub fib (UInt $n) {
- state $seen = [0,1,1];
- $seensize = +@$seen;
- $seen[$n] //= fib($n-1) + fib($n-2);
+ my sub fib (Int $n) {
+ state $seen = [0,1,1];
+ $seensize = +@$seen;
+ $seen[$n] //= fib($n-1) + fib($n-2);
}
is fib(10), 55, "fib 2 works";
is $seensize, 11, "[list] assignment state in fib memoizes";

0 comments on commit a269417

Please sign in to comment.