Little test program
767887
public static void main(String[] argv) throws IOException {
    final File outputDir = new File(argv[0]);

    final Random rand = new Random();
    final double mean1 = 5.0;
    final double mean2 = 7.0;
    final double dev1 = 2.0;
    final double dev2 = 4.0;

    final double[] data1 = new double[100];
    final double[] data2 = new double[100];

    for (int i = 0; i < 100; ++i) {
      data1[i] = rand.nextGaussian() * dev1 + mean1;
      data2[i] = rand.nextGaussian() * dev2 + mean2;
    }

    BoxPlot.builder()
        .addDataset(Dataset.createAdoptingData("A", data1))
        .addDataset(Dataset.createAdoptingData("B", data2))
        .setTitle("A vs B")
        .setXAxis(Axis.xAxis().setLabel("FooCategory").build())
        .setYAxis(Axis.yAxis().setLabel("FooValue").setRange(Range.closed(0.0, 15.0)).build())
        .hideKey()
        .build().renderToEmptyDirectory(outputDir);
  }
1199676
def setup(interactive, not_relative, dry_run, reset, root_dir, testuser):
    """"""

    click.echo("[cellpy] (setup)")

    # generate variables
    init_filename = create_custom_init_filename()
    userdir, dst_file = get_user_dir_and_dst(init_filename)

    if testuser:
        if not root_dir:
            root_dir = os.getcwd()

        click.echo(f"[cellpy] (setup) DEV-MODE testuser: {testuser}")
        init_filename = create_custom_init_filename(testuser)
        userdir = root_dir
        dst_file = get_dst_file(userdir, init_filename)
        click.echo(f"[cellpy] (setup) DEV-MODE userdir: {userdir}")
        click.echo(f"[cellpy] (setup) DEV-MODE dst_file: {dst_file}")

    if not pathlib.Path(dst_file).is_file():
        reset = True

    if interactive:
        click.echo(" interactive mode ".center(80, "-"))
        _update_paths(root_dir, not not_relative, dry_run=dry_run, reset=reset)
        _write_config_file(
            userdir, dst_file,
            init_filename, dry_run,
        )
        _check()

    else:
        _write_config_file(userdir, dst_file, init_filename, dry_run)
        _check()
799188
def interactive(self):
        """"""
        while True:
            line = sys.stdin.readline().strip()
            if line == 'quit':
                sys.exit()
            elif line == 'validate':
                self.check_syntax()
                self.check_imports()
                self.check_install_json()
                self.check_layout_json()
                self.print_json()

            # reset validation_data
            self.validation_data = self._validation_data
233460
def main():
    
    e = mod_env.Internet('VAIS - Load testing',  'Simulation of several websites')
    e.create(800)
    print(e)
    
    #Create some users to browse the web and load test website
    print(npc.web_users.params)
1115225
def TEST():
    
    grd = Grid(4,4, [2,4])
    grd.new_tile()
    grd.new_tile()
    print(grd)
    print("There are ", grd.count_blank_positions(), " blanks in grid 1\n")

    grd2 = Grid(5,5, ['A','B'])
    grd2.new_tile(26)
    print(grd2)
    build_board_checkers()

    print("There are ", grd2.count_blank_positions(), " blanks in grid 2")
694754
def check_dependencies(self):
        ""
        if self.test_program == 'nose':
            try:
                import nose
            except ImportError:
                sys.exit('Nosetests is not available on your system. Please install it and try to run it again')
        if self.test_program == 'py':
            try:
                import py
            except:
                sys.exit('py.test is not available on your system. Please install it and try to run it again')
        if self.test_program == 'django':
            try:
                import django
            except:
                sys.exit('django is not available on your system. Please install it and try to run it again')
        if self.test_program == 'phpunit':
            try:
                process = subprocess.check_call(['phpunit','--version']) 
            except:
                sys.exit('phpunit is not available on your system. Please install it and try to run it again')
        if self.test_program == 'tox':
            try:
                import tox
            except ImportError:
                sys.exit('tox is not available on your system. Please install it and try to run it again')
704357
public static void main(String[] args) {
                System.out.println("Testing packing and delta ");
                testWithDeltas(false);
                testWithDeltas(true);
                System.out.println("Testing packing alone ");
                test(false);
                test(true);
        }
1290759
def _main():
    """"""
    import signal

    # Handle "Broken pipe" gracefully
    try:
        signal.signal(signal.SIGPIPE, lambda signum, frame: sys.exit(1))
    except AttributeError:
        pass    # not supported on Windows

    style_guide = StyleGuide(parse_argv=True)
    options = style_guide.options

    if options.doctest or options.testsuite:
        from testsuite.support import run_tests
        report = run_tests(style_guide)
    else:
        report = style_guide.check_files()

    if options.statistics:
        report.print_statistics()

    if options.benchmark:
        report.print_benchmark()

    if options.testsuite and not options.quiet:
        report.print_results()

    if report.total_errors:
        if options.count:
            sys.stderr.write(str(report.total_errors) + '\n')
        sys.exit(1)
