com.oracle.testlibrary.jsr292.Helper Java Examples

The following examples show how to use com.oracle.testlibrary.jsr292.Helper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CatchExceptionTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void assertReturn(Object returned, Object arg0, Object arg1,
        int catchDrops, Object... args) {
    int lag = 0;
    if (throwMode == ThrowMode.CAUGHT) {
        lag = 1;
    }
    Helper.assertCalled(lag, callName(), arg0, arg1);

    if (throwMode == ThrowMode.NOTHING) {
        assertEQ(cast.apply(arg0), returned);
    } else if (throwMode == ThrowMode.CAUGHT) {
        List<Object> catchArgs = new ArrayList<>(Arrays.asList(args));
        // catcher receives an initial subsequence of target arguments:
        catchArgs.subList(args.length - catchDrops, args.length).clear();
        // catcher also receives the exception, prepended:
        catchArgs.add(0, thrown);
        Helper.assertCalled("catcher", catchArgs);
        assertEQ(cast.apply(catchArgs), returned);
    }
    Asserts.assertEQ(0, fakeIdentityCount);
}
 
Example #2
Source File: CatchExceptionTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public TestFactory() {
    if (Helper.IS_THOROUGH) {
        maxArgs = maxDrops = CatchExceptionTest.MAX_ARITY;
    } else {
        maxArgs = MIN_TESTED_ARITY
                + Helper.RNG.nextInt(CatchExceptionTest.MAX_ARITY
                        - MIN_TESTED_ARITY)
                + 1;
        maxDrops = MIN_TESTED_ARITY
                + Helper.RNG.nextInt(maxArgs - MIN_TESTED_ARITY)
                + 1;
        args = 1;
    }

    System.out.printf("maxArgs = %d%nmaxDrops = %d%n", maxArgs, maxDrops);
    constructorSize = TestCase.CONSTRUCTORS.size();
}
 
Example #3
Source File: CatchExceptionTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public TestFactory() {
    if (Helper.IS_THOROUGH) {
        maxArgs = maxDrops = CatchExceptionTest.MAX_ARITY;
    } else {
        maxArgs = MIN_TESTED_ARITY
                + Helper.RNG.nextInt(CatchExceptionTest.MAX_ARITY
                        - MIN_TESTED_ARITY)
                + 1;
        maxDrops = MIN_TESTED_ARITY
                + Helper.RNG.nextInt(maxArgs - MIN_TESTED_ARITY)
                + 1;
        args = 1;
    }

    System.out.printf("maxArgs = %d%nmaxDrops = %d%n", maxArgs, maxDrops);
    constructorSize = TestCase.CONSTRUCTORS.size();
}
 
Example #4
Source File: CatchExceptionTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private CatchExceptionTest createTest() {
    if (!Helper.IS_THOROUGH) {
        return new CatchExceptionTest(
                TestCase.CONSTRUCTORS.get(constructor++).get(),
                Helper.RNG.nextBoolean(), args, dropArgs);
    } else {
        if (isVararg) {
            isVararg = false;
            return new CatchExceptionTest(
                    TestCase.CONSTRUCTORS.get(constructor++).get(),
                    isVararg, args, dropArgs);
        } else {
            isVararg = true;
            return new CatchExceptionTest(
                    TestCase.CONSTRUCTORS.get(constructor).get(),
                    isVararg, args, dropArgs);
        }
    }
}
 
Example #5
Source File: CatchExceptionTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public CatchExceptionTest(TestCase testCase, final boolean isVararg, final int argsCount,
        final int catchDrops) {
    this.testCase = testCase;
    this.dropped = catchDrops;
    MethodHandle thrower = testCase.thrower;
    int throwerLen = thrower.type().parameterCount();
    List<Class<?>> classes;
    int extra = Math.max(0, argsCount - throwerLen);
    classes = getThrowerParams(isVararg, extra);
    this.argsCount = throwerLen + classes.size();
    thrower = Helper.addTrailingArgs(thrower, this.argsCount, classes);
    if (isVararg && argsCount > throwerLen) {
        MethodType mt = thrower.type();
        Class<?> lastParam = mt.parameterType(mt.parameterCount() - 1);
        thrower = thrower.asVarargsCollector(lastParam);
    }
    this.thrower = thrower;
    this.dropped = Math.min(this.argsCount, catchDrops);
    catcher = testCase.getCatcher(getCatcherParams());
    nargs = Math.max(2, this.argsCount);
}
 
