Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added tests for pos operations
  • Loading branch information
Carl Masak committed May 12, 2012
1 parent 8fc6415 commit b0705d6
Showing 1 changed file with 63 additions and 1 deletion.
64 changes: 63 additions & 1 deletion t/qast/qast.t
@@ -1,6 +1,6 @@
use QRegex;

plan(37);
plan(41);

# Following a test infrastructure.
sub compile_qast($qast) {
Expand Down Expand Up @@ -405,6 +405,68 @@ test_qast_result(
ok($r<bananas>.m eq 'a', 'bindkey operation (str)');
});

is_qast_args(
QAST::Block.new(
QAST::Op.new(
:op('atpos'),
QAST::Var.new( :name('$a'), :scope('lexical'), :decl('param') ),
QAST::IVal.new(:value(1))
)
),
[nqp::list(1, 2, 3)],
2,
'atkey operation (int)');

is_qast_args(
QAST::Block.new(
QAST::Op.new(
:op('atpos'),
QAST::Var.new( :name('$a'), :scope('lexical'), :decl('param') ),
QAST::IVal.new(:value(2))
)
),
[nqp::list('huey', 'dewey', 'louie')],
'louie',
'atkey operation (str)');

test_qast_result(
QAST::Block.new(
QAST::Op.new(
:op('bind'),
QAST::Var.new( :name('list'), :scope('local'), :decl('var') ),
QAST::Op.new( :op('list') ),
),
QAST::Op.new(
:op('bindpos'),
QAST::Var.new( :name('list'), :scope('local') ),
QAST::IVal.new(:value(0)),
QAST::WVal.new(:value(D))
),
QAST::Var.new( :name('list'), :scope('local') )
),
-> $r {
ok($r[0].m == 206, 'bindkey operation (int)');
});

test_qast_result(
QAST::Block.new(
QAST::Op.new(
:op('bind'),
QAST::Var.new( :name('list'), :scope('local'), :decl('var') ),
QAST::Op.new( :op('list') ),
),
QAST::Op.new(
:op('bindpos'),
QAST::Var.new( :name('list'), :scope('local') ),
QAST::IVal.new(:value(3)),
QAST::WVal.new(:value(A))
),
QAST::Var.new( :name('list'), :scope('local') )
),
-> $r {
ok($r[3].m eq 'a', 'bindkey operation (str)');
});

is_qast(
QAST::Block.new(
QAST::Op.new(
Expand Down

0 comments on commit b0705d6

Please sign in to comment.