13153
def main():
    
    mkdir_p('/tmp/test/test')
    source('/root/.bash_profile')
    yum_install(['httpd', 'git'])
    yum_install(['httpd', 'git'], dest_dir='/tmp/test/test', downloadonly=True)
    sed('/Users/yennaco/Downloads/homer_testing/network', '^HOSTNAME.*', 'HOSTNAME=foo.joe')
    test_script = '/Users/yennaco/Downloads/homer/script.sh'
    results = run_command([test_script], timeout_sec=1000)
    print('Script {s} produced exit code [{c}] and output:\n{o}'.format(
        s=test_script, c=results['code'], o=results['output']))
793609
def main(*args):
    """"""
    parser = argparse.ArgumentParser()
    parser.add_argument("action",
                        help="create, check, run, make-nb, or run-nb")
    parser.add_argument("--directory", "-dir", default=os.getcwd(),
                        help="path to directory with a .sciunit file")
    parser.add_argument("--stop", "-s", default=True,
                        help="stop and raise errors, halting the program")
    parser.add_argument("--tests", "-t", default=False,
                        help="runs tests instead of suites")
    if args:
        args = parser.parse_args(args)
    else:
        args = parser.parse_args()
    file_path = os.path.join(args.directory, '.sciunit')
    config = None
    if args.action == 'create':
        create(file_path)
    elif args.action == 'check':
        config = parse(file_path, show=True)
        print("\nNo configuration errors reported.")
    elif args.action == 'run':
        config = parse(file_path)
        run(config, path=args.directory,
            stop_on_error=args.stop, just_tests=args.tests)
    elif args.action == 'make-nb':
        config = parse(file_path)
        make_nb(config, path=args.directory,
                stop_on_error=args.stop, just_tests=args.tests)
    elif args.action == 'run-nb':
        config = parse(file_path)
        run_nb(config, path=args.directory)
    else:
        raise NameError('No such action %s' % args.action)
    if config:
        cleanup(config, path=args.directory)
519723
def validate_program(self):
        """"""
        terminals = [0]
        for node in self.program:
            if isinstance(node, _Function):
                terminals.append(node.arity)
            else:
                terminals[-1] -= 1
                while terminals[-1] == 0:
                    terminals.pop()
                    terminals[-1] -= 1
        return terminals == [-1]
690739
function main() {

    var database = fs.createWriteStream('./lib/database-min.js', { flags: 'w', encoding: 'utf8' });
    var testFile;

    fs.mkdir('./data', 493, function (error) {  // 493 == 0755 (no octal in strict mode.)
        // ignore errors.
    });
    
    database.write("// Do not edit this file, your changes will be lost.\n");
    database.write("module.exports = { \n");
    getJSON('http://alscan.info/agent_groups/groups.json', function (groups) {
        var s = JSON.stringify(groups);
        database.write("groups:" + s + ",\n");
        testFile = fs.createWriteStream('./data/groups.json', { flags: 'w', encoding: 'utf8' });
        testFile.write(s+"\n");
        testFile.end();
        getJSON('http://alscan.info/agent_sources/sources.json', function (sources) {
            var s = JSON.stringify(sources);
            database.write("sources:" + s + ",\n");
            testFile = fs.createWriteStream('./data/sources.json', { flags: 'w', encoding: 'utf8' });
            testFile.write(s+"\n");
            testFile.end();
            getJSON('http://alscan.info/patterns/patterns.json', function (patterns) {
                database.write("patterns:[\n");
                patterns.forEach(function (pattern) {
                    database.write("{p: new RegExp('" + pattern.pattern + "'), x:" + 
                            agentdb.getX(pattern.groupId, pattern.sourceId) + "},");
                });
                database.write("],\n");
                testFile = fs.createWriteStream('./data/patterns.json', { flags: 'w', encoding: 'utf8' });
                testFile.write(JSON.stringify(patterns)+"\n");
                testFile.end();
                getJSON('http://alscan.info/agents/agents.json', function (agents) {
                    var hash = new HashTable(HASH_TABLE_SIZE, HASH_TABLE_SEED, HASH_TABLE_MULTIPLIER);
                    agents.forEach(function (agent) {
                        if (agent.status < 2) {
                            var obj = { a: agent.agent, x: agentdb.getX(agent.groupId, agent.sourceId) };
                            hash.add('a', obj);
                        }
                    });
                    database.write("table:" + JSON.stringify(hash.table) + ",\n");
                    database.write("HASH_TABLE_SIZE:" + HASH_TABLE_SIZE + ",\n");
                    database.write("HASH_TABLE_SEED:" + HASH_TABLE_SEED + ",\n");
                    database.write("HASH_TABLE_MULTIPLIER:" + HASH_TABLE_MULTIPLIER + ",\n");
                    database.write("hash: undefined\n}\n");
                    testFile = fs.createWriteStream('./data/agents.json', { flags: 'w', encoding: 'utf8' });
                    testFile.write(JSON.stringify(agents)+"\n");
                    testFile.end();
                    if (debug) {
                        var history = hash.getHistory();
                        console.log("Hash table history");
                        for (var n=0; n < history.length; n++) {
                            console.log("  Depth=" + n + ", count=" + history[n] + ", percent=" + (history[n] / HASH_TABLE_SIZE));
                        }
                    }
                });
            });
        });
    });
}
1018147
function __runProgram() {
            try {
                eval(__program);
            } catch (err) {
                if (err.rethrow) throw(err);
                err = new Error(err.message+" in meta program of '"+__filename+"':\n"+__err2code(__program, err));
                err.rethrow = true;
                throw(err);
            }
        }
