used in unittests
199751
def get(self, start, end):
        
        return [self.read_byte(addr) for addr in xrange(start, end)]
860809
function UnitCode(unitCode) {
	switch (typeof unitCode) {
	case "string":
		unitCode = parseInt(unitCode, 10);
		if (unitCode || unitCode === 0) {
			var index = unitCode - 1;
			if ((index >= 0) && (index <= (deviceCodes.length - 1))) {
				this.raw = deviceCodes[index];
			} else {
				throw new Error("Unit code string out of range.");
			}
		} else {
			throw new Error("Invalid unit code.");
		}
		break;
	default:
		if (deviceCodes.indexOf(unitCode) !== -1) {
			this.raw = unitCode;
		} else {
			throw new Error("Unit code number out of range.");
		}
		break;
	}
	return this.raw;
}
351853
function(tc) {
            var t = this;
            var output = '';
            if (tc.getResult() != TestCase.UNTESTED) {

                output += '        <testcase name="' + encode(tc.getName()) + '"'
                    + ' time="' + (tc.getDuration() / 1000) + '">\n';

                if (tc.getResult() == TestCase.SKIPPED) {
                    output += '            <skipped></skipped>\n';
                }

                tc.getAssertions().forEach(
                    function(assertion) {
                        output += t.getAssertion(assertion);
                    }
                );

                var ge = tc.getGeneralError();
                if (ge) {
                    output += t.getError(ge);
                }

                output += '        </testcase>\n';
            }
            return output;
        }
324602
@SuppressWarnings("rawtypes")
	@Override
	public Iterable<Class<?>> getSuites() {
		TestsToRun scanned = scanResult.applyFilter(new PowerUnitProviderScannerFilter(parameters), testClassLoader);
		return runOrderCalculator.orderTestClasses(scanned);
	}
1326210
function(sControlName, aControlsToTest, aExcludedControls, bIncludeNonRenderable, bIncludeNonInstantiable) {
		if (!sControlName) {
			return false;
		}

		if (aControlsToTest.length) { // only test specific controls
			if (aControlsToTest.indexOf(sControlName) === -1) { // not one of the chosen ones
				return false;
			}
		} else if (aExcludedControls.indexOf(sControlName) > -1) {
			return false;
		}

		if (!bIncludeNonRenderable && !ControlIterator.controlCanBeRendered(sControlName)) {
			return false;
		}

		if (!bIncludeNonInstantiable && !ControlIterator.controlCanBeInstantiated(sControlName)) {
			return false;
		}

		return true;
	}
479612
function() {
      for (var i = 0; i < JSLitmus._tests.length; i++)
        JSLitmus.renderTest(JSLitmus._tests[i]);
      JSLitmus.renderChart();
    }
868104
private Iterator<Tuple> getSatisfyingTuples( final TestCaseDef testCase, VarTupleSet varTupleSet)
    {
    final Comparator<VarBindingDef> byUsage = byUsage( varTupleSet);

    return
      IteratorUtils.transformedIterator(
        // Iterate over all combinations of bindings...
        new CartesianProduct<VarBindingDef>(

          // ...combining members from all sets of bindings...
          new ArrayList<Set<VarBindingDef>>(
            CollectionUtils.collect(
              // ...where each set of bindings is derived from a disjunct of unsatisfied test case conditions....
              testCase.getRequired().getDisjuncts(),

              // ...and contains the set of compatible bindings that could satisfy this disjunct...
              disjunct ->
                {
                Set<String> unsatisfied =
                  CollectionUtils.collect(
                    disjunct.getAssertions(),
                    assertion -> assertion.getProperty(),
                    new HashSet<String>());

                Iterator<VarBindingDef> satisfyingBindings =
                  IteratorUtils.filteredIterator(
                    getPropertyProviders( unsatisfied).iterator(),
                    binding -> testCase.isCompatible( binding));

                // ...arranging satisfying bindings in order of decreasing preference...
                return
                  CollectionUtils.collect(
                    satisfyingBindings,
                    nopTransformer(),
                    new TreeSet<VarBindingDef>( byUsage));
                },

              // ...arranging sets in a well-defined order for repeatable combinations...
              new TreeSet<Set<VarBindingDef>>( varBindingSetSorter_))),
          
          // ...ignoring any infeasible combinations...
          bindings -> Tuple.of( bindings) != null),
        
         // ... forming each combination of satisfying bindings into a tuple...
        Tuple::of);
    }
1234841
def addError(self, test: unittest.case.TestCase, exc_info: tuple) -> None:
        
        # noinspection PyTypeChecker
        self.add_result(TestState.error, test, exc_info)
