当前位置: 首页>>代码示例>>Java>>正文


Java Util.myAssert方法代码示例

本文整理汇总了Java中com.sri.ai.util.Util.myAssert方法的典型用法代码示例。如果您正苦于以下问题:Java Util.myAssert方法的具体用法?Java Util.myAssert怎么用?Java Util.myAssert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sri.ai.util.Util的用法示例。


在下文中一共展示了Util.myAssert方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: replace

import com.sri.ai.util.Util; //导入方法依赖的package包/类
@Override
public Expression replace(Expression expression, Expression newSubExpression) {
	AbstractQuantifiedExpression quantifiedExpression = castOrThrowError(AbstractQuantifiedExpression.class, expression, "Attempt to use " + IndexExpressionTypeSubExpressionAddress.class.getSimpleName() + " to replace sub-expression " + newSubExpression + " in %s, but the latter should have been an instance of %s but is instead an instance of %s");
	Util.myAssert(() -> quantifiedExpression.getIndexExpressions() instanceof ExtensionalIndexExpressionsSet, () -> quantifiedExpression.getClass().getSimpleName() + ".replaceIndexExpression assumes extensional set of index expressions but " + quantifiedExpression + " has a non-extensional index expression set");

	List<Expression> indexExpressionsList = ((ExtensionalIndexExpressionsSet) quantifiedExpression.getIndexExpressions()).getList();
	List<Expression> newIndexExpressionsList =
			replaceElementNonDestructively(indexExpressionsList, indexExpressionIndex,
					ie -> replaceAddressedSubExpressionInIndexExpressionByNewSubExpression(ie, newSubExpression));

	Expression result;
	if (newIndexExpressionsList != indexExpressionsList) {
		IndexExpressionsSet newIndexExpressions = new ExtensionalIndexExpressionsSet(newIndexExpressionsList);
		result = quantifiedExpression.setIndexExpressions(newIndexExpressions);
	}
	else {
		result = quantifiedExpression;
	}
	
	return result;
}
 
开发者ID:aic-sri-international,项目名称:aic-expresso,代码行数:22,代码来源:AbstractQuantifiedExpression.java

示例2: nullary

import com.sri.ai.util.Util; //导入方法依赖的package包/类
private void nullary() {
	try {
		Util.myAssert(() -> true , () -> "error message 1");
		Util.myAssert(() -> false, () -> "error message 2");
		if (System.getProperty(Util.MY_ASSERT_OFF) == null) {
			fail("Should have thrown an AssertionError but did not. System.getProperty(Util.MY_ASSERT_OFF) = " + System.getProperty(Util.MY_ASSERT_OFF));
		}
	}
	catch (AssertionError error) {
		if (error.getMessage().equals("error message 2")) {
			if (System.getProperty(Util.MY_ASSERT_OFF) == null) {
				// good, passed the unit test
			}
			else {
				fail("Threw assertion error when it should not have.");
			}
		}
		else {
			fail("Threw the wrong assertion error.");
		}
	}
	// good, passed the unit test
}
 
开发者ID:aic-sri-international,项目名称:aic-util,代码行数:24,代码来源:MyAssertTest.java

示例3: isLiteral

import com.sri.ai.util.Util; //导入方法依赖的package包/类
/**
 * Convenience for <code>this.getTheory().isLiteral(expression, this)</code>.
 * @param expression
 * @return
 */
default boolean isLiteral(Expression expression) {
	Theory theory = getTheory();
	Util.myAssert(theory != null, () -> "Context does not contain a theory, but is trying to check if " + expression + " is a literal according to some theory. Please make sure the context has been provided a theory");
	boolean result = theory.isLiteralOrBooleanConstant(expression, this);
	return result;
}
 
开发者ID:aic-sri-international,项目名称:aic-expresso,代码行数:12,代码来源:Context.java

示例4: extendWithSymbolsAndTypes

import com.sri.ai.util.Util; //导入方法依赖的package包/类
/**
 * Extends with pairs of symbols and their respective types represented as strings.
 * @param symbolsAndTypes
 * @return
 */
default Registry extendWithSymbolsAndTypes(Expression... symbolsAndTypes) {
	Util.myAssert(symbolsAndTypes.length % 2 == 0, () -> "Need to extend registry with a sequence of symbols and their types");
	List<Expression> indexExpressions = makeIndexExpressionsFromSymbolsAndTypes(symbolsAndTypes);
	Registry result = extendWith(new ExtensionalIndexExpressionsSet(indexExpressions));
	return result;
}
 
开发者ID:aic-sri-international,项目名称:aic-expresso,代码行数:12,代码来源:Registry.java

示例5: getExpressionAndIndexExpressionsFromProblemExpression

