use Test;
use lib <t/packages/Test-Helpers>;
use Test::Helpers;

plan 106;

# t/spec/S03-sequence/misc.t
# https://github.com/rakudo/rakudo/issues/5520
{
    my @result;
    Q| @result.push($_) for 1...5...3 |.AST.EVAL;
    is-deeply @result, [1, 2, 3, 4, 5, 4, 3], ".say works with chained sequence and for";
}

# ???
# https://github.com/rakudo/rakudo/issues/5546
{
    is-run 'Q| use trace; my %a{Str} |.AST.EVAL', :err("2 (EVAL_0 line 1)\nmy \%a\{Str} \n"),
        "trace pragma works with hash shapes";
}

# t/spec/S04-phasers/in-loop.t
# https://github.com/rakudo/rakudo/issues/5517
{
    my @a;
    Q| for () { FIRST @a.push: 'first'; ENTER @a.push: 'enter'; NEXT @a.push: 'next'; LEAVE @a.push: 'leave'; LAST @a.push: 'last'; } |.AST.EVAL;
    is-deeply @a, [], "phasers do not fire for loop that did not run";
}

# t/spec/S05-match/basics.t
# https://github.com/rakudo/rakudo/issues/5454
{
    is Q| $_="0X"; m/\d/ ~ m/X/ |.AST.EVAL, "0X", "multiple m// works correctly";
}

# t/spec/S09-hashes/objecthash.t
# https://github.com/rakudo/rakudo/issues/5419
{
    is Q| my %h{Int}; %h.of |.AST.EVAL, Mu, "creating an object hash without specifying an 'of type' defaults to Mu";
}

# t/spec/S06-currying/misc.t (?)
# https://github.com/rakudo/rakudo/issues/5116
{
    nok Q| my &a = *.uc; my &b = *.lc; &a eqv &b |.AST.EVAL, "*.uc and *.lc are not considered equivalent";
    ok  Q| my &a = *.uc; my &b = *.uc; &a eqv &b |.AST.EVAL, "*.uc and *.uc are considered equivalent";
    nok Q| my &a = *.uc ~ *.lc ~ (*.uc ~ *.lc); my &b = *.lc ~ *.lc ~ (*.lc ~ *.lc); &a eqv &b |.AST.EVAL,
        "equivalence is still correct for more complicated WhateverCodes";
}

# ???
# https://github.com/rakudo/rakudo/issues/2360
# XXX: LIKELY DUE TO MISSING OPTIMIZATIONS
{
    lives-ok { Q| use nqp; my %*FOO is Set = <a b c> |.AST.EVAL }, "the :initialize flag is not sent to Set.STORE";
}

# t/spec/S04-blocks-and-statements/pointy.t
# https://github.com/rakudo/rakudo/issues/2295
{
    is Q| .WHAT given -> --> Int:D {} |.AST.EVAL, Block but Callable[Int:D],
        "Pointy blocks are parameterized with return types";

    ok Q| my Int:D &foo = -> --> Int:D {}; &foo.signature |.AST.EVAL ~~ :( --> Int:D),
        "Pointy blocks can be assigned to a parameterized Callable container";
}

# t/spec/S04-declarations/constant.t
# https://github.com/rakudo/rakudo/issues/1587
{
    dies-ok { Q| my Int constant .= new: 42 |.AST.EVAL }, "creating a constant without a name dies";
}

# t/spec/S06-advanced/wrap.t
# https://github.com/rakudo/rakudo/issues/1561
# XXX: Almost certainly just due to lack of optimizations
{
    my @result;
    {
        my $handle;
        Q§ $handle = &infix:<|>.wrap: -> | { @result.push("ok"); True }; -> $ where {$_ ~~ Int|Num} {}(42) §.AST.EVAL;
        is-deeply @result, ["ok"], "wrapping infix:<|> works";
        Q§ &infix:<|>.unwrap($handle) §.AST.EVAL;
    }

    @result = [];
    {
        my $handle;
        Q§ $handle = &postfix:<++>.wrap: -> | { @result.push("ok2") }; my int $x; $x++ §.AST.EVAL;
        is-deeply @result, ["ok2"], "wrapping postfix:<++> works";
        Q§ &postfix:<++>.unwrap($handle) §.AST.EVAL;
    }
}

