use of plugin.pretokens.parser.PreRuleParser in project pcgen by PCGen.
the class PreRuleTest method ruleDisabled.
/**
* Test to ensure that we return false when races don't match.
*
* @throws Exception
*/
public void ruleDisabled() throws Exception {
assertFalse("Our rule should start as false", Globals.checkRule("PRERULE"));
PreRuleParser parser = new PreRuleParser();
Prerequisite prereq = parser.parse("RULE", "1,PRERULE", false, false);
boolean passes = PrereqHandler.passes(prereq, getCharacter(), null);
assertFalse("PreRule should fail when rule is disabled.", passes);
prereq = parser.parse("RULE", "1,PRERULE", true, false);
passes = PrereqHandler.passes(prereq, getCharacter(), null);
assertTrue("!PreRule should pass when rule is disabled.", passes);
}
use of plugin.pretokens.parser.PreRuleParser in project pcgen by PCGen.
the class PreRuleTest method ruleEnabled.
/**
* Test to ensure that we return false when races don't match.
*
* @throws Exception
*/
public void ruleEnabled() throws Exception {
RuleCheck preRule = SettingsHandler.getGame().getModeContext().getReferenceContext().silentlyGetConstructedCDOMObject(RuleCheck.class, "PRERULE");
preRule.setDefault(true);
assertTrue("Our rule should now be true", Globals.checkRule("PRERULE"));
PreRuleParser parser = new PreRuleParser();
Prerequisite prereq = parser.parse("RULE", "1,PRERULE", false, false);
boolean passes = PrereqHandler.passes(prereq, getCharacter(), null);
assertTrue("PreRule should pass when rule is enabled.", passes);
prereq = parser.parse("RULE", "1,PRERULE", true, false);
passes = PrereqHandler.passes(prereq, getCharacter(), null);
assertFalse("!PreRule should fail when rule is enabled.", passes);
}
use of plugin.pretokens.parser.PreRuleParser in project pcgen by PCGen.
the class PreRuleRoundRobin method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
TokenRegistration.register(new PreRuleParser());
TokenRegistration.register(new PreRuleWriter());
}
use of plugin.pretokens.parser.PreRuleParser in project pcgen by PCGen.
the class PreRuleParserTest method testPositive.
/**
* @throws Exception
*/
@Test
public void testPositive() throws Exception {
PreRuleParser parser = new PreRuleParser();
Prerequisite prereq = parser.parse("RULE", "1,DISPLAYTYPETRAITS", false, false);
assertEquals("<prereq kind=\"rule\" key=\"DISPLAYTYPETRAITS\" operator=\"GTEQ\" operand=\"1\" >\n</prereq>\n", prereq.toString());
assertFalse("Prerule should nto need a character", prereq.isCharacterRequired());
}
use of plugin.pretokens.parser.PreRuleParser in project pcgen by PCGen.
the class PreRuleParserTest method testNegative.
/**
* @throws Exception
*/
@Test
public void testNegative() throws Exception {
PreRuleParser parser = new PreRuleParser();
Prerequisite prereq = parser.parse("RULE", "1,DISPLAYTYPETRAITS", true, false);
assertEquals("<prereq kind=\"rule\" key=\"DISPLAYTYPETRAITS\" operator=\"LT\" operand=\"1\" >\n</prereq>\n", prereq.toString());
assertFalse("Prerule should nto need a character", prereq.isCharacterRequired());
}
Aggregations