import com.sri.ai.util.Util; //导入方法依赖的package包/类
@Override
public Pair<Expression, IndexExpressionsSet> getExpressionAndIndexExpressionsFromProblemExpression(Expression expression, Context context) {
	String functorString = getFunctionString();
	Util.myAssert(() -> expression.hasFunctor(functorString), () -> "Expression expected to be application of " + functorString + " but is " + expression);
	IntensionalSet set = (IntensionalSet) expression.get(0);
	Expression body = IfThenElse.make(set.getCondition(), set.getHead(), additiveIdentityElement());
	Pair<Expression, IndexExpressionsSet> result = Pair.make(body, set.getIndexExpressions());
	return result;
}
 
开发者ID:aic-sri-international,项目名称:aic-expresso,代码行数:10,代码来源:AbstractFunctionBasedGroup.java

示例6: assertFunctionType

import com.sri.ai.util.Util; //导入方法依赖的package包/类
/**
 * Assert that the give expression represents a function type application.
 * 
 * @param expression
 *            the expression to be tested.
 */
public static void assertFunctionType(Expression expression) {
	Util.myAssert(expression.hasFunctor(FUNCTION_TYPE), () -> "Functor in expression " + expression
			+ " should be a functional type (that is, have functor '->')");
	Util.myAssert(expression.numberOfArguments() == 1 || expression.numberOfArguments() == 2,
			() -> "Function type has illegal number of arguments (should be 1 or 2), has "
					+ expression.numberOfArguments() + " for " + expression);
}
 
开发者ID:aic-sri-international,项目名称:aic-expresso,代码行数:14,代码来源:FunctionType.java

示例7: CompoundTheory

import com.sri.ai.util.Util; //导入方法依赖的package包/类
public CompoundTheory(Theory... subTheoriesArray) {
	super();
	this.subTheories = list(subTheoriesArray);
	Util.myAssert(() -> subTheories.size() != 0, () -> getClass() + " needs to receive at least one sub-theory but got none.");
}
 
开发者ID:aic-sri-international,项目名称:aic-expresso,代码行数:6,代码来源:CompoundTheory.java

示例8: replace

import com.sri.ai.util.Util; //导入方法依赖的package包/类
@Override
public Expression replace(Expression expression, Expression newSubExpression) {
	Util.myAssert(() -> expression instanceof AbstractExtensionalSet, () -> getClass().getSimpleName() + ".IndexAddress applied to expression " + expression + " of class " + expression.getClass());
	Expression result = ((ExtensionalSet)expression).setElementDefinition(this.index, newSubExpression);
	return result;
}
 
开发者ID:aic-sri-international,项目名称:aic-expresso,代码行数:7,代码来源:AbstractExtensionalSet.java

示例9: getSubExpressionOf

import com.sri.ai.util.Util; //导入方法依赖的package包/类
@Override
public Expression getSubExpressionOf(Expression expression) {
	Util.myAssert(() -> expression instanceof AbstractExtensionalSet, () -> getClass().getSimpleName() + ".IndexAddress applied to expression " + expression + " of class " + expression.getClass());
	Expression result = ((AbstractExtensionalSet) expression).getElementDefinition(index);
	return result;
}
 
开发者ID:aic-sri-international,项目名称:aic-expresso,代码行数:7,代码来源:AbstractExtensionalSet.java

示例10: replace

import com.sri.ai.util.Util; //导入方法依赖的package包/类
@Override
public Expression replace(Expression expression, Expression newSubExpression) {
	Util.myAssert(() -> expression instanceof DefaultTuple, () -> DefaultTuple.class.getSimpleName() + ".IndexAddress applied to expression " + expression + " of class " + expression.getClass());
	Expression result = expression.set(this.index, newSubExpression);
	return result;
}
 
开发者ID:aic-sri-international,项目名称:aic-expresso,代码行数:7,代码来源:DefaultTuple.java

示例11: replace

import com.sri.ai.util.Util; //导入方法依赖的package包/类
@Override
public Expression replace(Expression expression, Expression newSubExpression) {
	Util.myAssert(() -> expression.getSyntacticFormType().equals(FunctionApplication.SYNTACTIC_FORM_TYPE), () -> DefaultFunctionApplication.class.getSimpleName() + ".IndexAddress applied to expression " + expression + " of class " + expression.getClass());
	Expression result = expression.set(this.index, newSubExpression);
	return result;
}
 
开发者ID:aic-sri-international,项目名称:aic-expresso,代码行数:7,代码来源:DefaultFunctionApplication.java

示例12: computeCurrent

import com.sri.ai.util.Util; //导入方法依赖的package包/类
public T computeCurrent() {
	Util.myAssert(baseCurrentIsInitialized, () -> "No current element defined for iterator.");
	T result = function.apply(baseCurrent);
	return result;
}
 
开发者ID:aic-sri-international,项目名称:aic-util,代码行数:6,代码来源:FunctionIterator.java


注:本文中的com.sri.ai.util.Util.myAssert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。