Example #6
Source File: CatchExceptionTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public TestFactory() {
    if (Helper.IS_THOROUGH) {
        maxArgs = maxDrops = CatchExceptionTest.MAX_ARITY;
    } else {
        maxArgs = MIN_TESTED_ARITY
                + Helper.RNG.nextInt(CatchExceptionTest.MAX_ARITY
                        - MIN_TESTED_ARITY)
                + 1;
        maxDrops = MIN_TESTED_ARITY
                + Helper.RNG.nextInt(maxArgs - MIN_TESTED_ARITY)
                + 1;
        args = 1;
    }

    System.out.printf("maxArgs = %d%nmaxDrops = %d%n", maxArgs, maxDrops);
    constructorSize = TestCase.CONSTRUCTORS.size();
}
 
Example #7
Source File: CatchExceptionTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void assertReturn(Object returned, Object arg0, Object arg1,
        int catchDrops, Object... args) {
    int lag = 0;
    if (throwMode == ThrowMode.CAUGHT) {
        lag = 1;
    }
    Helper.assertCalled(lag, callName(), arg0, arg1);

    if (throwMode == ThrowMode.NOTHING) {
        assertEQ(cast.apply(arg0), returned);
    } else if (throwMode == ThrowMode.CAUGHT) {
        List<Object> catchArgs = new ArrayList<>(Arrays.asList(args));
        // catcher receives an initial subsequence of target arguments:
        catchArgs.subList(args.length - catchDrops, args.length).clear();
        // catcher also receives the exception, prepended:
        catchArgs.add(0, thrown);
        Helper.assertCalled("catcher", catchArgs);
        assertEQ(cast.apply(catchArgs), returned);
    }
    Asserts.assertEQ(0, fakeIdentityCount);
}
 
Example #8
Source File: CatchExceptionTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void assertReturn(Object returned, Object arg0, Object arg1,
        int catchDrops, Object... args) {
    int lag = 0;
    if (throwMode == ThrowMode.CAUGHT) {
        lag = 1;
    }
    Helper.assertCalled(lag, callName(), arg0, arg1);

    if (throwMode == ThrowMode.NOTHING) {
        assertEQ(cast.apply(arg0), returned);
    } else if (throwMode == ThrowMode.CAUGHT) {
        List<Object> catchArgs = new ArrayList<>(Arrays.asList(args));
        // catcher receives an initial subsequence of target arguments:
        catchArgs.subList(args.length - catchDrops, args.length).clear();
        // catcher also receives the exception, prepended:
        catchArgs.add(0, thrown);
        Helper.assertCalled("catcher", catchArgs);
        assertEQ(cast.apply(catchArgs), returned);
    }
    Asserts.assertEQ(0, fakeIdentityCount);
}
 
Example #9
Source File: LambdaFormTestCase.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
TestRun(Function<TestMethods, LambdaFormTestCase> ctor, Collection<TestMethods> testMethods) {
    this.ctor = ctor;
    this.testMethods = testMethods;
    long testCaseNum = testMethods.size();
    long iterations = Math.max(1, Helper.TEST_LIMIT / testCaseNum);
    System.out.printf("Number of iterations according to -DtestLimit is %d (%d cases)%n",
            iterations, iterations * testCaseNum);
    System.out.printf("Number of iterations is set to %d (%d cases)%n",
            iterations, iterations * testCaseNum);
    System.out.flush();
    totalIterations = iterations;
    doneIterations = 0L;
    testCounter = 0L;
    failCounter = 0L;
    passed = true;
}
 
Example #10
Source File: CatchExceptionTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public CatchExceptionTest(TestCase testCase, final boolean isVararg, final int argsCount,
        final int catchDrops) {
    this.testCase = testCase;
    this.dropped = catchDrops;
    MethodHandle thrower = testCase.thrower;
    int throwerLen = thrower.type().parameterCount();
    List<Class<?>> classes;
    int extra = Math.max(0, argsCount - throwerLen);
    classes = getThrowerParams(isVararg, extra);
    this.argsCount = throwerLen + classes.size();
    thrower = Helper.addTrailingArgs(thrower, this.argsCount, classes);
    if (isVararg && argsCount > throwerLen) {
        MethodType mt = thrower.type();
        Class<?> lastParam = mt.parameterType(mt.parameterCount() - 1);
        thrower = thrower.asVarargsCollector(lastParam);
    }
    this.thrower = thrower;
    this.dropped = Math.min(this.argsCount, catchDrops);
    catcher = testCase.getCatcher(getCatcherParams());
    nargs = Math.max(2, this.argsCount);
}
 
