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


Java Helper类代码示例

本文整理汇总了Java中com.oracle.testlibrary.jsr292.Helper的典型用法代码示例。如果您正苦于以下问题:Java Helper类的具体用法?Java Helper怎么用?Java Helper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: CatchExceptionTest

import com.oracle.testlibrary.jsr292.Helper; //导入依赖的package包/类
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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:CatchExceptionTest.java

示例2: TestFactory

import com.oracle.testlibrary.jsr292.Helper; //导入依赖的package包/类
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();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:CatchExceptionTest.java

示例3: createTest

import com.oracle.testlibrary.jsr292.Helper; //导入依赖的package包/类
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);
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:CatchExceptionTest.java

示例4: assertReturn

import com.oracle.testlibrary.jsr292.Helper; //导入依赖的package包/类
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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:CatchExceptionTest.java

示例5: TestRun

import com.oracle.testlibrary.jsr292.Helper; //导入依赖的package包/类
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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:LambdaFormTestCase.java

示例6: createTest

import com.oracle.testlibrary.jsr292.Helper; //导入依赖的package包/类
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);
       }
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:20,代码来源:CatchExceptionTest.java

示例7: TestFactory

import com.oracle.testlibrary.jsr292.Helper; //导入依赖的package包/类
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();
}
 
开发者ID:infobip,项目名称:infobip-open-jdk-8,代码行数:21,代码来源:CatchExceptionTest.java

示例8: nextTest

import com.oracle.testlibrary.jsr292.Helper; //导入依赖的package包/类
/**
 * @return next test from test matrix: {varArgs, noVarArgs} x
 * TestCase.rtypes x TestCase.THROWABLES x {1, .., maxArgs } x
 * {0, .., maxDrops}
 */