# ???
# https://github.com/rakudo/rakudo/issues/1532
{
    my @result;
    Q| my $foo = "bar"; my %bar = :42foo, :70bar; @result = [:%::($foo)] |.AST.EVAL;
    is-deeply @result, ["::(\$foo)" => {:bar(70), :foo(42)}],
        "Colonpairs with indirect-lookup as variables work";

    Q| my $foo = "bar"; my %bar = :42foo, :70bar; @result = [$foo => %::($foo)] |.AST.EVAL;
    is-deeply @result, [:bar({:bar(70), :foo(42)})],
        "Colonpairs with indirect-lookup as variables work (complex)"
}

# ???
# https://github.com/rakudo/rakudo/issues/1516
{
    lives-ok { Q| { my grammar A { token x(&a) { <.&a> } } } |.AST.EVAL }, "no error messages from code params to regexes (<.&a>)";
    lives-ok { Q| { my grammar A { token x(&a) {  <&a> } } } |.AST.EVAL }, "no error messages from code params to regexes (<&a>)";
}

# ???
# https://github.com/rakudo/rakudo/issues/1463
{
    lives-ok { Q| eager (1..10) |.AST.EVAL }, "eager on parenthesized range works without issue";
}

# t/spec/S12-introspection/definite.t (?)
# https://github.com/rakudo/rakudo/issues/1412
{
    dies-ok  { Q| my Positional:D[Int] $x := ("x", "b") |.AST.EVAL }, "Parametarization with DefiniteHOWs is not ignored in binding";
    is-deeply Q| my Positional:D[Int] $x := Array[Int].new(1, 2) |.AST.EVAL, Array[Int].new(1, 2),
        "Parametarization with DefiniteHOWs works where it should";

    ok Q| my Positional:D[Int] $x; $x.WHAT === Positional:D[Int] |.AST.EVAL,
        "Parameterization with DefiniteHOWs is propagated to scalar container";
}

# t/spec/S03-operators/adverbial-modifiers.t
# https://github.com/rakudo/rakudo/issues/1378
{
    throws-like { Q| my %h = :1k; say 1 ~ %h<k>:exists ~ 1 |.AST.EVAL }, X::Syntax::AmbiguousAdverb, "Ambiguous adverb usage results in coherent exception";
}

# t/spec/S32-array/multislice-6e.t (?)
# https://github.com/rakudo/rakudo/issues/1297
{
    is Q| my @matrix[2;2]; @matrix["0"; "0"] = 42 |.AST.EVAL, 42, "String indices work where valid in multi-dimensional array access";
}

# t/spec/S02-types/signed-unsigned-native.t (?)
# <no open issue>
{
    is Q| sub a(uint $a) { $a }; a -1 |.AST.EVAL, (my uint $a = -1), "unsigned native parameters wrap around when provided with negative numbers";
}

# t/spec/S03-metaops/???
# https://github.com/rakudo/rakudo/issues/4424
{
    is-run 'Q| [[&say]] "hello ", "world" |.AST.EVAL', :out("hello world\n"),
        "No useless use of sink reporting for [[&say]]";
    is-run 'Q| "hello" R[&say] "world " |.AST.EVAL', :out("world hello\n"),
        "No useless use of sink reporting for R[&say]";
    is-run 'Q| sub equal($a, $b) { $a eqv $b };  say "hello" [&equal] "world" |.AST.EVAL', :out("False\n"),
        "No useless use of sink reporting for user-declared function";
}

# t/spec/S19-command-line/arguments.t
# https://github.com/rakudo/rakudo/issues/1915
{
    (temp %*ENV)<RAKUDO_RAKUAST> = 1;

    is-run :in("one\ntwo\nthree"), :compiler-args(['-n']),
            'state @a; @a.push: $_; @a.elems.say; note @a.join("|")', :out("1\n2\n3\n"), :err("one\none|two\none|two|three\n"),
            "'-n' compiler option iterates once per newline of input";
    is-run :in("one\ntwo\nthree"), :compiler-args(['-p']),
            '$_ .= tc ~= .uc', :out("OneONE\nTwoTWO\nThreeTHREE\n"),
            "'-p' compiler option iterates once per newline of input and the topic is writeable";
    is-run :in("one\ntwo\nthree"), :compiler-args(['-n']),
            'say "{$_}"', :out("one\ntwo\nthree\n"),
            "topic variable is successfully lowered while using '-n'";
}

