react 0.6.3 → 0.9.0-rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. package/README.md +10 -222
  2. package/addons.js +1 -0
  3. package/lib/AutoFocusMixin.js +30 -0
  4. package/lib/CSSCore.js +115 -0
  5. package/lib/CSSProperty.js +121 -0
  6. package/lib/CSSPropertyOperations.js +97 -0
  7. package/lib/ChangeEventPlugin.js +387 -0
  8. package/lib/ClientReactRootIndex.js +30 -0
  9. package/lib/CompositionEventPlugin.js +260 -0
  10. package/lib/DOMChildrenOperations.js +165 -0
  11. package/lib/DOMProperty.js +268 -0
  12. package/lib/DOMPropertyOperations.js +181 -0
  13. package/lib/Danger.js +187 -0
  14. package/lib/DefaultDOMPropertyConfig.js +197 -0
  15. package/lib/DefaultEventPluginOrder.js +44 -0
  16. package/lib/EnterLeaveEventPlugin.js +145 -0
  17. package/lib/EventConstants.js +76 -0
  18. package/lib/EventListener.js +69 -0
  19. package/lib/EventPluginHub.js +291 -0
  20. package/lib/EventPluginRegistry.js +260 -0
  21. package/lib/EventPluginUtils.js +214 -0
  22. package/lib/EventPropagators.js +143 -0
  23. package/lib/ExecutionEnvironment.js +44 -0
  24. package/lib/LinkedStateMixin.js +46 -0
  25. package/lib/LinkedValueUtils.js +161 -0
  26. package/lib/MobileSafariClickEventPlugin.js +63 -0
  27. package/lib/PooledClass.js +119 -0
  28. package/lib/React.js +95 -0
  29. package/lib/ReactCSSTransitionGroup.js +65 -0
  30. package/lib/ReactCSSTransitionGroupChild.js +138 -0
  31. package/lib/ReactChildren.js +132 -0
  32. package/lib/ReactComponent.js +550 -0
  33. package/lib/ReactComponentBrowserEnvironment.js +158 -0
  34. package/lib/ReactComponentEnvironment.js +26 -0
  35. package/lib/ReactCompositeComponent.js +1455 -0
  36. package/lib/ReactContext.js +67 -0
  37. package/lib/ReactCurrentOwner.js +39 -0
  38. package/lib/ReactDOM.js +207 -0
  39. package/lib/ReactDOMButton.js +68 -0
  40. package/lib/ReactDOMComponent.js +399 -0
  41. package/lib/ReactDOMForm.js +59 -0
  42. package/lib/ReactDOMIDOperations.js +218 -0
  43. package/lib/ReactDOMImg.js +58 -0
  44. package/lib/ReactDOMInput.js +181 -0
  45. package/lib/ReactDOMOption.js +51 -0
  46. package/lib/ReactDOMSelect.js +179 -0
  47. package/lib/ReactDOMSelection.js +189 -0
  48. package/lib/ReactDOMTextarea.js +140 -0
  49. package/lib/ReactDefaultBatchingStrategy.js +75 -0
  50. package/lib/ReactDefaultInjection.js +115 -0
  51. package/lib/ReactDefaultPerf.js +244 -0
  52. package/lib/ReactDefaultPerfAnalysis.js +199 -0
  53. package/lib/ReactErrorUtils.js +37 -0
  54. package/lib/ReactEventEmitter.js +337 -0
  55. package/lib/ReactEventEmitterMixin.js +57 -0
  56. package/lib/ReactEventTopLevelCallback.js +109 -0
  57. package/lib/ReactInjection.js +39 -0
  58. package/lib/ReactInputSelection.js +140 -0
  59. package/lib/ReactInstanceHandles.js +338 -0
  60. package/lib/ReactLink.js +54 -0
  61. package/lib/ReactMarkupChecksum.js +53 -0
  62. package/lib/ReactMount.js +641 -0
  63. package/lib/ReactMountReady.js +95 -0
  64. package/lib/ReactMultiChild.js +425 -0
  65. package/lib/ReactMultiChildUpdateTypes.js +38 -0
  66. package/lib/ReactOwner.js +154 -0
  67. package/lib/ReactPerf.js +85 -0
  68. package/lib/ReactPropTransferer.js +147 -0
  69. package/lib/ReactPropTypeLocationNames.js +31 -0
  70. package/lib/ReactPropTypeLocations.js +29 -0
  71. package/lib/ReactPropTypes.js +359 -0
  72. package/lib/ReactPutListenerQueue.js +61 -0
  73. package/lib/ReactReconcileTransaction.js +181 -0
  74. package/lib/ReactRootIndex.js +36 -0
  75. package/lib/ReactServerRendering.js +59 -0
  76. package/lib/ReactStateSetters.js +111 -0
  77. package/lib/ReactTextComponent.js +99 -0
  78. package/lib/ReactTransitionChildMapping.js +106 -0
  79. package/lib/ReactTransitionEvents.js +97 -0
  80. package/lib/ReactTransitionGroup.js +187 -0
  81. package/lib/ReactUpdates.js +148 -0
  82. package/lib/ReactWithAddons.js +46 -0
  83. package/lib/SelectEventPlugin.js +200 -0
  84. package/lib/ServerReactRootIndex.js +36 -0
  85. package/lib/SimpleEventPlugin.js +413 -0
  86. package/lib/SyntheticClipboardEvent.js +51 -0
  87. package/lib/SyntheticCompositionEvent.js +51 -0
  88. package/lib/SyntheticDragEvent.js +44 -0
  89. package/lib/SyntheticEvent.js +164 -0
  90. package/lib/SyntheticFocusEvent.js +44 -0
  91. package/lib/SyntheticKeyboardEvent.js +58 -0
  92. package/lib/SyntheticMouseEvent.js +85 -0
  93. package/lib/SyntheticTouchEvent.js +50 -0
  94. package/lib/SyntheticUIEvent.js +45 -0
  95. package/lib/SyntheticWheelEvent.js +66 -0
  96. package/lib/Transaction.js +276 -0
  97. package/lib/ViewportMetrics.js +37 -0
  98. package/lib/accumulate.js +54 -0
  99. package/lib/adler32.js +39 -0
  100. package/lib/cloneWithProps.js +59 -0
  101. package/lib/containsNode.js +49 -0
  102. package/lib/copyProperties.js +54 -0
  103. package/lib/createArrayFrom.js +91 -0
  104. package/lib/createFullPageComponent.js +63 -0
  105. package/lib/createNodesFromMarkup.js +93 -0
  106. package/lib/createObjectFrom.js +61 -0
  107. package/lib/cx.js +44 -0
  108. package/lib/dangerousStyleValue.js +57 -0
  109. package/lib/emptyFunction.js +43 -0
  110. package/lib/escapeTextForBrowser.js +47 -0
  111. package/lib/flattenChildren.js +57 -0
  112. package/lib/forEachAccumulated.js +36 -0
  113. package/lib/getActiveElement.js +34 -0
  114. package/lib/getEventKey.js +85 -0
  115. package/lib/getEventTarget.js +36 -0
  116. package/lib/getMarkupWrap.js +118 -0
  117. package/lib/getNodeForCharacterOffset.js +80 -0
  118. package/lib/getReactRootElementInContainer.js +40 -0
  119. package/lib/getTextContentAccessor.js +42 -0
  120. package/lib/getUnboundedScrollPosition.js +45 -0
  121. package/lib/hyphenate.js +35 -0
  122. package/lib/invariant.js +62 -0
  123. package/lib/isEventSupported.js +70 -0
  124. package/lib/isNode.js +33 -0
  125. package/lib/isTextInputElement.js +49 -0
  126. package/lib/isTextNode.js +30 -0
  127. package/lib/joinClasses.js +44 -0
  128. package/lib/keyMirror.js +58 -0
  129. package/lib/keyOf.js +41 -0
  130. package/lib/memoizeStringOnly.js +39 -0
  131. package/lib/merge.js +37 -0
  132. package/lib/mergeHelpers.js +136 -0
  133. package/lib/mergeInto.js +45 -0
  134. package/lib/mixInto.js +34 -0
  135. package/lib/objMap.js +47 -0
  136. package/lib/objMapKeyVal.js +47 -0
  137. package/lib/onlyChild.js +43 -0
  138. package/lib/performanceNow.js +42 -0
  139. package/lib/shallowEqual.js +49 -0
  140. package/lib/shouldUpdateReactComponent.js +58 -0
  141. package/lib/toArray.js +75 -0
  142. package/lib/traverseAllChildren.js +189 -0
  143. package/lib/warning.js +40 -0
  144. package/package.json +32 -21
  145. package/react.js +1 -0
  146. package/.npmignore +0 -7
  147. package/.travis.yml +0 -5
  148. package/Jakefile.js +0 -39
  149. package/LICENSE +0 -19
  150. package/browser-test/dist.html +0 -90
  151. package/browser-test/index.html +0 -86
  152. package/browser-test/min.html +0 -90
  153. package/dist/react.js +0 -3107
  154. package/dist/react.min.js +0 -22
  155. package/doc/advanced.md +0 -174
  156. package/doc/color-def.graffle +0 -938
  157. package/doc/color-def.png +0 -0
  158. package/doc/simple.dot +0 -25
  159. package/doc/simple.png +0 -0
  160. package/examples/longer-example.js +0 -41
  161. package/examples/simple.js +0 -45
  162. package/examples/using-ast-directly.js +0 -30
  163. package/examples/using-events1.js +0 -79
  164. package/examples/using-log-events.js +0 -43
  165. package/lib/base-task.js +0 -123
  166. package/lib/cb-task.js +0 -84
  167. package/lib/core.js +0 -138
  168. package/lib/dsl.js +0 -138
  169. package/lib/error.js +0 -55
  170. package/lib/event-collector.js +0 -81
  171. package/lib/event-manager.js +0 -89
  172. package/lib/eventemitter.js +0 -20
  173. package/lib/finalcb-first-task.js +0 -68
  174. package/lib/finalcb-task.js +0 -65
  175. package/lib/id.js +0 -22
  176. package/lib/input-parser.js +0 -56
  177. package/lib/log-events.js +0 -101
  178. package/lib/parse.js +0 -41
  179. package/lib/promise-resolve.js +0 -50
  180. package/lib/promise-task.js +0 -93
  181. package/lib/react.js +0 -59
  182. package/lib/ret-task.js +0 -71
  183. package/lib/sprintf.js +0 -18
  184. package/lib/status.js +0 -14
  185. package/lib/task.js +0 -251
  186. package/lib/track-tasks.js +0 -74
  187. package/lib/validate.js +0 -159
  188. package/lib/vcon.js +0 -90
  189. package/lib/when-task.js +0 -85
  190. package/src/dist.build.requirejs +0 -20
  191. package/test/ast.mocha.js +0 -136
  192. package/test/cb-task.mocha.js +0 -220
  193. package/test/core-deferred.mocha.js +0 -143
  194. package/test/core-when.mocha.js +0 -96
  195. package/test/core.mocha.js +0 -589
  196. package/test/dsl.mocha.js +0 -350
  197. package/test/event-manager.mocha.js +0 -119
  198. package/test/exec-options.mocha.js +0 -48
  199. package/test/finalcb-task.mocha.js +0 -58
  200. package/test/input-parser.mocha.js +0 -86
  201. package/test/log-events.mocha.js +0 -88
  202. package/test/mocha.opts +0 -2
  203. package/test/module-use.mocha.js +0 -147
  204. package/test/promise-auto-resolve.mocha.js +0 -68
  205. package/test/ret-task.mocha.js +0 -220
  206. package/test/task.mocha.js +0 -42
  207. package/test/validate-cb-task.mocha.js +0 -100
  208. package/test/validate-ret-task.mocha.js +0 -110
  209. package/test/validate.mocha.js +0 -324
  210. package/test/vcon.mocha.js +0 -193
  211. package/vendor/chai/chai.js +0 -2038
  212. package/vendor/jquery/jquery-1.7.1.js +0 -9266
  213. package/vendor/jquery/jquery-1.7.1.min.js +0 -4
  214. package/vendor/mocha/mocha.css +0 -135
  215. package/vendor/mocha/mocha.js +0 -3589
  216. package/vendor/node/util.js +0 -531
  217. package/vendor/requirejs/require.js +0 -2053
  218. package/vendor/requirejs/require.min.js +0 -33