Example #11
Source File: CatchExceptionTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void assertReturn(Object returned, Object arg0, Object arg1,
        int catchDrops, Object... args) {
    int lag = 0;
    if (throwMode == ThrowMode.CAUGHT) {
        lag = 1;
    }
    Helper.assertCalled(lag, callName(), arg0, arg1);

    if (throwMode == ThrowMode.NOTHING) {
        assertEQ(cast.apply(arg0), returned);
    } else if (throwMode == ThrowMode.CAUGHT) {
        List<Object> catchArgs = new ArrayList<>(Arrays.asList(args));
        // catcher receives an initial subsequence of target arguments:
        catchArgs.subList(args.length - catchDrops, args.length).clear();
        // catcher also receives the exception, prepended:
        catchArgs.add(0, thrown);
        Helper.assertCalled("catcher", catchArgs);
        assertEQ(cast.apply(catchArgs), returned);
    }
    Asserts.assertEQ(0, fakeIdentityCount);
}
 
Example #12
Source File: LambdaFormTestCase.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
TestRun(Function<TestMethods, LambdaFormTestCase> ctor, Collection<TestMethods> testMethods) {
    this.ctor = ctor;
    this.testMethods = testMethods;
    long testCaseNum = testMethods.size();
    long iterations = Math.max(1, Helper.TEST_LIMIT / testCaseNum);
    System.out.printf("Number of iterations according to -DtestLimit is %d (%d cases)%n",
            iterations, iterations * testCaseNum);
    System.out.printf("Number of iterations is set to %d (%d cases)%n",
            iterations, iterations * testCaseNum);
    System.out.flush();
    totalIterations = iterations;
    doneIterations = 0L;
    testCounter = 0L;
    failCounter = 0L;
    passed = true;
}
 
Example #13
Source File: CatchExceptionTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public TestFactory() {
    if (Helper.IS_THOROUGH) {
        maxArgs = maxDrops = CatchExceptionTest.MAX_ARITY;
    } else {
        maxArgs = MIN_TESTED_ARITY
                + Helper.RNG.nextInt(CatchExceptionTest.MAX_ARITY
                        - MIN_TESTED_ARITY)
                + 1;
        maxDrops = MIN_TESTED_ARITY
                + Helper.RNG.nextInt(maxArgs - MIN_TESTED_ARITY)
                + 1;
        args = 1;
    }

    System.out.printf("maxArgs = %d%nmaxDrops = %d%n", maxArgs, maxDrops);
    constructorSize = TestCase.CONSTRUCTORS.size();
}
 
Example #14
Source File: CatchExceptionTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private CatchExceptionTest createTest() {
    if (!Helper.IS_THOROUGH) {
        return new CatchExceptionTest(
                TestCase.CONSTRUCTORS.get(constructor++).get(),
                Helper.RNG.nextBoolean(), args, dropArgs);
    } else {
        if (isVararg) {
            isVararg = false;
            return new CatchExceptionTest(
                    TestCase.CONSTRUCTORS.get(constructor++).get(),
                    isVararg, args, dropArgs);
        } else {
            isVararg = true;
            return new CatchExceptionTest(
                    TestCase.CONSTRUCTORS.get(constructor).get(),
                    isVararg, args, dropArgs);
        }
    }
}
 
Example #15
Source File: CatchExceptionTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public TestFactory() {
    if (Helper.IS_THOROUGH) {
        maxArgs = maxDrops = CatchExceptionTest.MAX_ARITY;
    } else {
        maxArgs = MIN_TESTED_ARITY
                + Helper.RNG.nextInt(CatchExceptionTest.MAX_ARITY
                        - MIN_TESTED_ARITY)
                + 1;
        maxDrops = MIN_TESTED_ARITY
                + Helper.RNG.nextInt(maxArgs - MIN_TESTED_ARITY)
                + 1;
        args = 1;
    }

    if (Helper.IS_VERBOSE) {
        System.out.printf("maxArgs = %d%nmaxDrops = %d%n",
                maxArgs, maxDrops);
    }
    constructorSize = TestCase.CONSTRUCTORS.size();
}
 
