"duff");
Value x = factory.createStringValue("x");
Value y = factory.createStringValue("y");
Value x2 = factory.createStringValue("x2");
ExpressionScope scopeA = new SimpleExpressionScope(factory,
null);
ExpressionScope scopeB = new SimpleExpressionScope(factory,
scopeA);
scopeA.declareVariable(nameX, x);
scopeB.declareVariable(nameX, x2);
scopeA.declareVariable(nameX2, x2);
scopeB.declareVariable(nameY, y);
assertSame("Scope A's variable x should have been available",
x,
scopeA.resolveVariable(nameX).getValue());
assertSame("Scope A's variable x should be hidden",
x2,
scopeB.resolveVariable(nameX).getValue());
assertSame("Scope A's variable x2 should have been available",
x2,
scopeB.resolveVariable(nameX2).getValue());
assertNull("The duff variable should not have been available",
scopeB.resolveVariable(duff));
assertNull("Scope A's variable y should not have been available",
scopeA.resolveVariable(nameY));
assertSame("Scope B's variable y should have been available",
y,
scopeB.resolveVariable(nameY).getValue());
}