Sha256: 013dbfd2f7f31eafa7b6f3c9ae76a31bddd04ee98d902e0a5e676d97d34955aa

Contents?: true

Size: 1.49 KB

Versions: 125

Compression:

Stored size: 1.49 KB

Contents

/* -*- Mode: js; js-indent-level: 2; -*- */
/*
 * Copyright 2011 Mozilla Foundation and contributors
 * Licensed under the New BSD license. See LICENSE or:
 * http://opensource.org/licenses/BSD-3-Clause
 */
if (typeof define !== 'function') {
    var define = require('amdefine')(module, require);
}
define(function (require, exports, module) {

  var binarySearch = require('../../lib/source-map/binary-search');

  function numberCompare(a, b) {
    return a - b;
  }

  exports['test too high'] = function (assert, util) {
    var needle = 30;
    var haystack = [2,4,6,8,10,12,14,16,18,20];

    assert.doesNotThrow(function () {
      binarySearch.search(needle, haystack, numberCompare);
    });

    assert.equal(binarySearch.search(needle, haystack, numberCompare), 20);
  };

  exports['test too low'] = function (assert, util) {
    var needle = 1;
    var haystack = [2,4,6,8,10,12,14,16,18,20];

    assert.doesNotThrow(function () {
      binarySearch.search(needle, haystack, numberCompare);
    });

    assert.equal(binarySearch.search(needle, haystack, numberCompare), null);
  };

  exports['test exact search'] = function (assert, util) {
    var needle = 4;
    var haystack = [2,4,6,8,10,12,14,16,18,20];

    assert.equal(binarySearch.search(needle, haystack, numberCompare), 4);
  };

  exports['test fuzzy search'] = function (assert, util) {
    var needle = 19;
    var haystack = [2,4,6,8,10,12,14,16,18,20];

    assert.equal(binarySearch.search(needle, haystack, numberCompare), 18);
  };

});

Version data entries

125 entries across 91 versions & 13 rubygems

Version Path
epuber-stylus-source-0.56.0 vendor/node_modules/uglify-js/node_modules/source-map/test/source-map/test-binary-search.js
epuber-stylus-source-0.54.8 vendor/node_modules/uglify-js/node_modules/source-map/test/source-map/test-binary-search.js
ilog-0.4.1 node_modules/source-map-support/node_modules/source-map/test/source-map/test-binary-search.js
ilog-0.4.0 node_modules/source-map-support/node_modules/source-map/test/source-map/test-binary-search.js
ilog-0.3.3 node_modules/source-map-support/node_modules/source-map/test/source-map/test-binary-search.js
babel-schmooze-sprockets-0.1.3 node_modules/source-map-support/node_modules/source-map/test/source-map/test-binary-search.js
babel-schmooze-sprockets-0.1.2 node_modules/source-map-support/node_modules/source-map/test/source-map/test-binary-search.js
babel-schmooze-sprockets-0.1.1 node_modules/source-map-support/node_modules/source-map/test/source-map/test-binary-search.js
babel-schmooze-sprockets-0.1.0 node_modules/source-map-support/node_modules/source-map/test/source-map/test-binary-search.js
babel-schmooze-sprockets-0.1.0.alpha.3 node_modules/source-map-support/node_modules/source-map/test/source-map/test-binary-search.js
babel-schmooze-sprockets-0.1.0.alpha.2 node_modules/source-map-support/node_modules/source-map/test/source-map/test-binary-search.js
es6_tilt-0.1.2 test/dummy/node_modules/source-map/test/source-map/test-binary-search.js
es6_tilt-0.1.2 test/dummy/app/assets/javascripts/node_modules/source-map-support/node_modules/source-map/test/source-map/test-binary-search.js
es6_tilt-0.1.2 test/dummy/app/assets/javascripts/node_modules/jstransform/node_modules/source-map/test/source-map/test-binary-search.js
es6_tilt-0.1.2 test/dummy/node_modules/source-map-support/node_modules/source-map/test/source-map/test-binary-search.js
es6_tilt-0.1.2 test/dummy/node_modules/babel-register/node_modules/source-map/test/source-map/test-binary-search.js
es6_tilt-0.1.1 test/dummy/node_modules/babel-register/node_modules/source-map/test/source-map/test-binary-search.js
es6_tilt-0.1.1 test/dummy/app/assets/javascripts/node_modules/jstransform/node_modules/source-map/test/source-map/test-binary-search.js
es6_tilt-0.1.1 test/dummy/node_modules/source-map-support/node_modules/source-map/test/source-map/test-binary-search.js
es6_tilt-0.1.1 test/dummy/app/assets/javascripts/node_modules/source-map-support/node_modules/source-map/test/source-map/test-binary-search.js