used in unit tests
180052
def find_object
      if params.key?(:product_id)
        @obj = find_product
      elsif params.key?(:repository_id)
        @obj = find_repository
      else
        fail HttpErrors::NotFound, N_("Couldn't find subject of synchronization") if @obj.nil?
      end
      @obj
    end
1007286
public boolean usesMethod(String className, String methodName, String descriptor) {
		int classIndex = findClass(className);
		if (classIndex == NOT_FOUND) return false;
		int nameAndTypeIndex = findNameAndType(methodName, descriptor);
		if (nameAndTypeIndex == NOT_FOUND) return false;
		
		for (int i = 1; i < maxPoolSize; i++) {
			if (isMethod(i) && 
					readValue(offsets[i]) == classIndex && 
					readValue(offsets[i] + 2) == nameAndTypeIndex) return true;
		}
		return false;
	}
250726
function() {
            var assert = this;

            // Backwards compatibility fix.
            // Allows the direct use of global exported assertions and QUnit.assert.*
            // Although, it's use is not recommended as it can leak assertions
            // to other tests from async tests, because we only get a reference to the current test,
            // not exactly the test where assertion were intended to be called.
            if ( !QUnit.config.current ) {
                throw new Error( "assertion outside test context, in " + sourceFromStacktrace( 2 ) );
            }
            if ( !( assert instanceof Assert ) ) {
                assert = QUnit.config.current.assert;
            }
            return assert.test.push.apply( assert.test, arguments );
        }
326168
public static void checkLoaded() {
    if (LOAD_ERROR != null) {
      throw LOAD_ERROR;
    }
    // Make a test call, sometimes the error won't occur until you try the native method.
    // 2 ^ 3 = 8, 8 mod 5 = 3
    BigInteger two = BigInteger.valueOf(2);
    BigInteger three = BigInteger.valueOf(3);
    BigInteger four = BigInteger.valueOf(4);
    BigInteger five = BigInteger.valueOf(5);
    BigInteger answer;

    answer = modPowInsecure(two, three, five);
    if (!three.equals(answer)) {
      throw new AssertionError("libgmp is loaded but modPowInsecure returned the wrong answer");
    }

    answer = modPowSecure(two, three, five);
    if (!three.equals(answer)) {
      throw new AssertionError("libgmp is loaded but modPowSecure returned the wrong answer");
    }

    int answr = kronecker(four, five);
    if (answr != 1) {
      throw new AssertionError("libgmp is loaded but kronecker returned the wrong answer");
    }
  }
119181
def method_missing(method, *args, &block)
      if method.to_s =~ UNIT_LIST_REGEX

        if $2 || $4 || $6
          conditions = []

          conditions << "unit.is_#{$2}_unit?"     if $2
          conditions << "!unit.is_prefixed_unit?" if $4
          conditions << "unit.is_#{$6}_unit?"     if $6

          units = Unit.units.values.select { |unit| instance_eval(conditions.join(" && ")) }
        else
          units = Unit.units.values
        end

        return_format = ( $8 ? $8.to_sym : nil )
        units.map(&return_format).to_a
        
      elsif unit = Unit.for(method)

        return unit
      else

        super
      end
    end