Example #16
Source File: CatchExceptionTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public CatchExceptionTest(TestCase testCase, final boolean isVararg, final int argsCount,
        final int catchDrops) {
    this.testCase = testCase;
    this.dropped = catchDrops;
    MethodHandle thrower = testCase.thrower;
    int throwerLen = thrower.type().parameterCount();
    List<Class<?>> classes;
    int extra = Math.max(0, argsCount - throwerLen);
    classes = getThrowerParams(isVararg, extra);
    this.argsCount = throwerLen + classes.size();
    thrower = Helper.addTrailingArgs(thrower, this.argsCount, classes);
    if (isVararg && argsCount > throwerLen) {
        MethodType mt = thrower.type();
        Class<?> lastParam = mt.parameterType(mt.parameterCount() - 1);
        thrower = thrower.asVarargsCollector(lastParam);
    }
    this.thrower = thrower;
    this.dropped = Math.min(this.argsCount, catchDrops);
    catcher = testCase.getCatcher(getCatcherParams());
    nargs = Math.max(2, this.argsCount);
}
 
Example #17
Source File: LambdaFormTestCase.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
TestRun(Function<TestMethods, LambdaFormTestCase> ctor, Collection<TestMethods> testMethods) {
    this.ctor = ctor;
    this.testMethods = testMethods;
    long testCaseNum = testMethods.size();
    long iterations = Math.max(1, Helper.TEST_LIMIT / testCaseNum);
    System.out.printf("Number of iterations according to -DtestLimit is %d (%d cases)%n",
            iterations, iterations * testCaseNum);
    System.out.printf("Number of iterations is set to %d (%d cases)%n",
            iterations, iterations * testCaseNum);
    System.out.flush();
    totalIterations = iterations;
    doneIterations = 0L;
    testCounter = 0L;
    failCounter = 0L;
    passed = true;
}
 
Example #18
Source File: CatchExceptionTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public CatchExceptionTest(TestCase testCase, final boolean isVararg, final int argsCount,
        final int catchDrops) {
    this.testCase = testCase;
    this.dropped = catchDrops;
    MethodHandle thrower = testCase.thrower;
    int throwerLen = thrower.type().parameterCount();
    List<Class<?>> classes;
    int extra = Math.max(0, argsCount - throwerLen);
    classes = getThrowerParams(isVararg, extra);
    this.argsCount = throwerLen + classes.size();
    thrower = Helper.addTrailingArgs(thrower, this.argsCount, classes);
    if (isVararg && argsCount > throwerLen) {
        MethodType mt = thrower.type();
        Class<?> lastParam = mt.parameterType(mt.parameterCount() - 1);
        thrower = thrower.asVarargsCollector(lastParam);
    }
    this.thrower = thrower;
    this.dropped = Math.min(this.argsCount, catchDrops);
    catcher = testCase.getCatcher(getCatcherParams());
    nargs = Math.max(2, this.argsCount);
}
 
Example #19
Source File: CatchExceptionTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private CatchExceptionTest createTest() {
    if (!Helper.IS_THOROUGH) {
        return new CatchExceptionTest(
                TestCase.CONSTRUCTORS.get(constructor++).get(),
                Helper.RNG.nextBoolean(), args, dropArgs);
    } else {
       if (isVararg) {
           isVararg = false;
           return new CatchExceptionTest(
                   TestCase.CONSTRUCTORS.get(constructor++).get(),
                   isVararg, args, dropArgs);
       } else {
           isVararg = true;
           return new CatchExceptionTest(
                   TestCase.CONSTRUCTORS.get(constructor).get(),
                   isVararg, args, dropArgs);
       }
    }
}
 
Example #20
Source File: CatchExceptionTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private CatchExceptionTest createTest() {
    if (!Helper.IS_THOROUGH) {
        return new CatchExceptionTest(
                TestCase.CONSTRUCTORS.get(constructor++).get(),
                Helper.RNG.nextBoolean(), args, dropArgs);
    } else {
        if (isVararg) {
            isVararg = false;
            return new CatchExceptionTest(
                    TestCase.CONSTRUCTORS.get(constructor++).get(),
                    isVararg, args, dropArgs);
        } else {
            isVararg = true;
            return new CatchExceptionTest(
                    TestCase.CONSTRUCTORS.get(constructor).get(),
                    isVararg, args, dropArgs);
        }
    }
}
 
