public VariableReference appendFloatPrimitive(float f) { FloatPrimitiveStatement primitiveStmt = new FloatPrimitiveStatement(tc, f); tc.addStatement(primitiveStmt); return primitiveStmt.getReturnValue(); }
/** {@inheritDoc} */ @Override public void decrement() { increment(-1); }
statement = new DoublePrimitiveStatement(tc); } else if (clazz == float.class) { statement = new FloatPrimitiveStatement(tc); } else if (clazz == short.class) { statement = new ShortPrimitiveStatement(tc);
private void after(FloatPrimitiveStatement statement, Scope scope) { float valueOf = statement.getValue(); VariableReference varRef = statement.getReturnValue(); String varRefName = varRef.getName(); RealVariable realVariable = buildRealVariable(varRefName, valueOf, -Float.MAX_VALUE, Float.MAX_VALUE); symb_expressions.put(varRefName, realVariable); Float float_instance; try { float_instance = (Float) varRef.getObject(scope); } catch (CodeUnderTestException e) { throw new EvosuiteError(e); } ReferenceConstant floatRef = newFloatReference(float_instance, realVariable); symb_references.put(varRefName, floatRef); }
/** {@inheritDoc} */ @Override public void delta() { double P = Randomness.nextDouble(); if(P < 1d/3d) { value += (float)Randomness.nextGaussian() * Properties.MAX_DELTA; } else if(P < 2d/3d) { value += (float)Randomness.nextGaussian(); } else { int precision = Randomness.nextInt(7); chopPrecision(precision); } }
private TestCase getFloatTest(float x, float y) throws NoSuchMethodException, SecurityException, ConstructionFailedException, ClassNotFoundException { Class<?> sut = TestGenerationContext.getInstance().getClassLoaderForSUT().loadClass(Properties.TARGET_CLASS); GenericClass clazz = new GenericClass(sut); DefaultTestCase test = new DefaultTestCase(); GenericConstructor gc = new GenericConstructor(clazz.getRawClass().getConstructors()[0], clazz); TestFactory testFactory = TestFactory.getInstance(); VariableReference callee = testFactory.addConstructor(test, gc, 0, 0); VariableReference intVar1 = test.addStatement(new FloatPrimitiveStatement(test, x)); VariableReference intVar0 = test.addStatement(new FloatPrimitiveStatement(test, y)); Method m = clazz.getRawClass().getMethod("testMe", new Class<?>[] { float.class, float.class }); GenericMethod method = new GenericMethod(m, sut); MethodStatement ms = new MethodStatement(test, method, callee, Arrays.asList(new VariableReference[] {intVar0, intVar1})); test.addStatement(ms); return test; }
/** {@inheritDoc} */ @Override public void randomize() { if (Randomness.nextDouble() >= Properties.PRIMITIVE_POOL) { value = (float)(Randomness.nextGaussian() * Properties.MAX_INT); int precision = Randomness.nextInt(7); chopPrecision(precision); } else { ConstantPool constantPool = ConstantPoolManager.getInstance().getConstantPool(); value = constantPool.getRandomFloat(); } }
/** {@inheritDoc} */ @Override public void increment() { increment(1.0F); }