325544
@Override
    public void sawOpcode(int seen) {
        boolean sawCreate = false;
        Integer itemPC = null;

        try {
            stack.precomputation(this);

            if (seen == Const.INVOKEINTERFACE) {
                String className = getClassConstantOperand();
                String methodInfo = getNameConstantOperand() + ':' + getSigConstantOperand();
                if ("org/w3c/dom/Document".equals(className) && domCreationMethods.contains(methodInfo)) {
                    sawCreate = true;
                    itemPC = Integer.valueOf(getPC());
                }
            } else if (OpcodeUtils.isAStore(seen)) {
                Integer pc = findDOMNodeCreationPoint(0);
                int reg = RegisterUtils.getAStoreReg(this, seen);
                if (pc != null) {
                    nodeStores.put(Integer.valueOf(reg), pc);
                } else {
                    nodeStores.remove(Integer.valueOf(reg));
                }
            } else if (seen == Const.PUTFIELD) {
                // Stores to member variables are assumed ok
                findDOMNodeCreationPoint(0);
            } else if (OpcodeUtils.isALoad(seen)) {
                int reg = RegisterUtils.getALoadReg(this, seen);
                itemPC = nodeStores.get(Integer.valueOf(reg));
                if (itemPC != null) {
                    sawCreate = true;
                }
            } else if ((seen == Const.ARETURN) && (stack.getStackDepth() > 0)) {
                OpcodeStack.Item itm = stack.getStackItem(0);
                int reg = itm.getRegisterNumber();
                nodeCreations.remove(itm);
                nodeStores.remove(Integer.valueOf(reg));
            }

            if (!sawCreate
                    && ((seen == Const.INVOKEINTERFACE) || (seen == Const.INVOKEVIRTUAL) || (seen == Const.INVOKESTATIC) || (seen == Const.INVOKESPECIAL))) {
                String methodSig = getSigConstantOperand();
                int argCount = SignatureUtils.getNumParameters(methodSig);
                if (stack.getStackDepth() >= argCount) {
                    for (int a = 0; a < argCount; a++) {
                        OpcodeStack.Item itm = stack.getStackItem(a);
                        if (nodeCreations.containsKey(itm)) {
                            int reg = itm.getRegisterNumber();
                            nodeCreations.remove(itm);
                            nodeStores.remove(Integer.valueOf(reg));
                        }
                    }
                    if ((seen != Const.INVOKESTATIC) && (stack.getStackDepth() > argCount)) {
                        nodeCreations.remove(stack.getStackItem(argCount));
                    }
                }
            }
        } finally {
            stack.sawOpcode(this, seen);
            if (sawCreate && (stack.getStackDepth() > 0)) {
                nodeCreations.put(stack.getStackItem(0), itemPC);
            }
        }
    }
581120
@Override
    public void visitClassContext(ClassContext classContext) {
        try {
            unusedParms = new BitSet();
            regToParm = new HashMap<>();
            stack = new OpcodeStack();
            super.visitClassContext(classContext);
        } finally {
            stack = null;
            regToParm = null;
            unusedParms.clear();
        }
    }
130142
@Override
    public void sawOpcode(int seen) {
        try {

            stack.precomputation(this);

            if (OpcodeUtils.isStandardInvoke(seen)) {
                String clsName = getClassConstantOperand();
                if (!safeClasses.contains(clsName)) {
                    try {
                        JavaClass cls = Repository.lookupClass(clsName);
                        Method[] methods = cls.getMethods();
                        String methodName = getNameConstantOperand();
                        String signature = getSigConstantOperand();
                        boolean found = false;
                        for (Method m : methods) {
                            if (m.getName().equals(methodName) && m.getSignature().equals(signature)) {

                                if (isAnonymousInnerCtor(m, cls)) {
                                    // The java compiler doesn't properly attached an Exception Table to anonymous
                                    // constructors, so just clear if so
                                    break;
                                }

                                ExceptionTable et = m.getExceptionTable();
                                if (et != null) {
                                    String[] thrownExceptions = et.getExceptionNames();
                                    for (String thrownException : thrownExceptions) {
                                        removeThrownExceptionHierarchy(thrownException);
                                    }
                                }
                                found = true;
                                break;
                            }
                        }

                        if (!found) {
                            clearExceptions();
                        }
                    } catch (ClassNotFoundException cnfe) {
                        bugReporter.reportMissingClass(cnfe);
                        clearExceptions();
                    }
                } else if ("wait".equals(getNameConstantOperand())) {
                    removeException("java.lang.InterruptedException");
                }
            } else if (seen == Const.ATHROW) {
                if (stack.getStackDepth() > 0) {
                    OpcodeStack.Item item = stack.getStackItem(0);
                    String exSig = item.getSignature();
                    String thrownException = SignatureUtils.stripSignature(exSig);
                    removeThrownExceptionHierarchy(thrownException);
                } else {
                    clearExceptions();
                }
            }
        } finally {
            stack.sawOpcode(this, seen);
        }
    }
