/* package for unit tests
16271
static Map<String, Object> sumOfDelta(Map<String, Object> state, Map<String, Object> delta) {
        InstanceKey instanceId = (InstanceKey) delta.get("InstanceKey");
        if (instanceId == null) {
            throw new RuntimeException("InstanceKey can not be null");
        }
        for (String key : delta.keySet()) {
            Object existing = state.get(key);
            Object current = delta.get(key);
            if (current instanceof Number) {
                if (existing == null) {
                    existing = 0;
                }
                Number v = (Number) existing;
                Number d = (Number) delta.get(key);
                state.put(key, v.longValue() + d.longValue());
            } else if (current instanceof NumberList) {
                if (existing == null) {
                    state.put(key, current);
                } else {
                    state.put(key, ((NumberList) existing).sum((NumberList) current));
                }
            } else {
                Object o = delta.get(key);
                if (o instanceof String[]) {
                    String[] vs = (String[]) o;
                    if (vs.length == 1) {
                        Object previousAggregateString = state.get(key);
                        if (previousAggregateString instanceof AggregateString) {
                            state.put(key, ((AggregateString) previousAggregateString).update(null, vs[0], instanceId));
                        } else {
                            state.put(key, AggregateString.create(vs[0], instanceId));
                        }
                    } else {
                        // it should always be AggregateString here since that's all we add above
                        AggregateString pas = (AggregateString) state.get(key);
                        state.put(key, pas.update(vs[0], vs[1], instanceId));
                    }
                } else {
                    state.put(key, String.valueOf(o));
                }

            }
        }
        return state;
    }
111231
async function getInvalidPackages() {
  const packages = (await new Project(__dirname).getPackages())
    .filter(p => p.scripts.build) // Only packages that have a build target
    .filter(p => isPf3
      ? p.location.indexOf('patternfly-3') !== -1 || commonPackages.indexOf(p.name) !== -1
      : true) // Based off argv
    .filter(p => isPf4
      ? p.location.indexOf('patternfly-4') !== -1 || commonPackages.indexOf(p.name) !== -1
      : true) // Based off argv

  for (let p of packages) {
    const watchDir = getDir(p.name);
    p.hash = (await hashElement(`${p.location}/${watchDir}`)).hash;
    p.valid = cache && cache[p.name] === p.hash;
    if (p.valid) {
      console.info('Skipping', p.name, '(already built).');
    }
  }

  return packages.filter(p => !p.valid);
}
767704
function generateStepMap( $package, &$persistentData )
    {
        $steps = $this->attribute( 'steps' );
        $map = array();
        $lastStep = false;
        $currentSteps = array();
        for ( $i = 0; $i < count( $steps ); ++$i )
        {
            $step =& $steps[$i];
            if ( !isset( $step['previous_step'] ) )
            {
                if ( $lastStep )
                    $step['previous_step'] = $lastStep['id'];
                else
                    $step['previous_step'] = false;
            }
            if ( !isset( $step['next_step'] ) )
            {
                if ( $i + 1 < count( $steps ) )
                    $step['next_step'] = $steps[$i+1]['id'];
                else
                    $step['next_step'] = false;
            }
            if ( isset( $step['methods']['initialize'] ) )
                $this->InitializeStepMethodMap[$step['id']] = $step['methods']['initialize'];
            if( isset( $step['methods']['load'] ) )
                $this->LoadStepMethodMap[$step['id']] = $step['methods']['load'];
            if ( isset( $step['methods']['validate'] ) )
                $this->ValidateStepMethodMap[$step['id']] = $step['methods']['validate'];
            if ( isset( $step['methods']['commit'] ) )
                $this->CommitStepMethodMap[$step['id']] = $step['methods']['commit'];
            $isStepIncluded = true;
            if ( isset( $step['methods']['check'] ) )
            {
                $checkMethod = $step['methods']['check'];
                $isStepIncluded = $this->$checkMethod( $package, $persistentData );
            }
            if ( $isStepIncluded )
            {
                $map[$step['id']] =& $step;
                $lastStep =& $step;
                $currentSteps[] =& $step;
            }
        }
        $this->StepMap = array( 'first' => &$steps[0],
                                'map' => &$map,
                                'steps' => &$steps );
        $this->Attributes['step_map'] =& $this->StepMap;
        $this->Attributes['current_steps'] = $currentSteps;
    }
763675
function validateObjectLimits( $package, $http, $currentStepID, &$stepMap, &$persistentData, &$errorList )
    {
        $options =& $persistentData['object_options'];

        $options['include_classes'] = $http->hasPostVariable( 'IncludeClasses' ) ? $http->postVariable( 'IncludeClasses' ) : false;
        $options['include_templates'] = $http->hasPostVariable( 'IncludeTemplates' ) ? $http->postVariable( 'IncludeTemplates' ) : false;
        $options['site_access_array'] = $http->postVariable( 'SiteAccesses' );
        $options['versions'] = $http->postVariable( 'VersionExport' );
        $options['language_array'] = $http->postVariable( 'Languages' );
        $options['node_assignment'] = $http->postVariable( 'NodeAssignment' );
        $options['related_objects'] = $http->postVariable( 'RelatedObjects' );
        $options['minimal_template_set'] = $http->hasPostVariable( 'MinimalTemplateSet' ) ? $http->postVariable( 'MinimalTemplateSet' ) : false;

        $result = true;
        if ( count( $persistentData['object_options']['language_array'] ) == 0 )
        {
            $errorList[] = array( 'field' => ezpI18n::tr( 'kernel/package', 'Selected nodes' ),
                                  'description' => ezpI18n::tr( 'kernel/package', 'You must choose one or more languages.' ) );
            $result = false;
        }

        if ( $persistentData['object_options']['include_templates'] &&
             count( $persistentData['object_options']['site_access_array'] ) == 0 )
        {
            $errorList[] = array( 'field' => ezpI18n::tr( 'kernel/package', 'Selected nodes' ),
                                  'description' => ezpI18n::tr( 'kernel/package', 'You must choose one or more site access.' ) );
            $result = false;
        }

        return $result;
    }
1055236
function SpecXUnitFile(runner) {
  var spec = new Spec(runner);
  Base.call(this, runner);
  var stats = this.stats
    , tests = []
    , self = this;
  runner.on('suite', function(suite){
    if(consoleOutput.suite){
      console.log('  ' + suite.title);
    }
  });

  runner.on('test', function(test){
    if(consoleOutput.test){
      console.log('  ◦ ' + test.title);
    }
  });

  runner.on('pass', function(test){
    tests.push(test);
  });

  runner.on('fail', function(test){
    if(consoleOutput.fail){
      console.log('  - ' + test.title);
    }
    tests.push(test);
  });

  runner.on('pending', function(test) {
    tests.push(test);
  });

  runner.on('end', function(){

    var filePath = process.env.XUNIT_FILE || config.file || process.cwd() + "/xunit.xml"
      , fd = fs.openSync(filePath, 'w', 0755)
      ;
    appendLine(fd, writeTag('testsuite', {
      name: 'Mocha Tests'
      , tests: stats.tests
      , failures: stats.failures
      , errors: stats.failures
      , skipped: stats.tests - stats.failures - stats.passes
      , timestamp: (new Date()).toUTCString()
      , time: stats.duration / 1000
    }, false));

    tests.forEach(function(test){
      writeTest(fd, test);

    });
    appendLine(fd, '</testsuite>');
    fs.closeSync(fd);
  });

}
240079
function(testPath) {
    var testStartTime = +new Date();

    var waitForTest = function(resolve, reject) {
      // executeScript runs the passed method in the "window" context of
      // the current test. JSUnit exposes hooks into the test's status through
      // the "G_testRunner" global object.
      browser
          .executeScript(function() {
            if (window['G_testRunner'] &&
                window['G_testRunner']['isFinished']()) {
              var status = {};
              status['isFinished'] = true;
              status['isSuccess'] = window['G_testRunner']['isSuccess']();
              status['report'] = window['G_testRunner']['getReport']();
              return status;
            } else {
              return {'isFinished': false};
            }
          })
          .then(
              function(status) {
                if (status && status.isFinished) {
                  resolve(status);
                } else {
                  var currTime = +new Date();
                  if (currTime - testStartTime > TEST_TIMEOUT) {
                    status.isSuccess = false;
                    status.report = testPath + ' timed out after ' +
                        (TEST_TIMEOUT / 1000) + 's!';
                    // resolve so tests continue running.
                    resolve(status);
                  } else {
                    // Check every 300ms for completion.
                    setTimeout(
                        waitForTest.bind(undefined, resolve, reject), 300);
                  }
                }
              },
              function(err) {
                reject(err);
              });
    };

    return new Promise(function(resolve, reject) {
      waitForTest(resolve, reject);
    });
  }
1280658
function mockServer(app) {
        const jsonRouter = jsonServer.router(db);

        const shouldMockReq = req => {
          return (
            req.method !== "GET" ||
            (req.headers.accept &&
              req.headers.accept.indexOf("application/json") !== -1)
          );
        };

        if (serverOpts.delay) {
          app.use((req, res, next) => {
            if (shouldMockReq(req)) {
              return pause(serverOpts.delay)(req, res, next);
            }
            return next();
          });
        }

        app.use(jsonServer.rewriter(rewrites));

        // user defined routers
        app.use(jsonServer.bodyParser);

        // user query normalizr
        app.use((req, res, next) => {
          if (shouldMockReq(req)) {
            req.query = toJsonServer(req.query);
            return next();
          }
          return next();
        });

        routers.forEach(router => app.use(router));

        // json server router
        app.use((req, res, next) => {
          if (shouldMockReq(req)) {
            return jsonRouter(req, res, next);
          }
          return next();
        });

        return app;
      }
1319889
private MethodSpec generateContentValuesMethod(ObjectMappableAnnotatedClass clazz,
      String mapperClassName, String className) {

    ClassName typeName = ClassName.get(getPackageName(clazz), mapperClassName, className);

    return MethodSpec.methodBuilder("contentValues")
        .addJavadoc("Get a typesafe ContentValues Builder \n")
        .addJavadoc("@return The ContentValues Builder \n")
        .addModifiers(Modifier.PUBLIC, Modifier.STATIC)
        .returns(typeName)
        .addStatement("return new $T()", typeName)
        .build();
  }
550053
function helpCli() {
	console.log('');
	console.log('usage: node <script> [--version] [--help] <command> [<args>]');
	console.log('usage with demo: node demo/index.js [--version] [--help] <command> [<args>]');
	console.log('');
	console.log('node-mock-server commands:');
	console.log('    --version            print node-mock-server version');
	console.log('    swagger-import       run a swagger import');
	console.log('    validate             run a validation for all mock data');
	console.log('    collections          lists all available collections');
	console.log('    collections <id>     activate collection');
	console.log('');
}
295429
function buildArgs(sonarOptions, data) {
            // Default arguments
            var args = [
                '-Dsonar.sources=src',
                '-Dsonar.tests=test',
                '-Dsonar.javascript.jstestdriver.reportsPath=results',
                '-Dsonar.genericcoverage.unitTestReportPaths=' + 'results' + path.sep + 'TESTS-junit.xml',
                '-Dsonar.javascript.jstestdriver.itReportsPath=results',
                '-Dsonar.javascript.lcov.reportPaths=' + 'results' + path.sep + 'coverage_report.lcov' + ',' + 'results' + path.sep + 'it_coverage_report.lcov',
                '-Dsonar.javascript.lcov.reportPath=' + 'results' + path.sep + 'coverage_report.lcov',
                '-Dsonar.javascript.lcov.itReportPath=' + 'results' + path.sep + 'it_coverage_report.lcov'
            ];

            // Add the parameter (-D) only when the 'key' exists in the 'object'
            function addParameter(prop, object, key) {
                var value = _.result(object, key);
                if (value !== undefined && value !== null && sonarOptions.excludedProperties.indexOf(prop) === -1) {
                    args.push('-D' + prop + '=' + value);
                }
            }

            addParameter('sonar.host.url', sonarOptions.instance, 'hostUrl');
            addParameter('sonar.jdbc.url', sonarOptions.instance, 'jdbcUrl');
            addParameter('sonar.jdbc.username', sonarOptions.instance, 'jdbcUsername');
            addParameter('sonar.jdbc.password', sonarOptions.instance, 'jdbcPassword');
            addParameter('sonar.login', sonarOptions.instance, 'login');
            addParameter('sonar.password', sonarOptions.instance, 'password');

            addParameter('sonar.sourceEncoding', sonarOptions, 'sourceEncoding');
            addParameter('sonar.language', sonarOptions, 'language');
            addParameter('sonar.dynamicAnalysis', sonarOptions, 'dynamicAnalysis');
            addParameter('sonar.projectBaseDir', sonarOptions, 'defaultOutputDir');
            addParameter('sonar.scm.disabled', sonarOptions, 'scmDisabled');

            addParameter('sonar.projectKey', data.project, 'key');
            addParameter('sonar.projectName', data.project, 'name');
            addParameter('sonar.projectVersion', data.project, 'version');

            addParameter('sonar.exclusions', data, 'exclusions');
            return args;
        }
1124721
private List<String> listCompiledClassesRegex(File classFolder) {
        List<String> classNames = new ArrayList<String>();

        Stack<File> todo = new Stack<File>();
        todo.push(classFolder);
        String classFolderPath = classFolder.getAbsolutePath();
        getLog().info("ClassFolderPath=" + classFolderPath);

        Pattern pat = Pattern.compile(classFolderPath + File.separator + "(.*).class");
        File workDir;
        String name;
        while (!todo.isEmpty()) {
            workDir = todo.pop();
            for (File file : workDir.listFiles()) {
                if (file.isDirectory()) {
                    todo.push(file);
                } else {
                    if (file.getName().endsWith(".class")) {
                        name = file.getAbsolutePath();
                        name = pat.matcher(name).group(1);
                        name = name.replace(File.separator, ".");
                        getLog().debug("Found class: " + name);
                        classNames.add(name);
                    }
                }
            }

        }
        return classNames;
    }
768485
function (test) {
                const bits = QRUtil.getBCHTypeNumber(_typeNumber);

                for (var i = 0; i < 18; i += 1) {
                    var mod = (!test && ((bits >> i) & 1) == 1);
                    /** @type {(boolean|null)[][]} */
                    (_modules)[Math.floor(i / 3)][i % 3 + _moduleCount - 8 - 3] = mod;
                }

                for (var i = 0; i < 18; i += 1) {
                    var mod = (!test && ((bits >> i) & 1) == 1);
                    /** @type {(boolean|null)[][]} */
                    (_modules)[i % 3 + _moduleCount - 8 - 3][Math.floor(i / 3)] = mod;
                }
            }