# t/spec/S06-currying/misc.t
# https://github.com/rakudo/rakudo/issues/5004
{
    lives-ok { Q| sub problems($x) { (1 .. 100).roll(1) andthen .map(* + 2) andthen .grep(* %% $x) }; problems(16) |.AST.EVAL },
        "andthen chaining does not disrupt WhateverCode construction";
}

# t/02-rakudo/repl.t
# https://github.com/rakudo/rakudo/issues/1690
{
    (temp %*ENV)<RAKUDO_RAKUAST> = 1;

    my $eof = $*DISTRO.is-win ?? "'^Z'" !! "'^D'";
    my $*REPL-SCRUBBER = -> $_ is copy {
        .lines
            .skip(4)
            .join("\n")
            .subst( /^^ "You may want to `zef install Readline`, `zef install Linenoise`,"
        " or `zef install Terminal::LineEditor`"
        " or use rlwrap for a line editor\n\n"/)
            .subst( /^^ "To exit type 'exit' or $eof\n"/ )
            .subst( /^^ '[' \d+ '] > '  /, :global)  # Strip out the prompts
            .subst( /^^ "* "+ /,           :global)  # Strip out the continuation-prompts
            .subst( /    ">" $ /,          :global)  # Strip out the final prompt
    }

    is-run-repl "use lib <t/packages/12-rakuast/lib>;\nuse Depth::One;\nuse Depth;\nDepth.new\n",
        :out("Nil\nNil\nNil\nDepth.new\n"),
        "repl can successfully use and instantiate a class ('Depth') that is shadowed and surpassed by an earlier used class ('Depth::One')";
}

# ??? (useless useless use removed)
# https://github.com/rakudo/rakudo/issues/1525
{
    is-run 'Q|subset Char of Str where (*.chars == 1)|.AST.EVAL', :out(''), :err(''),
        "no worry of a useless 'useless use' for parenthesized prime expression in where clause";
}

# ???
# https://github.com/rakudo/rakudo/issues/4925
{
    lives-ok { Q|class A { class A::B { ... }; class A::B { has $.c } }|.AST.EVAL },
        "stubbed classes that belong to parent package cause no issues when stubbed and defined within parent package scope";
}

# https://irclogs.raku.org/raku/2024-07-12.html#12:20
{
    my @a;
    lives-ok { Q|for <a b c> { @a.push($_) with "{.succ}"; }|.AST.EVAL },
        "using the topic inside a 'with' and an embedded code block in a qq string";
    is-deeply @a, [<b c d>], 'did the code do the right thing';
}

# https://github.com/rakudo/rakudo/issues/5649
{
    todo "compilation error in legacy grammar" unless %*ENV<RAKUDO_RAKUAST>;
    is (try 'our Str $a = "foo"'.EVAL), "foo", 'can have constraint on "our" variable';
}

# https://github.com/rakudo/rakudo/issues/1898
{
    my @m = [1,2,3],[2,6,10],[3,12,21];
    for @m -> @r {
        my $div = @r[0];
        @r X/= $div;
    }
    todo "handling of X/= when sunk" unless %*ENV<RAKUDO_RAKUAST>;
    is-deeply @m, [[1.0, 2.0, 3.0], [1.0, 3.0, 5.0], [1.0, 4.0, 7.0]],
      'handled X/= correctly';
}

# https://github.com/rakudo/rakudo/issues/1947
{
    my $ran;
    my sub a (IO(Cool:D) $) { $ran = True };
    a "foo".IO;
    ok $ran, 'dispatch went correctly';
}