Example #21
Source File: CatchExceptionTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void assertReturn(Object returned, Object arg0, Object arg1,
        int catchDrops, Object... args) {
    int lag = 0;
    if (throwMode == ThrowMode.CAUGHT) {
        lag = 1;
    }
    Helper.assertCalled(lag, callName(), arg0, arg1);

    if (throwMode == ThrowMode.NOTHING) {
        assertEQ(cast.apply(arg0), returned);
    } else if (throwMode == ThrowMode.CAUGHT) {
        List<Object> catchArgs = new ArrayList<>(Arrays.asList(args));
        // catcher receives an initial subsequence of target arguments:
        catchArgs.subList(args.length - catchDrops, args.length).clear();
        // catcher also receives the exception, prepended:
        catchArgs.add(0, thrown);
        Helper.assertCalled("catcher", catchArgs);
        assertEQ(cast.apply(catchArgs), returned);
    }
    Asserts.assertEQ(0, fakeIdentityCount);
}
 
Example #22
Source File: LambdaFormTestCase.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
TestRun(Function<TestMethods, LambdaFormTestCase> ctor, Collection<TestMethods> testMethods) {
    this.ctor = ctor;
    this.testMethods = testMethods;
    long testCaseNum = testMethods.size();
    long iterations = Math.max(1, Helper.TEST_LIMIT / testCaseNum);
    System.out.printf("Number of iterations according to -DtestLimit is %d (%d cases)%n",
            iterations, iterations * testCaseNum);
    System.out.printf("Number of iterations is set to %d (%d cases)%n",
            iterations, iterations * testCaseNum);
    System.out.flush();
    totalIterations = iterations;
    doneIterations = 0L;
    testCounter = 0L;
    failCounter = 0L;
    passed = true;
}
 
Example #23
Source File: CatchExceptionTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public CatchExceptionTest(TestCase testCase, final boolean isVararg, final int argsCount,
        final int catchDrops) {
    this.testCase = testCase;
    this.dropped = catchDrops;
    MethodHandle thrower = testCase.thrower;
    int throwerLen = thrower.type().parameterCount();
    List<Class<?>> classes;
    int extra = Math.max(0, argsCount - throwerLen);
    classes = getThrowerParams(isVararg, extra);
    this.argsCount = throwerLen + classes.size();
    thrower = Helper.addTrailingArgs(thrower, this.argsCount, classes);
    if (isVararg && argsCount > throwerLen) {
        MethodType mt = thrower.type();
        Class<?> lastParam = mt.parameterType(mt.parameterCount() - 1);
        thrower = thrower.asVarargsCollector(lastParam);
    }
    this.thrower = thrower;
    this.dropped = Math.min(this.argsCount, catchDrops);
    catcher = testCase.getCatcher(getCatcherParams());
    nargs = Math.max(2, this.argsCount);
}
 
Example #24
Source File: CatchExceptionTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void assertReturn(Object returned, Object arg0, Object arg1,
        int catchDrops, Object... args) {
    int lag = 0;
    if (throwMode == ThrowMode.CAUGHT) {
        lag = 1;
    }
    Helper.assertCalled(lag, callName(), arg0, arg1);

    if (throwMode == ThrowMode.NOTHING) {
        assertEQ(cast.apply(arg0), returned);
    } else if (throwMode == ThrowMode.CAUGHT) {
        List<Object> catchArgs = new ArrayList<>(Arrays.asList(args));
        // catcher receives an initial subsequence of target arguments:
        catchArgs.subList(args.length - catchDrops, args.length).clear();
        // catcher also receives the exception, prepended:
        catchArgs.add(0, thrown);
        Helper.assertCalled("catcher", catchArgs);
        assertEQ(cast.apply(catchArgs), returned);
    }
    Asserts.assertEQ(0, fakeIdentityCount);
}
 
Example #25
Source File: CatchExceptionTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private CatchExceptionTest createTest() {
    if (!Helper.IS_THOROUGH) {
        return new CatchExceptionTest(
                TestCase.CONSTRUCTORS.get(constructor++).get(),
                Helper.RNG.nextBoolean(), args, dropArgs);
    } else {
        if (isVararg) {
            isVararg = false;
            return new CatchExceptionTest(
                    TestCase.CONSTRUCTORS.get(constructor++).get(),
                    isVararg, args, dropArgs);
        } else {
            isVararg = true;
            return new CatchExceptionTest(
                    TestCase.CONSTRUCTORS.get(constructor).get(),
                    isVararg, args, dropArgs);
        }
    }
}
 