863409
function( name, testEnvironment, executeNow ) {
		var module, moduleFns;
		var currentModule = config.currentModule;

		if ( arguments.length === 2 ) {
			if ( objectType( testEnvironment ) === "function" ) {
				executeNow = testEnvironment;
				testEnvironment = undefined;
			}
		}

		module = createModule();

		if ( testEnvironment && ( testEnvironment.setup || testEnvironment.teardown ) ) {
			console.warn(
				"Module's `setup` and `teardown` are not hooks anymore on QUnit 2.0, use " +
				"`beforeEach` and `afterEach` instead\n" +
				"Details in our upgrade guide at https://qunitjs.com/upgrade-guide-2.x/"
			);
		}

		moduleFns = {
			before: setHook( module, "before" ),
			beforeEach: setHook( module, "beforeEach" ),
			afterEach: setHook( module, "afterEach" ),
			after: setHook( module, "after" )
		};

		if ( objectType( executeNow ) === "function" ) {
			config.moduleStack.push( module );
			setCurrentModule( module );
			executeNow.call( module.testEnvironment, moduleFns );
			config.moduleStack.pop();
			module = module.parentModule || currentModule;
		}

		setCurrentModule( module );

		function createModule() {
			var parentModule = config.moduleStack.length ?
				config.moduleStack.slice( -1 )[ 0 ] : null;
			var moduleName = parentModule !== null ?
				[ parentModule.name, name ].join( " > " ) : name;
			var module = {
				name: moduleName,
				parentModule: parentModule,
				tests: [],
				moduleId: generateHash( moduleName ),
				testsRun: 0
			};

			var env = {};
			if ( parentModule ) {
				parentModule.childModule = module;
				extend( env, parentModule.testEnvironment );
				delete env.beforeEach;
				delete env.afterEach;
			}
			extend( env, testEnvironment );
			module.testEnvironment = env;

			config.modules.push( module );
			return module;
		}

		function setCurrentModule( module ) {
			config.currentModule = module;
		}

	}
