Skip to content

Commit

Permalink
Test attribute binding.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed May 12, 2012
1 parent 4924891 commit ef0edcb
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion t/qast/qast.t
@@ -1,6 +1,6 @@
use QRegex;

plan(41);
plan(45);

# Following a test infrastructure.
sub compile_qast($qast) {
Expand Down Expand Up @@ -35,6 +35,7 @@ class A { method m() { 'a' } }
class B { method m() { 'b' } }
class C { method add($a, $b) { $a + $b } }
class D { method m() { 206 } }
class E { has int $!x; }

is_qast(
QAST::Block.new(
Expand Down Expand Up @@ -572,3 +573,28 @@ is_qast(
),
'a',
'lexical binding in a nested block');

test_qast_result(
QAST::Block.new(
QAST::Op.new(
:op('bind'),
QAST::Var.new( :name('foo'), :scope('local'), :decl('var') ),
QAST::Op.new(
:op('create'),
QAST::WVal.new( :value(E) )
)
),
QAST::Op.new(
:op('bind'),
QAST::Var.new(
:scope('attribute'), :name('$!x'), :returns(int),
QAST::Var.new( :name('foo'), :scope('local') ),
QAST::WVal.new( :value(E) )
),
QAST::IVal.new( :value(99) )
),
QAST::Var.new( :name('foo'), :scope('local') )
),
-> $r {
ok(nqp::getattr_i($r, E, '$!x') == 99, 'attribute binding works');
});

0 comments on commit ef0edcb

Please sign in to comment.