# https://github.com/rakudo/rakudo/issues/1986
{
    my $a;
    try Q/42 R[||]= $a/.EVAL;
    todo "R[||]= doesn't compile" unless %*ENV<RAKUDO_RAKUAST>;
    is $a, 42, 'did R[||]= work';

    my $b;
    try Q/666 R[&&]= $b/.EVAL;
    todo "R[&&]= doesn't compile" unless %*ENV<RAKUDO_RAKUAST>;
    is $b, 666, 'did R[&&]= work';

    my $c;
    try Q|137 R[//]= $c|.EVAL;
    todo "R[//]= doesn't compile" unless %*ENV<RAKUDO_RAKUAST>;
    is $c, 137, 'did R[//]= work';
}

# https://github.com/rakudo/rakudo/issues/2034
{
    todo "signature smartmatch doesn't compile" unless %*ENV<RAKUDO_RAKUAST>;
    is-deeply (try ":(<a>) ~~ :()".EVAL), False, 'signature smartmatch ok';
}

# https://github.com/rakudo/rakudo/issues/2152
{
    my $code := Q:to/CODE/;
my class A { has %.h = (a => 1) }
my class B is A {
    submethod BUILD () { %.h = (b => 1) }
}
B.new
CODE

    todo "doesn't compile" unless %*ENV<RAKUDO_RAKUAST>;
    my $B = try $code.EVAL;
    is-deeply ($B && $B.h<b>), 1, 'did the object get built';
}

# https://github.com/rakudo/rakudo/issues/2360
{
    try my %*FOO is Set = <a b c>;
    todo "dies" unless %*ENV<RAKUDO_RAKUAST>;
    is-deeply %*FOO, <a b c>.Set, 'is Set on dynvar works';
}

# https://github.com/rakudo/rakudo/issues/2362
subtest 'use of &?ROUTINE and &?BLOCK' => {
    my @r;
    my @b;
    my @subs =
      sub for-sub {
          for 1 {
              @r.push: &?ROUTINE; @b.push: &?BLOCK;
          }
      },
      sub do-sub {
          do {
              @r.push: &?ROUTINE; @b.push: &?BLOCK;
          }
      },
      sub given-sub {
          given Nil {
              @r.push: &?ROUTINE; @b.push: &?BLOCK;
          }
      },
      sub if-sub {
          if True {
              @r.push: &?ROUTINE; @b.push: &?BLOCK;
          }
      },
      sub when-sub {
          when ?True {
              @r.push: &?ROUTINE; @b.push: &?BLOCK;
          }
      },
      sub loop-sub {
          loop {
              @r.push: &?ROUTINE; @b.push: &?BLOCK; last;
          }
      },
      sub while-sub {
          while True {
              @r.push: &?ROUTINE; @b.push: &?BLOCK; last;
          }
      }
    ;

    plan 2 * @subs;
    for @subs.kv -> $i, &code {
        is-deeply &code, @subs[$i], "sub @subs[$i].name() is ok";
        nok &code =:= @b[$i]<>, "block inside @subs[$i].name() is different";
    }
}

# https://github.com/rakudo/rakudo/issues/2541
{
    my int8  $a = 127;
    my int16 $b = 32767;

    todo "incorrect value for int8" unless %*ENV<RAKUDO_RAKUAST>;
    is $a++, 127, 'did post increment int8 return correct value';
    is $a,  -128, 'did int8 get correct value';

    todo "incorrect value for int16" unless %*ENV<RAKUDO_RAKUAST>;
    is $b++, 32767, 'did post increment int16 return correct value';
    is $b,  -32768, 'did int16 get correct value';
}

# https://github.com/rakudo/rakudo/issues/2581
{
    my role A { has Int $.a }
    my class B does A {
        method b(\a) {
           $!a := a
        }
    }
    my $b = B.new;
    todo "dies", 2 unless %*ENV<RAKUDO_RAKUAST>;
    is (try $b.b(42)), 42, 'is the value being bound returned';
    is $b.a, 42, 'did the value get bound';
}

# https://github.com/rakudo/rakudo/issues/2619
{
    my $ran;
    multi trait_mod:<is>(Attribute $attr, :&bla!) {
        $ran = True;
    }
    try Q|role :: { has $.a is bla{;} }|.EVAL;
    todo "dies", 2 unless %*ENV<RAKUDO_RAKUAST>;
    is-deeply $ran, True, 'did the trait get run';
}

# https://github.com/rakudo/rakudo/issues/2836
{
    my $i = 0;
    my $last;
    my sub runner { loop { last if $i == 7; $i++; LAST $last = True } }
    runner if  %*ENV<RAKUDO_RAKUAST>;  # uncatchable crash
    todo "dies", 2 unless %*ENV<RAKUDO_RAKUAST>;
    is $i, 7, 'loop completed successfully';
    is-deeply $last, True, 'did LAST run';
}

# https://github.com/rakudo/rakudo/issues/2996
{
    my $fired;
    try '$fired = True if !! 42'.EVAL;
    todo "dies" unless %*ENV<RAKUDO_RAKUAST>;
    is-deeply $fired, True, 'was the syntax valid and did it fire';
}

# https://github.com/rakudo/rakudo/issues/3220
{
    my sub foo {
        %( foobar => { &?ROUTINE.name => "bar" } )
    }
    todo "name is missing" unless %*ENV<RAKUDO_RAKUAST>;
    is-deeply foo(), { foobar => {foo => "bar"} },
      'Routine name properly codegenned';
}

# https://github.com/rakudo/rakudo/issues/3574
{
    my @a = (state $ = rand) xx 5;
    todo "returned value is Any" unless %*ENV<RAKUDO_RAKUAST>;
    ok @a[0], 'got a random value with state';
    is-deeply ([==] @a), True, 'all values the same with state';

    @a = (once rand) xx 5;
    todo "returned value is VMNull", 2 unless %*ENV<RAKUDO_RAKUAST>;
    ok @a[0], 'got a random value with once';
    is-deeply (try [==] @a), True, 'all values the same with once';
}

# https://github.com/rakudo/rakudo/issues/3626
{
    my $defined;
    my sub foo () {
        loop {
            state $n = 0;
            $n++;
            last if $n > 2;
            LAST { $defined = $n.defined }
        }
    }
    foo;
    todo "state variable appears undefined" unless %*ENV<RAKUDO_RAKUAST>;
    is-deeply $defined, True, 'LAST can see the state variable';
}

# https://github.com/rakudo/rakudo/issues/3786
{
    todo "doesn't compile" unless %*ENV<RAKUDO_RAKUAST>;
    is-deeply
      (try 'my class C { has $.sig = :(); }; C.new.sig'.EVAL),
      :(), 'can have a signature as a default for an attribute';
}

# https://github.com/rakudo/rakudo/commit/fa370cb8e2
{
    use nqp;
    my sub a(\a --> uint) is raw {
        my uint $ = nqp::bitand_I(a, 0xffffffffffffffff, Int)
    }
    my sub b(\b --> uint64) is raw {
        my uint64 $ = nqp::bitand_I(b, 0xffffffffffffffff, Int)
    }
    todo "becomes signed", 2 unless %*ENV<RAKUDO_RAKUAST>;
    is a(18446744073709551615), 18446744073709551615, 'uint ok';
    is b(18446744073709551615), 18446744073709551615, 'uint64 ok';
}

# https://github.com/rakudo/rakudo/issues/3935
{
    my int $handled;
    try EVAL '{
        die("oops");
        CATCH {
            default {
                $handled++
           }
        }
    }';
    todo "doesn't compile" unless %*ENV<RAKUDO_RAKUAST>;
    is $handled, 1, 'did the code run and handle the exception';
}