183110
public ReturnCode doPackage() {
        boolean isClient = bootProps.getProcessType() == BootstrapConstants.LOC_PROCESS_TYPE_CLIENT;
        if (isClient) {
            System.out.println(MessageFormat.format(BootstrapConstants.messages.getString("info.clientPackaging"), serverName));
        } else {
            System.out.println(MessageFormat.format(BootstrapConstants.messages.getString("info.serverPackaging"), serverName));
        }

        // Use initialized bootstrap configuration to find the server lock file.
        ServerLock serverLock = ServerLock.createServerLock(bootProps);

        ReturnCode packageRc = ReturnCode.PACKAGE_ACTION;

        // create timestamp
        SimpleDateFormat sdf = new SimpleDateFormat("yy.MM.dd_HH.mm.ss");
        Date date = new Date();
        String packageTimestamp = sdf.format(date);

        File archive = null;
        if (serverLock.testServerRunning()) {
            packageRc = ReturnCode.SERVER_ACTIVE_STATUS;
        } else {
            archive = getArchive(serverName, new File(serverOutputDir));

            if (archive == null) {
                System.out.println(MessageFormat.format(BootstrapConstants.messages.getString("error.package.extension"), serverName));
                return ReturnCode.ERROR_SERVER_PACKAGE;
            }

            //generate package txt
            File packageInfoFile = new File(serverOutputDir, BootstrapConstants.SERVER_PACKAGE_INFO_FILE_PREFIX + packageTimestamp + ".txt");
            generatePackageInfo(packageInfoFile, serverName, date);

            packageRc = packageServerRuntime(archive, false);

            //clean up package txt
            FileUtils.recursiveClean(packageInfoFile);
        }

        if (isClient) {
            if (packageRc == ReturnCode.OK) {
                System.out.println(MessageFormat.format(BootstrapConstants.messages.getString("info.clientPackageComplete"), serverName, archive.getAbsolutePath()));
            } else if (packageRc == ReturnCode.SERVER_ACTIVE_STATUS) {
                System.out.println(MessageFormat.format(BootstrapConstants.messages.getString("info.clientIsRunning"), serverName));
                System.out.println(MessageFormat.format(BootstrapConstants.messages.getString("info.clientPackageUnreachable"), serverName));
            } else {
                System.out.println(MessageFormat.format(BootstrapConstants.messages.getString("info.clientPackageException"), serverName));
            }
        } else {
            if (packageRc == ReturnCode.OK) {
                System.out.println(MessageFormat.format(BootstrapConstants.messages.getString("info.serverPackageComplete"), serverName, archive.getAbsolutePath()));
            } else if (packageRc == ReturnCode.SERVER_ACTIVE_STATUS) {
                System.out.println(MessageFormat.format(BootstrapConstants.messages.getString("info.serverIsRunning"), serverName));
                System.out.println(MessageFormat.format(BootstrapConstants.messages.getString("info.serverPackageUnreachable"), serverName));
            } else {
                System.out.println(MessageFormat.format(BootstrapConstants.messages.getString("info.serverPackageException"), serverName));
            }
        }

        return packageRc;
    }