28725
public Object getExact(SimpleTest test) {
    for (int i = 0; i < size; i++) {
      if (ranges[i].correspondsTo(test))
        return ranges[i].target;
    }
    return null;
  }
1170648
function(oUnitTest) {
          var _,
              /**
               * An array-like object representing the <abbr title=
               * "abstract syntax tree">AST</abbr> obtained after consolidation.
               * @type {!TSyntacticCodeUnit}
               */
              oSyntacticCodeUnitActual =
                  exports.ast_consolidate(oParser.parse(oUnitTest.sInput)),
              /**
               * An array-like object representing the expected <abbr title=
               * "abstract syntax tree">AST</abbr>.
               * @type {!TSyntacticCodeUnit}
               */
              oSyntacticCodeUnitExpected = oParser.parse(
                  oUnitTest.hasOwnProperty('sOutput') ?
                  oUnitTest.sOutput : oUnitTest.sInput);

          delete oSyntacticCodeUnitActual.scope;
          oWalker = oProcessor.ast_walker();
          oWalker.with_walkers(
              oWalkersPurifiers,
              cContext(oWalker, oSyntacticCodeUnitActual));
          try {
            oAssert.deepEqual(
                oSyntacticCodeUnitActual,
                oSyntacticCodeUnitExpected);
          } catch (oException) {
            console.error(
                '########## A unit test has failed.\n' +
                oUnitTest.sTitle + '\n' +
                '#####  actual code  (' +
                oProcessor.gen_code(oSyntacticCodeUnitActual).length +
                ' bytes)\n' +
                oProcessor.gen_code(
                    oSyntacticCodeUnitActual,
                    oCodeGenerationOptions) + '\n' +
                '##### expected code (' +
                oProcessor.gen_code(oSyntacticCodeUnitExpected).length +
                ' bytes)\n' +
                oProcessor.gen_code(
                    oSyntacticCodeUnitExpected,
                    oCodeGenerationOptions));
          }
        }
436156
def addSuccess(self, test: unittest.case.TestCase) -> None:
        
        # noinspection PyTypeChecker
        self.add_result(TestState.success, test)
182704
private List<TestCaseDef> getFailureCases( FunctionInputDef inputDef, VarTupleSet failureTuples, VarTupleSet validTuples)
    {
    logger_.debug( "{}: Creating failure test cases", inputDef);
    
    List<TestCaseDef> failureCases = new ArrayList<TestCaseDef>();

    // For each failure input tuple not yet used in a test case...
    Tuple nextUnused;
    while( (nextUnused = failureTuples.getNextUnused()) != null)
      {
      // Completed bindings for all variables?
      TestCaseDef failureCase = createTestCase( nextUnused, inputDef, validTuples);
      if( failureCase != null)
        {
        // Yes, add new failure test case.
        failureTuples.used( nextUnused);
        failureCases.add( failureCase);
        }
      }

    logger_.info( "{}: Created {} failure test cases", inputDef, failureCases.size());
    return failureCases;
    }