# https://github.com/rakudo/rakudo/issues/4062
{
    my $seen = 0;
    role Foo[|c] { $seen++ }
    Foo[42].new;
    todo "runs 0 times or 2 times" unless %*ENV<RAKUDO_RAKUAST>;
    is $seen, 1, 'role body only ran once';
}

# https://github.com/rakudo/rakudo/issues/4193
{
    my $proc = run $*EXECUTABLE, '-e',
      'for 1, 2, 3, 4, 5 -> $n { (print $n for ^5) xx 2 }', :out, :err;

    todo "optimizer stales variable" unless %*ENV<RAKUDO_RAKUAST>;
    is $proc.out.slurp, '11111111112222222222333333333344444444445555555555',
      'was the variable not stale';
    todo "worries about RHS of xx" if %*ENV<RAKUDO_RAKUAST>;
    is $proc.err.slurp, '', 'no worries';
}

# https://github.com/rakudo/rakudo/issues/4198
{
    my $rx = /\w+/;
    todo "doesn't interpolate correctly" unless %*ENV<RAKUDO_RAKUAST>;
    is ('"foo".match: / $rx /'.EVAL).gist, '｢foo｣', 'regex interpolated ok';
}

# https://github.com/rakudo/rakudo/issues/4351
{
    my $a = 42;
    for 1 .. 3 {
        todo "doesn't return correctly" unless %*ENV<RAKUDO_RAKUAST>;
        is-deeply (FIRST $a++), 42, 'Do we always get the first value';
    }
}

