exposed for testing
10095
int bucket(double x) {
        if (x <= min) {
            return 0;
        } else if (x >= max) {
            return counts.length - 1;
        } else {
            return bucketIndex(x);
        }
    }
174532
def run(self) -> None:
        
        while not self.cleanup:
            try:
                result, test, additional_info = self.result_queue.get(timeout=1)
            except queue.Empty:
                continue

            self.result_queue.task_done()

            if result == TestState.serialization_failure:
                test = self.tests[test]
                warnings.warn("Serialization error: {} on test {}".format(
                    additional_info, test), SerializationWarning)
                test(self)

            else:
                self.testsRun += 1

                if result == TestState.success:
                    self.addSuccess(test)
                elif result == TestState.failure:
                    self.addFailure(test, additional_info)
                elif result == TestState.error:
                    self.addError(test, additional_info)
                elif result == TestState.skipped:
                    self.addSkip(test, additional_info)
                elif result == TestState.expected_failure:
                    self.addExpectedFailure(test, additional_info)
                elif result == TestState.unexpected_success:
                    self.addUnexpectedSuccess(test)
                else:
                    raise Exception("This is not a valid test type :", result)
468463
function showWarning() {
    var method = showWarning.caller.name;
    if (!configurations.areTestsRunnning()) {
      console.warn('This method (' + method + ') is deprecated and its going to be removed on next versions');
    }
  }
272917
function() {
  require('coffee-script')

  var path = require('path')
  var fs = require('fs')
  var Mocha = require('mocha')

  // Allow unlimited listeners for tests.
  process.setMaxListeners(0)

  var testDir = path.resolve(__dirname, '../test')
  var files = fs.readdirSync(testDir).filter(function(f) {
    return f.match(/\.js$/)
  })

  var mocha = new Mocha({
    reporter: 'spec'
  })

  for (var i = 0; i < files.length; i++) {
    var file = files[i]
    mocha.addFile(path.resolve(testDir, file))
  }

  mocha.run(function(failures) {
    var exitCode = failures === 0 ? 0 : 1

    process.send({
      type: 'shutdown',
      code: exitCode
    })
    process.exit(failures)
  })
}
1099202
async function tryExample () {
  // Use the connected resource
  const {User} = db.resources
  let user = await User.create({username: 'Black Fire', password: 'Super Cool'})
  /* ... */
}
320591
def run(self, test):
        ""
        # These parts of Nose's pluggability are baked into
        # nose.core.TextTestRunner. Reproduce them:
        wrapper = self.config.plugins.prepareTest(test)
        if wrapper is not None:
            test = wrapper
        wrapped = self.config.plugins.setOutputStream(self.stream)
        if wrapped is not None:
            self.stream = wrapped

        result = self._makeResult()
        startTime = time()
        try:
            test(result)
        except KeyboardInterrupt:
            # we need to ignore these exception to not
            # show traceback when user intentionally
            # interrupted test suite execution, and
            # to output some reasonable results on
            # already passed and failed tests.
            pass
        stopTime = time()

        # We don't care to hear about errors again at the end; we take care of
        # that in result.addError(), while the tests run.
        # result.printErrors()
        #
        # However, we do need to call this one useful line from
        # nose.result.TextTestResult's implementation of printErrors() to make
        # sure other plugins get a chance to report:
        self.config.plugins.report(self.stream)

        result.printSummary(startTime, stopTime)
        self.config.plugins.finalize(result)
        return result
259507
def coverage():
    """"""
    run("coverage run --source {PROJECT_NAME} -m py.test".format(PROJECT_NAME=PROJECT_NAME))
    run("coverage report -m")
    run("coverage html")

    webbrowser.open('file://' + os.path.realpath("htmlcov/index.html"), new=2)
999007
def cmp_out(test)
      test.out_result = FileUtils.cmp(test.expected_out_path, 
                                      test.result_out_path)
    end
462626
@Override
	public void onEnd(TestContext<Object> context) {
		try {
			System.setErr(oldErr);
			System.setOut(oldOut);
		} catch (SecurityException e) {
			// ignored
		}
	}
1321838
def assert_hidden(tag, element_id)
			if RWebSpec.framework =~ /selenium/i
      	perform_assertion { assert(!eval("#{tag}(:id, '#{element_id.to_s}').displayed?"), "Element '#{tag}' with id: '#{element_id}' is visible") }
			else
      	perform_assertion { assert(!eval("#{tag}(:id, '#{element_id.to_s}').visible?"), "Element '#{tag}' with id: '#{element_id}' is visible") }
			end
    end
52959
private function _checkInnerAssignment() {
		// If the test if active and we are inside a control statement
		if ($this->_isActive('checkInnerAssignment') && $this->_inControlStatement) {

			// If the control statement is not listed as an exception
			if (!$this->_config->isException('checkInnerAssignment', $this->_currentStatement)) {
				$this->_writeError('checkInnerAssignment', $this->_getMessage('INSIDE_ASSIGNMENT'));
			}
		}
	}
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;
	}
276013
function() {
      if (!JSLitmus.currentTest) {
        var test = JSLitmus._queue.shift();
        if (test) {
          jsl.$('stop_button').disabled = false;
          JSLitmus.currentTest = test;
          test.run();
          JSLitmus.renderTest(test);
          if (JSLitmus.onTestStart) JSLitmus.onTestStart(test);
        } else {
          jsl.$('stop_button').disabled = true;
          JSLitmus.renderChart();
        }
      }
    }
479612
function() {
      for (var i = 0; i < JSLitmus._tests.length; i++)
        JSLitmus.renderTest(JSLitmus._tests[i]);
      JSLitmus.renderChart();
    }
1275867
function () {
    var scopes = fs.readdirSync('./test_scopes').filter(function (filename) {
      return filename[0] !== '.';
    });
    var config = {
      options: {
        color: false,
        interactive: false
      }
    };
    // Create a sub config for each test scope
    for (var idx in scopes) {
      var scope = scopes[idx];
      config['test_scopes_' + scope] = {
        options: {
          cwd: 'test_scopes/' + scope,
          production: false
        }
      };
    }
    return config;
  }
543110
public static void assertAccessibility(String htmlString, Testable testable) {
        assertThat(htmlString, is(compliantTo(testable)));
    }
1092082
def SecurityCheck(self, func, request, *args, **kwargs):
    """"""
    request.user = self.username
    request.token = access_control.ACLToken(
        username="Testing", reason="Just a test")
    return func(request, *args, **kwargs)