From 57a990ce257402f79552cec141f2435e099e2233 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 8 Sep 2012 19:26:43 -0700 Subject: [PATCH] Add "underscore" build test. Former-commit-id: 8050e285fae94c96e7db1c8847ace45ae5cade33 --- build.js | 92 +++++++++++++++++++++++----------------------- test/test-build.js | 26 ++++++++++++- 2 files changed, 71 insertions(+), 47 deletions(-) diff --git a/build.js b/build.js index f8ce5ad36..6b8b3054b 100755 --- a/build.js +++ b/build.js @@ -52,52 +52,6 @@ 'uniq': ['unique'] }; - /** Used to track Backbone's Lo-Dash dependencies */ - var backboneDependencies = [ - 'bind', - 'bindAll', - 'clone', - 'contains', - 'escape', - 'every', - 'extend', - 'filter', - 'find', - 'first', - 'forEach', - 'groupBy', - 'has', - 'indexOf', - 'initial', - 'invoke', - 'isArray', - 'isEmpty', - 'isEqual', - 'isFunction', - 'isObject', - 'isRegExp', - 'keys', - 'last', - 'lastIndexOf', - 'map', - 'max', - 'min', - 'mixin', - 'reduce', - 'reduceRight', - 'reject', - 'rest', - 'result', - 'shuffle', - 'size', - 'some', - 'sortBy', - 'sortedIndex', - 'toArray', - 'uniqueId', - 'without' - ]; - /** Used to track function dependencies */ var dependencyMap = { 'after': [], @@ -221,6 +175,52 @@ /** List of all Lo-Dash methods */ var allMethods = _.keys(dependencyMap); + /** List Backbone's Lo-Dash dependencies */ + var backboneDependencies = [ + 'bind', + 'bindAll', + 'clone', + 'contains', + 'escape', + 'every', + 'extend', + 'filter', + 'find', + 'first', + 'forEach', + 'groupBy', + 'has', + 'indexOf', + 'initial', + 'invoke', + 'isArray', + 'isEmpty', + 'isEqual', + 'isFunction', + 'isObject', + 'isRegExp', + 'keys', + 'last', + 'lastIndexOf', + 'map', + 'max', + 'min', + 'mixin', + 'reduce', + 'reduceRight', + 'reject', + 'rest', + 'result', + 'shuffle', + 'size', + 'some', + 'sortBy', + 'sortedIndex', + 'toArray', + 'uniqueId', + 'without' + ]; + /** List of methods used by Underscore */ var underscoreMethods = _.without.apply(_, [allMethods].concat([ 'countBy', diff --git a/test/test-build.js b/test/test-build.js index d4b52283c..b4fe7626e 100644 --- a/test/test-build.js +++ b/test/test-build.js @@ -444,7 +444,7 @@ ); commands.forEach(function(command) { - var start = _.after(2, QUnit.start); + var start = _.after(2, _.once(QUnit.start)); asyncTest('`lodash ' + command +'`', function() { build(['--silent'].concat(command.split(' ')), function(filepath, source) { @@ -520,6 +520,8 @@ }); ['non-strict', 'strict'].forEach(function(strictMode, index) { + var start = _.after(2, _.once(QUnit.start)); + asyncTest(strictMode + ' should ' + (index ? 'error': 'silently fail') + ' attempting to overwrite read-only properties', function() { var commands = ['--silent', 'include=bindAll,defaults,extend']; if (index) { @@ -546,4 +548,26 @@ }); }); }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('underscore modifier'); + + (function() { + var start = _.once(QUnit.start); + + asyncTest('should not have deep clone', function() { + build(['--silent', 'underscore'], function(filepath, source) { + vm.runInContext(source, context); + + var array = [{ 'a': 1 }], + basename = path.basename(filepath, '.js'), + lodash = context._; + + ok(lodash.clone(array, true)[0] === array[0], basename); + start(); + }); + }); + }()); + }());