twigg-app 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (208) hide show
  1. checksums.yaml +4 -4
  2. data/assets/javascripts/_bootstrap.js +7 -0
  3. data/assets/javascripts/_jquery.js +19 -0
  4. data/assets/javascripts/_tables.js +3 -0
  5. data/assets/javascripts/_views.js +10 -0
  6. data/assets/javascripts/application.js +9 -0
  7. data/{public/application.js → assets/javascripts/views/_commit_set_bar_chart.js} +32 -34
  8. data/assets/javascripts/views/_russia.js +61 -0
  9. data/assets/javascripts/views/_tags.js +56 -0
  10. data/assets/javascripts/views/_tags_word_cloud.js +51 -0
  11. data/assets/stylesheets/_bootstrap_overrides.scss +15 -0
  12. data/assets/stylesheets/_footer.scss +28 -0
  13. data/assets/stylesheets/_global.scss +14 -0
  14. data/assets/stylesheets/_tables.scss +20 -0
  15. data/assets/stylesheets/application.scss +10 -0
  16. data/assets/stylesheets/d3/_bar_chart.scss +25 -0
  17. data/assets/stylesheets/d3/_bubble_chart.scss +22 -0
  18. data/lib/twigg-app/app/routes.rb +4 -0
  19. data/lib/twigg-app/app/server.rb +78 -21
  20. data/lib/twigg-app/app/version.rb +1 -1
  21. data/public/vendor/bootstrap/Gruntfile.js +32 -10
  22. data/public/vendor/bootstrap/README.md +2 -0
  23. data/public/vendor/bootstrap/_config.yml +5 -10
  24. data/public/vendor/bootstrap/_includes/footer.html +2 -1
  25. data/public/vendor/bootstrap/_includes/nav-components.html +33 -31
  26. data/public/vendor/bootstrap/_includes/nav-css.html +32 -22
  27. data/public/vendor/bootstrap/_includes/nav-getting-started.html +17 -1
  28. data/public/vendor/bootstrap/_includes/nav-javascript.html +1 -1
  29. data/public/vendor/bootstrap/_includes/nav-main.html +1 -1
  30. data/public/vendor/bootstrap/_includes/social-buttons.html +1 -1
  31. data/public/vendor/bootstrap/_layouts/default.html +18 -14
  32. data/public/vendor/bootstrap/_layouts/home.html +9 -6
  33. data/public/vendor/bootstrap/assets/css/docs.css +584 -396
  34. data/public/vendor/bootstrap/assets/ico/apple-touch-icon-114-precomposed.png +0 -0
  35. data/public/vendor/bootstrap/assets/ico/apple-touch-icon-144-precomposed.png +0 -0
  36. data/public/vendor/bootstrap/assets/ico/apple-touch-icon-57-precomposed.png +0 -0
  37. data/public/vendor/bootstrap/assets/ico/apple-touch-icon-72-precomposed.png +0 -0
  38. data/public/vendor/bootstrap/assets/ico/favicon.png +0 -0
  39. data/public/vendor/bootstrap/assets/js/application.js +2 -1
  40. data/public/vendor/bootstrap/assets/js/customizer.js +160 -45
  41. data/public/vendor/bootstrap/assets/js/filesaver.js +169 -0
  42. data/public/vendor/bootstrap/assets/js/jquery.js +6 -5
  43. data/public/vendor/bootstrap/assets/js/raw-files.js +3 -0
  44. data/public/vendor/bootstrap/bower.json +1 -1
  45. data/public/vendor/bootstrap/components.html +787 -364
  46. data/public/vendor/bootstrap/composer.json +1 -1
  47. data/public/vendor/bootstrap/css.html +413 -248
  48. data/public/vendor/bootstrap/customize.html +413 -447
  49. data/public/vendor/bootstrap/dist/css/bootstrap-theme.css +384 -0
  50. data/public/vendor/bootstrap/dist/css/bootstrap-theme.min.css +1 -0
  51. data/public/vendor/bootstrap/dist/css/bootstrap.css +3033 -1807
  52. data/public/vendor/bootstrap/dist/css/bootstrap.min.css +1 -1
  53. data/public/vendor/bootstrap/dist/fonts/glyphicons-halflings-regular.eot +0 -0
  54. data/public/vendor/bootstrap/dist/fonts/glyphicons-halflings-regular.svg +228 -0
  55. data/public/vendor/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf +0 -0
  56. data/public/vendor/bootstrap/dist/fonts/glyphicons-halflings-regular.woff +0 -0
  57. data/public/vendor/bootstrap/dist/js/bootstrap.js +18 -12
  58. data/public/vendor/bootstrap/dist/js/bootstrap.min.js +1 -1
  59. data/public/vendor/bootstrap/examples/carousel/carousel.css +128 -0
  60. data/public/vendor/bootstrap/examples/carousel/index.html +201 -0
  61. data/public/vendor/bootstrap/examples/grid/grid.css +28 -0
  62. data/public/vendor/bootstrap/examples/grid/index.html +119 -0
  63. data/public/vendor/bootstrap/examples/jumbotron/index.html +111 -0
  64. data/public/vendor/bootstrap/examples/jumbotron/jumbotron.css +5 -0
  65. data/public/vendor/bootstrap/examples/jumbotron-narrow/index.html +78 -0
  66. data/public/vendor/bootstrap/examples/jumbotron-narrow/jumbotron-narrow.css +79 -0
  67. data/public/vendor/bootstrap/examples/justified-nav/index.html +79 -0
  68. data/public/vendor/bootstrap/examples/justified-nav/justified-nav.css +88 -0
  69. data/public/vendor/bootstrap/examples/navbar/index.html +83 -0
  70. data/public/vendor/bootstrap/examples/navbar/navbar.css +7 -0
  71. data/public/vendor/bootstrap/examples/navbar-fixed-top/index.html +86 -0
  72. data/public/vendor/bootstrap/examples/navbar-fixed-top/navbar-fixed-top.css +4 -0
  73. data/public/vendor/bootstrap/examples/navbar-static-top/index.html +87 -0
  74. data/public/vendor/bootstrap/examples/navbar-static-top/navbar-static-top.css +7 -0
  75. data/public/vendor/bootstrap/examples/non-responsive/index.html +96 -0
  76. data/public/vendor/bootstrap/examples/non-responsive/non-responsive.css +117 -0
  77. data/public/vendor/bootstrap/examples/offcanvas/index.html +127 -0
  78. data/public/vendor/bootstrap/examples/offcanvas/offcanvas.css +48 -0
  79. data/public/vendor/bootstrap/examples/offcanvas/offcanvas.js +5 -0
  80. data/public/vendor/bootstrap/examples/screenshots/carousel.jpg +0 -0
  81. data/public/vendor/bootstrap/examples/screenshots/grid.jpg +0 -0
  82. data/public/vendor/bootstrap/examples/screenshots/jumbotron-narrow.jpg +0 -0
  83. data/public/vendor/bootstrap/examples/screenshots/jumbotron.jpg +0 -0
  84. data/public/vendor/bootstrap/examples/screenshots/justified-nav.jpg +0 -0
  85. data/public/vendor/bootstrap/examples/screenshots/navbar-fixed.jpg +0 -0
  86. data/public/vendor/bootstrap/examples/screenshots/navbar-static.jpg +0 -0
  87. data/public/vendor/bootstrap/examples/screenshots/navbar.jpg +0 -0
  88. data/public/vendor/bootstrap/examples/screenshots/non-responsive.jpg +0 -0
  89. data/public/vendor/bootstrap/examples/screenshots/offcanvas.jpg +0 -0
  90. data/public/vendor/bootstrap/examples/screenshots/sign-in.jpg +0 -0
  91. data/public/vendor/bootstrap/examples/screenshots/starter-template.jpg +0 -0
  92. data/public/vendor/bootstrap/examples/screenshots/sticky-footer-navbar.jpg +0 -0
  93. data/public/vendor/bootstrap/examples/screenshots/sticky-footer.jpg +0 -0
  94. data/public/vendor/bootstrap/examples/screenshots/theme.jpg +0 -0
  95. data/public/vendor/bootstrap/examples/signin/index.html +46 -0
  96. data/public/vendor/bootstrap/examples/signin/signin.css +40 -0
  97. data/public/vendor/bootstrap/examples/starter-template/index.html +63 -0
  98. data/public/vendor/bootstrap/examples/starter-template/starter-template.css +7 -0
  99. data/public/vendor/bootstrap/examples/sticky-footer/index.html +51 -0
  100. data/public/vendor/bootstrap/examples/sticky-footer/sticky-footer.css +39 -0
  101. data/public/vendor/bootstrap/examples/sticky-footer-navbar/index.html +86 -0
  102. data/public/vendor/bootstrap/examples/sticky-footer-navbar/sticky-footer-navbar.css +46 -0
  103. data/public/vendor/bootstrap/examples/theme/index.html +387 -0
  104. data/public/vendor/bootstrap/examples/theme/theme.css +14 -0
  105. data/public/vendor/bootstrap/fonts/glyphicons-halflings-regular.eot +0 -0
  106. data/public/vendor/bootstrap/fonts/glyphicons-halflings-regular.svg +228 -0
  107. data/public/vendor/bootstrap/fonts/glyphicons-halflings-regular.ttf +0 -0
  108. data/public/vendor/bootstrap/fonts/glyphicons-halflings-regular.woff +0 -0
  109. data/public/vendor/bootstrap/getting-started.html +513 -22
  110. data/public/vendor/bootstrap/index.html +3 -4
  111. data/public/vendor/bootstrap/javascript.html +123 -115
  112. data/public/vendor/bootstrap/js/dropdown.js +3 -3
  113. data/public/vendor/bootstrap/js/modal.js +5 -3
  114. data/public/vendor/bootstrap/js/tests/unit/modal.js +19 -0
  115. data/public/vendor/bootstrap/js/tests/vendor/jquery.js +6 -5
  116. data/public/vendor/bootstrap/js/tooltip.js +9 -5
  117. data/public/vendor/bootstrap/js/transition.js +1 -1
  118. data/public/vendor/bootstrap/less/alerts.less +7 -11
  119. data/public/vendor/bootstrap/less/bootstrap.less +17 -21
  120. data/public/vendor/bootstrap/less/button-groups.less +14 -10
  121. data/public/vendor/bootstrap/less/buttons.less +3 -2
  122. data/public/vendor/bootstrap/less/carousel.less +6 -1
  123. data/public/vendor/bootstrap/less/dropdowns.less +22 -5
  124. data/public/vendor/bootstrap/less/forms.less +36 -15
  125. data/public/vendor/bootstrap/less/glyphicons.less +232 -0
  126. data/public/vendor/bootstrap/less/grid.less +9 -3
  127. data/public/vendor/bootstrap/less/input-groups.less +1 -1
  128. data/public/vendor/bootstrap/less/jumbotron.less +16 -5
  129. data/public/vendor/bootstrap/less/labels.less +9 -5
  130. data/public/vendor/bootstrap/less/mixins.less +73 -43
  131. data/public/vendor/bootstrap/less/modals.less +8 -0
  132. data/public/vendor/bootstrap/less/navbar.less +251 -189
  133. data/public/vendor/bootstrap/less/navs.less +13 -12
  134. data/public/vendor/bootstrap/less/pager.less +1 -1
  135. data/public/vendor/bootstrap/less/pagination.less +20 -9
  136. data/public/vendor/bootstrap/less/panels.less +28 -8
  137. data/public/vendor/bootstrap/less/progress-bars.less +6 -10
  138. data/public/vendor/bootstrap/less/responsive-utilities.less +120 -49
  139. data/public/vendor/bootstrap/less/scaffolding.less +37 -18
  140. data/public/vendor/bootstrap/less/tables.less +84 -59
  141. data/public/vendor/bootstrap/less/theme.less +232 -0
  142. data/public/vendor/bootstrap/less/thumbnails.less +8 -19
  143. data/public/vendor/bootstrap/less/type.less +2 -2
  144. data/public/vendor/bootstrap/less/variables.less +63 -50
  145. data/public/vendor/bootstrap/package.json +2 -1
  146. data/public/vendor/components-backbone/LICENSE +22 -0
  147. data/public/vendor/components-backbone/README.md +10 -0
  148. data/public/vendor/components-backbone/backbone-min.js +4 -0
  149. data/public/vendor/components-backbone/backbone.js +1571 -0
  150. data/public/vendor/components-backbone/bower.json +17 -0
  151. data/public/vendor/components-backbone/component.json +21 -0
  152. data/public/vendor/components-backbone/composer.json +37 -0
  153. data/public/vendor/components-backbone/package.json +24 -0
  154. data/public/vendor/d3.layout.cloud.js +401 -0
  155. data/public/vendor/replacejs/CHANGELOG.md +4 -0
  156. data/public/vendor/replacejs/replace.js +21 -2
  157. data/public/vendor/underscore/CNAME +1 -0
  158. data/public/vendor/underscore/CONTRIBUTING.md +9 -0
  159. data/public/vendor/underscore/LICENSE +22 -0
  160. data/public/vendor/underscore/README.md +19 -0
  161. data/public/vendor/underscore/Rakefile +10 -0
  162. data/public/vendor/underscore/docs/docco.css +192 -0
  163. data/public/vendor/underscore/docs/favicon.ico +0 -0
  164. data/public/vendor/underscore/docs/images/background.png +0 -0
  165. data/public/vendor/underscore/docs/images/underscore.png +0 -0
  166. data/public/vendor/underscore/docs/underscore.html +823 -0
  167. data/public/vendor/underscore/favicon.ico +0 -0
  168. data/public/vendor/underscore/index.html +2467 -0
  169. data/public/vendor/underscore/index.js +1 -0
  170. data/public/vendor/underscore/package.json +16 -0
  171. data/public/vendor/underscore/test/arrays.js +200 -0
  172. data/public/vendor/underscore/test/chaining.js +59 -0
  173. data/public/vendor/underscore/test/collections.js +453 -0
  174. data/public/vendor/underscore/test/functions.js +265 -0
  175. data/public/vendor/underscore/test/index.html +44 -0
  176. data/public/vendor/underscore/test/objects.js +570 -0
  177. data/public/vendor/underscore/test/speed.js +75 -0
  178. data/public/vendor/underscore/test/utility.js +266 -0
  179. data/public/vendor/underscore/test/vendor/jquery.js +9404 -0
  180. data/public/vendor/underscore/test/vendor/jslitmus.js +670 -0
  181. data/public/vendor/underscore/test/vendor/qunit.css +235 -0
  182. data/public/vendor/underscore/test/vendor/qunit.js +1977 -0
  183. data/public/vendor/underscore/test/vendor/runner.js +98 -0
  184. data/public/vendor/underscore/underscore-min.js +1 -0
  185. data/public/vendor/underscore/underscore.js +1226 -0
  186. data/views/dashboard.haml +1 -1
  187. data/views/layout.haml +8 -4
  188. metadata +132 -25
  189. data/public/vendor/bootstrap/_layouts/customize.html +0 -52
  190. data/public/vendor/bootstrap/assets/js/jquery.bbq.min.js +0 -1287
  191. data/public/vendor/bootstrap-glyphicons/CHANGELOG.md +0 -3
  192. data/public/vendor/bootstrap-glyphicons/CNAME +0 -1
  193. data/public/vendor/bootstrap-glyphicons/CONTRIBUTING.md +0 -54
  194. data/public/vendor/bootstrap-glyphicons/LICENSE +0 -19
  195. data/public/vendor/bootstrap-glyphicons/README.md +0 -61
  196. data/public/vendor/bootstrap-glyphicons/_config.yml +0 -12
  197. data/public/vendor/bootstrap-glyphicons/composer.json +0 -9
  198. data/public/vendor/bootstrap-glyphicons/css/bootstrap-glyphicons.css +0 -2
  199. data/public/vendor/bootstrap-glyphicons/css/bootstrap.css +0 -9
  200. data/public/vendor/bootstrap-glyphicons/css/docs.css +0 -160
  201. data/public/vendor/bootstrap-glyphicons/fonts/glyphiconshalflings-regular.eot +0 -0
  202. data/public/vendor/bootstrap-glyphicons/fonts/glyphiconshalflings-regular.otf +0 -0
  203. data/public/vendor/bootstrap-glyphicons/fonts/glyphiconshalflings-regular.svg +0 -175
  204. data/public/vendor/bootstrap-glyphicons/fonts/glyphiconshalflings-regular.ttf +0 -0
  205. data/public/vendor/bootstrap-glyphicons/fonts/glyphiconshalflings-regular.woff +0 -0
  206. data/public/vendor/bootstrap-glyphicons/index.html +0 -255
  207. data/public/vendor/bootstrap-glyphicons/less/bootstrap-glyphicons.less +0 -201
  208. data/public/vendor/bootstrap-glyphicons/package.json +0 -18
