Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Start a test file for QAST.
  • Loading branch information
jnthn committed Apr 22, 2012
1 parent 4aed1c0 commit 95641b4
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions t/qast/qast.t
@@ -0,0 +1,37 @@
use QRegex;

plan(3);

sub compile_qast($qast) {
my $post := QAST::Compiler.as_post($qast);
my $pir := QAST::Compiler.pir($post);
QAST::Compiler.evalpmc($pir);
}
sub is_qast($qast, $value, $desc) {
try {
my $code := compile_qast($qast);
ok($code() eq $value, $desc);
CATCH { ok(0, $desc) }
}
}

is_qast(
QAST::Block.new(
QAST::IVal.new( :value(42) )
),
42,
'IVal node');

is_qast(
QAST::Block.new(
QAST::NVal.new( :value(6.9) )
),
6.9,
'NVal node');

is_qast(
QAST::Block.new(
QAST::SVal.new( :value('Gorillas just love pizza') )
),
'Gorillas just love pizza',
'SVal node');

0 comments on commit 95641b4

Please sign in to comment.