# https://github.com/rakudo/rakudo/issues/4493
{
    multi b(Int:D $x) { $x + 1 }
    multi b(int $x)   { $x     }
    todo "selects the wrong candidate" unless %*ENV<RAKUDO_RAKUAST>;
    is b(0), 1, 'Int:D candidate selected';

    multi d(Int:D $x) { $x     }
    multi d(int $x)   { $x + 1 }
    is d(0), 0, 'Int:D candidate selected';
}

# https://github.com/rakudo/rakudo/issues/4757
{
    my sub infix:<foo>($a, $b) is assoc<right> { "($a,$b)" }
    my sub infix:<bar>($a, $b) is assoc<left>  { "($a,$b)" }

    is-deeply ([foo]  1, 2, 3, 4), "(1,(2,(3,4)))", 'foo';
    is-deeply ([Rfoo] 1, 2, 3, 4), "(4,(3,(2,1)))", 'Rfoo';
    is-deeply ([bar]  1, 2, 3, 4), "(((1,2),3),4)", 'bar';
    todo "gets associativity wrong" unless %*ENV<RAKUDO_RAKUAST>;
    is-deeply ([Rbar] 1, 2, 3, 4), "(4,(3,(2,1)))", 'Rbar';
}

# https://github.com/rakudo/rakudo/issues/4797
{
    my int $test;
    my sub f (|c) is test-assertion {
        is-deeply c, \(:foo), ':foo test ' ~ ++$test;
    }

    f :foo(  'a'  ne 'd');
    f foo => 'a'  ne 'd';
    todo "passes positional instead of named", 2 unless %*ENV<RAKUDO_RAKUAST>;
    f :foo(  'a' !eq 'd');
    f foo => 'a' !eq 'd';
}

# https://github.com/rakudo/rakudo/issues/4847
{
    todo "does not compile" unless %*ENV<RAKUDO_RAKUAST>;
    lives-ok { 'if 42 { } elsif "/knorkator".IO andthen .f && .r { }'.EVAL },
      'can have andthen as part of an elseif';
}

# https://github.com/rakudo/rakudo/issues/4904
{
    my class C {
        method add($x) { $!x += $x }
        has int $.x
    }
    my $c = C.new;
    is-deeply $c.x, 0, 'can access attribute';
    todo "throws error" unless %*ENV<RAKUDO_RAKUAST>;
    lives-ok { $c.add(1) }, 'can add to the attribute';
    todo "did not get updated" unless %*ENV<RAKUDO_RAKUAST>;
    is-deeply $c.x, 1, 'attribute got incremented';
}

# https://github.com/rakudo/rakudo/issues/5056
{
    class Value { method COERCE() { Value } }

    multi foo(Hash:D) { "yes" };
    multi foo(Value(Any:D)) { "no" };

    todo "dispatch error" unless %*ENV<RAKUDO_RAKUAST>;
    is (try foo { :foo }), "yes", "dispatch worked ok";
}

# https://github.com/rakudo/rakudo/issues/5100
{
    my $proc := run $*EXECUTABLE, '-e', 'sub MAIN( $a, $b = $a, #= boom
) {}', :out, :err;
    is $proc.out.slurp, "", 'no output';
    todo "execution error" unless %*ENV<RAKUDO_RAKUAST>;
    ok $proc.err.slurp.starts-with("Usage"), 'error message is about usage';
}

