lodash: Rename to lodash and update support files. [jddalton]

This commit is contained in:
John-David Dalton
2012-04-17 20:05:59 -04:00
parent c499d81633
commit 8e65243edf
10 changed files with 4948 additions and 1097 deletions

View File

@@ -2,18 +2,18 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>LowDash.js Test Suite</title>
<title>Lo-Dash Test Suite</title>
<link rel="stylesheet" href="../vendor/qunit/qunit/qunit.css">
</head>
<body>
<h1 id="qunit-header">LowDash.js Test Suite</h1>
<h1 id="qunit-header">Lo-Dash Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<script src="../vendor/qunit/qunit/qunit.js"></script>
<script>var lowDash2, lowDash = 1;</script>
<script src="../lowdash.js"></script>
<script>var _2, _ = 1;</script>
<script src="../lodash.js"></script>
<script src="../vendor/requirejs/require.js"></script>
<script>
if (/[?&]norequire=true(?:&|$)/.test(location.search)) {
@@ -21,16 +21,16 @@
document.write('<script src="test.js"><\/script>');
}
else {
define.amd.lowDash = true;
define.amd.lodash = true;
require({
'baseUrl': '../vendor/requirejs/',
'urlArgs': 't=' + (+new Date),
'paths': {
'lowdash': '../../lowdash'
'lodash': '../../lodash'
}
},
['lowdash'], function(lowDash) {
lowDash2 = lowDash.noConflict();
['lodash'], function(_) {
_2 = _.noConflict();
require(['test.js']);
});
}

7
test/run-test.sh Executable file
View File

@@ -0,0 +1,7 @@
cd "$(dirname "$0")"
for cmd in rhino ringo narwhal node; do
echo "Testing in $cmd..."
$cmd test.js
done
echo "Testing in a browser..."
open index.html

75
test/test.js Normal file
View File

@@ -0,0 +1,75 @@
(function(window, undefined) {
/** Use a single load function */
var load = typeof require == 'function' ? require : window.load;
/** The unit testing framework */
var QUnit =
window.QUnit || (
window.setTimeout || (window.addEventListener = window.setTimeout = / /),
window.QUnit = load('../vendor/qunit/qunit/qunit.js') || window.QUnit,
load('../vendor/qunit-clib/qunit-clib.js'),
(window.addEventListener || 0).test && delete window.addEventListener,
window.QUnit
);
/** The `lodash` function to test */
var _ =
window._ || (
_ = load('../lodash.js') || window._,
_._ || _
);
/** Shortcut used to convert array-like objects to arrays */
var slice = [].slice;
/** Used to resolve a value's internal [[Class]] */
var toString = {}.toString;
/*--------------------------------------------------------------------------*/
/**
* Skips a given number of tests with a passing result.
*
* @private
* @param {Number} count The number of tests to skip.
*/
function skipTest(count) {
while (count--) {
ok(true, 'test skipped');
}
}
/*--------------------------------------------------------------------------*/
// must explicitly use `QUnit.module` instead of `module()`
// in case we are in a CLI environment
QUnit.module('lodash');
(function() {
test('supports loading lodash.js as a module', function() {
if (window.document && window.require) {
equal((_2 || {}).VERSION, _.VERSION);
} else {
skipTest(1)
}
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash constructor');
(function() {
test('creates a new instance when called without the `new` operator', function() {
ok(_() instanceof _);
});
}());
/*--------------------------------------------------------------------------*/
// explicitly call `QUnit.start()` in a CLI environment
if (!window.document) {
QUnit.start();
}
}(typeof global == 'object' && global || this));

View File

@@ -6,7 +6,7 @@
<script type="text/javascript" src="vendor/jquery.js"></script>
<script type="text/javascript" src="vendor/qunit.js"></script>
<script type="text/javascript" src="vendor/jslitmus.js"></script>
<script type="text/javascript" src="../../underscore.js"></script>
<script type="text/javascript" src="../../lodash.js"></script>
<script type="text/javascript" src="collections.js"></script>
<script type="text/javascript" src="arrays.js"></script>
<script type="text/javascript" src="functions.js"></script>