Example #26
Source File: CatchExceptionTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private CatchExceptionTest createTest() {
    if (!Helper.IS_THOROUGH) {
        return new CatchExceptionTest(
                TestCase.CONSTRUCTORS.get(constructor++).get(),
                Helper.RNG.nextBoolean(), args, dropArgs);
    } else {
       if (isVararg) {
           isVararg = false;
           return new CatchExceptionTest(
                   TestCase.CONSTRUCTORS.get(constructor++).get(),
                   isVararg, args, dropArgs);
       } else {
           isVararg = true;
           return new CatchExceptionTest(
                   TestCase.CONSTRUCTORS.get(constructor).get(),
                   isVararg, args, dropArgs);
       }
    }
}
 
Example #27
Source File: CatchExceptionTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void assertReturn(Object returned, Object arg0, Object arg1,
        int catchDrops, Object... args) {
    int lag = 0;
    if (throwMode == ThrowMode.CAUGHT) {
        lag = 1;
    }
    Helper.assertCalled(lag, callName(), arg0, arg1);

    if (throwMode == ThrowMode.NOTHING) {
        assertEQ(cast.apply(arg0), returned);
    } else if (throwMode == ThrowMode.CAUGHT) {
        List<Object> catchArgs = new ArrayList<>(Arrays.asList(args));
        // catcher receives an initial subsequence of target arguments:
        catchArgs.subList(args.length - catchDrops, args.length).clear();
        // catcher also receives the exception, prepended:
        catchArgs.add(0, thrown);
        Helper.assertCalled("catcher", catchArgs);
        assertEQ(cast.apply(catchArgs), returned);
    }
    Asserts.assertEQ(0, fakeIdentityCount);
}
 
Example #28
Source File: LambdaFormTestCase.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
TestRun(Function<TestMethods, LambdaFormTestCase> ctor, Collection<TestMethods> testMethods) {
    this.ctor = ctor;
    this.testMethods = testMethods;
    long testCaseNum = testMethods.size();
    long iterations = Math.max(1, Helper.TEST_LIMIT / testCaseNum);
    System.out.printf("Number of iterations according to -DtestLimit is %d (%d cases)%n",
            iterations, iterations * testCaseNum);
    System.out.printf("Number of iterations is set to %d (%d cases)%n",
            iterations, iterations * testCaseNum);
    System.out.flush();
    totalIterations = iterations;
    doneIterations = 0L;
    testCounter = 0L;
    failCounter = 0L;
    passed = true;
}
 
Example #29
Source File: CatchExceptionTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public TestFactory() {
    if (Helper.IS_THOROUGH) {
        maxArgs = maxDrops = CatchExceptionTest.MAX_ARITY;
    } else {
        maxArgs = MIN_TESTED_ARITY
                + Helper.RNG.nextInt(CatchExceptionTest.MAX_ARITY
                        - MIN_TESTED_ARITY)
                + 1;
        maxDrops = MIN_TESTED_ARITY
                + Helper.RNG.nextInt(maxArgs - MIN_TESTED_ARITY)
                + 1;
        args = 1;
    }

    System.out.printf("maxArgs = %d%nmaxDrops = %d%n", maxArgs, maxDrops);
    constructorSize = TestCase.CONSTRUCTORS.size();
}
 
Example #30
Source File: CatchExceptionTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public TestFactory() {
    if (Helper.IS_THOROUGH) {
        maxArgs = maxDrops = CatchExceptionTest.MAX_ARITY;
    } else {
        maxArgs = MIN_TESTED_ARITY
                + Helper.RNG.nextInt(CatchExceptionTest.MAX_ARITY
                        - MIN_TESTED_ARITY)
                + 1;
        maxDrops = MIN_TESTED_ARITY
                + Helper.RNG.nextInt(maxArgs - MIN_TESTED_ARITY)
                + 1;
        args = 1;
    }

    System.out.printf("maxArgs = %d%nmaxDrops = %d%n", maxArgs, maxDrops);
    constructorSize = TestCase.CONSTRUCTORS.size();
}