Package com.pholser.junit.quickcheck.internal

Examples of com.pholser.junit.quickcheck.internal.ParameterContext


            .thenReturn(0);
        when(constraint.value()).thenReturn("#_ > 0");
    }

    @Test public void whenDiscardRatioExceededEvenWithSomeSuccesses() {
        ParameterContext parameter = new ParameterContext(int.class);
        parameter.addQuantifier(quantifier);
        parameter.addConstraint(constraint);

        GenerationContext generation =
            new GenerationContext(parameter, new GeneratorRepository(random).register(generator));

        thrown.expect(GenerationContext.DiscardRatioExceededException.class);
        thrown.expectMessage(String.format(
            GenerationContext.DiscardRatioExceededException.MESSAGE_TEMPLATE,
            parameter.discardRatio(),
            30,
            10,
            3D));

        while (generation.shouldContinue())
View Full Code Here


        Object[] args = new Object[parameterTypes.length];

        for (int i = 0; i < args.length; ++i) {
            AnnotatedConstructorParameter ctorParameter = new AnnotatedConstructorParameter(parameterAnnotations[i]);
            ParameterContext parameter = new ParameterContext(parameterTypes[i]).annotate(ctorParameter);
            args[i] = generatorFor(parameter).generate(random, status);
        }

        return args;
    }
View Full Code Here

            repository.register(auxiliarySource);

        RandomTheoryParameterGenerator generator =
            new RandomTheoryParameterGenerator(randomForParameterGenerator, repository);

        ParameterContext context = new ParameterContext(parameterType());
        context.addQuantifier(quantifier);
        context.addConstraint(constraint);
        if (explicitGenerators.value() != null)
            context.addGenerators(explicitGenerators);
        for (Map.Entry<Class<? extends Annotation>, Annotation> each : configurations().entrySet())
            context.addConfiguration(each.getKey(), each.getValue());

        theoryParameters = generator.generate(context);
    }
View Full Code Here

    @Override public T generate(SourceOfRandomness random, GenerationStatus status) {
        Class<T> type = types().get(0);
        Object generated = Reflection.instantiate(type);

        for (Field each : allDeclaredFieldsOf(type)) {
            ParameterContext parameter = new ParameterContext(each.getGenericType()).annotate(each);
            setField(each, generated, generatorFor(parameter).generate(random, status), true);
        }

        return type.cast(generated);
    }
View Full Code Here

TOP

Related Classes of com.pholser.junit.quickcheck.internal.ParameterContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.