/*
(c) Copyright 2008, 2009 Hewlett-Packard Development Company, LP
All rights reserved.
$Id$
*/
package com.hp.jena.rules.ast.tests;
import static org.junit.Assert.*;
import org.junit.Test;
import com.hp.jena.rules.ast.*;
import com.hp.jena.rules.ast.tests.TestElement.VisitElement;
import com.hp.jena.shared.Ref;
public class TestLet
{
@Test public void ensureLetExposesFields()
{
Expr e = new Expr( "someFunction" );
Item name = Item.createVariable( "x" );
assertSame( e, new Let( name, e ).getExpr() );
assertSame( name, new Let( name, e ).getName() );
}
static class VisitLet extends TestElement.VisitElement
{
@Override public void visitLet( Let let )
{ seen.set( let ); }
}
@Test public void ensureLetVisitInvokesVisitFilter()
{
Expr e = new Expr( "someFunction" );
Item name = Item.createVariable( "x" );
Ref<Element> seen = new Ref<Element>();
VisitElement v = new VisitLet();
Let l = new Let( name, e );
l.visit( v );
assertSame( l, v.seen.get() );
}
}