1279082
private void generateTCBasedData(List<TestCaseResult> allTestsList) {
        logger.entering(allTestsList);
        SummarizedData tempClass;
        SummarizedData tempGroupClass;
        Map<String, SummarizedData> mpClassData = new HashMap<String, SummarizedData>();
        int outputSheetRowCounter = 3;

        for (TestCaseResult tcResult : allTestsList) {

            // Segregating for class data
            String sTempClassName = tcResult.getClassName();

            // If class not already added to Class data, then create new ClassObject exists
            if (!mpClassData.containsKey(sTempClassName)) {
                tempClass = new SummarizedData();
                tempClass.setsName(sTempClassName);

            } else {
                tempClass = mpClassData.get(sTempClassName);
            }

            // Adding test to total count
            tempClass.incrementiTotal();

            // Adding all groups to map
            for (String sGroup : tcResult.getGroup()) {

                // Forming a key for the GroupClass map which is <GroupName><ClassName>
                String sGroupClassName = sGroup + sTempClassName;
                if (!mpGroupClassData.containsKey(sGroupClassName)) {
                    tempGroupClass = new SummarizedData();
                    tempGroupClass.setsName(sTempClassName);
                } else {
                    tempGroupClass = mpGroupClassData.get(sGroupClassName);
                }

                tempGroupClass.incrementiTotal();
                tempGroupClass.incrementCount(tcResult.getStatus());
                tempGroupClass.incrementDuration(tcResult.getDurationTaken());
                mpGroupClassData.put(sGroupClassName, tempGroupClass);
            }

            // Segregating for detailed Testcase Status wise data
            List<String> str = new ArrayList<String>();
            str.add(tcResult.getClassName());
            str.add(tcResult.getMethodName());
            str.add(tcResult.getTestDesc());
            str.add(tcResult.getGroup().toString());
            str.add(String.valueOf(tcResult.getDurationTaken()));
            str.add("'" + ReportSheetNames.TESTOUTPUTDETAILSREPORT.getName() + "'!B"
                    + Integer.toString(outputSheetRowCounter));

            List<String> outputStr = new ArrayList<String>();
            outputStr.add("Class Name:" + tcResult.getClassName());
            outputStr.add("Method/Testcase id:" + tcResult.getMethodName());
            outputStr.addAll(tcResult.getssmsg());

            // Based on status, incrementing class count and adding str to correct
            // list for TC detailed report
            switch (tcResult.getStatus()) {
                case ITestResult.FAILURE: {
                    tcFailedData.add(str);
                    // For failed cases adding data for defect description sheet
                    for (int iErrorCount = 0; iErrorCount < tcResult.getError().size(); iErrorCount++) {
                        List<String> tmpList = new ArrayList<String>();
                        tmpList.addAll(0, str);
                        tmpList.add(tcResult.getDefect().get(iErrorCount));
                        tmpList.add(tcResult.getError().get(iErrorCount));
                        outputStr.add("Stacktrace:" + tcResult.getError().get(iErrorCount));
                        tcDefectData.add(tmpList);
                    }
                    break;
                }
                case ITestResult.SUCCESS: {
                    tcPassedData.add(str);
                    break;
                }
                case ITestResult.SKIP: {
                    tcSkippedData.add(str);
                    break;
                }
                default: {
                    break;
                }
            }
            tcOutputData.add(outputStr);
            outputSheetRowCounter = outputSheetRowCounter + 1 + outputStr.size();

            tempClass.incrementCount(tcResult.getStatus());
            // Add to the total runtime of the class
            tempClass.setlRuntime(tempClass.getlRuntime() + tcResult.getDurationTaken());
            mpClassData.put(sTempClassName, tempClass);
        }
        lClasses.addAll(mpClassData.values());
        Collections.sort(lClasses);
        logger.exiting();
    }
1127911
private CodeableConcept makeUnits(String text, String ucum) {
		if (Utilities.noString(text) && Utilities.noString(ucum))
			return null;
		CodeableConcept cc = new CodeableConcept();
		cc.setText(text);
		cc.getCoding().add(new Coding().setCode(ucum).setSystem("http://unitsofmeasure.org"));
		return cc;
	}
996347
def lookup_sig(cls, sigs, method_name, expr_args, stmt_or_expr, context):
        

        def synonymise(s):
            return s.replace('int128', 'num').replace('uint256', 'num')

        # for sig in sigs['self']
        full_sig = cls.get_full_sig(
            stmt_or_expr.func.attr,
            expr_args,
            None,
            context.custom_units,
            context.structs,
            context.constants,
        )
        method_names_dict = dict(Counter([x.split('(')[0] for x in context.sigs['self']]))
        if method_name not in method_names_dict:
            raise FunctionDeclarationException(
                "Function not declared yet (reminder: functions cannot "
                "call functions later in code than themselves): %s" % method_name
            )

        if method_names_dict[method_name] == 1:
            return next(
                sig
                for name, sig
                in context.sigs['self'].items()
                if name.split('(')[0] == method_name
            )
        if full_sig in context.sigs['self']:
            return context.sigs['self'][full_sig]
        else:
            synonym_sig = synonymise(full_sig)
            syn_sigs_test = [synonymise(k) for k in context.sigs.keys()]
            if len(syn_sigs_test) != len(set(syn_sigs_test)):
                raise Exception(
                    'Incompatible default parameter signature,'
                    'can not tell the number type of literal', stmt_or_expr
                )
            synonym_sigs = [(synonymise(k), v) for k, v in context.sigs['self'].items()]
            ssig = [s[1] for s in synonym_sigs if s[0] == synonym_sig]
            if len(ssig) == 0:
                raise FunctionDeclarationException(
                    "Function not declared yet (reminder: functions cannot "
                    "call functions later in code than themselves): %s" % method_name
                )
            return ssig[0]
1246039
def inspect
      expr = @expr || @unit.expr
      expr = (expr) ? ","+expr.inspect : ""
      sufx = (@@verbose_inspect) ? " "+@unit.inspect : ""
      self.class.to_s+"["+Unit::Utils.num_inspect(@value)+expr+"]"+sufx
    end
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)