978605
function( name, test, startFunc, extra ) {
		var self = this;

		// Require an active state for tests
		self.requireState( munit.ASSERT_STATE_ACTIVE, startFunc || self.ok );

		// Prevent non empty string names
		if ( ! munit.isString( name ) || ! name.length ) {
			throw new munit.AssertionError(
				"Name not found for test on '" + self.nsPath + "'",
				startFunc || self.ok
			);
		}
		// Prevent duplicate tests
		else if ( self.tests[ name ] ) {
			throw new munit.AssertionError(
				"Duplicate Test '" + name + "' on '" + self.nsPath + "'",
				startFunc || self.ok
			);
		}

		// Increment test count and mark it
		self[ !!( test ) ? '_pass' : '_fail' ]( name, startFunc || self.ok, extra );
		
		// Reached expected number of tests, close off
		if ( self.options.expect > 0 && self.count >= self.options.expect ) {
			self.close();
		}

		return self;
	}
1119244
def httprettified(test):
    ""
    def decorate_class(klass):
        for attr in dir(klass):
            if not attr.startswith('test_'):
                continue

            attr_value = getattr(klass, attr)
            if not hasattr(attr_value, "__call__"):
                continue

            setattr(klass, attr, decorate_callable(attr_value))
        return klass

    def decorate_callable(test):
        @functools.wraps(test)
        def wrapper(*args, **kw):
            httpretty.reset()
            httpretty.enable()
            try:
                return test(*args, **kw)
            finally:
                httpretty.disable()
        return wrapper

    if isinstance(test, ClassTypes):
        return decorate_class(test)
    return decorate_callable(test)
1293594
private void check() {
		final Constructor<?> constructor = getConstructor();
		final XParameter[] parameters = getParameters();
		final Class<?>[] parameterTypes = constructor.getParameterTypes();
		Validate.isTrue(parameters.length == parameterTypes.length,
				"Wrong number of parameters: [" + parameters.length
						+ "], expected [" + parameterTypes.length + "].");
		for (int index = 0; index < parameters.length; index++) {
			final XParameter parameter = parameters[index];
			final Class<?> parameterType = parameterTypes[index];
			Validate.isTrue(parameterType.equals(parameter.getType()),
					"Wrong parameter type: [" + parameter.getType()
							+ "], expected [" + parameterType + "]");
		}
	}
148467
function (test) {
    var ret = []
    for (var n = 0; n < batchTest.length; n++) {
      if (batchTest[n] === test) continue
      ret.push(batchTest[n])
    }
    batchTest = ret
  }
459956
def main(): # mini/unit test
    
    options = optionsParser().parse_args()
    params = getSelectionParams(options)
    if options.list or options.details:
        specifiedMaps = filterMapNames(
            options.mapname,
            records = filterMapAttrs(**params),
            excludeRegex=options.exclude,
            closestMatch=options.best
        )
        if specifiedMaps:
            for v in specifiedMaps:
                if options.details: v.display()
                else:               print(v)
            print("Found %d maps that match given criteria."%(len(specifiedMaps)))
        else:
            print("No matching maps found.")
    else:
        try:
            specifiedMaps = selectMap(
                options.mapname,
                excludeName =options.exclude,
                closestMatch=options.best,
                **params)
        except Exception as e:
            specifiedMaps = []
            print("No matching maps found: %s"%e)
        if not isinstance(specifiedMaps, list):
            specifiedMaps = [specifiedMaps]
        for m in specifiedMaps:
            if options.path:    print(m.path)
            else:               print(m.name)