631319
function( ns ) {
		munit.each( ns, function( assert, name ) {
			if ( render.focusPath( assert.nsPath ) ) {
				munit.tests.push( assert );
			}
			else {
				assert.trigger();
			}

			// Traverse down the module tree
			render._renderNS( assert.ns );
		});

		return munit.tests;
	}
522615
public static void typeCheck(INode classdef, Interpreter interpreter,
			CallSequence test, Environment outer) throws AnalysisException,
			Exception
	{
		FlatEnvironment env = null;

		if (classdef instanceof SClassDefinition)
		{
			env = new FlatEnvironment(interpreter.getAssistantFactory(), classdef.apply(interpreter.getAssistantFactory().getSelfDefinitionFinder()), outer);
		} else
		{
			List<PDefinition> defs = new Vector<>();
			
			if(classdef instanceof AModuleModules)
			{
				defs.addAll(((AModuleModules) classdef).getDefs());
			}
			
			env = new FlatEnvironment(interpreter.getAssistantFactory(), defs, outer);
		}

		for (int i = 0; i < test.size(); i++)
		{
			PStm statement = test.get(i);

			if (statement instanceof TraceVariableStatement)
			{
				((TraceVariableStatement) statement).typeCheck(env, NameScope.NAMESANDSTATE);
			} else
			{
				statement = statement.clone();
				test.set(i, statement);
				interpreter.typeCheck(statement, env);
			}
		}
	}
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));
          }
        }