160756
def main():
  
  parser = argparse.ArgumentParser(description='A distributed test framework')
  parser.add_argument('testfile',
      help='The file that is used to determine the test suite run')
  parser.add_argument('--test-only',
      nargs='*',
      dest='test_list',
      help='run only the named tests to help debug broken tests')
  parser.add_argument('--machine-list',
      nargs='*',
      dest='machine_list',
      help='''mapping of logical host names to physical names allowing the same
              test suite to run on different hardware, each argument is a pair
              of logical name and physical name separated by a =''')
  parser.add_argument('--config-overrides',
      nargs='*',
      dest='config_overrides',
      help='''config overrides at execution time, each argument is a config with
              its value separated by a =. This has the highest priority of all
              configs''')
  parser.add_argument('-d', '--output-dir',
      dest='output_dir',
      help='''Directory to write output files and logs. Defaults to the current
              directory.''')
  parser.add_argument("--log-level", dest="log_level", help="Log level (default INFO)", default="INFO")
  parser.add_argument("--console-log-level", dest="console_level", help="Console Log level (default ERROR)",
                      default="ERROR")
  parser.add_argument("--nopassword", action='store_true', dest="nopassword", help="Disable password prompt")
  parser.add_argument("--user", dest="user", help="user to run the test as (defaults to current user)")
  args = parser.parse_args()
  try:
    call_main(args)
  except ValueError:
    #We only sys.exit here, as call_main is used as part of a unit test
    #and should not exit the system
    sys.exit(1)
581074
def hello_world(test, example, prompts):
  """"""
  test.logger.info('Hello World!')
  test.measurements.widget_type = prompts.prompt(
      'What\'s the widget type? (Hint: try `MyWidget` to PASS)',
      text_input=True)
  if test.measurements.widget_type == 'raise':
    raise Exception()
  test.measurements.widget_color = 'Black'
  test.measurements.widget_size = 3
  test.measurements.specified_as_args = 'Measurement args specified directly'
  test.logger.info('Plug value: %s', example.increment())
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;
	}
286112
function(results, run, options, done) {

    _.each(results, function(result) {

      var pkg = {
        name: result.testsuites.$.name,
        tests: parse(result.testsuites.$.tests),
        failures: parse(result.testsuites.$.failures),
        suites: []
      };
      pkg.isFailure = pkg.failures > 0;

      var filename = result.filename;
      _.each(result.testsuites.testsuite, function(suiteData) {
        var $ = suiteData.$;

        var suite = {
          name: $.name,
          pkgName: $.package,
          failures: parse($.failures),
          errors: parse($.errors),
          skipped: parse($.skipped),
          tests: parse($.tests),
          cases: []
        };

        // Sometimes the package name isn't in the
        // xml reports...
        if (!pkg.name) {
          if (result.testsuites.filename) {
            pkg.name = result.testsuites.filename;
          } else {
            pkg.name = suite.pkgName;
          }
        } else {
          if (result.testsuites.filename) {
            pkg.name = result.testsuites.filename + '-' + pkg.name;
          }
        }

        suite.passed = suite.tests - suite.errors - suite.failures;
        suite.isFailure = suite.errors > 0 || suite.failures > 0;
        suite.errmessages = $['system-err'];
        pkg.suites.push(suite);

        _.each(suiteData.testcase, function(caseData) {

          var assert = {
            message: caseData.$.name,
            time: caseData.$.time,
            stacktrace: '',
            failure: false,
            skipped: false,
            screenshots: []

            // failure: false or failure message,
            // screenshots: ['path/to/screen1', '/path/to/screen2']
          };

          if (caseData.skipped)
            assert.skipped = true;

          if (caseData.failure && caseData.failure.length > 0)
            assert.failure = caseData.failure[0].$.message;

          if (caseData['system-out']) {
            var sspaths = getScreenshotPaths(caseData['system-out']);

            sspaths.map(function(sspath) {
              if (options.relativeScreenshots) {
                sspath = getRelativePath(options.fullOutputFilename, sspath);
              }
              assert.screenshots.push(sspath);
            });
          }

          assert.isFailure = assert.failure;
          suite.cases.push(assert);

          if (assert.isFailure)
            suite.isFailure = true;

        });

        if (suite.isFailure)
          pkg.isFailure = true;

      });

      run.addPackage(pkg);

    });

    done(null, run);
  }