718646
private Matching getMatchingInstance()
  {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
          SibTr.entry(tc, "getMatchingInstance", Boolean.valueOf(unitTestMode));
        Matching result = null;
        if (unitTestMode)
        {
          // In unit test mode, go directly to Matching to get an instance.
          // This avoids the need for MessageProcessor to be initialised.
          try
          {
        result = Matching.getInstance();
          }
          catch(Exception e)
          {
                // No FFDC code needed.
                // This path is possible only in unit test
          }
        }
        else
        {
          result = (Matching) MessageProcessor.getSingletonInstance(
                SIMPConstants.MATCHING_INSTANCE);
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
          SibTr.exit(tc, "getMatchingInstance", result);
        return result;
  }
246855
function () /*:Void*/ {

        if (!this._initialized) {

            /**
             * Fires when loading a test page
             * @event testpagebegin
             * @param curPage {string} the page being loaded
             * @static
             */

            /**
             * Fires when a test page is complete
             * @event testpagecomplete
             * @param obj {page: string, results: object} the name of the
             * page that was loaded, and the test suite results
             * @static
             */

            /**
             * Fires when the test manager starts running all test pages
             * @event testmanagerbegin
             * @static
             */

            /**
             * Fires when the test manager finishes running all test pages.  External
             * test runners should subscribe to this event in order to get the
             * aggregated test results.
             * @event testmanagercomplete
             * @param obj { pages_passed: int, pages_failed: int, tests_passed: int
             *              tests_failed: int, passed: string[], failed: string[],
             *              page_results: {} }
             * @static
             */

            //create iframe if not already available
            if (!this._frame){
                var frame /*:HTMLElement*/ = document.createElement("iframe");
                frame.style.visibility = "hidden";
                frame.style.position = "absolute";
                document.body.appendChild(frame);
                this._frame = frame.contentWindow || frame.contentDocument.parentWindow;
            }

            this._initialized = true;
        }


        // reset the results cache
        this._results = {

            passed: 0,
            failed: 0,
            ignored: 0,
            total: 0,
            type: "report",
            name: "YUI Test Results",
            duration: 0,
            failedPages:[],
            passedPages:[]
            /*
            // number of pages that pass
            pages_passed: 0,
            // number of pages that fail
            pages_failed: 0,
            // total number of tests passed
            tests_passed: 0,
            // total number of tests failed
            tests_failed: 0,
            // array of pages that passed
            passed: [],
            // array of pages that failed
            failed: [],
            // map of full results for each page
            page_results: {}*/
        };

        this.fire(this.TEST_MANAGER_BEGIN_EVENT, null);
        this._run();

    }
262179
public static Boolean exists(
            EvaluationContext ctx,
            Object tests,
            Object target) {

        if (!(tests instanceof List)) {
            if (tests == null) {
                ctx.notifyEvt(() -> new ASTEventBase(FEELEvent.Severity.ERROR, Msg.createMessage(Msg.IS_NULL, "value"), null));
                return null;
            }
            return applyUnaryTest(ctx, tests, target);
        }

        for (Object test : (List) tests) {
            Boolean r = applyUnaryTest(ctx, test, target);
            if (Boolean.TRUE.equals(r)) {
                return true;
            }
        }

        return false;
    }
168780
public static void checkUnusedParameters(SQLiteModelMethod method, Set<String> usedMethodParameters, TypeName excludedClasses) {
		int paramsCount = method.getParameters().size();
		int usedCount = usedMethodParameters.size();

		if (paramsCount > usedCount) {
			StringBuilder sb = new StringBuilder();
			String separator = "";
			for (Pair<String, TypeName> item : method.getParameters()) {
				if (excludedClasses != null && item.value1.equals(excludedClasses)) {
					usedCount++;
				} else {
					if (!usedMethodParameters.contains(item.value0)) {
						sb.append(separator + "'" + item.value0 + "'");
						separator = ", ";
					}
				}
			}

			if (paramsCount > usedCount) {
				throw (new InvalidMethodSignException(method, "unused parameter(s) " + sb.toString()));
			}
		}
	}