public CatchExceptionTest nextTest() {
    if (constructor < constructorSize) {
        return createTest();
    }
    constructor = 0;
    count++;
    if (!Helper.IS_THOROUGH && count > Helper.TEST_LIMIT) {
        System.out.println("test limit is exceeded");
        return null;
    }
    if (dropArgs <= currentMaxDrops) {
        if (dropArgs == 0) {
            if (Helper.IS_THOROUGH || Helper.RNG.nextBoolean()) {
                ++dropArgs;
                return createTest();
            } else if (Helper.IS_VERBOSE) {
                System.out.printf(
                        "argsCount=%d : \"drop\" scenarios are skipped%n",
                        args);
            }
        } else {
            ++dropArgs;
            return createTest();
        }
    }

    if (args < maxArgs) {
        dropArgs = 0;
        currentMaxDrops = Math.min(args, maxDrops);
        ++args;
        return createTest();
    }
    return null;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:40,代码来源:CatchExceptionTest.java

示例9: throwOrReturn

import com.oracle.testlibrary.jsr292.Helper; //导入依赖的package包/类
private static <T extends Throwable>
        Object throwOrReturn(Object normal, T exception) throws T {
    if (exception != null) {
        Helper.called("throwOrReturn/throw", normal, exception);
        throw exception;
    }
    Helper.called("throwOrReturn/normal", normal, exception);
    return normal;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:CatchExceptionTest.java

示例10: testMultipleArgs

import com.oracle.testlibrary.jsr292.Helper; //导入依赖的package包/类
/**
 * Tests that MHs.eCA method works correctly with MHs with multiple arguments.
 * @throws Throwable
 */
public static void testMultipleArgs() throws Throwable {
    int arity = 1 + RNG.nextInt(Helper.MAX_ARITY / 2 - 2);
    int arityMinus = RNG.nextInt(arity);
    int arityPlus = arity + RNG.nextInt(Helper.MAX_ARITY / 2 - arity) + 1;
    MethodType mType = Helper.randomMethodTypeGenerator(arity);
    MethodType mTypeNew = Helper.randomMethodTypeGenerator(arity);
    MethodType mTypeNewMinus = Helper.randomMethodTypeGenerator(arityMinus);
    MethodType mTypeNewPlus = Helper.randomMethodTypeGenerator(arityPlus);
    Class<?> rType = mType.returnType();
    MethodHandle original;
    if (rType.equals(void.class)) {
        MethodType mt = MethodType.methodType(void.class);
        original = MethodHandles.publicLookup()
                .findStatic(THIS_CLASS, "retVoid", mt);
    } else {
        Object rValue = Helper.castToWrapper(1, rType);
        original = MethodHandles.constant(rType, rValue);
    }
    original = Helper.addTrailingArgs(original, arity, mType.parameterList());
    MethodHandle target = MethodHandles
                .explicitCastArguments(original, mTypeNew);
    Object[] parList = Helper.randomArgs(mTypeNew.parameterList());
    for (int i = 0; i < parList.length; i++) {
        if (parList[i] instanceof String) {
            parList[i] = null; //getting rid of Stings produced by randomArgs
        }
    }
    target.invokeWithArguments(parList);
    checkForWrongMethodTypeException(original, mTypeNewMinus);
    checkForWrongMethodTypeException(original, mTypeNewPlus);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:36,代码来源:ExplicitCastArgumentsTest.java

示例11: nextTest

import com.oracle.testlibrary.jsr292.Helper; //导入依赖的package包/类
/**
 * @return next test from test matrix:
 * {varArgs, noVarArgs} x TestCase.rtypes x TestCase.THROWABLES x {1, .., maxArgs } x {0, .., maxDrops}
 */
public CatchExceptionTest nextTest() {
    if (constructor < constructorSize) {
        return createTest();
    }
    constructor = 0;
    count++;
    if (!Helper.IS_THOROUGH && count > Helper.TEST_LIMIT) {
        System.out.println("test limit is exceeded");
        return null;
    }
    if (dropArgs <= currentMaxDrops) {
        if (dropArgs == 0) {
            if (Helper.IS_THOROUGH || Helper.RNG.nextBoolean()) {
                ++dropArgs;
                return createTest();
            } else if (Helper.IS_VERBOSE) {
                System.out.printf(
                        "argsCount=%d : \"drop\" scenarios are skipped%n",
                        args);
            }
        } else {
            ++dropArgs;
            return createTest();
        }
    }

    if (args < maxArgs) {
        dropArgs = 0;
        currentMaxDrops = Math.min(args, maxDrops);
        ++args;
        return createTest();
    }
    return null;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:39,代码来源:CatchExceptionTest.java

示例12: throwOrReturn

import com.oracle.testlibrary.jsr292.Helper; //导入依赖的package包/类
private static <T extends Throwable>
Object throwOrReturn(Object normal, T exception) throws T {
    if (exception != null) {
        Helper.called("throwOrReturn/throw", normal, exception);
        throw exception;
    }
    Helper.called("throwOrReturn/normal", normal, exception);
    return normal;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:10,代码来源:CatchExceptionTest.java

示例13: CatchExceptionTest

import com.oracle.testlibrary.jsr292.Helper; //导入依赖的package包/类
public CatchExceptionTest(TestCase testCase, final boolean isVararg, final int argsCount,
        final int catchDrops) {
    this.testCase = testCase;
    this.dropped = catchDrops;
    if (Helper.IS_VERBOSE) {
        System.out.printf("CatchException::CatchException(%s, isVararg=%b " +
                        "argsCount=%d catchDrops=%d)%n",
                testCase, isVararg, argsCount, 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);
}
 
开发者ID:infobip,项目名称:infobip-open-jdk-8,代码行数:28,代码来源:CatchExceptionTest.java

示例14: runTest

import com.oracle.testlibrary.jsr292.Helper; //导入依赖的package包/类
private void runTest() {
    Helper.clear();

    Object[] args = Helper.randomArgs(
            argsCount, thrower.type().parameterArray());
    Object arg0 = Helper.MISSING_ARG;
    Object arg1 = testCase.thrown;
    if (argsCount > 0) {
        arg0 = args[0];
    }
    if (argsCount > 1) {
        args[1] = arg1;
    }
    Asserts.assertEQ(nargs, thrower.type().parameterCount());
    if (argsCount < nargs) {
        Object[] appendArgs = {arg0, arg1};
        appendArgs = Arrays.copyOfRange(appendArgs, argsCount, nargs);
        thrower = MethodHandles.insertArguments(
                thrower, argsCount, appendArgs);
    }
    Asserts.assertEQ(argsCount, thrower.type().parameterCount());

    MethodHandle target = MethodHandles.catchException(
            testCase.filter(thrower), testCase.throwableClass,
            testCase.filter(catcher));

    Asserts.assertEQ(thrower.type(), target.type());
    Asserts.assertEQ(argsCount, target.type().parameterCount());

    Object returned;
    try {
        returned = target.invokeWithArguments(args);
    } catch (Throwable ex) {
        testCase.assertCatch(ex);
        returned = ex;
    }

    testCase.assertReturn(returned, arg0, arg1, dropped, args);
}
 
开发者ID:infobip,项目名称:infobip-open-jdk-8,代码行数:40,代码来源:CatchExceptionTest.java


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