@@ -0,0 +1,570 @@
1
+ $(document).ready(function() {
2
+
3
+ module("Objects");
4
+
5
+ test("keys", function() {
6
+ equal(_.keys({one : 1, two : 2}).join(', '), 'one, two', 'can extract the keys from an object');
7
+ // the test above is not safe because it relies on for-in enumeration order
8
+ var a = []; a[1] = 0;
9
+ equal(_.keys(a).join(', '), '1', 'is not fooled by sparse arrays; see issue #95');
10
+ raises(function() { _.keys(null); }, TypeError, 'throws an error for `null` values');
11
+ raises(function() { _.keys(void 0); }, TypeError, 'throws an error for `undefined` values');
12
+ raises(function() { _.keys(1); }, TypeError, 'throws an error for number primitives');
13
+ raises(function() { _.keys('a'); }, TypeError, 'throws an error for string primitives');
14
+ raises(function() { _.keys(true); }, TypeError, 'throws an error for boolean primitives');
15
+ });
16
+
17
+ test("values", function() {
18
+ equal(_.values({one: 1, two: 2}).join(', '), '1, 2', 'can extract the values from an object');
19
+ equal(_.values({one: 1, two: 2, length: 3}).join(', '), '1, 2, 3', '... even when one of them is "length"');
20
+ });
21
+
22
+ test("pairs", function() {
23
+ deepEqual(_.pairs({one: 1, two: 2}), [['one', 1], ['two', 2]], 'can convert an object into pairs');
24
+ deepEqual(_.pairs({one: 1, two: 2, length: 3}), [['one', 1], ['two', 2], ['length', 3]], '... even when one of them is "length"');
25
+ });
26
+
27
+ test("invert", function() {
28
+ var obj = {first: 'Moe', second: 'Larry', third: 'Curly'};
29
+ equal(_.keys(_.invert(obj)).join(' '), 'Moe Larry Curly', 'can invert an object');
30
+ ok(_.isEqual(_.invert(_.invert(obj)), obj), 'two inverts gets you back where you started');
31
+
32
+ var obj = {length: 3};
33
+ ok(_.invert(obj)['3'] == 'length', 'can invert an object with "length"')
34
+ });
35
+
36
+ test("functions", function() {
37
+ var obj = {a : 'dash', b : _.map, c : (/yo/), d : _.reduce};
38
+ ok(_.isEqual(['b', 'd'], _.functions(obj)), 'can grab the function names of any passed-in object');
39
+
40
+ var Animal = function(){};
41
+ Animal.prototype.run = function(){};
42
+ equal(_.functions(new Animal).join(''), 'run', 'also looks up functions on the prototype');
43
+ });
44
+
45
+ test("extend", function() {
46
+ var result;
47
+ equal(_.extend({}, {a:'b'}).a, 'b', 'can extend an object with the attributes of another');
48
+ equal(_.extend({a:'x'}, {a:'b'}).a, 'b', 'properties in source override destination');
49
+ equal(_.extend({x:'x'}, {a:'b'}).x, 'x', 'properties not in source dont get overriden');
50
+ result = _.extend({x:'x'}, {a:'a'}, {b:'b'});
51
+ ok(_.isEqual(result, {x:'x', a:'a', b:'b'}), 'can extend from multiple source objects');
52
+ result = _.extend({x:'x'}, {a:'a', x:2}, {a:'b'});
53
+ ok(_.isEqual(result, {x:2, a:'b'}), 'extending from multiple source objects last property trumps');
54
+ result = _.extend({}, {a: void 0, b: null});
55
+ equal(_.keys(result).join(''), 'ab', 'extend does not copy undefined values');
56
+
57
+ try {
58
+ result = {};
59
+ _.extend(result, null, undefined, {a:1});
60
+ } catch(ex) {}
61
+
62
+ equal(result.a, 1, 'should not error on `null` or `undefined` sources');
63
+ });
64
+
65
+ test("pick", function() {
66
+ var result;
67
+ result = _.pick({a:1, b:2, c:3}, 'a', 'c');
68
+ ok(_.isEqual(result, {a:1, c:3}), 'can restrict properties to those named');
69
+ result = _.pick({a:1, b:2, c:3}, ['b', 'c']);
70
+ ok(_.isEqual(result, {b:2, c:3}), 'can restrict properties to those named in an array');
71
+ result = _.pick({a:1, b:2, c:3}, ['a'], 'b');
72
+ ok(_.isEqual(result, {a:1, b:2}), 'can restrict properties to those named in mixed args');
73
+
74
+ var Obj = function(){};
75
+ Obj.prototype = {a: 1, b: 2, c: 3};
76
+ ok(_.isEqual(_.pick(new Obj, 'a', 'c'), {a:1, c: 3}), 'include prototype props');
77
+ });
78
+
79
+ test("omit", function() {
80
+ var result;
81
+ result = _.omit({a:1, b:2, c:3}, 'b');
82
+ ok(_.isEqual(result, {a:1, c:3}), 'can omit a single named property');
83
+ result = _.omit({a:1, b:2, c:3}, 'a', 'c');
84
+ ok(_.isEqual(result, {b:2}), 'can omit several named properties');
85
+ result = _.omit({a:1, b:2, c:3}, ['b', 'c']);
86
+ ok(_.isEqual(result, {a:1}), 'can omit properties named in an array');
87
+
88
+ var Obj = function(){};
89
+ Obj.prototype = {a: 1, b: 2, c: 3};
90
+ ok(_.isEqual(_.omit(new Obj, 'b'), {a:1, c: 3}), 'include prototype props');
91
+ });
92
+
93
+ test("defaults", function() {
94
+ var result;
95
+ var options = {zero: 0, one: 1, empty: "", nan: NaN, string: "string"};
96
+
97
+ _.defaults(options, {zero: 1, one: 10, twenty: 20});
98
+ equal(options.zero, 0, 'value exists');
99
+ equal(options.one, 1, 'value exists');
100
+ equal(options.twenty, 20, 'default applied');
101
+
102
+ _.defaults(options, {empty: "full"}, {nan: "nan"}, {word: "word"}, {word: "dog"});
103
+ equal(options.empty, "", 'value exists');
104
+ ok(_.isNaN(options.nan), "NaN isn't overridden");
105
+ equal(options.word, "word", 'new value is added, first one wins');
106
+
107
+ try {
108
+ options = {};
109
+ _.defaults(options, null, undefined, {a:1});
110
+ } catch(ex) {}
111
+
112
+ equal(options.a, 1, 'should not error on `null` or `undefined` sources');
113
+ });
114
+
115
+ test("clone", function() {
116
+ var moe = {name : 'moe', lucky : [13, 27, 34]};
117
+ var clone = _.clone(moe);
118
+ equal(clone.name, 'moe', 'the clone as the attributes of the original');
119
+
120
+ clone.name = 'curly';
121
+ ok(clone.name == 'curly' && moe.name == 'moe', 'clones can change shallow attributes without affecting the original');
122
+
123
+ clone.lucky.push(101);
124
+ equal(_.last(moe.lucky), 101, 'changes to deep attributes are shared with the original');
125
+
126
+ equal(_.clone(undefined), void 0, 'non objects should not be changed by clone');
127
+ equal(_.clone(1), 1, 'non objects should not be changed by clone');
128
+ equal(_.clone(null), null, 'non objects should not be changed by clone');
129
+ });
130
+
131
+ test("isEqual", function() {
132
+ function First() {
133
+ this.value = 1;
134
+ }
135
+ First.prototype.value = 1;
136
+ function Second() {
137
+ this.value = 1;
138
+ }
139
+ Second.prototype.value = 2;
140
+
141
+ // Basic equality and identity comparisons.
142
+ ok(_.isEqual(null, null), "`null` is equal to `null`");
143
+ ok(_.isEqual(), "`undefined` is equal to `undefined`");
144
+
145
+ ok(!_.isEqual(0, -0), "`0` is not equal to `-0`");
146
+ ok(!_.isEqual(-0, 0), "Commutative equality is implemented for `0` and `-0`");
147
+ ok(!_.isEqual(null, undefined), "`null` is not equal to `undefined`");
148
+ ok(!_.isEqual(undefined, null), "Commutative equality is implemented for `null` and `undefined`");
149
+
150
+ // String object and primitive comparisons.
151
+ ok(_.isEqual("Curly", "Curly"), "Identical string primitives are equal");
152
+ ok(_.isEqual(new String("Curly"), new String("Curly")), "String objects with identical primitive values are equal");
153
+ ok(_.isEqual(new String("Curly"), "Curly"), "String primitives and their corresponding object wrappers are equal");
154
+ ok(_.isEqual("Curly", new String("Curly")), "Commutative equality is implemented for string objects and primitives");
155
+
156
+ ok(!_.isEqual("Curly", "Larry"), "String primitives with different values are not equal");
157
+ ok(!_.isEqual(new String("Curly"), new String("Larry")), "String objects with different primitive values are not equal");
158
+ ok(!_.isEqual(new String("Curly"), {toString: function(){ return "Curly"; }}), "String objects and objects with a custom `toString` method are not equal");
159
+
160
+ // Number object and primitive comparisons.
161
+ ok(_.isEqual(75, 75), "Identical number primitives are equal");
162
+ ok(_.isEqual(new Number(75), new Number(75)), "Number objects with identical primitive values are equal");
163
+ ok(_.isEqual(75, new Number(75)), "Number primitives and their corresponding object wrappers are equal");
164
+ ok(_.isEqual(new Number(75), 75), "Commutative equality is implemented for number objects and primitives");
165
+ ok(!_.isEqual(new Number(0), -0), "`new Number(0)` and `-0` are not equal");
166
+ ok(!_.isEqual(0, new Number(-0)), "Commutative equality is implemented for `new Number(0)` and `-0`");
167
+
168
+ ok(!_.isEqual(new Number(75), new Number(63)), "Number objects with different primitive values are not equal");
169
+ ok(!_.isEqual(new Number(63), {valueOf: function(){ return 63; }}), "Number objects and objects with a `valueOf` method are not equal");
170
+
171
+ // Comparisons involving `NaN`.
172
+ ok(_.isEqual(NaN, NaN), "`NaN` is equal to `NaN`");
173
+ ok(!_.isEqual(61, NaN), "A number primitive is not equal to `NaN`");
174
+ ok(!_.isEqual(new Number(79), NaN), "A number object is not equal to `NaN`");
175
+ ok(!_.isEqual(Infinity, NaN), "`Infinity` is not equal to `NaN`");
176
+
177
+ // Boolean object and primitive comparisons.
178
+ ok(_.isEqual(true, true), "Identical boolean primitives are equal");
179
+ ok(_.isEqual(new Boolean, new Boolean), "Boolean objects with identical primitive values are equal");
180
+ ok(_.isEqual(true, new Boolean(true)), "Boolean primitives and their corresponding object wrappers are equal");
181
+ ok(_.isEqual(new Boolean(true), true), "Commutative equality is implemented for booleans");
182
+ ok(!_.isEqual(new Boolean(true), new Boolean), "Boolean objects with different primitive values are not equal");
183
+
184
+ // Common type coercions.
185
+ ok(!_.isEqual(true, new Boolean(false)), "Boolean objects are not equal to the boolean primitive `true`");
186
+ ok(!_.isEqual("75", 75), "String and number primitives with like values are not equal");
187
+ ok(!_.isEqual(new Number(63), new String(63)), "String and number objects with like values are not equal");
188
+ ok(!_.isEqual(75, "75"), "Commutative equality is implemented for like string and number values");
189
+ ok(!_.isEqual(0, ""), "Number and string primitives with like values are not equal");
190
+ ok(!_.isEqual(1, true), "Number and boolean primitives with like values are not equal");
191
+ ok(!_.isEqual(new Boolean(false), new Number(0)), "Boolean and number objects with like values are not equal");
192
+ ok(!_.isEqual(false, new String("")), "Boolean primitives and string objects with like values are not equal");
193
+ ok(!_.isEqual(12564504e5, new Date(2009, 9, 25)), "Dates and their corresponding numeric primitive values are not equal");
194
+
195
+ // Dates.
196
+ ok(_.isEqual(new Date(2009, 9, 25), new Date(2009, 9, 25)), "Date objects referencing identical times are equal");
197
+ ok(!_.isEqual(new Date(2009, 9, 25), new Date(2009, 11, 13)), "Date objects referencing different times are not equal");
198
+ ok(!_.isEqual(new Date(2009, 11, 13), {
199
+ getTime: function(){
200
+ return 12606876e5;
201
+ }
202
+ }), "Date objects and objects with a `getTime` method are not equal");
203
+ ok(!_.isEqual(new Date("Curly"), new Date("Curly")), "Invalid dates are not equal");
204
+
205
+ // Functions.
206
+ ok(!_.isEqual(First, Second), "Different functions with identical bodies and source code representations are not equal");
207
+
208
+ // RegExps.
209
+ ok(_.isEqual(/(?:)/gim, /(?:)/gim), "RegExps with equivalent patterns and flags are equal");
210
+ ok(!_.isEqual(/(?:)/g, /(?:)/gi), "RegExps with equivalent patterns and different flags are not equal");
211
+ ok(!_.isEqual(/Moe/gim, /Curly/gim), "RegExps with different patterns and equivalent flags are not equal");
212
+ ok(!_.isEqual(/(?:)/gi, /(?:)/g), "Commutative equality is implemented for RegExps");
213
+ ok(!_.isEqual(/Curly/g, {source: "Larry", global: true, ignoreCase: false, multiline: false}), "RegExps and RegExp-like objects are not equal");
214
+
215
+ // Empty arrays, array-like objects, and object literals.
216
+ ok(_.isEqual({}, {}), "Empty object literals are equal");
217
+ ok(_.isEqual([], []), "Empty array literals are equal");
218
+ ok(_.isEqual([{}], [{}]), "Empty nested arrays and objects are equal");
219
+ ok(!_.isEqual({length: 0}, []), "Array-like objects and arrays are not equal.");
220
+ ok(!_.isEqual([], {length: 0}), "Commutative equality is implemented for array-like objects");
221
+
222
+ ok(!_.isEqual({}, []), "Object literals and array literals are not equal");
223
+ ok(!_.isEqual([], {}), "Commutative equality is implemented for objects and arrays");
224
+
225
+ // Arrays with primitive and object values.
226
+ ok(_.isEqual([1, "Larry", true], [1, "Larry", true]), "Arrays containing identical primitives are equal");
227
+ ok(_.isEqual([(/Moe/g), new Date(2009, 9, 25)], [(/Moe/g), new Date(2009, 9, 25)]), "Arrays containing equivalent elements are equal");
228
+
229
+ // Multi-dimensional arrays.
230
+ var a = [new Number(47), false, "Larry", /Moe/, new Date(2009, 11, 13), ['running', 'biking', new String('programming')], {a: 47}];
231
+ var b = [new Number(47), false, "Larry", /Moe/, new Date(2009, 11, 13), ['running', 'biking', new String('programming')], {a: 47}];
232
+ ok(_.isEqual(a, b), "Arrays containing nested arrays and objects are recursively compared");
233
+
234
+ // Overwrite the methods defined in ES 5.1 section 15.4.4.
235
+ a.forEach = a.map = a.filter = a.every = a.indexOf = a.lastIndexOf = a.some = a.reduce = a.reduceRight = null;
236
+ b.join = b.pop = b.reverse = b.shift = b.slice = b.splice = b.concat = b.sort = b.unshift = null;
237
+
238
+ // Array elements and properties.
239
+ ok(_.isEqual(a, b), "Arrays containing equivalent elements and different non-numeric properties are equal");
240
+ a.push("White Rocks");
241
+ ok(!_.isEqual(a, b), "Arrays of different lengths are not equal");
242
+ a.push("East Boulder");
243
+ b.push("Gunbarrel Ranch", "Teller Farm");
244
+ ok(!_.isEqual(a, b), "Arrays of identical lengths containing different elements are not equal");
245
+
246
+ // Sparse arrays.
247
+ ok(_.isEqual(Array(3), Array(3)), "Sparse arrays of identical lengths are equal");
248
+ ok(!_.isEqual(Array(3), Array(6)), "Sparse arrays of different lengths are not equal when both are empty");
249
+
250
+ // Simple objects.
251
+ ok(_.isEqual({a: "Curly", b: 1, c: true}, {a: "Curly", b: 1, c: true}), "Objects containing identical primitives are equal");
252
+ ok(_.isEqual({a: /Curly/g, b: new Date(2009, 11, 13)}, {a: /Curly/g, b: new Date(2009, 11, 13)}), "Objects containing equivalent members are equal");
253
+ ok(!_.isEqual({a: 63, b: 75}, {a: 61, b: 55}), "Objects of identical sizes with different values are not equal");
254
+ ok(!_.isEqual({a: 63, b: 75}, {a: 61, c: 55}), "Objects of identical sizes with different property names are not equal");
255
+ ok(!_.isEqual({a: 1, b: 2}, {a: 1}), "Objects of different sizes are not equal");
256
+ ok(!_.isEqual({a: 1}, {a: 1, b: 2}), "Commutative equality is implemented for objects");
257
+ ok(!_.isEqual({x: 1, y: undefined}, {x: 1, z: 2}), "Objects with identical keys and different values are not equivalent");
258
+
259
+ // `A` contains nested objects and arrays.
260
+ a = {
261
+ name: new String("Moe Howard"),
262
+ age: new Number(77),
263
+ stooge: true,
264
+ hobbies: ["acting"],
265
+ film: {
266
+ name: "Sing a Song of Six Pants",
267
+ release: new Date(1947, 9, 30),
268
+ stars: [new String("Larry Fine"), "Shemp Howard"],
269
+ minutes: new Number(16),
270
+ seconds: 54
271
+ }
272
+ };
273
+
274
+ // `B` contains equivalent nested objects and arrays.
275
+ b = {
276
+ name: new String("Moe Howard"),
277
+ age: new Number(77),
278
+ stooge: true,
279
+ hobbies: ["acting"],
280
+ film: {
281
+ name: "Sing a Song of Six Pants",
282
+ release: new Date(1947, 9, 30),
283
+ stars: [new String("Larry Fine"), "Shemp Howard"],
284
+ minutes: new Number(16),
285
+ seconds: 54
286
+ }
287
+ };
288
+ ok(_.isEqual(a, b), "Objects with nested equivalent members are recursively compared");
289
+
290
+ // Instances.
291
+ ok(_.isEqual(new First, new First), "Object instances are equal");
292
+ ok(!_.isEqual(new First, new Second), "Objects with different constructors and identical own properties are not equal");
293
+ ok(!_.isEqual({value: 1}, new First), "Object instances and objects sharing equivalent properties are not equal");
294
+ ok(!_.isEqual({value: 2}, new Second), "The prototype chain of objects should not be examined");
295
+
296
+ // Circular Arrays.
297
+ (a = []).push(a);
298
+ (b = []).push(b);
299
+ ok(_.isEqual(a, b), "Arrays containing circular references are equal");
300
+ a.push(new String("Larry"));
301
+ b.push(new String("Larry"));
302
+ ok(_.isEqual(a, b), "Arrays containing circular references and equivalent properties are equal");
303
+ a.push("Shemp");
304
+ b.push("Curly");
305
+ ok(!_.isEqual(a, b), "Arrays containing circular references and different properties are not equal");
306
+
307
+ // More circular arrays #767.
308
+ a = ["everything is checked but", "this", "is not"];
309
+ a[1] = a;
310
+ b = ["everything is checked but", ["this", "array"], "is not"];
311
+ ok(!_.isEqual(a, b), "Comparison of circular references with non-circular references are not equal");
312
+
313
+ // Circular Objects.
314
+ a = {abc: null};
315
+ b = {abc: null};
316
+ a.abc = a;
317
+ b.abc = b;
318
+ ok(_.isEqual(a, b), "Objects containing circular references are equal");
319
+ a.def = 75;
320
+ b.def = 75;
321
+ ok(_.isEqual(a, b), "Objects containing circular references and equivalent properties are equal");
322
+ a.def = new Number(75);
323
+ b.def = new Number(63);
324
+ ok(!_.isEqual(a, b), "Objects containing circular references and different properties are not equal");
325
+
326
+ // More circular objects #767.
327
+ a = {everything: "is checked", but: "this", is: "not"};
328
+ a.but = a;
329
+ b = {everything: "is checked", but: {that:"object"}, is: "not"};
330
+ ok(!_.isEqual(a, b), "Comparison of circular references with non-circular object references are not equal");
331
+
332
+ // Cyclic Structures.
333
+ a = [{abc: null}];
334
+ b = [{abc: null}];
335
+ (a[0].abc = a).push(a);
336
+ (b[0].abc = b).push(b);
337
+ ok(_.isEqual(a, b), "Cyclic structures are equal");
338
+ a[0].def = "Larry";
339
+ b[0].def = "Larry";
340
+ ok(_.isEqual(a, b), "Cyclic structures containing equivalent properties are equal");
341
+ a[0].def = new String("Larry");
342
+ b[0].def = new String("Curly");
343
+ ok(!_.isEqual(a, b), "Cyclic structures containing different properties are not equal");
344
+
345
+ // Complex Circular References.
346
+ a = {foo: {b: {foo: {c: {foo: null}}}}};
347
+ b = {foo: {b: {foo: {c: {foo: null}}}}};
348
+ a.foo.b.foo.c.foo = a;
349
+ b.foo.b.foo.c.foo = b;
350
+ ok(_.isEqual(a, b), "Cyclic structures with nested and identically-named properties are equal");
351
+
352
+ // Chaining.
353
+ ok(!_.isEqual(_({x: 1, y: undefined}).chain(), _({x: 1, z: 2}).chain()), 'Chained objects containing different values are not equal');
354
+
355
+ a = _({x: 1, y: 2}).chain();
356
+ b = _({x: 1, y: 2}).chain();
357
+ equal(_.isEqual(a.isEqual(b), _(true)), true, '`isEqual` can be chained');
358
+
359
+ // Objects from another frame.
360
+ ok(_.isEqual({}, iObject));
361
+ });
362
+
363
+ test("isEmpty", function() {
364
+ ok(!_([1]).isEmpty(), '[1] is not empty');
365
+ ok(_.isEmpty([]), '[] is empty');
366
+ ok(!_.isEmpty({one : 1}), '{one : 1} is not empty');
367
+ ok(_.isEmpty({}), '{} is empty');
368
+ ok(_.isEmpty(new RegExp('')), 'objects with prototype properties are empty');
369
+ ok(_.isEmpty(null), 'null is empty');
370
+ ok(_.isEmpty(), 'undefined is empty');
371
+ ok(_.isEmpty(''), 'the empty string is empty');
372
+ ok(!_.isEmpty('moe'), 'but other strings are not');
373
+
374
+ var obj = {one : 1};
375
+ delete obj.one;
376
+ ok(_.isEmpty(obj), 'deleting all the keys from an object empties it');
377
+ });
378
+
379
+ // Setup remote variables for iFrame tests.
380
+ var iframe = document.createElement('iframe');
381
+ jQuery(iframe).appendTo(document.body);
382
+ var iDoc = iframe.contentDocument || iframe.contentWindow.document;
383
+ iDoc.write(
384
+ "<script>\
385
+ parent.iElement = document.createElement('div');\
386
+ parent.iArguments = (function(){ return arguments; })(1, 2, 3);\
387
+ parent.iArray = [1, 2, 3];\
388
+ parent.iString = new String('hello');\
389
+ parent.iNumber = new Number(100);\
390
+ parent.iFunction = (function(){});\
391
+ parent.iDate = new Date();\
392
+ parent.iRegExp = /hi/;\
393
+ parent.iNaN = NaN;\
394
+ parent.iNull = null;\
395
+ parent.iBoolean = new Boolean(false);\
396
+ parent.iUndefined = undefined;\
397
+ parent.iObject = {};\
398
+ </script>"
399
+ );
400
+ iDoc.close();
401
+
402
+ test("isElement", function() {
403
+ ok(!_.isElement('div'), 'strings are not dom elements');
404
+ ok(_.isElement($('html')[0]), 'the html tag is a DOM element');
405
+ ok(_.isElement(iElement), 'even from another frame');
406
+ });
407
+
408
+ test("isArguments", function() {
409
+ var args = (function(){ return arguments; })(1, 2, 3);
410
+ ok(!_.isArguments('string'), 'a string is not an arguments object');
411
+ ok(!_.isArguments(_.isArguments), 'a function is not an arguments object');
412
+ ok(_.isArguments(args), 'but the arguments object is an arguments object');
413
+ ok(!_.isArguments(_.toArray(args)), 'but not when it\'s converted into an array');
414
+ ok(!_.isArguments([1,2,3]), 'and not vanilla arrays.');
415
+ ok(_.isArguments(iArguments), 'even from another frame');
416
+ });
417
+
418
+ test("isObject", function() {
419
+ ok(_.isObject(arguments), 'the arguments object is object');
420
+ ok(_.isObject([1, 2, 3]), 'and arrays');
421
+ ok(_.isObject($('html')[0]), 'and DOM element');
422
+ ok(_.isObject(iElement), 'even from another frame');
423
+ ok(_.isObject(function () {}), 'and functions');
424
+ ok(_.isObject(iFunction), 'even from another frame');
425
+ ok(!_.isObject(null), 'but not null');
426
+ ok(!_.isObject(undefined), 'and not undefined');
427
+ ok(!_.isObject('string'), 'and not string');
428
+ ok(!_.isObject(12), 'and not number');
429
+ ok(!_.isObject(true), 'and not boolean');
430
+ ok(_.isObject(new String('string')), 'but new String()');
431
+ });
432
+
433
+ test("isArray", function() {
434
+ ok(!_.isArray(arguments), 'the arguments object is not an array');
435
+ ok(_.isArray([1, 2, 3]), 'but arrays are');
436
+ ok(_.isArray(iArray), 'even from another frame');
437
+ });
438
+
439
+ test("isString", function() {
440
+ ok(!_.isString(document.body), 'the document body is not a string');
441
+ ok(_.isString([1, 2, 3].join(', ')), 'but strings are');
442
+ ok(_.isString(iString), 'even from another frame');
443
+ });
444
+
445
+ test("isNumber", function() {
446
+ ok(!_.isNumber('string'), 'a string is not a number');
447
+ ok(!_.isNumber(arguments), 'the arguments object is not a number');
448
+ ok(!_.isNumber(undefined), 'undefined is not a number');
449
+ ok(_.isNumber(3 * 4 - 7 / 10), 'but numbers are');
450
+ ok(_.isNumber(NaN), 'NaN *is* a number');
451
+ ok(_.isNumber(Infinity), 'Infinity is a number');
452
+ ok(_.isNumber(iNumber), 'even from another frame');
453
+ ok(!_.isNumber('1'), 'numeric strings are not numbers');
454
+ });
455
+
456
+ test("isBoolean", function() {
457
+ ok(!_.isBoolean(2), 'a number is not a boolean');
458
+ ok(!_.isBoolean("string"), 'a string is not a boolean');
459
+ ok(!_.isBoolean("false"), 'the string "false" is not a boolean');
460
+ ok(!_.isBoolean("true"), 'the string "true" is not a boolean');
461
+ ok(!_.isBoolean(arguments), 'the arguments object is not a boolean');
462
+ ok(!_.isBoolean(undefined), 'undefined is not a boolean');
463
+ ok(!_.isBoolean(NaN), 'NaN is not a boolean');
464
+ ok(!_.isBoolean(null), 'null is not a boolean');
465
+ ok(_.isBoolean(true), 'but true is');
466
+ ok(_.isBoolean(false), 'and so is false');
467
+ ok(_.isBoolean(iBoolean), 'even from another frame');
468
+ });
469
+
470
+ test("isFunction", function() {
471
+ ok(!_.isFunction([1, 2, 3]), 'arrays are not functions');
472
+ ok(!_.isFunction('moe'), 'strings are not functions');
473
+ ok(_.isFunction(_.isFunction), 'but functions are');
474
+ ok(_.isFunction(iFunction), 'even from another frame');
475
+ });
476
+
477
+ test("isDate", function() {
478
+ ok(!_.isDate(100), 'numbers are not dates');
479
+ ok(!_.isDate({}), 'objects are not dates');
480
+ ok(_.isDate(new Date()), 'but dates are');
481
+ ok(_.isDate(iDate), 'even from another frame');
482
+ });
483
+
484
+ test("isRegExp", function() {
485
+ ok(!_.isRegExp(_.identity), 'functions are not RegExps');
486
+ ok(_.isRegExp(/identity/), 'but RegExps are');
487
+ ok(_.isRegExp(iRegExp), 'even from another frame');
488
+ });
489
+
490
+ test("isFinite", function() {
491
+ ok(!_.isFinite(undefined), 'undefined is not Finite');
492
+ ok(!_.isFinite(null), 'null is not Finite');
493
+ ok(!_.isFinite(NaN), 'NaN is not Finite');
494
+ ok(!_.isFinite(Infinity), 'Infinity is not Finite');
495
+ ok(!_.isFinite(-Infinity), '-Infinity is not Finite');
496
+ ok(_.isFinite('12'), 'Numeric strings are numbers');
497
+ ok(!_.isFinite('1a'), 'Non numeric strings are not numbers');
498
+ ok(!_.isFinite(''), 'Empty strings are not numbers');
499
+ var obj = new Number(5);
500
+ ok(_.isFinite(obj), 'Number instances can be finite');
501
+ ok(_.isFinite(0), '0 is Finite');
502
+ ok(_.isFinite(123), 'Ints are Finite');
503
+ ok(_.isFinite(-12.44), 'Floats are Finite');
504
+ });
505
+
506
+ test("isNaN", function() {
507
+ ok(!_.isNaN(undefined), 'undefined is not NaN');
508
+ ok(!_.isNaN(null), 'null is not NaN');
509
+ ok(!_.isNaN(0), '0 is not NaN');
510
+ ok(_.isNaN(NaN), 'but NaN is');
511
+ ok(_.isNaN(iNaN), 'even from another frame');
512
+ ok(_.isNaN(new Number(NaN)), 'wrapped NaN is still NaN');
513
+ });
514
+
515
+ test("isNull", function() {
516
+ ok(!_.isNull(undefined), 'undefined is not null');
517
+ ok(!_.isNull(NaN), 'NaN is not null');
518
+ ok(_.isNull(null), 'but null is');
519
+ ok(_.isNull(iNull), 'even from another frame');
520
+ });
521
+
522
+ test("isUndefined", function() {
523
+ ok(!_.isUndefined(1), 'numbers are defined');
524
+ ok(!_.isUndefined(null), 'null is defined');
525
+ ok(!_.isUndefined(false), 'false is defined');
526
+ ok(!_.isUndefined(NaN), 'NaN is defined');
527
+ ok(_.isUndefined(), 'nothing is undefined');
528
+ ok(_.isUndefined(undefined), 'undefined is undefined');
529
+ ok(_.isUndefined(iUndefined), 'even from another frame');
530
+ });
531
+
532
+ if (window.ActiveXObject) {
533
+ test("IE host objects", function() {
534
+ var xml = new ActiveXObject("Msxml2.DOMDocument.3.0");
535
+ ok(!_.isNumber(xml));
536
+ ok(!_.isBoolean(xml));
537
+ ok(!_.isNaN(xml));
538
+ ok(!_.isFunction(xml));
539
+ ok(!_.isNull(xml));
540
+ ok(!_.isUndefined(xml));
541
+ });
542
+ }
543
+
544
+ test("tap", function() {
545
+ var intercepted = null;
546
+ var interceptor = function(obj) { intercepted = obj; };
547
+ var returned = _.tap(1, interceptor);
548
+ equal(intercepted, 1, "passes tapped object to interceptor");
549
+ equal(returned, 1, "returns tapped object");
550
+
551
+ returned = _([1,2,3]).chain().
552
+ map(function(n){ return n * 2; }).
553
+ max().
554
+ tap(interceptor).
555
+ value();
556
+ ok(returned == 6 && intercepted == 6, 'can use tapped objects in a chain');
557
+ });
558
+
559
+ test("has", function () {
560
+ var obj = {foo: "bar", func: function () {} };
561
+ ok (_.has(obj, "foo"), "has() checks that the object has a property.");
562
+ ok (_.has(obj, "baz") == false, "has() returns false if the object doesn't have the property.");
563
+ ok (_.has(obj, "func"), "has() works for functions too.");
564
+ obj.hasOwnProperty = null;
565
+ ok (_.has(obj, "foo"), "has() works even when the hasOwnProperty method is deleted.");
566
+ var child = {};
567
+ child.prototype = obj;
568
+ ok (_.has(child, "foo") == false, "has() does not check the prototype chain for a property.")
569
+ });
570
+ });
@@ -0,0 +1,75 @@
1
+ (function() {
2
+
3
+ var numbers = [];
4
+ for (var i=0; i<1000; i++) numbers.push(i);
5
+ var objects = _.map(numbers, function(n){ return {num : n}; });
6
+ var randomized = _.sortBy(numbers, function(){ return Math.random(); });
7
+ var deep = _.map(_.range(100), function() { return _.range(1000); });
8
+
9
+ JSLitmus.test('_.each()', function() {
10
+ var timesTwo = [];
11
+ _.each(numbers, function(num){ timesTwo.push(num * 2); });
12
+ return timesTwo;
13
+ });
14
+
15
+ JSLitmus.test('_(list).each()', function() {
16
+ var timesTwo = [];
17
+ _(numbers).each(function(num){ timesTwo.push(num * 2); });
18
+ return timesTwo;
19
+ });
20
+
21
+ JSLitmus.test('jQuery.each()', function() {
22
+ var timesTwo = [];
23
+ jQuery.each(numbers, function(){ timesTwo.push(this * 2); });
24
+ return timesTwo;
25
+ });
26
+
27
+ JSLitmus.test('_.map()', function() {
28
+ return _.map(objects, function(obj){ return obj.num; });
29
+ });
30
+
31
+ JSLitmus.test('jQuery.map()', function() {
32
+ return jQuery.map(objects, function(obj){ return obj.num; });
33
+ });
34
+
35
+ JSLitmus.test('_.pluck()', function() {
36
+ return _.pluck(objects, 'num');
37
+ });
38
+
39
+ JSLitmus.test('_.uniq()', function() {
40
+ return _.uniq(randomized);
41
+ });
42
+
43
+ JSLitmus.test('_.uniq() (sorted)', function() {
44
+ return _.uniq(numbers, true);
45
+ });
46
+
47
+ JSLitmus.test('_.sortBy()', function() {
48
+ return _.sortBy(numbers, function(num){ return -num; });
49
+ });
50
+
51
+ JSLitmus.test('_.isEqual()', function() {
52
+ return _.isEqual(numbers, randomized);
53
+ });
54
+
55
+ JSLitmus.test('_.keys()', function() {
56
+ return _.keys(objects);
57
+ });
58
+
59
+ JSLitmus.test('_.values()', function() {
60
+ return _.values(objects);
61
+ });
62
+
63
+ JSLitmus.test('_.intersection()', function() {
64
+ return _.intersection(numbers, randomized);
65
+ });
66
+
67
+ JSLitmus.test('_.range()', function() {
68
+ return _.range(1000);
69
+ });
70
+
71
+ JSLitmus.test('_.flatten()', function() {
72
+ return _.flatten(deep);
73
+ });
74
+
75
+ })();