# https://github.com/rakudo/rakudo/issues/5147
{
    todo "no val processing" unless %*ENV<RAKUDO_RAKUAST>;
    is-deeply qq:v:to/FOO/, IntStr.new(42, "42\n"), "val processing kept";
    42
    FOO
}

# https://github.com/rakudo/rakudo/issues/5329
{
    my %m = "a" => 1, "b" => 2, "c" => 3;
    my subset X2 of Str() where * (elem) %m;
    sub t2 (X2 $x) { }
    if %*ENV<RAKUDO_RAKUAST> {
        lives-ok { ("a" .. "c").hyper(:batch(1), :degree(2)).map(&t2) },
          "should not crash with typecheck error";
    }
    else {
        todo "crashes";
        flunk "should not crash with typecheck error";
    }
}

# https://github.com/rakudo/rakudo/issues/5391
{
    todo "compilation error" unless %*ENV<RAKUDO_RAKUAST>;
    lives-ok { 'use variables :D; my int $a'.EVAL },
      'native integers do not require an initializer with variables:D';
    todo "typecheck error" unless %*ENV<RAKUDO_RAKUAST>;
    lives-ok { 'use variables :D; my int $a = 42'.EVAL },
      'native integers can be initialized  with variables:D';
}

# https://github.com/rakudo/rakudo/issues/5599
{
    my enum E <one>;
    my role R {
        has $.e = one;
        method m() {
            todo "attribute not initialized" unless %*ENV<RAKUDO_RAKUAST>;
            ok $!e === one, 'attribute got initialized ok';
        }
    }
    R.new.m;
}

# https://github.com/rakudo/rakudo/issues/1616
{
    todo "does not compile" unless %*ENV<RAKUDO_RAKUAST>;
    isa-ok (try Q|&[RRRRRRRRZZZZZZZZZZZZZZZZZZRRRRRRRRRSSSSSSSS+]|.EVAL), Block,
      'auto generated Callable ok';
}

# https://github.com/rakudo/rakudo/issues/1691
{
    todo "throws execution error" unless %*ENV<RAKUDO_RAKUAST>;
    lives-ok { eager do loop { last } }, 'exits loop as expected';
}

# https://github.com/rakudo/rakudo/issues/1768
{
    my sub z { is &?ROUTINE.name, "z", 'name is ok' for ^1 }
    todo "name empty" unless %*ENV<RAKUDO_RAKUAST>;
    z;
}

# https://github.com/rakudo/rakudo/issues/1871
{
    todo "throws wrong error" unless %*ENV<RAKUDO_RAKUAST>;
    throws-like { Q|1.::(1)|.EVAL }, X::Syntax::Number::IllegalDecimal,
      "throws an illegal decimal error";
}

# https://github.com/rakudo/rakudo/issues/1965
{
    todo "throws wrong error", 2 unless %*ENV<RAKUDO_RAKUAST>;
    try throws-like { Q|role R { }; &R|.EVAL }, X::Undeclared::Symbols,
      unk_routines => { '&R' => (1,) },
      "throws undeclared error";
    try throws-like { Q|class C { }; &C|.EVAL }, X::Undeclared::Symbols,
      unk_routines => { '&C' => (1,) },
      "throws undeclared error";
}

# https://github.com/rakudo/rakudo/issues/5249
{
    todo "throws compilation error" unless %*ENV<RAKUDO_RAKUAST>;
    is-deeply (try Q|"@.x"|.EVAL), '@.x', 'interpolation of non-existing @!x';
}

# https://github.com/rakudo/rakudo/issues/5119
{
    is-deeply ("{$_}" for ^1).join, "0", 'was $_ set to 0';
}

# https://github.com/rakudo/rakudo/issues/5685
{
    todo q|throws You can't adverb &infix:<&&>|, 2 unless %*ENV<RAKUDO_RAKUAST>;
    my $answer;
    lives-ok { Q|my %a = 1 => True; $answer = True && %a<1>:exists|.EVAL },
            'adverbs to hashes do not accidentally get passed to infixes';
    ok $answer, 'adverbs to hashes with infixes work as expected';
}

# vim: expandtab shiftwidth=4