@@ -1,2038 +0,0 @@
1
- !function (name, definition) {
2
- if (typeof define == 'function' && typeof define.amd == 'object') define(definition);
3
- else this[name] = definition();
4
- }('chai', function () {
5
-
6
- // CommonJS require()
7
-
8
- function require(p){
9
- var path = require.resolve(p)
10
- , mod = require.modules[path];
11
- if (!mod) throw new Error('failed to require "' + p + '"');
12
- if (!mod.exports) {
13
- mod.exports = {};
14
- mod.call(mod.exports, mod, mod.exports, require.relative(path));
15
- }
16
- return mod.exports;
17
- }
18
-
19
- require.modules = {};
20
-
21
- require.resolve = function (path){
22
- var orig = path
23
- , reg = path + '.js'
24
- , index = path + '/index.js';
25
- return require.modules[reg] && reg
26
- || require.modules[index] && index
27
- || orig;
28
- };
29
-
30
- require.register = function (path, fn){
31
- require.modules[path] = fn;
32
- };
33
-
34
- require.relative = function (parent) {
35
- return function(p){
36
- if ('.' != p[0]) return require(p);
37
-
38
- var path = parent.split('/')
39
- , segs = p.split('/');
40
- path.pop();
41
-
42
- for (var i = 0; i < segs.length; i++) {
43
- var seg = segs[i];
44
- if ('..' == seg) path.pop();
45
- else if ('.' != seg) path.push(seg);
46
- }
47
-
48
- return require(path.join('/'));
49
- };
50
- };
51
-
52
-
53
- require.register("assertion.js", function(module, exports, require){
54
- /*!
55
- * chai
56
- * Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
57
- * MIT Licensed
58
- *
59
- * Primarily a refactor of: should.js
60
- * https://github.com/visionmedia/should.js
61
- * Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
62
- * MIT Licensed
63
- */
64
-
65
- /**
66
- * ### BDD Style Introduction
67
- *
68
- * The BDD style is exposed through `expect` or `should` interfaces. In both
69
- * scenarios, you chain together natural language assertions.
70
- *
71
- * // expect
72
- * var expect = require('chai').expect;
73
- * expect(foo).to.equal('bar');
74
- *
75
- * // should
76
- * var should = require('chai').should();
77
- * foo.should.equal('bar');
78
- *
79
- * #### Differences
80
- *
81
- * The `expect` interface provides a function as a starting point for chaining
82
- * your language assertions. It works on both node.js and in the browser.
83
- *
84
- * The `should` interface extends `Object.prototype` to provide a single getter as
85
- * the starting point for your language assertions. Most browser don't like
86
- * extensions to `Object.prototype` so it is not recommended for browser use.
87
- *
88
- * #### Configuration
89
- *
90
- * By default, Chai does not show stack traces upon an AssertionError. This can
91
- * be changed by modifying the `includeStack` parameter for chai.Assertion. For example:
92
- *
93
- * var chai = require('chai');
94
- * chai.Assertion.includeStack = true; // defaults to false
95
- */
96
-
97
- /*!
98
- * Module dependencies.
99
- */
100
-
101
- var AssertionError = require('./error')
102
- , eql = require('./utils/eql')
103
- , inspect = require('./utils/inspect');
104
-
105
- /*!
106
- * Module export.
107
- */
108
-
109
- module.exports = Assertion;
110
-
111
-
112
- /*!
113
- * # Assertion Constructor
114
- *
115
- * Creates object for chaining.
116
- *
117
- * @api private
118
- */
119
-
120
- function Assertion (obj, msg, stack) {
121
- this.ssfi = stack || arguments.callee;
122
- this.obj = obj;
123
- this.msg = msg;
124
- }
125
-
126
- /*!
127
- * ## Assertion.includeStack
128
- *
129
- * User configurable property, influences whether stack trace
130
- * is included in Assertion error message. Default of false
131
- * suppresses stack trace in the error message
132
- *
133
- * Assertion.includeStack = true; // enable stack on error
134
- *
135
- * @api public
136
- */
137
-
138
- Assertion.includeStack = false;
139
-
140
- /*!
141
- * # .assert(expression, message, negateMessage)
142
- *
143
- * Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass.
144
- *
145
- * @name assert
146
- * @param {Philosophical} expression to be tested
147
- * @param {String} message to display if fails
148
- * @param {String} negatedMessage to display if negated expression fails
149
- * @api private
150
- */
151
-
152
- Assertion.prototype.assert = function (expr, msg, negateMsg) {
153
- var msg = (this.negate ? negateMsg : msg)
154
- , ok = this.negate ? !expr : expr;
155
-
156
- if (!ok) {
157
- throw new AssertionError({
158
- operator: this.msg,
159
- message: msg,
160
- stackStartFunction: (Assertion.includeStack) ? this.assert : this.ssfi
161
- });
162
- }
163
- };
164
-
165
- /*!
166
- * # inspect
167
- *
168
- * Returns the current object stringified.
169
- *
170
- * @name inspect
171
- * @api private
172
- */
173
-
174
- Object.defineProperty(Assertion.prototype, 'inspect',
175
- { get: function () {
176
- return inspect(this.obj);
177
- },
178
- configurable: true
179
- });
180
-
181
- /**
182
- * # to
183
- *
184
- * Language chain.
185
- *
186
- * @name to
187
- * @api public
188
- */
189
-
190
- Object.defineProperty(Assertion.prototype, 'to',
191
- { get: function () {
192
- return this;
193
- },
194
- configurable: true
195
- });
196
-
197
- /**
198
- * # be
199
- *
200
- * Language chain.
201
- *
202
- * @name be
203
- * @api public
204
- */
205
-
206
- Object.defineProperty(Assertion.prototype, 'be',
207
- { get: function () {
208
- return this;
209
- },
210
- configurable: true
211
- });
212
-
213
- /**
214
- * # been
215
- *
216
- * Language chain. Also tests `tense` to past for addon
217
- * modules that use the tense feature.
218
- *
219
- * @name been
220
- * @api public
221
- */
222
-
223
- Object.defineProperty(Assertion.prototype, 'been',
224
- { get: function () {
225
- this.tense = 'past';
226
- return this;
227
- },
228
- configurable: true
229
- });
230
-
231
- /**
232
- * # an
233
- *
234
- * Language chain.
235
- *
236
- * @name an
237
- * @api public
238
- */
239
-
240
- Object.defineProperty(Assertion.prototype, 'an',
241
- { get: function () {
242
- return this;
243
- },
244
- configurable: true
245
- });
246
- /**
247
- * # is
248
- *
249
- * Language chain.
250
- *
251
- * @name is
252
- * @api public
253
- */
254
-
255
- Object.defineProperty(Assertion.prototype, 'is',
256
- { get: function () {
257
- return this;
258
- },
259
- configurable: true
260
- });
261
-
262
- /**
263
- * # and
264
- *
265
- * Language chain.
266
- *
267
- * @name and
268
- * @api public
269
- */
270
-
271
- Object.defineProperty(Assertion.prototype, 'and',
272
- { get: function () {
273
- return this;
274
- },
275
- configurable: true
276
- });
277
-
278
- /**
279
- * # have
280
- *
281
- * Language chain.
282
- *
283
- * @name have
284
- * @api public
285
- */
286
-
287
- Object.defineProperty(Assertion.prototype, 'have',
288
- { get: function () {
289
- return this;
290
- },
291
- configurable: true
292
- });
293
-
294
- /**
295
- * # with
296
- *
297
- * Language chain.
298
- *
299
- * @name with
300
- * @api public
301
- */
302
-
303
- Object.defineProperty(Assertion.prototype, 'with',
304
- { get: function () {
305
- return this;
306
- },
307
- configurable: true
308
- });
309
-
310
- /**
311
- * # .not
312
- *
313
- * Negates any of assertions following in the chain.
314
- *
315
- * @name not
316
- * @api public
317
- */
318
-
319
- Object.defineProperty(Assertion.prototype, 'not',
320
- { get: function () {
321
- this.negate = true;
322
- return this;
323
- },
324
- configurable: true
325
- });
326
-
327
- /**
328
- * # .ok
329
- *
330
- * Assert object truthiness.
331
- *
332
- * expect('everthing').to.be.ok;
333
- * expect(false).to.not.be.ok;
334
- * expect(undefined).to.not.be.ok;
335
- * expect(null).to.not.be.ok;
336
- *
337
- * @name ok
338
- * @api public
339
- */
340
-
341
- Object.defineProperty(Assertion.prototype, 'ok',
342
- { get: function () {
343
- this.assert(
344
- this.obj
345
- , 'expected ' + this.inspect + ' to be truthy'
346
- , 'expected ' + this.inspect + ' to be falsey');
347
-
348
- return this;
349
- },
350
- configurable: true
351
- });
352
-
353
- /**
354
- * # .true
355
- *
356
- * Assert object is true
357
- *
358
- * @name true
359
- * @api public
360
- */
361
-
362
- Object.defineProperty(Assertion.prototype, 'true',
363
- { get: function () {
364
- this.assert(
365
- true === this.obj
366
- , 'expected ' + this.inspect + ' to be true'
367
- , 'expected ' + this.inspect + ' to be false');
368
-
369
- return this;
370
- },
371
- configurable: true
372
- });
373
-
374
- /**
375
- * # .false
376
- *
377
- * Assert object is false
378
- *
379
- * @name false
380
- * @api public
381
- */
382
-
383
- Object.defineProperty(Assertion.prototype, 'false',
384
- { get: function () {
385
- this.assert(
386
- false === this.obj
387
- , 'expected ' + this.inspect + ' to be false'
388
- , 'expected ' + this.inspect + ' to be true');
389
-
390
- return this;
391
- },
392
- configurable: true
393
- });
394
-
395
- /**
396
- * # .exist
397
- *
398
- * Assert object exists (null).
399
- *
400
- * var foo = 'hi'
401
- * , bar;
402
- * expect(foo).to.exist;
403
- * expect(bar).to.not.exist;
404
- *
405
- * @name exist
406
- * @api public
407
- */
408
-
409
- Object.defineProperty(Assertion.prototype, 'exist',
410
- { get: function () {
411
- this.assert(
412
- null != this.obj
413
- , 'expected ' + this.inspect + ' to exist'
414
- , 'expected ' + this.inspect + ' to not exist');
415
-
416
- return this;
417
- },
418
- configurable: true
419
- });
420
-
421
- /**
422
- * # .empty
423
- *
424
- * Assert object's length to be 0.
425
- *
426
- * expect([]).to.be.empty;
427
- *
428
- * @name empty
429
- * @api public
430
- */
431
-
432
- Object.defineProperty(Assertion.prototype, 'empty',
433
- { get: function () {
434
- new Assertion(this.obj).to.have.property('length');
435
-
436
- this.assert(
437
- 0 === this.obj.length
438
- , 'expected ' + this.inspect + ' to be empty'
439
- , 'expected ' + this.inspect + ' not to be empty');
440
-
441
- return this;
442
- },
443
- configurable: true
444
- });
445
-
446
- /**
447
- * # .arguments
448
- *
449
- * Assert object is an instanceof arguments.
450
- *
451
- * function test () {
452
- * expect(arguments).to.be.arguments;
453
- * }
454
- *
455
- * @name arguments
456
- * @api public
457
- */
458
-
459
- Object.defineProperty(Assertion.prototype, 'arguments',
460
- { get: function () {
461
- this.assert(
462
- '[object Arguments]' == Object.prototype.toString.call(this.obj)
463
- , 'expected ' + this.inspect + ' to be arguments'
464
- , 'expected ' + this.inspect + ' to not be arguments');
465
-
466
- return this;
467
- },
468
- configurable: true
469
- });
470
-
471
- /**
472
- * # .equal(value)
473
- *
474
- * Assert strict equality.
475
- *
476
- * expect('hello').to.equal('hello');
477
- *
478
- * @name equal
479
- * @param {*} value
480
- * @api public
481
- */
482
-
483
- Assertion.prototype.equal = function (val) {
484
- this.assert(
485
- val === this.obj
486
- , 'expected ' + this.inspect + ' to equal ' + inspect(val)
487
- , 'expected ' + this.inspect + ' to not equal ' + inspect(val));
488
-
489
- return this;
490
- };
491
-
492
- /**
493
- * # .eql(value)
494
- *
495
- * Assert deep equality.
496
- *
497
- * expect({ foo: 'bar' }).to.eql({ foo: 'bar' });
498
- *
499
- * @name eql
500
- * @param {*} value
501
- * @api public
502
- */
503
-
504
- Assertion.prototype.eql = function (obj) {
505
- this.assert(
506
- eql(obj, this.obj)
507
- , 'expected ' + this.inspect + ' to equal ' + inspect(obj)
508
- , 'expected ' + this.inspect + ' to not equal ' + inspect(obj));
509
- return this;
510
- };
511
-
512
- /**
513
- * # .above(value)
514
- *
515
- * Assert greater than `value`.
516
- *
517
- * expect(10).to.be.above(5);
518
- *
519
- * @name above
520
- * @param {Number} value
521
- * @api public
522
- */
523
-
524
- Assertion.prototype.above = function (val) {
525
- this.assert(
526
- this.obj > val
527
- , 'expected ' + this.inspect + ' to be above ' + val
528
- , 'expected ' + this.inspect + ' to be below ' + val);
529
-
530
- return this;
531
- };
532
-
533
- /**
534
- * # .below(value)
535
- *
536
- * Assert less than `value`.
537
- *
538
- * expect(5).to.be.below(10);
539
- *
540
- * @name below
541
- * @param {Number} value
542
- * @api public
543
- */
544
-
545
- Assertion.prototype.below = function (val) {
546
- this.assert(
547
- this.obj < val
548
- , 'expected ' + this.inspect + ' to be below ' + val
549
- , 'expected ' + this.inspect + ' to be above ' + val);
550
-
551
- return this;
552
- };
553
-
554
- /**
555
- * # .within(start, finish)
556
- *
557
- * Assert that a number is within a range.
558
- *
559
- * expect(7).to.be.within(5,10);
560
- *
561
- * @name within
562
- * @param {Number} start lowerbound inclusive
563
- * @param {Number} finish upperbound inclusive
564
- * @api public
565
- */
566
-
567
- Assertion.prototype.within = function (start, finish) {
568
- var range = start + '..' + finish;
569
-
570
- this.assert(
571
- this.obj >= start && this.obj <= finish
572
- , 'expected ' + this.inspect + ' to be within ' + range
573
- , 'expected ' + this.inspect + ' to not be within ' + range);
574
-
575
- return this;
576
- };
577
-
578
- /**
579
- * # .a(type)
580
- *
581
- * Assert typeof.
582
- *
583
- * expect('test').to.be.a('string');
584
- *
585
- * @name a
586
- * @param {String} type
587
- * @api public
588
- */
589
-
590
- Assertion.prototype.a = function (type) {
591
- this.assert(
592
- type == typeof this.obj
593
- , 'expected ' + this.inspect + ' to be a ' + type
594
- , 'expected ' + this.inspect + ' not to be a ' + type);
595
-
596
- return this;
597
- };
598
-
599
- /**
600
- * # .instanceof(constructor)
601
- *
602
- * Assert instanceof.
603
- *
604
- * var Tea = function (name) { this.name = name; }
605
- * , Chai = new Tea('chai');
606
- *
607
- * expect(Chai).to.be.an.instanceOf(Tea);
608
- *
609
- * @name instanceof
610
- * @param {Constructor}
611
- * @alias instanceOf
612
- * @api public
613
- */
614
-
615
- Assertion.prototype.instanceof = function (constructor) {
616
- var name = constructor.name;
617
- this.assert(
618
- this.obj instanceof constructor
619
- , 'expected ' + this.inspect + ' to be an instance of ' + name
620
- , 'expected ' + this.inspect + ' to not be an instance of ' + name);
621
-
622
- return this;
623
- };
624
-
625
- /**
626
- * # .property(name, [value])
627
- *
628
- * Assert that property of `name` exists, optionally with `value`.
629
- *
630
- * var obj = { foo: 'bar' }
631
- * expect(obj).to.have.property('foo');
632
- * expect(obj).to.have.property('foo', 'bar');
633
- * expect(obj).to.have.property('foo').to.be.a('string');
634
- *
635
- * @name property
636
- * @param {String} name
637
- * @param {*} value (optional)
638
- * @returns value of property for chaining
639
- * @api public
640
- */
641
-
642
- Assertion.prototype.property = function (name, val) {
643
- if (this.negate && undefined !== val) {
644
- if (undefined === this.obj[name]) {
645
- throw new Error(this.inspect + ' has no property ' + inspect(name));
646
- }
647
- } else {
648
- this.assert(
649
- undefined !== this.obj[name]
650
- , 'expected ' + this.inspect + ' to have a property ' + inspect(name)
651
- , 'expected ' + this.inspect + ' to not have property ' + inspect(name));
652
- }
653
-
654
- if (undefined !== val) {
655
- this.assert(
656
- val === this.obj[name]
657
- , 'expected ' + this.inspect + ' to have a property ' + inspect(name) + ' of ' +
658
- inspect(val) + ', but got ' + inspect(this.obj[name])
659
- , 'expected ' + this.inspect + ' to not have a property ' + inspect(name) + ' of ' + inspect(val));
660
- }
661
-
662
- this.obj = this.obj[name];
663
- return this;
664
- };
665
-
666
- /**
667
- * # .ownProperty(name)
668
- *
669
- * Assert that has own property by `name`.
670
- *
671
- * expect('test').to.have.ownProperty('length');
672
- *
673
- * @name ownProperty
674
- * @alias haveOwnProperty
675
- * @param {String} name
676
- * @api public
677
- */
678
-
679
- Assertion.prototype.ownProperty = function (name) {
680
- this.assert(
681
- this.obj.hasOwnProperty(name)
682
- , 'expected ' + this.inspect + ' to have own property ' + inspect(name)
683
- , 'expected ' + this.inspect + ' to not have own property ' + inspect(name));
684
- return this;
685
- };
686
-
687
- /**
688
- * # .length(val)
689
- *
690
- * Assert that object has expected length.
691
- *
692
- * expect([1,2,3]).to.have.length(3);
693
- * expect('foobar').to.have.length(6);
694
- *
695
- * @name length
696
- * @alias lengthOf
697
- * @param {Number} length
698
- * @api public
699
- */
700
-
701
- Assertion.prototype.length = function (n) {
702
- new Assertion(this.obj).to.have.property('length');
703
- var len = this.obj.length;
704
-
705
- this.assert(
706
- len == n
707
- , 'expected ' + this.inspect + ' to have a length of ' + n + ' but got ' + len
708
- , 'expected ' + this.inspect + ' to not have a length of ' + len);
709
-
710
- return this;
711
- };
712
-
713
- /**
714
- * # .match(regexp)
715
- *
716
- * Assert that matches regular expression.
717
- *
718
- * expect('foobar').to.match(/^foo/);
719
- *
720
- * @name match
721
- * @param {RegExp} RegularExpression
722
- * @api public
723
- */
724
-
725
- Assertion.prototype.match = function (re) {
726
- this.assert(
727
- re.exec(this.obj)
728
- , 'expected ' + this.inspect + ' to match ' + re
729
- , 'expected ' + this.inspect + ' not to match ' + re);
730
-
731
- return this;
732
- };
733
-
734
- /**
735
- * # .include(obj)
736
- *
737
- * Assert the inclusion of an object in an Array or substring in string.
738
- *
739
- * expect([1,2,3]).to.include(2);
740
- *
741
- * @name include
742
- * @param {Object|String|Number} obj
743
- * @api public
744
- */
745
-
746
- Assertion.prototype.include = function (obj) {
747
- this.assert(
748
- ~this.obj.indexOf(obj)
749
- , 'expected ' + this.inspect + ' to include ' + inspect(obj)
750
- , 'expected ' + this.inspect + ' to not include ' + inspect(obj));
751
-
752
- return this;
753
- };
754
-
755
- /**
756
- * # .string(string)
757
- *
758
- * Assert inclusion of string in string.
759
- *
760
- * expect('foobar').to.have.string('bar');
761
- *
762
- * @name string
763
- * @param {String} string
764
- * @api public
765
- */
766
-
767
- Assertion.prototype.string = function (str) {
768
- new Assertion(this.obj).is.a('string');
769
-
770
- this.assert(
771
- ~this.obj.indexOf(str)
772
- , 'expected ' + this.inspect + ' to contain ' + inspect(str)
773
- , 'expected ' + this.inspect + ' to not contain ' + inspect(str));
774
-
775
- return this;
776
- };
777
-
778
-
779
-
780
- /**
781
- * # contain
782
- *
783
- * Toggles the `contain` flag for the `keys` assertion.
784
- *
785
- * @name contain
786
- * @api public
787
- */
788
-
789
- Object.defineProperty(Assertion.prototype, 'contain',
790
- { get: function () {
791
- this.contains = true;
792
- return this;
793
- },
794
- configurable: true
795
- });
796
-
797
- /**
798
- * # .keys(key1, [key2], [...])
799
- *
800
- * Assert exact keys or the inclusing of keys using the `contain` modifier.
801
- *
802
- * expect({ foo: 1, bar: 2 }).to.have.keys(['foo', 'bar']);
803
- * expect({ foo: 1, bar: 2, baz: 3 }).to.contain.keys('foo', 'bar');
804
- *
805
- * @name keys
806
- * @alias key
807
- * @param {String|Array} Keys
808
- * @api public
809
- */
810
-
811
- Assertion.prototype.keys = function(keys) {
812
- var str
813
- , ok = true;
814
-
815
- keys = keys instanceof Array
816
- ? keys
817
- : Array.prototype.slice.call(arguments);
818
-
819
- if (!keys.length) throw new Error('keys required');
820
-
821
- var actual = Object.keys(this.obj)
822
- , len = keys.length;
823
-
824
- // Inclusion
825
- ok = keys.every(function(key){
826
- return ~actual.indexOf(key);
827
- });
828
-
829
- // Strict
830
- if (!this.negate && !this.contains) {
831
- ok = ok && keys.length == actual.length;
832
- }
833
-
834
- // Key string
835
- if (len > 1) {
836
- keys = keys.map(function(key){
837
- return inspect(key);
838
- });
839
- var last = keys.pop();
840
- str = keys.join(', ') + ', and ' + last;
841
- } else {
842
- str = inspect(keys[0]);
843
- }
844
-
845
- // Form
846
- str = (len > 1 ? 'keys ' : 'key ') + str;
847
-
848
- // Have / include
849
- str = (this.contains ? 'contain ' : 'have ') + str;
850
-
851
- // Assertion
852
- this.assert(
853
- ok
854
- , 'expected ' + this.inspect + ' to ' + str
855
- , 'expected ' + this.inspect + ' to not ' + str);
856
-
857
- return this;
858
- }
859
-
860
- /**
861
- * # .throw(constructor)
862
- *
863
- * Assert that a function will throw a specific type of error.
864
- *
865
- * var fn = function () { throw new ReferenceError(''); }
866
- * expect(fn).to.throw(ReferenceError);
867
- *
868
- * @name throw
869
- * @alias throws
870
- * @alias Throw
871
- * @param {ErrorConstructor} constructor
872
- * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
873
- * @api public
874
- */
875
-
876
- Assertion.prototype.throw = function (constructor) {
877
- new Assertion(this.obj).is.a('function');
878
-
879
- var thrown = false;
880
-
881
- try {
882
- this.obj();
883
- } catch (err) {
884
- if (constructor && 'function' === typeof constructor && constructor.constructor != RegExp) {
885
- this.assert(
886
- err instanceof constructor && err.name == constructor.name
887
- , 'expected ' + this.inspect + ' to throw ' + constructor.name + ' but a ' + err.name + ' was thrown'
888
- , 'expected ' + this.inspect + ' to not throw ' + constructor.name );
889
- return this;
890
- } else if (constructor && constructor instanceof RegExp) {
891
- this.assert(
892
- constructor.exec(err.message)
893
- , 'expected ' + this.inspect + ' to throw error matching ' + constructor + ' but got ' + inspect(err.message)
894
- , 'expected ' + this.inspect + ' to throw error not matching ' + constructor);
895
- return this;
896
- } else {
897
- thrown = true;
898
- }
899
- }
900
-
901
- var name = (constructor ? constructor.name : 'an error');
902
-
903
- this.assert(
904
- thrown === true
905
- , 'expected ' + this.inspect + ' to throw ' + name
906
- , 'expected ' + this.inspect + ' to not throw ' + name);
907
-
908
- return this;
909
- };
910
-
911
- /*!
912
- * Aliases.
913
- */
914
-
915
- (function alias(name, as){
916
- Assertion.prototype[as] = Assertion.prototype[name];
917
- return alias;
918
- })
919
- ('length', 'lengthOf')
920
- ('keys', 'key')
921
- ('ownProperty', 'haveOwnProperty')
922
- ('above', 'greaterThan')
923
- ('below', 'lessThan')
924
- ('throw', 'throws')
925
- ('throw', 'Throw') // for troublesome browsers
926
- ('instanceof', 'instanceOf');
927
-
928
- }); // module: assertion.js
929
-
930
- require.register("chai.js", function(module, exports, require){
931
- /*!
932
- * chai
933
- * Copyright(c) 2011-2012 Jake Luer <jake@alogicalparadox.com>
934
- * MIT Licensed
935
- */
936
-
937
- var used = [];
938
- var exports = module.exports = {};
939
-
940
- exports.version = '0.3.4';
941
-
942
- exports.Assertion = require('./assertion');
943
- exports.AssertionError = require('./error');
944
-
945
- exports.inspect = require('./utils/inspect');
946
-
947
- exports.use = function (fn) {
948
- if (!~used.indexOf(fn)) {
949
- fn(this);
950
- used.push(fn);
951
- }
952
-
953
- return this;
954
- };
955
-
956
- exports.fail = function (actual, expected, message, operator, stackStartFunction) {
957
- throw new exports.AssertionError({
958
- message: message,
959
- actual: actual,
960
- expected: expected,
961
- operator: operator,
962
- stackStartFunction: stackStartFunction
963
- });
964
- };
965
-
966
- var expect = require('./interface/expect');
967
- exports.use(expect);
968
-
969
- var should = require('./interface/should');
970
- exports.use(should);
971
-
972
- var assert = require('./interface/assert');
973
- exports.use(assert);
974
-
975
- }); // module: chai.js
976
-
977
- require.register("error.js", function(module, exports, require){
978
- /*!
979
- * chai
980
- * Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
981
- * MIT Licensed
982
- */
983
-
984
- var fail = require('./chai').fail;
985
-
986
- module.exports = AssertionError;
987
-
988
- /*!
989
- * Inspired by node.js assert module
990
- * https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/assert.js
991
- */
992
- function AssertionError (options) {
993
- options = options || {};
994
- this.name = 'AssertionError';
995
- this.message = options.message;
996
- this.actual = options.actual;
997
- this.expected = options.expected;
998
- this.operator = options.operator;
999
- var stackStartFunction = options.stackStartFunction || fail;
1000
-
1001
- if (Error.captureStackTrace) {
1002
- Error.captureStackTrace(this, stackStartFunction);
1003
- }
1004
- }
1005
-
1006
- AssertionError.prototype.__proto__ = Error.prototype;
1007
-
1008
- AssertionError.prototype.summary = function() {
1009
- var str = '';
1010
-
1011
- if (this.operator) {
1012
- str += 'In: \'' + this.operator + '\'\n\t';
1013
- }
1014
-
1015
- str += '' + this.name + (this.message ? ': ' + this.message : '');
1016
-
1017
- return str;
1018
- };
1019
-
1020
- AssertionError.prototype.details = function() {
1021
- return this.summary();
1022
- };
1023
-
1024
- AssertionError.prototype.toString = function() {
1025
- return this.summary();
1026
- };
1027
- }); // module: error.js
1028
-
1029
- require.register("interface/assert.js", function(module, exports, require){
1030
- /*!
1031
- * chai
1032
- * Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
1033
- * MIT Licensed
1034
- */
1035
-
1036
- /**
1037
- * ### TDD Style Introduction
1038
- *
1039
- * The TDD style is exposed through `assert` interfaces. This provides
1040
- * the classic assert.`test` notation, similiar to that packaged with
1041
- * node.js. This assert module, however, provides several additional
1042
- * tests and is browser compatible.
1043
- *
1044
- * // assert
1045
- * var assert = require('chai').assert;
1046
- * , foo = 'bar';
1047
- *
1048
- * assert.typeOf(foo, 'string');
1049
- * assert.equal(foo, 'bar');
1050
- *
1051
- * #### Configuration
1052
- *
1053
- * By default, Chai does not show stack traces upon an AssertionError. This can
1054
- * be changed by modifying the `includeStack` parameter for chai.Assertion. For example:
1055
- *
1056
- * var chai = require('chai');
1057
- * chai.Assertion.includeStack = true; // defaults to false
1058
- */
1059
-
1060
- module.exports = function (chai) {
1061
- /*!
1062
- * Chai dependencies.
1063
- */
1064
- var Assertion = chai.Assertion
1065
- , inspect = chai.inspect;
1066
-
1067
- /*!
1068
- * Module export.
1069
- */
1070
-
1071
- var assert = chai.assert = {};
1072
-
1073
- /**
1074
- * # .ok(object, [message])
1075
- *
1076
- * Assert object is truthy.
1077
- *
1078
- * assert.ok('everthing', 'everything is ok');
1079
- * assert.ok(false, 'this will fail');
1080
- *
1081
- * @name ok
1082
- * @param {*} object to test
1083
- * @param {String} message
1084
- * @api public
1085
- */
1086
-
1087
- assert.ok = function (val, msg) {
1088
- new Assertion(val, msg).is.ok;
1089
- };
1090
-
1091
- /**
1092
- * # .equal(actual, expected, [message])
1093
- *
1094
- * Assert strict equality.
1095
- *
1096
- * assert.equal(3, 3, 'these numbers are equal');
1097
- *
1098
- * @name equal
1099
- * @param {*} actual
1100
- * @param {*} expected
1101
- * @param {String} message
1102
- * @api public
1103
- */
1104
-
1105
- assert.equal = function (act, exp, msg) {
1106
- var test = new Assertion(act, msg);
1107
-
1108
- test.assert(
1109
- exp == test.obj
1110
- , 'expected ' + test.inspect + ' to equal ' + inspect(exp)
1111
- , 'expected ' + test.inspect + ' to not equal ' + inspect(exp));
1112
- };
1113
-
1114
- /**
1115
- * # .notEqual(actual, expected, [message])
1116
- *
1117
- * Assert not equal.
1118
- *
1119
- * assert.notEqual(3, 4, 'these numbers are not equal');
1120
- *
1121
- * @name notEqual
1122
- * @param {*} actual
1123
- * @param {*} expected
1124
- * @param {String} message
1125
- * @api public
1126
- */
1127
-
1128
- assert.notEqual = function (act, exp, msg) {
1129
- var test = new Assertion(act, msg);
1130
-
1131
- test.assert(
1132
- exp != test.obj
1133
- , 'expected ' + test.inspect + ' to equal ' + inspect(exp)
1134
- , 'expected ' + test.inspect + ' to not equal ' + inspect(exp));
1135
- };
1136
-
1137
- /**
1138
- * # .strictEqual(actual, expected, [message])
1139
- *
1140
- * Assert strict equality.
1141
- *
1142
- * assert.strictEqual(true, true, 'these booleans are strictly equal');
1143
- *
1144
- * @name strictEqual
1145
- * @param {*} actual
1146
- * @param {*} expected
1147
- * @param {String} message
1148
- * @api public
1149
- */
1150
-
1151
- assert.strictEqual = function (act, exp, msg) {
1152
- new Assertion(act, msg).to.equal(exp);
1153
- };
1154
-
1155
- /**
1156
- * # .notStrictEqual(actual, expected, [message])
1157
- *
1158
- * Assert strict equality.
1159
- *
1160
- * assert.notStrictEqual(1, true, 'these booleans are not strictly equal');
1161
- *
1162
- * @name notStrictEqual
1163
- * @param {*} actual
1164
- * @param {*} expected
1165
- * @param {String} message
1166
- * @api public
1167
- */
1168
-
1169
- assert.notStrictEqual = function (act, exp, msg) {
1170
- new Assertion(act, msg).to.not.equal(exp);
1171
- };
1172
-
1173
- /**
1174
- * # .deepEqual(actual, expected, [message])
1175
- *
1176
- * Assert not deep equality.
1177
- *
1178
- * assert.deepEqual({ tea: 'green' }, { tea: 'green' });
1179
- *
1180
- * @name deepEqual
1181
- * @param {*} actual
1182
- * @param {*} expected
1183
- * @param {String} message
1184
- * @api public
1185
- */
1186
-
1187
- assert.deepEqual = function (act, exp, msg) {
1188
- new Assertion(act, msg).to.eql(exp);
1189
- };
1190
-
1191
- /**
1192
- * # .notDeepEqual(actual, expected, [message])
1193
- *
1194
- * Assert not deep equality.
1195
- *
1196
- * assert.notDeepEqual({ tea: 'green' }, { tea: 'jasmine' });
1197
- *
1198
- * @name notDeepEqual
1199
- * @param {*} actual
1200
- * @param {*} expected
1201
- * @param {String} message
1202
- * @api public
1203
- */
1204
-
1205
- assert.notDeepEqual = function (act, exp, msg) {
1206
- new Assertion(act, msg).to.not.eql(exp);
1207
- };
1208
-
1209
- /**
1210
- * # .isTrue(value, [message])
1211
- *
1212
- * Assert `value` is true.
1213
- *
1214
- * var tea_served = true;
1215
- * assert.isTrue(tea_served, 'the tea has been served');
1216
- *
1217
- * @name isTrue
1218
- * @param {Boolean} value
1219
- * @param {String} message
1220
- * @api public
1221
- */
1222
-
1223
- assert.isTrue = function (val, msg) {
1224
- new Assertion(val, msg).is.true;
1225
- };
1226
-
1227
- /**
1228
- * # .isFalse(value, [message])
1229
- *
1230
- * Assert `value` is false.
1231
- *
1232
- * var tea_served = false;
1233
- * assert.isFalse(tea_served, 'no tea yet? hmm...');
1234
- *
1235
- * @name isFalse
1236
- * @param {Boolean} value
1237
- * @param {String} message
1238
- * @api public
1239
- */
1240
-
1241
- assert.isFalse = function (val, msg) {
1242
- new Assertion(val, msg).is.false;
1243
- };
1244
-
1245
- /**
1246
- * # .isNull(value, [message])
1247
- *
1248
- * Assert `value` is null.
1249
- *
1250
- * assert.isNull(err, 'no errors');
1251
- *
1252
- * @name isNull
1253
- * @param {*} value
1254
- * @param {String} message
1255
- * @api public
1256
- */
1257
-
1258
- assert.isNull = function (val, msg) {
1259
- new Assertion(val, msg).to.not.exist;
1260
- };
1261
-
1262
- /**
1263
- * # .isNotNull(value, [message])
1264
- *
1265
- * Assert `value` is not null.
1266
- *
1267
- * var tea = 'tasty chai';
1268
- * assert.isNotNull(tea, 'great, time for tea!');
1269
- *
1270
- * @name isNotNull
1271
- * @param {*} value
1272
- * @param {String} message
1273
- * @api public
1274
- */
1275
-
1276
- assert.isNotNull = function (val, msg) {
1277
- new Assertion(val, msg).to.exist;
1278
- };
1279
-
1280
- /**
1281
- * # .isUndefined(value, [message])
1282
- *
1283
- * Assert `value` is undefined.
1284
- *
1285
- * assert.isUndefined(tea, 'no tea defined');
1286
- *
1287
- * @name isUndefined
1288
- * @param {*} value
1289
- * @param {String} message
1290
- * @api public
1291
- */
1292
-
1293
- assert.isUndefined = function (val, msg) {
1294
- new Assertion(val, msg).to.equal(undefined);
1295
- };
1296
-
1297
- /**
1298
- * # .isFunction(value, [message])
1299
- *
1300
- * Assert `value` is a function.
1301
- *
1302
- * var serve_tea = function () { return 'cup of tea'; };
1303
- * assert.isFunction(serve_tea, 'great, we can have tea now');
1304
- *
1305
- * @name isFunction
1306
- * @param {Function} value
1307
- * @param {String} message
1308
- * @api public
1309
- */
1310
-
1311
- assert.isFunction = function (val, msg) {
1312
- new Assertion(val, msg).to.be.a('function');
1313
- };
1314
-
1315
- /**
1316
- * # .isObject(value, [message])
1317
- *
1318
- * Assert `value` is an object.
1319
- *
1320
- * var selection = { name: 'Chai', serve: 'with spices' };
1321
- * assert.isObject(selection, 'tea selection is an object');
1322
- *
1323
- * @name isObject
1324
- * @param {Object} value
1325
- * @param {String} message
1326
- * @api public
1327
- */
1328
-
1329
- assert.isObject = function (val, msg) {
1330
- new Assertion(val, msg).to.be.a('object');
1331
- };
1332
-
1333
- /**
1334
- * # .isArray(value, [message])
1335
- *
1336
- * Assert `value` is an instance of Array.
1337
- *
1338
- * var menu = [ 'green', 'chai', 'oolong' ];
1339
- * assert.isArray(menu, 'what kind of tea do we want?');
1340
- *
1341
- * @name isArray
1342
- * @param {*} value
1343
- * @param {String} message
1344
- * @api public
1345
- */
1346
-
1347
- assert.isArray = function (val, msg) {
1348
- new Assertion(val, msg).to.be.instanceof(Array);
1349
- };
1350
-
1351
- /**
1352
- * # .isString(value, [message])
1353
- *
1354
- * Assert `value` is a string.
1355
- *
1356
- * var teaorder = 'chai';
1357
- * assert.isString(tea_order, 'order placed');
1358
- *
1359
- * @name isString
1360
- * @param {String} value
1361
- * @param {String} message
1362
- * @api public
1363
- */
1364
-
1365
- assert.isString = function (val, msg) {
1366
- new Assertion(val, msg).to.be.a('string');
1367
- };
1368
-
1369
- /**
1370
- * # .isNumber(value, [message])
1371
- *
1372
- * Assert `value` is a number
1373
- *
1374
- * var cups = 2;
1375
- * assert.isNumber(cups, 'how many cups');
1376
- *
1377
- * @name isNumber
1378
- * @param {Number} value
1379
- * @param {String} message
1380
- * @api public
1381
- */
1382
-
1383
- assert.isNumber = function (val, msg) {
1384
- new Assertion(val, msg).to.be.instanceof(Number);
1385
- };
1386
-
1387
- /**
1388
- * # .isBoolean(value, [message])
1389
- *
1390
- * Assert `value` is a boolean
1391
- *
1392
- * var teaready = true
1393
- * , teaserved = false;
1394
- *
1395
- * assert.isBoolean(tea_ready, 'is the tea ready');
1396
- * assert.isBoolean(tea_served, 'has tea been served');
1397
- *
1398
- * @name isBoolean
1399
- * @param {*} value
1400
- * @param {String} message
1401
- * @api public
1402
- */
1403
-
1404
- assert.isBoolean = function (val, msg) {
1405
- new Assertion(val, msg).to.be.a('boolean');
1406
- };
1407
-
1408
- /**
1409
- * # .typeOf(value, name, [message])
1410
- *
1411
- * Assert typeof `value` is `name`.
1412
- *
1413
- * assert.typeOf('tea', 'string', 'we have a string');
1414
- *
1415
- * @name typeOf
1416
- * @param {*} value
1417
- * @param {String} typeof name
1418
- * @param {String} message
1419
- * @api public
1420
- */
1421
-
1422
- assert.typeOf = function (val, type, msg) {
1423
- new Assertion(val, msg).to.be.a(type);
1424
- };
1425
-
1426
- /**
1427
- * # .instanceOf(object, constructor, [message])
1428
- *
1429
- * Assert `value` is instanceof `constructor`.
1430
- *
1431
- * var Tea = function (name) { this.name = name; }
1432
- * , Chai = new Tea('chai');
1433
- *
1434
- * assert.instanceOf(Chai, Tea, 'chai is an instance of tea');
1435
- *
1436
- * @name instanceOf
1437
- * @param {Object} object
1438
- * @param {Constructor} constructor
1439
- * @param {String} message
1440
- * @api public
1441
- */
1442
-
1443
- assert.instanceOf = function (val, type, msg) {
1444
- new Assertion(val, msg).to.be.instanceof(type);
1445
- };
1446
-
1447
- /**
1448
- * # .include(value, includes, [message])
1449
- *
1450
- * Assert the inclusion of an object in another. Works
1451
- * for strings and arrays.
1452
- *
1453
- * assert.include('foobar', 'bar', 'foobar contains string `var`);
1454
- * assert.include([ 1, 2, 3], 3, 'array contains value);
1455
- *
1456
- * @name include
1457
- * @param {Array|String} value
1458
- * @param {*} includes
1459
- * @param {String} message
1460
- * @api public
1461
- */
1462
-
1463
- assert.include = function (exp, inc, msg) {
1464
- var obj = new Assertion(exp, msg);
1465
-
1466
- if (Array.isArray(exp)) {
1467
- obj.to.include(inc);
1468
- } else if ('string' === typeof exp) {
1469
- obj.to.contain.string(inc);
1470
- }
1471
- };
1472
-
1473
- /**
1474
- * # .match(value, regex, [message])
1475
- *
1476
- * Assert that `value` matches regular expression.
1477
- *
1478
- * assert.match('foobar', /^foo/, 'Regexp matches');
1479
- *
1480
- * @name match
1481
- * @param {*} value
1482
- * @param {RegExp} RegularExpression
1483
- * @param {String} message
1484
- * @api public
1485
- */
1486
-
1487
- assert.match = function (exp, re, msg) {
1488
- new Assertion(exp, msg).to.match(re);
1489
- };
1490
-
1491
- /**
1492
- * # .length(value, constructor, [message])
1493
- *
1494
- * Assert that object has expected length.
1495
- *
1496
- * assert.length([1,2,3], 3, 'Array has length of 3');
1497
- * assert.length('foobar', 5, 'String has length of 6');
1498
- *
1499
- * @name length
1500
- * @param {*} value
1501
- * @param {Number} length
1502
- * @param {String} message
1503
- * @api public
1504
- */
1505
-
1506
- assert.length = function (exp, len, msg) {
1507
- new Assertion(exp, msg).to.have.length(len);
1508
- };
1509
-
1510
- /**
1511
- * # .throws(function, [constructor/regexp], [message])
1512
- *
1513
- * Assert that a function will throw a specific
1514
- * type of error.
1515
- *
1516
- * assert.throw(fn, ReferenceError, 'function throw reference error');
1517
- *
1518
- * @name throws
1519
- * @alias throw
1520
- * @param {Function} function to test
1521
- * @param {ErrorConstructor} constructor
1522
- * @param {String} message
1523
- * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
1524
- * @api public
1525
- */
1526
-
1527
- assert.throws = function (fn, type, msg) {
1528
- if ('string' === typeof type) {
1529
- msg = type;
1530
- type = null;
1531
- }
1532
-
1533
- new Assertion(fn, msg).to.throw(type);
1534
- };
1535
-
1536
- /**
1537
- * # .doesNotThrow(function, [constructor/regexp], [message])
1538
- *
1539
- * Assert that a function will throw a specific
1540
- * type of error.
1541
- *
1542
- * var fn = function (err) { if (err) throw Error(err) };
1543
- * assert.doesNotThrow(fn, Error, 'function throw reference error');
1544
- *
1545
- * @name doesNotThrow
1546
- * @param {Function} function to test
1547
- * @param {ErrorConstructor} constructor
1548
- * @param {String} message
1549
- * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
1550
- * @api public
1551
- */
1552
-
1553
- assert.doesNotThrow = function (fn, type, msg) {
1554
- if ('string' === typeof type) {
1555
- msg = type;
1556
- type = null;
1557
- }
1558
-
1559
- new Assertion(fn, msg).to.not.throw(type);
1560
- };
1561
-
1562
- /*!
1563
- * Undocumented / untested
1564
- */
1565
-
1566
- assert.ifError = function (val, msg) {
1567
- new Assertion(val, msg).to.not.be.ok;
1568
- };
1569
-
1570
- /*!
1571
- * Aliases.
1572
- */
1573
-
1574
- (function alias(name, as){
1575
- assert[as] = assert[name];
1576
- return alias;
1577
- })
1578
- ('length', 'lengthOf')
1579
- ('throws', 'throw');
1580
- };
1581
-
1582
- }); // module: interface/assert.js
1583
-
1584
- require.register("interface/expect.js", function(module, exports, require){
1585
- /*!
1586
- * chai
1587
- * Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
1588
- * MIT Licensed
1589
- */
1590
-
1591
- module.exports = function (chai) {
1592
- chai.expect = function (val, message) {
1593
- return new chai.Assertion(val, message);
1594
- };
1595
- };
1596
-
1597
-
1598
- }); // module: interface/expect.js
1599
-
1600
- require.register("interface/should.js", function(module, exports, require){
1601
- /*!
1602
- * chai
1603
- * Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
1604
- * MIT Licensed
1605
- */
1606
-
1607
- module.exports = function (chai) {
1608
- var Assertion = chai.Assertion;
1609
-
1610
- chai.should = function () {
1611
- // modify Object.prototype to have `should`
1612
- Object.defineProperty(Object.prototype, 'should', {
1613
- set: function(){},
1614
- get: function(){
1615
- if (this instanceof String || this instanceof Number) {
1616
- return new Assertion(this.constructor(this));
1617
- } else if (this instanceof Boolean) {
1618
- return new Assertion(this == true);
1619
- }
1620
- return new Assertion(this);
1621
- },
1622
- configurable: true
1623
- });
1624
-
1625
- var should = {};
1626
-
1627
- should.equal = function (val1, val2) {
1628
- new Assertion(val1).to.equal(val2);
1629
- };
1630
-
1631
- should.throw = function (fn, err) {
1632
- new Assertion(fn).to.throw(err);
1633
- };
1634
-
1635
- should.exist = function (val) {
1636
- new Assertion(val).to.exist;
1637
- }
1638
-
1639
- // negation
1640
- should.not = {}
1641
-
1642
- should.not.equal = function (val1, val2) {
1643
- new Assertion(val1).to.not.equal(val2);
1644
- };
1645
-
1646
- should.not.throw = function (fn, err) {
1647
- new Assertion(fn).to.not.throw(err);
1648
- };
1649
-
1650
- should.not.exist = function (val) {
1651
- new Assertion(val).to.not.exist;
1652
- }
1653
-
1654
- return should;
1655
- };
1656
- };
1657
-
1658
- }); // module: interface/should.js
1659
-
1660
- require.register("utils/eql.js", function(module, exports, require){
1661
- // This is directly from Node.js assert
1662
- // https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/assert.js
1663
-
1664
-
1665
- module.exports = _deepEqual;
1666
-
1667
- // For browser implementation
1668
- if (!Buffer) {
1669
- var Buffer = {
1670
- isBuffer: function () {
1671
- return false;
1672
- }
1673
- };
1674
- }
1675
-
1676
- function _deepEqual(actual, expected) {
1677
- // 7.1. All identical values are equivalent, as determined by ===.
1678
- if (actual === expected) {
1679
- return true;
1680
-
1681
- } else if (Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) {
1682
- if (actual.length != expected.length) return false;
1683
-
1684
- for (var i = 0; i < actual.length; i++) {
1685
- if (actual[i] !== expected[i]) return false;
1686
- }
1687
-
1688
- return true;
1689
-
1690
- // 7.2. If the expected value is a Date object, the actual value is
1691
- // equivalent if it is also a Date object that refers to the same time.
1692
- } else if (actual instanceof Date && expected instanceof Date) {
1693
- return actual.getTime() === expected.getTime();
1694
-
1695
- // 7.3. Other pairs that do not both pass typeof value == 'object',
1696
- // equivalence is determined by ==.
1697
- } else if (typeof actual != 'object' && typeof expected != 'object') {
1698
- return actual === expected;
1699
-
1700
- // 7.4. For all other Object pairs, including Array objects, equivalence is
1701
- // determined by having the same number of owned properties (as verified
1702
- // with Object.prototype.hasOwnProperty.call), the same set of keys
1703
- // (although not necessarily the same order), equivalent values for every
1704
- // corresponding key, and an identical 'prototype' property. Note: this
1705
- // accounts for both named and indexed properties on Arrays.
1706
- } else {
1707
- return objEquiv(actual, expected);
1708
- }
1709
- }
1710
-
1711
- function isUndefinedOrNull(value) {
1712
- return value === null || value === undefined;
1713
- }
1714
-
1715
- function isArguments(object) {
1716
- return Object.prototype.toString.call(object) == '[object Arguments]';
1717
- }
1718
-
1719
- function objEquiv(a, b) {
1720
- if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
1721
- return false;
1722
- // an identical 'prototype' property.
1723
- if (a.prototype !== b.prototype) return false;
1724
- //~~~I've managed to break Object.keys through screwy arguments passing.
1725
- // Converting to array solves the problem.
1726
- if (isArguments(a)) {
1727
- if (!isArguments(b)) {
1728
- return false;
1729
- }
1730
- a = pSlice.call(a);
1731
- b = pSlice.call(b);
1732
- return _deepEqual(a, b);
1733
- }
1734
- try {
1735
- var ka = Object.keys(a),
1736
- kb = Object.keys(b),
1737
- key, i;
1738
- } catch (e) {//happens when one is a string literal and the other isn't
1739
- return false;
1740
- }
1741
- // having the same number of owned properties (keys incorporates
1742
- // hasOwnProperty)
1743
- if (ka.length != kb.length)
1744
- return false;
1745
- //the same set of keys (although not necessarily the same order),
1746
- ka.sort();
1747
- kb.sort();
1748
- //~~~cheap key test
1749
- for (i = ka.length - 1; i >= 0; i--) {
1750
- if (ka[i] != kb[i])
1751
- return false;
1752
- }
1753
- //equivalent values for every corresponding key, and
1754
- //~~~possibly expensive deep test
1755
- for (i = ka.length - 1; i >= 0; i--) {
1756
- key = ka[i];
1757
- if (!_deepEqual(a[key], b[key])) return false;
1758
- }
1759
- return true;
1760
- }
1761
- }); // module: utils/eql.js
1762
-
1763
- require.register("utils/inspect.js", function(module, exports, require){
1764
- // This is (almost) directly from Node.js utils
1765
- // https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/util.js
1766
-
1767
- module.exports = inspect;
1768
-
1769
- /**
1770
- * Echos the value of a value. Trys to print the value out
1771
- * in the best way possible given the different types.
1772
- *
1773
- * @param {Object} obj The object to print out.
1774
- * @param {Boolean} showHidden Flag that shows hidden (not enumerable)
1775
- * properties of objects.
1776
- * @param {Number} depth Depth in which to descend in object. Default is 2.
1777
- * @param {Boolean} colors Flag to turn on ANSI escape codes to color the
1778
- * output. Default is false (no coloring).
1779
- */
1780
- function inspect(obj, showHidden, depth, colors) {
1781
- var ctx = {
1782
- showHidden: showHidden,
1783
- seen: [],
1784
- stylize: function (str) { return str; }
1785
- };
1786
- return formatValue(ctx, obj, (typeof depth === 'undefined' ? 2 : depth));
1787
- }
1788
-
1789
- function formatValue(ctx, value, recurseTimes) {
1790
- // Provide a hook for user-specified inspect functions.
1791
- // Check that value is an object with an inspect function on it
1792
- if (value && typeof value.inspect === 'function' &&
1793
- // Filter out the util module, it's inspect function is special
1794
- value.inspect !== exports.inspect &&
1795
- // Also filter out any prototype objects using the circular check.
1796
- !(value.constructor && value.constructor.prototype === value)) {
1797
- return value.inspect(recurseTimes);
1798
- }
1799
-
1800
- // Primitive types cannot have properties
1801
- var primitive = formatPrimitive(ctx, value);
1802
- if (primitive) {
1803
- return primitive;
1804
- }
1805
-
1806
- // Look up the keys of the object.
1807
- var visibleKeys = Object.keys(value);
1808
- var keys = ctx.showHidden ? Object.getOwnPropertyNames(value) : visibleKeys;
1809
-
1810
- // Some type of object without properties can be shortcutted.
1811
- if (keys.length === 0) {
1812
- if (typeof value === 'function') {
1813
- var name = value.name ? ': ' + value.name : '';
1814
- return ctx.stylize('[Function' + name + ']', 'special');
1815
- }
1816
- if (isRegExp(value)) {
1817
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
1818
- }
1819
- if (isDate(value)) {
1820
- return ctx.stylize(Date.prototype.toUTCString.call(value), 'date');
1821
- }
1822
- if (isError(value)) {
1823
- return formatError(value);
1824
- }
1825
- }
1826
-
1827
- var base = '', array = false, braces = ['{', '}'];
1828
-
1829
- // Make Array say that they are Array
1830
- if (isArray(value)) {
1831
- array = true;
1832
- braces = ['[', ']'];
1833
- }
1834
-
1835
- // Make functions say that they are functions
1836
- if (typeof value === 'function') {
1837
- var n = value.name ? ': ' + value.name : '';
1838
- base = ' [Function' + n + ']';
1839
- }
1840
-
1841
- // Make RegExps say that they are RegExps
1842
- if (isRegExp(value)) {
1843
- base = ' ' + RegExp.prototype.toString.call(value);
1844
- }
1845
-
1846
- // Make dates with properties first say the date
1847
- if (isDate(value)) {
1848
- base = ' ' + Date.prototype.toUTCString.call(value);
1849
- }
1850
-
1851
- // Make error with message first say the error
1852
- if (isError(value)) {
1853
- base = ' ' + formatError(value);
1854
- }
1855
-
1856
- if (keys.length === 0 && (!array || value.length == 0)) {
1857
- return braces[0] + base + braces[1];
1858
- }
1859
-
1860
- if (recurseTimes < 0) {
1861
- if (isRegExp(value)) {
1862
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
1863
- } else {
1864
- return ctx.stylize('[Object]', 'special');
1865
- }
1866
- }
1867
-
1868
- ctx.seen.push(value);
1869
-
1870
- var output;
1871
- if (array) {
1872
- output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
1873
- } else {
1874
- output = keys.map(function(key) {
1875
- return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
1876
- });
1877
- }
1878
-
1879
- ctx.seen.pop();
1880
-
1881
- return reduceToSingleString(output, base, braces);
1882
- }
1883
-
1884
-
1885
- function formatPrimitive(ctx, value) {
1886
- switch (typeof value) {
1887
- case 'undefined':
1888
- return ctx.stylize('undefined', 'undefined');
1889
-
1890
- case 'string':
1891
- var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
1892
- .replace(/'/g, "\\'")
1893
- .replace(/\\"/g, '"') + '\'';
1894
- return ctx.stylize(simple, 'string');
1895
-
1896
- case 'number':
1897
- return ctx.stylize('' + value, 'number');
1898
-
1899
- case 'boolean':
1900
- return ctx.stylize('' + value, 'boolean');
1901
- }
1902
- // For some reason typeof null is "object", so special case here.
1903
- if (value === null) {
1904
- return ctx.stylize('null', 'null');
1905
- }
1906
- }
1907
-
1908
-
1909
- function formatError(value) {
1910
- return '[' + Error.prototype.toString.call(value) + ']';
1911
- }
1912
-
1913
-
1914
- function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
1915
- var output = [];
1916
- for (var i = 0, l = value.length; i < l; ++i) {
1917
- if (Object.prototype.hasOwnProperty.call(value, String(i))) {
1918
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
1919
- String(i), true));
1920
- } else {
1921
- output.push('');
1922
- }
1923
- }
1924
- keys.forEach(function(key) {
1925
- if (!key.match(/^\d+$/)) {
1926
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
1927
- key, true));
1928
- }
1929
- });
1930
- return output;
1931
- }
1932
-
1933
-
1934
- function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
1935
- var name, str;
1936
- if (value.__lookupGetter__) {
1937
- if (value.__lookupGetter__(key)) {
1938
- if (value.__lookupSetter__(key)) {
1939
- str = ctx.stylize('[Getter/Setter]', 'special');
1940
- } else {
1941
- str = ctx.stylize('[Getter]', 'special');
1942
- }
1943
- } else {
1944
- if (value.__lookupSetter__(key)) {
1945
- str = ctx.stylize('[Setter]', 'special');
1946
- }
1947
- }
1948
- }
1949
- if (visibleKeys.indexOf(key) < 0) {
1950
- name = '[' + key + ']';
1951
- }
1952
- if (!str) {
1953
- if (ctx.seen.indexOf(value[key]) < 0) {
1954
- if (recurseTimes === null) {
1955
- str = formatValue(ctx, value[key], null);
1956
- } else {
1957
- str = formatValue(ctx, value[key], recurseTimes - 1);
1958
- }
1959
- if (str.indexOf('\n') > -1) {
1960
- if (array) {
1961
- str = str.split('\n').map(function(line) {
1962
- return ' ' + line;
1963
- }).join('\n').substr(2);
1964
- } else {
1965
- str = '\n' + str.split('\n').map(function(line) {
1966
- return ' ' + line;
1967
- }).join('\n');
1968
- }
1969
- }
1970
- } else {
1971
- str = ctx.stylize('[Circular]', 'special');
1972
- }
1973
- }
1974
- if (typeof name === 'undefined') {
1975
- if (array && key.match(/^\d+$/)) {
1976
- return str;
1977
- }
1978
- name = JSON.stringify('' + key);
1979
- if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
1980
- name = name.substr(1, name.length - 2);
1981
- name = ctx.stylize(name, 'name');
1982
- } else {
1983
- name = name.replace(/'/g, "\\'")
1984
- .replace(/\\"/g, '"')
1985
- .replace(/(^"|"$)/g, "'");
1986
- name = ctx.stylize(name, 'string');
1987
- }
1988
- }
1989
-
1990
- return name + ': ' + str;
1991
- }
1992
-
1993
-
1994
- function reduceToSingleString(output, base, braces) {
1995
- var numLinesEst = 0;
1996
- var length = output.reduce(function(prev, cur) {
1997
- numLinesEst++;
1998
- if (cur.indexOf('\n') >= 0) numLinesEst++;
1999
- return prev + cur.length + 1;
2000
- }, 0);
2001
-
2002
- if (length > 60) {
2003
- return braces[0] +
2004
- (base === '' ? '' : base + '\n ') +
2005
- ' ' +
2006
- output.join(',\n ') +
2007
- ' ' +
2008
- braces[1];
2009
- }
2010
-
2011
- return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
2012
- }
2013
-
2014
- function isArray(ar) {
2015
- return Array.isArray(ar) ||
2016
- (typeof ar === 'object' && objectToString(ar) === '[object Array]');
2017
- }
2018
-
2019
- function isRegExp(re) {
2020
- return typeof re === 'object' && objectToString(re) === '[object RegExp]';
2021
- }
2022
-
2023
- function isDate(d) {
2024
- return typeof d === 'object' && objectToString(d) === '[object Date]';
2025
- }
2026
-
2027
- function isError(e) {
2028
- return typeof e === 'object' && objectToString(e) === '[object Error]';
2029
- }
2030
-
2031
- function objectToString(o) {
2032
- return Object.prototype.toString.call(o);
2033
- }
2034
- }); // module: utils/inspect.js
2035
-
2036
-
2037
- return require('chai');
2038
- });