snapdragon 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,54 @@
1
+ body { background-color: #eeeeee; padding: 0; margin: 5px; overflow-y: scroll; }
2
+
3
+ .html-reporter { font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333333; }
4
+ .html-reporter a { text-decoration: none; }
5
+ .html-reporter a:hover { text-decoration: underline; }
6
+ .html-reporter p, .html-reporter h1, .html-reporter h2, .html-reporter h3, .html-reporter h4, .html-reporter h5, .html-reporter h6 { margin: 0; line-height: 14px; }
7
+ .html-reporter .banner, .html-reporter .symbol-summary, .html-reporter .summary, .html-reporter .result-message, .html-reporter .spec .description, .html-reporter .spec-detail .description, .html-reporter .alert .bar, .html-reporter .stack-trace { padding-left: 9px; padding-right: 9px; }
8
+ .html-reporter .banner .version { margin-left: 14px; }
9
+ .html-reporter #jasmine_content { position: fixed; right: 100%; }
10
+ .html-reporter .version { color: #aaaaaa; }
11
+ .html-reporter .banner { margin-top: 14px; }
12
+ .html-reporter .duration { color: #aaaaaa; float: right; }
13
+ .html-reporter .symbol-summary { overflow: hidden; *zoom: 1; margin: 14px 0; }
14
+ .html-reporter .symbol-summary li { display: block; float: left; height: 7px; width: 14px; margin-bottom: 7px; font-size: 16px; }
15
+ .html-reporter .symbol-summary li.passed { font-size: 14px; }
16
+ .html-reporter .symbol-summary li.passed:before { color: #5e7d00; content: "\02022"; }
17
+ .html-reporter .symbol-summary li.failed { line-height: 9px; }
18
+ .html-reporter .symbol-summary li.failed:before { color: #b03911; content: "x"; font-weight: bold; margin-left: -1px; }
19
+ .html-reporter .symbol-summary li.disabled { font-size: 14px; }
20
+ .html-reporter .symbol-summary li.disabled:before { color: #bababa; content: "\02022"; }
21
+ .html-reporter .symbol-summary li.pending { line-height: 17px; }
22
+ .html-reporter .symbol-summary li.pending:before { color: #ba9d37; content: "*"; }
23
+ .html-reporter .exceptions { color: #fff; float: right; margin-top: 5px; margin-right: 5px; }
24
+ .html-reporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
25
+ .html-reporter .bar.failed { background-color: #b03911; }
26
+ .html-reporter .bar.passed { background-color: #a6b779; }
27
+ .html-reporter .bar.skipped { background-color: #bababa; }
28
+ .html-reporter .bar.menu { background-color: #fff; color: #aaaaaa; }
29
+ .html-reporter .bar.menu a { color: #333333; }
30
+ .html-reporter .bar a { color: white; }
31
+ .html-reporter.spec-list .bar.menu.failure-list, .html-reporter.spec-list .results .failures { display: none; }
32
+ .html-reporter.failure-list .bar.menu.spec-list, .html-reporter.failure-list .summary { display: none; }
33
+ .html-reporter .running-alert { background-color: #666666; }
34
+ .html-reporter .results { margin-top: 14px; }
35
+ .html-reporter.showDetails .summaryMenuItem { font-weight: normal; text-decoration: inherit; }
36
+ .html-reporter.showDetails .summaryMenuItem:hover { text-decoration: underline; }
37
+ .html-reporter.showDetails .detailsMenuItem { font-weight: bold; text-decoration: underline; }
38
+ .html-reporter.showDetails .summary { display: none; }
39
+ .html-reporter.showDetails #details { display: block; }
40
+ .html-reporter .summaryMenuItem { font-weight: bold; text-decoration: underline; }
41
+ .html-reporter .summary { margin-top: 14px; }
42
+ .html-reporter .summary ul { list-style-type: none; margin-left: 14px; padding-top: 0; padding-left: 0; }
43
+ .html-reporter .summary ul.suite { margin-top: 7px; margin-bottom: 7px; }
44
+ .html-reporter .summary li.passed a { color: #5e7d00; }
45
+ .html-reporter .summary li.failed a { color: #b03911; }
46
+ .html-reporter .summary li.pending a { color: #ba9d37; }
47
+ .html-reporter .description + .suite { margin-top: 0; }
48
+ .html-reporter .suite { margin-top: 14px; }
49
+ .html-reporter .suite a { color: #333333; }
50
+ .html-reporter .failures .spec-detail { margin-bottom: 28px; }
51
+ .html-reporter .failures .spec-detail .description { display: block; color: white; background-color: #b03911; }
52
+ .html-reporter .result-message { padding-top: 14px; color: #333333; white-space: pre; }
53
+ .html-reporter .result-message span.result { display: block; }
54
+ .html-reporter .stack-trace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #dddddd; background: white; white-space: pre; }
@@ -0,0 +1,2200 @@
1
+ /*
2
+ Copyright (c) 2008-2013 Pivotal Labs
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+ function getJasmineRequireObj() {
24
+ if (typeof module !== "undefined" && module.exports) {
25
+ return exports;
26
+ } else {
27
+ window.jasmineRequire = window.jasmineRequire || {};
28
+ return window.jasmineRequire;
29
+ }
30
+ }
31
+
32
+ getJasmineRequireObj().core = function(jRequire) {
33
+ j$ = {};
34
+
35
+ jRequire.base(j$);
36
+ j$.util = jRequire.util();
37
+ j$.Any = jRequire.Any();
38
+ j$.Clock = jRequire.Clock();
39
+ j$.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler();
40
+ j$.Env = jRequire.Env(j$);
41
+ j$.ExceptionFormatter = jRequire.ExceptionFormatter();
42
+ j$.Expectation = jRequire.Expectation();
43
+ j$.buildExpectationResult = jRequire.buildExpectationResult();
44
+ j$.JsApiReporter = jRequire.JsApiReporter();
45
+ j$.matchersUtil = jRequire.matchersUtil(j$);
46
+ j$.ObjectContaining = jRequire.ObjectContaining(j$);
47
+ j$.StringPrettyPrinter = jRequire.StringPrettyPrinter(j$);
48
+ j$.QueueRunner = jRequire.QueueRunner();
49
+ j$.ReportDispatcher = jRequire.ReportDispatcher();
50
+ j$.Spec = jRequire.Spec();
51
+ j$.Spy = jRequire.Spy(j$);
52
+ j$.Suite = jRequire.Suite();
53
+ j$.version = jRequire.version();
54
+
55
+ j$.matchers = jRequire.requireMatchers(jRequire);
56
+
57
+ return j$;
58
+ };
59
+
60
+ getJasmineRequireObj().requireMatchers = function(jRequire) {
61
+ var availableMatchers = [
62
+ "toBe",
63
+ "toBeCloseTo",
64
+ "toBeDefined",
65
+ "toBeFalsy",
66
+ "toBeGreaterThan",
67
+ "toBeLessThan",
68
+ "toBeNaN",
69
+ "toBeNull",
70
+ "toBeTruthy",
71
+ "toBeUndefined",
72
+ "toContain",
73
+ "toEqual",
74
+ "toHaveBeenCalled",
75
+ "toHaveBeenCalledWith",
76
+ "toMatch",
77
+ "toThrow",
78
+ "toThrowError"
79
+ ],
80
+ matchers = {};
81
+
82
+ for (var i = 0; i < availableMatchers.length; i++) {
83
+ var name = availableMatchers[i];
84
+ matchers[name] = jRequire[name]();
85
+ }
86
+
87
+ return matchers;
88
+ };
89
+
90
+ getJasmineRequireObj().base = function(j$) {
91
+ j$.unimplementedMethod_ = function() {
92
+ throw new Error("unimplemented method");
93
+ };
94
+
95
+ j$.DEFAULT_UPDATE_INTERVAL = 250;
96
+ j$.MAX_PRETTY_PRINT_DEPTH = 40;
97
+ j$.DEFAULT_TIMEOUT_INTERVAL = 5000;
98
+
99
+ j$.getGlobal = function() {
100
+ function getGlobal() {
101
+ return this;
102
+ }
103
+
104
+ return getGlobal();
105
+ };
106
+
107
+ j$.getEnv = function(options) {
108
+ var env = j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options);
109
+ //jasmine. singletons in here (setTimeout blah blah).
110
+ return env;
111
+ };
112
+
113
+ j$.isArray_ = function(value) {
114
+ return j$.isA_("Array", value);
115
+ };
116
+
117
+ j$.isString_ = function(value) {
118
+ return j$.isA_("String", value);
119
+ };
120
+
121
+ j$.isNumber_ = function(value) {
122
+ return j$.isA_("Number", value);
123
+ };
124
+
125
+ j$.isA_ = function(typeName, value) {
126
+ return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';
127
+ };
128
+
129
+ j$.pp = function(value) {
130
+ var stringPrettyPrinter = new j$.StringPrettyPrinter();
131
+ stringPrettyPrinter.format(value);
132
+ return stringPrettyPrinter.string;
133
+ };
134
+
135
+ j$.isDomNode = function(obj) {
136
+ return obj.nodeType > 0;
137
+ };
138
+
139
+ j$.any = function(clazz) {
140
+ return new j$.Any(clazz);
141
+ };
142
+
143
+ j$.objectContaining = function(sample) {
144
+ return new j$.ObjectContaining(sample);
145
+ };
146
+ };
147
+
148
+ getJasmineRequireObj().util = function() {
149
+
150
+ var util = {};
151
+
152
+ util.inherit = function(childClass, parentClass) {
153
+ var subclass = function() {
154
+ };
155
+ subclass.prototype = parentClass.prototype;
156
+ childClass.prototype = new subclass();
157
+ };
158
+
159
+ util.htmlEscape = function(str) {
160
+ if (!str) return str;
161
+ return str.replace(/&/g, '&amp;')
162
+ .replace(/</g, '&lt;')
163
+ .replace(/>/g, '&gt;');
164
+ };
165
+
166
+ util.argsToArray = function(args) {
167
+ var arrayOfArgs = [];
168
+ for (var i = 0; i < args.length; i++) arrayOfArgs.push(args[i]);
169
+ return arrayOfArgs;
170
+ };
171
+
172
+ util.isUndefined = function(obj) {
173
+ return obj === void 0;
174
+ };
175
+
176
+ return util;
177
+ };
178
+
179
+ getJasmineRequireObj().Spec = function() {
180
+ function Spec(attrs) {
181
+ this.encounteredExpectations = false;
182
+ this.expectationFactory = attrs.expectationFactory;
183
+ this.resultCallback = attrs.resultCallback || function() {};
184
+ this.id = attrs.id;
185
+ this.description = attrs.description || '';
186
+ this.fn = attrs.fn;
187
+ this.beforeFns = attrs.beforeFns || function() {};
188
+ this.afterFns = attrs.afterFns || function() {};
189
+ this.catchingExceptions = attrs.catchingExceptions;
190
+ this.onStart = attrs.onStart || function() {};
191
+ this.exceptionFormatter = attrs.exceptionFormatter || function() {};
192
+ this.getSpecName = attrs.getSpecName || function() { return ''; };
193
+ this.expectationResultFactory = attrs.expectationResultFactory || function() { };
194
+ this.queueRunner = attrs.queueRunner || function() {};
195
+ this.catchingExceptions = attrs.catchingExceptions || function() { return true; };
196
+
197
+ if (!this.fn) {
198
+ this.pend();
199
+ }
200
+
201
+ this.result = {
202
+ id: this.id,
203
+ description: this.description,
204
+ fullName: this.getFullName(),
205
+ status: this.status(),
206
+ failedExpectations: []
207
+ };
208
+ }
209
+
210
+ Spec.prototype.addExpectationResult = function(passed, data) {
211
+ this.encounteredExpectations = true;
212
+ if (passed) {
213
+ return;
214
+ }
215
+ this.result.failedExpectations.push(this.expectationResultFactory(data));
216
+ };
217
+
218
+ Spec.prototype.expect = function(actual) {
219
+ return this.expectationFactory(actual, this);
220
+ };
221
+
222
+ Spec.prototype.execute = function(onComplete) {
223
+ var self = this;
224
+
225
+ this.onStart(this);
226
+
227
+ if (this.markedPending || this.disabled) {
228
+ complete();
229
+ return;
230
+ }
231
+
232
+ var befores = this.beforeFns() || [],
233
+ afters = this.afterFns() || [];
234
+ var allFns = befores.concat(this.fn).concat(afters);
235
+
236
+ this.queueRunner({
237
+ fns: allFns,
238
+ onException: function(e) {
239
+ if (Spec.isPendingSpecException(e)) {
240
+ self.pend();
241
+ return;
242
+ }
243
+
244
+ self.addExpectationResult(false, {
245
+ matcherName: "",
246
+ passed: false,
247
+ expected: "",
248
+ actual: "",
249
+ error: e
250
+ });
251
+ },
252
+ onComplete: complete
253
+ });
254
+
255
+ function complete() {
256
+ self.result.status = self.status();
257
+ self.resultCallback(self.result);
258
+
259
+ if (onComplete) {
260
+ onComplete();
261
+ }
262
+ }
263
+ };
264
+
265
+ Spec.prototype.disable = function() {
266
+ this.disabled = true;
267
+ };
268
+
269
+ Spec.prototype.pend = function() {
270
+ this.markedPending = true;
271
+ };
272
+
273
+ Spec.prototype.status = function() {
274
+ if (this.disabled) {
275
+ return 'disabled';
276
+ }
277
+
278
+ if (this.markedPending || !this.encounteredExpectations) {
279
+ return 'pending';
280
+ }
281
+
282
+ if (this.result.failedExpectations.length > 0) {
283
+ return 'failed';
284
+ } else {
285
+ return 'passed';
286
+ }
287
+ };
288
+
289
+ Spec.prototype.getFullName = function() {
290
+ return this.getSpecName(this);
291
+ };
292
+
293
+ Spec.pendingSpecExceptionMessage = "=> marked Pending";
294
+
295
+ Spec.isPendingSpecException = function(e) {
296
+ return e.toString().indexOf(Spec.pendingSpecExceptionMessage) !== -1;
297
+ };
298
+
299
+ return Spec;
300
+ };
301
+
302
+ if (typeof window == void 0 && typeof exports == "object") {
303
+ exports.Spec = jasmineRequire.Spec;
304
+ }
305
+
306
+ getJasmineRequireObj().Env = function(j$) {
307
+ function Env(options) {
308
+ options = options || {};
309
+ var self = this;
310
+ var global = options.global || j$.getGlobal(),
311
+ now = options.now || function() { return new Date().getTime(); };
312
+
313
+ var catchExceptions = true;
314
+
315
+ this.clock = new j$.Clock(global, new j$.DelayedFunctionScheduler());
316
+
317
+ this.spies_ = [];
318
+ this.currentSpec = null;
319
+
320
+ this.reporter = new j$.ReportDispatcher([
321
+ "jasmineStarted",
322
+ "jasmineDone",
323
+ "suiteStarted",
324
+ "suiteDone",
325
+ "specStarted",
326
+ "specDone"
327
+ ]);
328
+
329
+ this.lastUpdate = 0;
330
+ this.specFilter = function() {
331
+ return true;
332
+ };
333
+
334
+ this.nextSpecId_ = 0;
335
+ this.nextSuiteId_ = 0;
336
+ this.equalityTesters_ = [];
337
+
338
+ var customEqualityTesters = [];
339
+ this.addCustomEqualityTester = function(tester) {
340
+ customEqualityTesters.push(tester);
341
+ };
342
+
343
+ j$.Expectation.addCoreMatchers(j$.matchers);
344
+
345
+ var expectationFactory = function(actual, spec) {
346
+ return j$.Expectation.Factory({
347
+ util: j$.matchersUtil,
348
+ customEqualityTesters: customEqualityTesters,
349
+ actual: actual,
350
+ addExpectationResult: addExpectationResult
351
+ });
352
+
353
+ function addExpectationResult(passed, result) {
354
+ return spec.addExpectationResult(passed, result);
355
+ }
356
+ };
357
+
358
+ var specStarted = function(spec) {
359
+ self.currentSpec = spec;
360
+ self.reporter.specStarted(spec.result);
361
+ };
362
+
363
+ var beforeFns = function(currentSuite) {
364
+ return function() {
365
+ var befores = [];
366
+ for (var suite = currentSuite; suite; suite = suite.parentSuite) {
367
+ befores = befores.concat(suite.beforeFns);
368
+ }
369
+ return befores.reverse();
370
+ };
371
+ };
372
+
373
+ var afterFns = function(currentSuite) {
374
+ return function() {
375
+ var afters = [];
376
+ for (var suite = currentSuite; suite; suite = suite.parentSuite) {
377
+ afters = afters.concat(suite.afterFns);
378
+ }
379
+ return afters;
380
+ };
381
+ };
382
+
383
+ var specConstructor = j$.Spec; // TODO: inline this
384
+
385
+ var getSpecName = function(spec, currentSuite) {
386
+ return currentSuite.getFullName() + ' ' + spec.description + '.';
387
+ };
388
+
389
+ // TODO: we may just be able to pass in the fn instead of wrapping here
390
+ var buildExpectationResult = j$.buildExpectationResult,
391
+ exceptionFormatter = new j$.ExceptionFormatter(),
392
+ expectationResultFactory = function(attrs) {
393
+ attrs.messageFormatter = exceptionFormatter.message;
394
+ attrs.stackFormatter = exceptionFormatter.stack;
395
+
396
+ return buildExpectationResult(attrs);
397
+ };
398
+
399
+ // TODO: fix this naming, and here's where the value comes in
400
+ this.catchExceptions = function(value) {
401
+ catchExceptions = !!value;
402
+ return catchExceptions;
403
+ };
404
+
405
+ this.catchingExceptions = function() {
406
+ return catchExceptions;
407
+ };
408
+
409
+ this.catchException = function(e){
410
+ return j$.Spec.isPendingSpecException(e) || catchExceptions;
411
+ };
412
+
413
+ var maximumSpecCallbackDepth = 100;
414
+ var currentSpecCallbackDepth = 0;
415
+
416
+ function encourageGarbageCollection(fn) {
417
+ currentSpecCallbackDepth++;
418
+ if (currentSpecCallbackDepth > maximumSpecCallbackDepth) {
419
+ currentSpecCallbackDepth = 0;
420
+ global.setTimeout(fn, 0);
421
+ } else {
422
+ fn();
423
+ }
424
+ }
425
+
426
+ var queueRunnerFactory = function(options) {
427
+ options.catchException = self.catchException;
428
+ options.encourageGC = options.encourageGarbageCollection || encourageGarbageCollection;
429
+
430
+ new j$.QueueRunner(options).run(options.fns, 0);
431
+ };
432
+
433
+ var totalSpecsDefined = 0;
434
+ this.specFactory = function(description, fn, suite) {
435
+ totalSpecsDefined++;
436
+
437
+ var spec = new specConstructor({
438
+ id: self.nextSpecId(),
439
+ beforeFns: beforeFns(suite),
440
+ afterFns: afterFns(suite),
441
+ expectationFactory: expectationFactory,
442
+ exceptionFormatter: exceptionFormatter,
443
+ resultCallback: specResultCallback,
444
+ getSpecName: function(spec) {
445
+ return getSpecName(spec, suite);
446
+ },
447
+ onStart: specStarted,
448
+ description: description,
449
+ expectationResultFactory: expectationResultFactory,
450
+ queueRunner: queueRunnerFactory,
451
+ fn: fn
452
+ });
453
+
454
+ if (!self.specFilter(spec)) {
455
+ spec.disable();
456
+ }
457
+
458
+ return spec;
459
+
460
+ function specResultCallback(result) {
461
+ self.removeAllSpies();
462
+ j$.Expectation.resetMatchers();
463
+ customEqualityTesters.length = 0;
464
+ self.clock.uninstall();
465
+ self.currentSpec = null;
466
+ self.reporter.specDone(result);
467
+ }
468
+ };
469
+
470
+ var suiteStarted = function(suite) {
471
+ self.reporter.suiteStarted(suite.result);
472
+ };
473
+
474
+ var suiteConstructor = j$.Suite;
475
+
476
+ this.topSuite = new j$.Suite({
477
+ env: this,
478
+ id: this.nextSuiteId(),
479
+ description: 'Jasmine__TopLevel__Suite',
480
+ queueRunner: queueRunnerFactory,
481
+ completeCallback: function() {}, // TODO - hook this up
482
+ resultCallback: function() {} // TODO - hook this up
483
+ });
484
+ this.currentSuite = this.topSuite;
485
+
486
+ this.suiteFactory = function(description) {
487
+ return new suiteConstructor({
488
+ env: self,
489
+ id: self.nextSuiteId(),
490
+ description: description,
491
+ parentSuite: self.currentSuite,
492
+ queueRunner: queueRunnerFactory,
493
+ onStart: suiteStarted,
494
+ resultCallback: function(attrs) {
495
+ self.reporter.suiteDone(attrs);
496
+ }
497
+ });
498
+ };
499
+
500
+ this.execute = function() {
501
+ var startTime = now();
502
+ this.reporter.jasmineStarted({
503
+ totalSpecsDefined: totalSpecsDefined
504
+ });
505
+ this.topSuite.execute(function() {
506
+ self.reporter.jasmineDone({executionTime: now() - startTime});
507
+ });
508
+ };
509
+ }
510
+
511
+ Env.prototype.addMatchers = function(matchersToAdd) {
512
+ j$.Expectation.addMatchers(matchersToAdd);
513
+ };
514
+
515
+ Env.prototype.version = function() {
516
+ return j$.version;
517
+ };
518
+
519
+ Env.prototype.expect = function(actual) {
520
+ return this.currentSpec.expect(actual);
521
+ };
522
+
523
+ Env.prototype.spyOn = function(obj, methodName) {
524
+ if (j$.util.isUndefined(obj)) {
525
+ throw "spyOn could not find an object to spy upon for " + methodName + "()";
526
+ }
527
+
528
+ if (j$.util.isUndefined(obj[methodName])) {
529
+ throw methodName + '() method does not exist';
530
+ }
531
+
532
+ if (obj[methodName] && obj[methodName].isSpy) {
533
+ //TODO?: should this return the current spy? Downside: may cause user confusion about spy state
534
+ throw new Error(methodName + ' has already been spied upon');
535
+ }
536
+
537
+ var spyObj = j$.createSpy(methodName);
538
+
539
+ this.spies_.push(spyObj);
540
+ spyObj.baseObj = obj;
541
+ spyObj.methodName = methodName;
542
+ spyObj.originalValue = obj[methodName];
543
+
544
+ obj[methodName] = spyObj;
545
+
546
+ return spyObj;
547
+ };
548
+
549
+ // TODO: move this to closure
550
+ Env.prototype.removeAllSpies = function() {
551
+ for (var i = 0; i < this.spies_.length; i++) {
552
+ var spy = this.spies_[i];
553
+ spy.baseObj[spy.methodName] = spy.originalValue;
554
+ }
555
+ this.spies_ = [];
556
+ };
557
+
558
+ // TODO: move this to closure
559
+ Env.prototype.versionString = function() {
560
+ console.log("DEPRECATED == use j$.version");
561
+ return j$.version;
562
+ };
563
+
564
+ // TODO: move this to closure
565
+ Env.prototype.nextSpecId = function() {
566
+ return this.nextSpecId_++;
567
+ };
568
+
569
+ // TODO: move this to closure
570
+ Env.prototype.nextSuiteId = function() {
571
+ return this.nextSuiteId_++;
572
+ };
573
+
574
+ // TODO: move this to closure
575
+ Env.prototype.addReporter = function(reporter) {
576
+ this.reporter.addReporter(reporter);
577
+ };
578
+
579
+ // TODO: move this to closure
580
+ Env.prototype.describe = function(description, specDefinitions) {
581
+ var suite = this.suiteFactory(description, specDefinitions);
582
+
583
+ var parentSuite = this.currentSuite;
584
+ parentSuite.addSuite(suite);
585
+ this.currentSuite = suite;
586
+
587
+ var declarationError = null;
588
+ try {
589
+ specDefinitions.call(suite);
590
+ } catch (e) {
591
+ declarationError = e;
592
+ }
593
+
594
+ if (declarationError) {
595
+ this.it("encountered a declaration exception", function() {
596
+ throw declarationError;
597
+ });
598
+ }
599
+
600
+ this.currentSuite = parentSuite;
601
+
602
+ return suite;
603
+ };
604
+
605
+ // TODO: move this to closure
606
+ Env.prototype.xdescribe = function(description, specDefinitions) {
607
+ var suite = this.describe(description, specDefinitions);
608
+ suite.disable();
609
+ return suite;
610
+ };
611
+
612
+ // TODO: move this to closure
613
+ Env.prototype.it = function(description, fn) {
614
+ var spec = this.specFactory(description, fn, this.currentSuite);
615
+ this.currentSuite.addSpec(spec);
616
+ return spec;
617
+ };
618
+
619
+ // TODO: move this to closure
620
+ Env.prototype.xit = function(description, fn) {
621
+ var spec = this.it(description, fn);
622
+ spec.pend();
623
+ return spec;
624
+ };
625
+
626
+ // TODO: move this to closure
627
+ Env.prototype.beforeEach = function(beforeEachFunction) {
628
+ this.currentSuite.beforeEach(beforeEachFunction);
629
+ };
630
+
631
+ // TODO: move this to closure
632
+ Env.prototype.afterEach = function(afterEachFunction) {
633
+ this.currentSuite.afterEach(afterEachFunction);
634
+ };
635
+
636
+ // TODO: move this to closure
637
+ Env.prototype.pending = function() {
638
+ throw j$.Spec.pendingSpecExceptionMessage;
639
+ };
640
+
641
+ // TODO: Still needed?
642
+ Env.prototype.currentRunner = function() {
643
+ return this.topSuite;
644
+ };
645
+
646
+ return Env;
647
+ };
648
+
649
+ getJasmineRequireObj().JsApiReporter = function() {
650
+ function JsApiReporter(jasmine) { // TODO: this doesn't appear to be used
651
+ this.jasmine = jasmine || {};
652
+ this.started = false;
653
+ this.finished = false;
654
+
655
+ var status = 'loaded';
656
+
657
+ this.jasmineStarted = function() {
658
+ this.started = true;
659
+ status = 'started';
660
+ };
661
+
662
+ var executionTime;
663
+
664
+ this.jasmineDone = function(options) {
665
+ this.finished = true;
666
+ executionTime = options.executionTime;
667
+ status = 'done';
668
+ };
669
+
670
+ this.status = function() {
671
+ return status;
672
+ };
673
+
674
+ var suites = {};
675
+
676
+ this.suiteStarted = function(result) {
677
+ storeSuite(result);
678
+ };
679
+
680
+ this.suiteDone = function(result) {
681
+ storeSuite(result);
682
+ };
683
+
684
+ function storeSuite(result) {
685
+ suites[result.id] = result;
686
+ }
687
+
688
+ this.suites = function() {
689
+ return suites;
690
+ };
691
+
692
+ var specs = [];
693
+ this.specStarted = function(result) { };
694
+
695
+ this.specDone = function(result) {
696
+ specs.push(result);
697
+ };
698
+
699
+ this.specResults = function(index, length) {
700
+ return specs.slice(index, index + length);
701
+ };
702
+
703
+ this.specs = function() {
704
+ return specs;
705
+ };
706
+
707
+ this.executionTime = function() {
708
+ return executionTime;
709
+ };
710
+
711
+ }
712
+
713
+ return JsApiReporter;
714
+ };
715
+
716
+ getJasmineRequireObj().Any = function() {
717
+
718
+ function Any(expectedObject) {
719
+ this.expectedObject = expectedObject;
720
+ }
721
+
722
+ Any.prototype.jasmineMatches = function(other) {
723
+ if (this.expectedObject == String) {
724
+ return typeof other == 'string' || other instanceof String;
725
+ }
726
+
727
+ if (this.expectedObject == Number) {
728
+ return typeof other == 'number' || other instanceof Number;
729
+ }
730
+
731
+ if (this.expectedObject == Function) {
732
+ return typeof other == 'function' || other instanceof Function;
733
+ }
734
+
735
+ if (this.expectedObject == Object) {
736
+ return typeof other == 'object';
737
+ }
738
+
739
+ return other instanceof this.expectedObject;
740
+ };
741
+
742
+ Any.prototype.jasmineToString = function() {
743
+ return '<jasmine.any(' + this.expectedClass + ')>';
744
+ };
745
+
746
+ return Any;
747
+ };
748
+ getJasmineRequireObj().Clock = function() {
749
+ function Clock(global, delayedFunctionScheduler) {
750
+ var self = this,
751
+ realTimingFunctions = {
752
+ setTimeout: global.setTimeout,
753
+ clearTimeout: global.clearTimeout,
754
+ setInterval: global.setInterval,
755
+ clearInterval: global.clearInterval
756
+ },
757
+ fakeTimingFunctions = {
758
+ setTimeout: setTimeout,
759
+ clearTimeout: clearTimeout,
760
+ setInterval: setInterval,
761
+ clearInterval: clearInterval
762
+ },
763
+ timer = realTimingFunctions,
764
+ installed = false;
765
+
766
+ self.install = function() {
767
+ installed = true;
768
+ timer = fakeTimingFunctions;
769
+ };
770
+
771
+ self.uninstall = function() {
772
+ delayedFunctionScheduler.reset();
773
+ installed = false;
774
+ timer = realTimingFunctions;
775
+ };
776
+
777
+ self.setTimeout = function(fn, delay, params) {
778
+ if (legacyIE()) {
779
+ if (arguments.length > 2) {
780
+ throw new Error("IE < 9 cannot support extra params to setTimeout without a polyfill");
781
+ }
782
+ return timer.setTimeout(fn, delay);
783
+ }
784
+ return timer.setTimeout.apply(global, arguments);
785
+ };
786
+
787
+ self.setInterval = function(fn, delay, params) {
788
+ if (legacyIE()) {
789
+ if (arguments.length > 2) {
790
+ throw new Error("IE < 9 cannot support extra params to setInterval without a polyfill");
791
+ }
792
+ return timer.setInterval(fn, delay);
793
+ }
794
+ return timer.setInterval.apply(global, arguments);
795
+ };
796
+
797
+ self.clearTimeout = function(id) {
798
+ return timer.clearTimeout.call(global, id);
799
+ };
800
+
801
+ self.clearInterval = function(id) {
802
+ return timer.clearInterval.call(global, id);
803
+ };
804
+
805
+ self.tick = function(millis) {
806
+ if (installed) {
807
+ delayedFunctionScheduler.tick(millis);
808
+ } else {
809
+ throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()");
810
+ }
811
+ };
812
+
813
+ return self;
814
+
815
+ function legacyIE() {
816
+ //if these methods are polyfilled, apply will be present
817
+ //TODO: it may be difficult to load the polyfill before jasmine loads
818
+ //(env should be new-ed inside of onload)
819
+ return !(global.setTimeout || global.setInterval).apply;
820
+ }
821
+
822
+ function setTimeout(fn, delay) {
823
+ return delayedFunctionScheduler.scheduleFunction(fn, delay, argSlice(arguments, 2));
824
+ }
825
+
826
+ function clearTimeout(id) {
827
+ return delayedFunctionScheduler.removeFunctionWithId(id);
828
+ }
829
+
830
+ function setInterval(fn, interval) {
831
+ return delayedFunctionScheduler.scheduleFunction(fn, interval, argSlice(arguments, 2), true);
832
+ }
833
+
834
+ function clearInterval(id) {
835
+ return delayedFunctionScheduler.removeFunctionWithId(id);
836
+ }
837
+
838
+ function argSlice(argsObj, n) {
839
+ return Array.prototype.slice.call(argsObj, 2);
840
+ }
841
+ }
842
+
843
+ return Clock;
844
+ };
845
+
846
+ getJasmineRequireObj().DelayedFunctionScheduler = function() {
847
+ function DelayedFunctionScheduler() {
848
+ var self = this;
849
+ var scheduledFunctions = {};
850
+ var currentTime = 0;
851
+ var delayedFnCount = 0;
852
+
853
+ self.tick = function(millis) {
854
+ millis = millis || 0;
855
+ runFunctionsWithinRange(currentTime, currentTime + millis);
856
+ currentTime = currentTime + millis;
857
+ };
858
+
859
+ self.scheduleFunction = function(funcToCall, millis, params, recurring, timeoutKey, runAtMillis) {
860
+ millis = millis || 0;
861
+ timeoutKey = timeoutKey || ++delayedFnCount;
862
+ runAtMillis = runAtMillis || (currentTime + millis);
863
+ scheduledFunctions[timeoutKey] = {
864
+ runAtMillis: runAtMillis,
865
+ funcToCall: funcToCall,
866
+ recurring: recurring,
867
+ params: params,
868
+ timeoutKey: timeoutKey,
869
+ millis: millis
870
+ };
871
+ return timeoutKey;
872
+ };
873
+
874
+ self.removeFunctionWithId = function(timeoutKey) {
875
+ delete scheduledFunctions[timeoutKey];
876
+ };
877
+
878
+ self.reset = function() {
879
+ currentTime = 0;
880
+ scheduledFunctions = {};
881
+ delayedFnCount = 0;
882
+ };
883
+
884
+ return self;
885
+
886
+ // finds/dupes functions within range and removes them.
887
+ function functionsWithinRange(startMillis, endMillis) {
888
+ var fnsToRun = [];
889
+ for (var timeoutKey in scheduledFunctions) {
890
+ var scheduledFunc = scheduledFunctions[timeoutKey];
891
+ if (scheduledFunc &&
892
+ scheduledFunc.runAtMillis >= startMillis &&
893
+ scheduledFunc.runAtMillis <= endMillis) {
894
+
895
+ // remove fn -- we'll reschedule later if it is recurring.
896
+ self.removeFunctionWithId(timeoutKey);
897
+ if (!scheduledFunc.recurring) {
898
+ fnsToRun.push(scheduledFunc); // schedules each function only once
899
+ } else {
900
+ fnsToRun.push(buildNthInstanceOf(scheduledFunc, 0));
901
+ var additionalTimesFnRunsInRange =
902
+ Math.floor((endMillis - scheduledFunc.runAtMillis) / scheduledFunc.millis);
903
+ for (var i = 0; i < additionalTimesFnRunsInRange; i++) {
904
+ fnsToRun.push(buildNthInstanceOf(scheduledFunc, i + 1));
905
+ }
906
+ reschedule(buildNthInstanceOf(scheduledFunc, additionalTimesFnRunsInRange));
907
+ }
908
+ }
909
+ }
910
+
911
+ return fnsToRun;
912
+ }
913
+
914
+ function buildNthInstanceOf(scheduledFunc, n) {
915
+ return {
916
+ runAtMillis: scheduledFunc.runAtMillis + (scheduledFunc.millis * n),
917
+ funcToCall: scheduledFunc.funcToCall,
918
+ params: scheduledFunc.params,
919
+ millis: scheduledFunc.millis,
920
+ recurring: scheduledFunc.recurring,
921
+ timeoutKey: scheduledFunc.timeoutKey
922
+ };
923
+ }
924
+
925
+ function reschedule(scheduledFn) {
926
+ self.scheduleFunction(scheduledFn.funcToCall,
927
+ scheduledFn.millis,
928
+ scheduledFn.params,
929
+ true,
930
+ scheduledFn.timeoutKey,
931
+ scheduledFn.runAtMillis + scheduledFn.millis);
932
+ }
933
+
934
+
935
+ function runFunctionsWithinRange(startMillis, endMillis) {
936
+ var funcsToRun = functionsWithinRange(startMillis, endMillis);
937
+ if (funcsToRun.length === 0) {
938
+ return;
939
+ }
940
+
941
+ funcsToRun.sort(function(a, b) {
942
+ return a.runAtMillis - b.runAtMillis;
943
+ });
944
+
945
+ for (var i = 0; i < funcsToRun.length; ++i) {
946
+ var funcToRun = funcsToRun[i];
947
+ funcToRun.funcToCall.apply(null, funcToRun.params);
948
+ }
949
+ }
950
+ }
951
+
952
+ return DelayedFunctionScheduler;
953
+ };
954
+
955
+ getJasmineRequireObj().ExceptionFormatter = function() {
956
+ function ExceptionFormatter() {
957
+ this.message = function(error) {
958
+ var message = error.name +
959
+ ': ' +
960
+ error.message;
961
+
962
+ if (error.fileName || error.sourceURL) {
963
+ message += " in " + (error.fileName || error.sourceURL);
964
+ }
965
+
966
+ if (error.line || error.lineNumber) {
967
+ message += " (line " + (error.line || error.lineNumber) + ")";
968
+ }
969
+
970
+ return message;
971
+ };
972
+
973
+ this.stack = function(error) {
974
+ return error ? error.stack : null;
975
+ };
976
+ }
977
+
978
+ return ExceptionFormatter;
979
+ };
980
+
981
+ getJasmineRequireObj().Expectation = function() {
982
+
983
+ var matchers = {};
984
+
985
+ function Expectation(options) {
986
+ this.util = options.util || { buildFailureMessage: function() {} };
987
+ this.customEqualityTesters = options.customEqualityTesters || [];
988
+ this.actual = options.actual;
989
+ this.addExpectationResult = options.addExpectationResult || function(){};
990
+ this.isNot = options.isNot;
991
+
992
+ for (var matcherName in matchers) {
993
+ this[matcherName] = matchers[matcherName];
994
+ }
995
+ }
996
+
997
+ Expectation.prototype.wrapCompare = function(name, matcherFactory) {
998
+ return function() {
999
+ var args = Array.prototype.slice.call(arguments, 0),
1000
+ expected = args.slice(0),
1001
+ message = "";
1002
+
1003
+ args.unshift(this.actual);
1004
+
1005
+ var result = matcherFactory(this.util, this.customEqualityTesters).compare.apply(null, args);
1006
+
1007
+ if (this.isNot) {
1008
+ result.pass = !result.pass;
1009
+ }
1010
+
1011
+ if (!result.pass) {
1012
+ if (!result.message) {
1013
+ args.unshift(this.isNot);
1014
+ args.unshift(name);
1015
+ message = this.util.buildFailureMessage.apply(null, args);
1016
+ } else {
1017
+ message = result.message;
1018
+ }
1019
+ }
1020
+
1021
+ if (expected.length == 1) {
1022
+ expected = expected[0];
1023
+ }
1024
+
1025
+ // TODO: how many of these params are needed?
1026
+ this.addExpectationResult(
1027
+ result.pass,
1028
+ {
1029
+ matcherName: name,
1030
+ passed: result.pass,
1031
+ message: message,
1032
+ actual: this.actual,
1033
+ expected: expected // TODO: this may need to be arrayified/sliced
1034
+ }
1035
+ );
1036
+ };
1037
+ };
1038
+
1039
+ Expectation.addCoreMatchers = function(matchers) {
1040
+ var prototype = Expectation.prototype;
1041
+ for (var matcherName in matchers) {
1042
+ var matcher = matchers[matcherName];
1043
+ prototype[matcherName] = prototype.wrapCompare(matcherName, matcher);
1044
+ }
1045
+ };
1046
+
1047
+ Expectation.addMatchers = function(matchersToAdd) {
1048
+ for (var name in matchersToAdd) {
1049
+ var matcher = matchersToAdd[name];
1050
+ matchers[name] = Expectation.prototype.wrapCompare(name, matcher);
1051
+ }
1052
+ };
1053
+
1054
+ Expectation.resetMatchers = function() {
1055
+ for (var name in matchers) {
1056
+ delete matchers[name];
1057
+ }
1058
+ };
1059
+
1060
+ Expectation.Factory = function(options) {
1061
+ options = options || {};
1062
+
1063
+ var expect = new Expectation(options);
1064
+
1065
+ // TODO: this would be nice as its own Object - NegativeExpectation
1066
+ // TODO: copy instead of mutate options
1067
+ options.isNot = true;
1068
+ expect.not = new Expectation(options);
1069
+
1070
+ return expect;
1071
+ };
1072
+
1073
+ return Expectation;
1074
+ };
1075
+
1076
+ //TODO: expectation result may make more sense as a presentation of an expectation.
1077
+ getJasmineRequireObj().buildExpectationResult = function() {
1078
+ function buildExpectationResult(options) {
1079
+ var messageFormatter = options.messageFormatter || function() {},
1080
+ stackFormatter = options.stackFormatter || function() {};
1081
+
1082
+ return {
1083
+ matcherName: options.matcherName,
1084
+ expected: options.expected,
1085
+ actual: options.actual,
1086
+ message: message(),
1087
+ stack: stack(),
1088
+ passed: options.passed
1089
+ };
1090
+
1091
+ function message() {
1092
+ if (options.passed) {
1093
+ return "Passed.";
1094
+ } else if (options.message) {
1095
+ return options.message;
1096
+ } else if (options.error) {
1097
+ return messageFormatter(options.error);
1098
+ }
1099
+ return "";
1100
+ }
1101
+
1102
+ function stack() {
1103
+ if (options.passed) {
1104
+ return "";
1105
+ }
1106
+
1107
+ var error = options.error;
1108
+ if (!error) {
1109
+ try {
1110
+ throw new Error(message());
1111
+ } catch (e) {
1112
+ error = e;
1113
+ }
1114
+ }
1115
+ return stackFormatter(error);
1116
+ }
1117
+ }
1118
+
1119
+ return buildExpectationResult;
1120
+ };
1121
+
1122
+ getJasmineRequireObj().ObjectContaining = function(j$) {
1123
+
1124
+ function ObjectContaining(sample) {
1125
+ this.sample = sample;
1126
+ }
1127
+
1128
+ ObjectContaining.prototype.jasmineMatches = function(other, mismatchKeys, mismatchValues) {
1129
+ mismatchKeys = mismatchKeys || [];
1130
+ mismatchValues = mismatchValues || [];
1131
+
1132
+ var hasKey = function(obj, keyName) {
1133
+ return obj !== null && !j$.util.isUndefined(obj[keyName]);
1134
+ };
1135
+
1136
+ for (var property in this.sample) {
1137
+ if (!hasKey(other, property) && hasKey(this.sample, property)) {
1138
+ mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
1139
+ }
1140
+ else if (!j$.matchersUtil.equals(this.sample[property], other[property], mismatchKeys, mismatchValues)) {
1141
+ mismatchValues.push("'" + property + "' was '" + (other[property] ? j$.util.htmlEscape(other[property].toString()) : other[property]) + "' in expected, but was '" + (this.sample[property] ? j$.util.htmlEscape(this.sample[property].toString()) : this.sample[property]) + "' in actual.");
1142
+ }
1143
+ }
1144
+
1145
+ return (mismatchKeys.length === 0 && mismatchValues.length === 0);
1146
+ };
1147
+
1148
+ ObjectContaining.prototype.jasmineToString = function() {
1149
+ return "<jasmine.objectContaining(" + j$.pp(this.sample) + ")>";
1150
+ };
1151
+
1152
+ return ObjectContaining;
1153
+ };
1154
+
1155
+ getJasmineRequireObj().StringPrettyPrinter = function(j$) {
1156
+
1157
+ function PrettyPrinter() {
1158
+ this.ppNestLevel_ = 0;
1159
+ }
1160
+
1161
+ PrettyPrinter.prototype.format = function(value) {
1162
+ this.ppNestLevel_++;
1163
+ try {
1164
+ if (j$.util.isUndefined(value)) {
1165
+ this.emitScalar('undefined');
1166
+ } else if (value === null) {
1167
+ this.emitScalar('null');
1168
+ } else if (value === j$.getGlobal()) {
1169
+ this.emitScalar('<global>');
1170
+ } else if (value.jasmineToString) {
1171
+ this.emitScalar(value.jasmineToString());
1172
+ } else if (typeof value === 'string') {
1173
+ this.emitString(value);
1174
+ } else if (j$.isSpy(value)) {
1175
+ this.emitScalar("spy on " + value.identity);
1176
+ } else if (value instanceof RegExp) {
1177
+ this.emitScalar(value.toString());
1178
+ } else if (typeof value === 'function') {
1179
+ this.emitScalar('Function');
1180
+ } else if (typeof value.nodeType === 'number') {
1181
+ this.emitScalar('HTMLNode');
1182
+ } else if (value instanceof Date) {
1183
+ this.emitScalar('Date(' + value + ')');
1184
+ } else if (value.__Jasmine_been_here_before__) {
1185
+ this.emitScalar('<circular reference: ' + (j$.isArray_(value) ? 'Array' : 'Object') + '>');
1186
+ } else if (j$.isArray_(value) || typeof value == 'object') {
1187
+ value.__Jasmine_been_here_before__ = true;
1188
+ if (j$.isArray_(value)) {
1189
+ this.emitArray(value);
1190
+ } else {
1191
+ this.emitObject(value);
1192
+ }
1193
+ delete value.__Jasmine_been_here_before__;
1194
+ } else {
1195
+ this.emitScalar(value.toString());
1196
+ }
1197
+ } finally {
1198
+ this.ppNestLevel_--;
1199
+ }
1200
+ };
1201
+
1202
+ PrettyPrinter.prototype.iterateObject = function(obj, fn) {
1203
+ for (var property in obj) {
1204
+ if (!obj.hasOwnProperty(property)) continue;
1205
+ if (property == '__Jasmine_been_here_before__') continue;
1206
+ fn(property, obj.__lookupGetter__ ? (!j$.util.isUndefined(obj.__lookupGetter__(property)) &&
1207
+ obj.__lookupGetter__(property) !== null) : false);
1208
+ }
1209
+ };
1210
+
1211
+ PrettyPrinter.prototype.emitArray = j$.unimplementedMethod_;
1212
+ PrettyPrinter.prototype.emitObject = j$.unimplementedMethod_;
1213
+ PrettyPrinter.prototype.emitScalar = j$.unimplementedMethod_;
1214
+ PrettyPrinter.prototype.emitString = j$.unimplementedMethod_;
1215
+
1216
+ function StringPrettyPrinter() {
1217
+ PrettyPrinter.call(this);
1218
+
1219
+ this.string = '';
1220
+ }
1221
+ j$.util.inherit(StringPrettyPrinter, PrettyPrinter);
1222
+
1223
+ StringPrettyPrinter.prototype.emitScalar = function(value) {
1224
+ this.append(value);
1225
+ };
1226
+
1227
+ StringPrettyPrinter.prototype.emitString = function(value) {
1228
+ this.append("'" + value + "'");
1229
+ };
1230
+
1231
+ StringPrettyPrinter.prototype.emitArray = function(array) {
1232
+ if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) {
1233
+ this.append("Array");
1234
+ return;
1235
+ }
1236
+
1237
+ this.append('[ ');
1238
+ for (var i = 0; i < array.length; i++) {
1239
+ if (i > 0) {
1240
+ this.append(', ');
1241
+ }
1242
+ this.format(array[i]);
1243
+ }
1244
+ this.append(' ]');
1245
+ };
1246
+
1247
+ StringPrettyPrinter.prototype.emitObject = function(obj) {
1248
+ if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) {
1249
+ this.append("Object");
1250
+ return;
1251
+ }
1252
+
1253
+ var self = this;
1254
+ this.append('{ ');
1255
+ var first = true;
1256
+
1257
+ this.iterateObject(obj, function(property, isGetter) {
1258
+ if (first) {
1259
+ first = false;
1260
+ } else {
1261
+ self.append(', ');
1262
+ }
1263
+
1264
+ self.append(property);
1265
+ self.append(' : ');
1266
+ if (isGetter) {
1267
+ self.append('<getter>');
1268
+ } else {
1269
+ self.format(obj[property]);
1270
+ }
1271
+ });
1272
+
1273
+ this.append(' }');
1274
+ };
1275
+
1276
+ StringPrettyPrinter.prototype.append = function(value) {
1277
+ this.string += value;
1278
+ };
1279
+
1280
+ return StringPrettyPrinter;
1281
+ };
1282
+
1283
+ getJasmineRequireObj().QueueRunner = function() {
1284
+
1285
+ function QueueRunner(attrs) {
1286
+ this.fns = attrs.fns || [];
1287
+ this.onComplete = attrs.onComplete || function() {};
1288
+ this.encourageGC = attrs.encourageGC || function(fn) {fn();};
1289
+ this.onException = attrs.onException || function() {};
1290
+ this.catchException = attrs.catchException || function() { return true; };
1291
+ }
1292
+
1293
+ QueueRunner.prototype.execute = function() {
1294
+ this.run(this.fns, 0);
1295
+ };
1296
+
1297
+ QueueRunner.prototype.run = function(fns, index) {
1298
+ if (index >= fns.length) {
1299
+ this.encourageGC(this.onComplete);
1300
+ return;
1301
+ }
1302
+
1303
+ var fn = fns[index];
1304
+ var self = this;
1305
+ if (fn.length > 0) {
1306
+ attempt(function() { fn.call(self, function() { self.run(fns, index + 1); }); });
1307
+ } else {
1308
+ attempt(function() { fn.call(self); });
1309
+ self.run(fns, index + 1);
1310
+ }
1311
+
1312
+ function attempt(fn) {
1313
+ try {
1314
+ fn();
1315
+ } catch (e) {
1316
+ self.onException(e);
1317
+ if (!self.catchException(e)) {
1318
+ //TODO: set a var when we catch an exception and
1319
+ //use a finally block to close the loop in a nice way..
1320
+ throw e;
1321
+ }
1322
+ }
1323
+ }
1324
+ };
1325
+
1326
+ return QueueRunner;
1327
+ };
1328
+
1329
+ getJasmineRequireObj().ReportDispatcher = function() {
1330
+ function ReportDispatcher(methods) {
1331
+
1332
+ var dispatchedMethods = methods || [];
1333
+
1334
+ for (var i = 0; i < dispatchedMethods.length; i++) {
1335
+ var method = dispatchedMethods[i];
1336
+ this[method] = function(m) {
1337
+ return function() {
1338
+ dispatch(m, arguments);
1339
+ };
1340
+ }(method);
1341
+ }
1342
+
1343
+ var reporters = [];
1344
+
1345
+ this.addReporter = function(reporter) {
1346
+ reporters.push(reporter);
1347
+ };
1348
+
1349
+ return this;
1350
+
1351
+ function dispatch(method, args) {
1352
+ for (var i = 0; i < reporters.length; i++) {
1353
+ var reporter = reporters[i];
1354
+ if (reporter[method]) {
1355
+ reporter[method].apply(reporter, args);
1356
+ }
1357
+ }
1358
+ }
1359
+ }
1360
+
1361
+ return ReportDispatcher;
1362
+ };
1363
+
1364
+
1365
+ getJasmineRequireObj().Spy = function(j$) {
1366
+
1367
+ function Spy(name) {
1368
+ this.identity = name || 'unknown';
1369
+ this.isSpy = true;
1370
+ this.plan = function() {
1371
+ };
1372
+ this.mostRecentCall = {};
1373
+
1374
+ this.argsForCall = [];
1375
+ this.calls = [];
1376
+ }
1377
+
1378
+ Spy.prototype.andCallThrough = function() {
1379
+ this.plan = this.originalValue;
1380
+ return this;
1381
+ };
1382
+
1383
+ Spy.prototype.andReturn = function(value) {
1384
+ this.plan = function() {
1385
+ return value;
1386
+ };
1387
+ return this;
1388
+ };
1389
+
1390
+ Spy.prototype.andThrow = function(exceptionMsg) {
1391
+ this.plan = function() {
1392
+ throw exceptionMsg;
1393
+ };
1394
+ return this;
1395
+ };
1396
+
1397
+ Spy.prototype.andCallFake = function(fakeFunc) {
1398
+ this.plan = fakeFunc;
1399
+ return this;
1400
+ };
1401
+
1402
+ Spy.prototype.reset = function() {
1403
+ this.wasCalled = false;
1404
+ this.callCount = 0;
1405
+ this.argsForCall = [];
1406
+ this.calls = [];
1407
+ this.mostRecentCall = {};
1408
+ };
1409
+
1410
+ j$.createSpy = function(name) {
1411
+
1412
+ var spyObj = function() {
1413
+ spyObj.wasCalled = true;
1414
+ spyObj.callCount++;
1415
+ var args = j$.util.argsToArray(arguments);
1416
+ spyObj.mostRecentCall.object = this;
1417
+ spyObj.mostRecentCall.args = args;
1418
+ spyObj.argsForCall.push(args);
1419
+ spyObj.calls.push({object: this, args: args});
1420
+ return spyObj.plan.apply(this, arguments);
1421
+ };
1422
+
1423
+ var spy = new Spy(name);
1424
+
1425
+ for (var prop in spy) {
1426
+ spyObj[prop] = spy[prop];
1427
+ }
1428
+
1429
+ spyObj.reset();
1430
+
1431
+ return spyObj;
1432
+ };
1433
+
1434
+ j$.isSpy = function(putativeSpy) {
1435
+ return putativeSpy && putativeSpy.isSpy;
1436
+ };
1437
+
1438
+ j$.createSpyObj = function(baseName, methodNames) {
1439
+ if (!j$.isArray_(methodNames) || methodNames.length === 0) {
1440
+ throw "createSpyObj requires a non-empty array of method names to create spies for";
1441
+ }
1442
+ var obj = {};
1443
+ for (var i = 0; i < methodNames.length; i++) {
1444
+ obj[methodNames[i]] = j$.createSpy(baseName + '.' + methodNames[i]);
1445
+ }
1446
+ return obj;
1447
+ };
1448
+
1449
+ return Spy;
1450
+ };
1451
+
1452
+ getJasmineRequireObj().Suite = function() {
1453
+ function Suite(attrs) {
1454
+ this.env = attrs.env;
1455
+ this.id = attrs.id;
1456
+ this.parentSuite = attrs.parentSuite;
1457
+ this.description = attrs.description;
1458
+ this.onStart = attrs.onStart || function() {};
1459
+ this.completeCallback = attrs.completeCallback || function() {};
1460
+ this.resultCallback = attrs.resultCallback || function() {};
1461
+ this.encourageGC = attrs.encourageGC || function(fn) {fn();};
1462
+
1463
+ this.beforeFns = [];
1464
+ this.afterFns = [];
1465
+ this.queueRunner = attrs.queueRunner || function() {};
1466
+ this.disabled = false;
1467
+
1468
+ this.children_ = []; // TODO: rename
1469
+ this.suites = []; // TODO: needed?
1470
+ this.specs = []; // TODO: needed?
1471
+
1472
+ this.result = {
1473
+ id: this.id,
1474
+ status: this.disabled ? 'disabled' : '',
1475
+ description: this.description,
1476
+ fullName: this.getFullName()
1477
+ };
1478
+ }
1479
+
1480
+ Suite.prototype.getFullName = function() {
1481
+ var fullName = this.description;
1482
+ for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
1483
+ if (parentSuite.parentSuite) {
1484
+ fullName = parentSuite.description + ' ' + fullName;
1485
+ }
1486
+ }
1487
+ return fullName;
1488
+ };
1489
+
1490
+ Suite.prototype.disable = function() {
1491
+ this.disabled = true;
1492
+ };
1493
+
1494
+ Suite.prototype.beforeEach = function(fn) {
1495
+ this.beforeFns.unshift(fn);
1496
+ };
1497
+
1498
+ Suite.prototype.afterEach = function(fn) {
1499
+ this.afterFns.unshift(fn);
1500
+ };
1501
+
1502
+ Suite.prototype.addSpec = function(spec) {
1503
+ this.children_.push(spec);
1504
+ this.specs.push(spec); // TODO: needed?
1505
+ };
1506
+
1507
+ Suite.prototype.addSuite = function(suite) {
1508
+ suite.parentSuite = this;
1509
+ this.children_.push(suite);
1510
+ this.suites.push(suite); // TODO: needed?
1511
+ };
1512
+
1513
+ Suite.prototype.children = function() {
1514
+ return this.children_;
1515
+ };
1516
+
1517
+ Suite.prototype.execute = function(onComplete) {
1518
+ var self = this;
1519
+ if (this.disabled) {
1520
+ complete();
1521
+ return;
1522
+ }
1523
+
1524
+ var allFns = [],
1525
+ children = this.children_;
1526
+
1527
+ for (var i = 0; i < children.length; i++) {
1528
+ allFns.push(wrapChild(children[i]));
1529
+ }
1530
+
1531
+ this.onStart(this);
1532
+
1533
+ this.queueRunner({
1534
+ fns: allFns,
1535
+ onComplete: complete
1536
+ });
1537
+
1538
+ function complete() {
1539
+ self.resultCallback(self.result);
1540
+
1541
+ if (onComplete) {
1542
+ onComplete();
1543
+ }
1544
+ }
1545
+
1546
+ function wrapChild(child) {
1547
+ return function(done) {
1548
+ child.execute(done);
1549
+ };
1550
+ }
1551
+ };
1552
+
1553
+ return Suite;
1554
+ };
1555
+
1556
+ if (typeof window == void 0 && typeof exports == "object") {
1557
+ exports.Suite = jasmineRequire.Suite;
1558
+ }
1559
+
1560
+ getJasmineRequireObj().matchersUtil = function(j$) {
1561
+ // TODO: what to do about jasmine.pp not being inject? move to JSON.stringify? gut PrettyPrinter?
1562
+
1563
+ return {
1564
+ equals: function(a, b, customTesters) {
1565
+ customTesters = customTesters || [];
1566
+
1567
+ return eq(a, b, [], [], customTesters);
1568
+ },
1569
+
1570
+ contains: function(haystack, needle, customTesters) {
1571
+ customTesters = customTesters || [];
1572
+
1573
+ if (Object.prototype.toString.apply(haystack) === "[object Array]") {
1574
+ for (var i = 0; i < haystack.length; i++) {
1575
+ if (eq(haystack[i], needle, [], [], customTesters)) {
1576
+ return true;
1577
+ }
1578
+ }
1579
+ return false;
1580
+ }
1581
+ return haystack.indexOf(needle) >= 0;
1582
+ },
1583
+
1584
+ buildFailureMessage: function() {
1585
+ var args = Array.prototype.slice.call(arguments, 0),
1586
+ matcherName = args[0],
1587
+ isNot = args[1],
1588
+ actual = args[2],
1589
+ expected = args.slice(3),
1590
+ englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
1591
+
1592
+ var message = "Expected " +
1593
+ j$.pp(actual) +
1594
+ (isNot ? " not " : " ") +
1595
+ englishyPredicate;
1596
+
1597
+ if (expected.length > 0) {
1598
+ for (var i = 0; i < expected.length; i++) {
1599
+ if (i > 0) message += ",";
1600
+ message += " " + j$.pp(expected[i]);
1601
+ }
1602
+ }
1603
+
1604
+ return message + ".";
1605
+ }
1606
+ };
1607
+
1608
+ // Equality function lovingly adapted from isEqual in
1609
+ // [Underscore](http://underscorejs.org)
1610
+ function eq(a, b, aStack, bStack, customTesters) {
1611
+ var result = true;
1612
+
1613
+ for (var i = 0; i < customTesters.length; i++) {
1614
+ result = customTesters[i](a, b);
1615
+ if (result) {
1616
+ return true;
1617
+ }
1618
+ }
1619
+
1620
+ if (a instanceof j$.Any) {
1621
+ result = a.jasmineMatches(b);
1622
+ if (result) {
1623
+ return true;
1624
+ }
1625
+ }
1626
+
1627
+ if (b instanceof j$.Any) {
1628
+ result = b.jasmineMatches(a);
1629
+ if (result) {
1630
+ return true;
1631
+ }
1632
+ }
1633
+
1634
+ if (b instanceof j$.ObjectContaining) {
1635
+ result = b.jasmineMatches(a);
1636
+ if (result) {
1637
+ return true;
1638
+ }
1639
+ }
1640
+
1641
+ if (a instanceof Error && b instanceof Error) {
1642
+ return a.message == b.message;
1643
+ }
1644
+
1645
+ // Identical objects are equal. `0 === -0`, but they aren't identical.
1646
+ // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
1647
+ if (a === b) return a !== 0 || 1 / a == 1 / b;
1648
+ // A strict comparison is necessary because `null == undefined`.
1649
+ if (a === null || b === null) return a === b;
1650
+ var className = Object.prototype.toString.call(a);
1651
+ if (className != Object.prototype.toString.call(b)) return false;
1652
+ switch (className) {
1653
+ // Strings, numbers, dates, and booleans are compared by value.
1654
+ case '[object String]':
1655
+ // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
1656
+ // equivalent to `new String("5")`.
1657
+ return a == String(b);
1658
+ case '[object Number]':
1659
+ // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
1660
+ // other numeric values.
1661
+ return a != +a ? b != +b : (a === 0 ? 1 / a == 1 / b : a == +b);
1662
+ case '[object Date]':
1663
+ case '[object Boolean]':
1664
+ // Coerce dates and booleans to numeric primitive values. Dates are compared by their
1665
+ // millisecond representations. Note that invalid dates with millisecond representations
1666
+ // of `NaN` are not equivalent.
1667
+ return +a == +b;
1668
+ // RegExps are compared by their source patterns and flags.
1669
+ case '[object RegExp]':
1670
+ return a.source == b.source &&
1671
+ a.global == b.global &&
1672
+ a.multiline == b.multiline &&
1673
+ a.ignoreCase == b.ignoreCase;
1674
+ }
1675
+ if (typeof a != 'object' || typeof b != 'object') return false;
1676
+ // Assume equality for cyclic structures. The algorithm for detecting cyclic
1677
+ // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
1678
+ var length = aStack.length;
1679
+ while (length--) {
1680
+ // Linear search. Performance is inversely proportional to the number of
1681
+ // unique nested structures.
1682
+ if (aStack[length] == a) return bStack[length] == b;
1683
+ }
1684
+ // Add the first object to the stack of traversed objects.
1685
+ aStack.push(a);
1686
+ bStack.push(b);
1687
+ var size = 0;
1688
+ // Recursively compare objects and arrays.
1689
+ if (className == '[object Array]') {
1690
+ // Compare array lengths to determine if a deep comparison is necessary.
1691
+ size = a.length;
1692
+ result = size == b.length;
1693
+ if (result) {
1694
+ // Deep compare the contents, ignoring non-numeric properties.
1695
+ while (size--) {
1696
+ if (!(result = eq(a[size], b[size], aStack, bStack, customTesters))) break;
1697
+ }
1698
+ }
1699
+ } else {
1700
+ // Objects with different constructors are not equivalent, but `Object`s
1701
+ // from different frames are.
1702
+ var aCtor = a.constructor, bCtor = b.constructor;
1703
+ if (aCtor !== bCtor && !(isFunction(aCtor) && (aCtor instanceof aCtor) &&
1704
+ isFunction(bCtor) && (bCtor instanceof bCtor))) {
1705
+ return false;
1706
+ }
1707
+ // Deep compare objects.
1708
+ for (var key in a) {
1709
+ if (has(a, key)) {
1710
+ // Count the expected number of properties.
1711
+ size++;
1712
+ // Deep compare each member.
1713
+ if (!(result = has(b, key) && eq(a[key], b[key], aStack, bStack, customTesters))) break;
1714
+ }
1715
+ }
1716
+ // Ensure that both objects contain the same number of properties.
1717
+ if (result) {
1718
+ for (key in b) {
1719
+ if (has(b, key) && !(size--)) break;
1720
+ }
1721
+ result = !size;
1722
+ }
1723
+ }
1724
+ // Remove the first object from the stack of traversed objects.
1725
+ aStack.pop();
1726
+ bStack.pop();
1727
+
1728
+ return result;
1729
+
1730
+ function has(obj, key) {
1731
+ return obj.hasOwnProperty(key);
1732
+ }
1733
+
1734
+ function isFunction(obj) {
1735
+ return typeof obj === 'function';
1736
+ }
1737
+ }
1738
+ };
1739
+ getJasmineRequireObj().toBe = function() {
1740
+ function toBe() {
1741
+ return {
1742
+ compare: function(actual, expected) {
1743
+ return {
1744
+ pass: actual === expected
1745
+ };
1746
+ }
1747
+ };
1748
+ }
1749
+
1750
+ return toBe;
1751
+ };
1752
+
1753
+ getJasmineRequireObj().toBeCloseTo = function() {
1754
+
1755
+ function toBeCloseTo() {
1756
+ return {
1757
+ compare: function(actual, expected, precision) {
1758
+ if (precision !== 0) {
1759
+ precision = precision || 2;
1760
+ }
1761
+
1762
+ return {
1763
+ pass: Math.abs(expected - actual) < (Math.pow(10, -precision) / 2)
1764
+ };
1765
+ }
1766
+ };
1767
+ }
1768
+
1769
+ return toBeCloseTo;
1770
+ };
1771
+
1772
+ getJasmineRequireObj().toBeDefined = function() {
1773
+ function toBeDefined() {
1774
+ return {
1775
+ compare: function(actual) {
1776
+ return {
1777
+ pass: (void 0 !== actual)
1778
+ };
1779
+ }
1780
+ };
1781
+ }
1782
+
1783
+ return toBeDefined;
1784
+ };
1785
+
1786
+ getJasmineRequireObj().toBeFalsy = function() {
1787
+ function toBeFalsy() {
1788
+ return {
1789
+ compare: function(actual) {
1790
+ return {
1791
+ pass: !!!actual
1792
+ };
1793
+ }
1794
+ };
1795
+ }
1796
+
1797
+ return toBeFalsy;
1798
+ };
1799
+
1800
+ getJasmineRequireObj().toBeGreaterThan = function() {
1801
+
1802
+ function toBeGreaterThan() {
1803
+ return {
1804
+ compare: function(actual, expected) {
1805
+ return {
1806
+ pass: actual > expected
1807
+ };
1808
+ }
1809
+ };
1810
+ }
1811
+
1812
+ return toBeGreaterThan;
1813
+ };
1814
+
1815
+
1816
+ getJasmineRequireObj().toBeLessThan = function() {
1817
+ function toBeLessThan() {
1818
+ return {
1819
+
1820
+ compare: function(actual, expected) {
1821
+ return {
1822
+ pass: actual < expected
1823
+ };
1824
+ }
1825
+ };
1826
+ }
1827
+
1828
+ return toBeLessThan;
1829
+ };
1830
+ getJasmineRequireObj().toBeNaN = function() {
1831
+
1832
+ function toBeNaN() {
1833
+ return {
1834
+ compare: function(actual) {
1835
+ var result = {
1836
+ pass: (actual !== actual)
1837
+ };
1838
+
1839
+ if (result.pass) {
1840
+ result.message = "Expected actual not to be NaN.";
1841
+ } else {
1842
+ result.message = "Expected " + j$.pp(actual) + " to be NaN.";
1843
+ }
1844
+
1845
+ return result;
1846
+ }
1847
+ };
1848
+ }
1849
+
1850
+ return toBeNaN;
1851
+ };
1852
+
1853
+ getJasmineRequireObj().toBeNull = function() {
1854
+
1855
+ function toBeNull() {
1856
+ return {
1857
+ compare: function(actual) {
1858
+ return {
1859
+ pass: actual === null
1860
+ };
1861
+ }
1862
+ };
1863
+ }
1864
+
1865
+ return toBeNull;
1866
+ };
1867
+
1868
+ getJasmineRequireObj().toBeTruthy = function() {
1869
+
1870
+ function toBeTruthy() {
1871
+ return {
1872
+ compare: function(actual) {
1873
+ return {
1874
+ pass: !!actual
1875
+ };
1876
+ }
1877
+ };
1878
+ }
1879
+
1880
+ return toBeTruthy;
1881
+ };
1882
+
1883
+ getJasmineRequireObj().toBeUndefined = function() {
1884
+
1885
+ function toBeUndefined() {
1886
+ return {
1887
+ compare: function(actual) {
1888
+ return {
1889
+ pass: void 0 === actual
1890
+ };
1891
+ }
1892
+ };
1893
+ }
1894
+
1895
+ return toBeUndefined;
1896
+ };
1897
+
1898
+ getJasmineRequireObj().toContain = function() {
1899
+ function toContain(util, customEqualityTesters) {
1900
+ customEqualityTesters = customEqualityTesters || [];
1901
+
1902
+ return {
1903
+ compare: function(actual, expected) {
1904
+
1905
+ return {
1906
+ pass: util.contains(actual, expected, customEqualityTesters)
1907
+ };
1908
+ }
1909
+ };
1910
+ }
1911
+
1912
+ return toContain;
1913
+ };
1914
+
1915
+ getJasmineRequireObj().toEqual = function() {
1916
+
1917
+ function toEqual(util, customEqualityTesters) {
1918
+ customEqualityTesters = customEqualityTesters || [];
1919
+
1920
+ return {
1921
+ compare: function(actual, expected) {
1922
+ var result = {
1923
+ pass: false
1924
+ };
1925
+
1926
+ result.pass = util.equals(actual, expected, customEqualityTesters);
1927
+
1928
+ return result;
1929
+ }
1930
+ };
1931
+ }
1932
+
1933
+ return toEqual;
1934
+ };
1935
+
1936
+ getJasmineRequireObj().toHaveBeenCalled = function() {
1937
+
1938
+ function toHaveBeenCalled() {
1939
+ return {
1940
+ compare: function(actual) {
1941
+ var result = {};
1942
+
1943
+ if (!j$.isSpy(actual)) {
1944
+ throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.');
1945
+ }
1946
+
1947
+ if (arguments.length > 1) {
1948
+ throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith');
1949
+ }
1950
+
1951
+ result.pass = actual.wasCalled;
1952
+
1953
+ result.message = result.pass ?
1954
+ "Expected spy " + actual.identity + " not to have been called." :
1955
+ "Expected spy " + actual.identity + " to have been called.";
1956
+
1957
+ return result;
1958
+ }
1959
+ };
1960
+ }
1961
+
1962
+ return toHaveBeenCalled;
1963
+ };
1964
+
1965
+ getJasmineRequireObj().toHaveBeenCalledWith = function() {
1966
+
1967
+ function toHaveBeenCalledWith(util) {
1968
+ return {
1969
+ compare: function() {
1970
+ var args = Array.prototype.slice.call(arguments, 0),
1971
+ actual = args[0],
1972
+ expectedArgs = args.slice(1);
1973
+
1974
+ if (!j$.isSpy(actual)) {
1975
+ throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.');
1976
+ }
1977
+
1978
+ return {
1979
+ pass: util.contains(actual.argsForCall, expectedArgs)
1980
+ };
1981
+ },
1982
+ message: function(actual) {
1983
+ return {
1984
+ affirmative: "Expected spy " + actual.identity + " to have been called.",
1985
+ negative: "Expected spy " + actual.identity + " not to have been called."
1986
+ };
1987
+ }
1988
+ };
1989
+ }
1990
+
1991
+ return toHaveBeenCalledWith;
1992
+ };
1993
+
1994
+ getJasmineRequireObj().toMatch = function() {
1995
+
1996
+ function toMatch() {
1997
+ return {
1998
+ compare: function(actual, expected) {
1999
+ var regexp = new RegExp(expected);
2000
+
2001
+ return {
2002
+ pass: regexp.test(actual)
2003
+ };
2004
+ }
2005
+ };
2006
+ }
2007
+
2008
+ return toMatch;
2009
+ };
2010
+
2011
+ getJasmineRequireObj().toThrow = function() {
2012
+
2013
+ function toThrow(util) {
2014
+ return {
2015
+ compare: function(actual, expected) {
2016
+ var result = { pass: false },
2017
+ threw = false,
2018
+ thrown;
2019
+
2020
+ if (typeof actual != "function") {
2021
+ throw new Error("Actual is not a Function");
2022
+ }
2023
+
2024
+ try {
2025
+ actual();
2026
+ } catch (e) {
2027
+ threw = true;
2028
+ thrown = e;
2029
+ }
2030
+
2031
+ if (!threw) {
2032
+ result.message = "Expected function to throw an exception.";
2033
+ return result;
2034
+ }
2035
+
2036
+ if (arguments.length == 1) {
2037
+ result.pass = true;
2038
+ result.message = "Expected function not to throw.";
2039
+
2040
+ return result;
2041
+ }
2042
+
2043
+ if (util.equals(thrown, expected)) {
2044
+ result.pass = true;
2045
+ result.message = "Expected function not to throw " + j$.pp(expected) + ".";
2046
+ } else {
2047
+ result.message = "Expected function to throw " + j$.pp(expected) + ".";
2048
+ }
2049
+
2050
+ return result;
2051
+ }
2052
+ };
2053
+ }
2054
+
2055
+ return toThrow;
2056
+ };
2057
+
2058
+ getJasmineRequireObj().toThrowError = function() {
2059
+ function toThrowError (util) {
2060
+ return {
2061
+ compare: function(actual) {
2062
+ var threw = false,
2063
+ thrown,
2064
+ errorType,
2065
+ message,
2066
+ regexp;
2067
+
2068
+ if (typeof actual != "function") {
2069
+ throw new Error("Actual is not a Function");
2070
+ }
2071
+
2072
+ extractExpectedParams.apply(null, arguments);
2073
+
2074
+ try {
2075
+ actual();
2076
+ } catch (e) {
2077
+ threw = true;
2078
+ thrown = e;
2079
+ }
2080
+
2081
+ if (!threw) {
2082
+ return fail("Expected function to throw an Error.");
2083
+ }
2084
+
2085
+ if (!(thrown instanceof Error)) {
2086
+ return fail("Expected function to throw an Error, but it threw " + thrown + ".");
2087
+ }
2088
+
2089
+ if (arguments.length == 1) {
2090
+ return pass("Expected function not to throw an Error, but it threw " + thrown + ".");
2091
+ }
2092
+
2093
+ if (errorType && message) {
2094
+ if (thrown.constructor == errorType && util.equals(thrown.message, message)) {
2095
+ return pass("Expected function not to throw Error with message \"" + message + "\".");
2096
+ } else {
2097
+ return fail("Expected function to throw Error with message \"" + message + "\".");
2098
+ }
2099
+ }
2100
+
2101
+ if (errorType && regexp) {
2102
+ if (thrown.constructor == errorType && regexp.test(thrown.message)) {
2103
+ return pass("Expected function not to throw Error with message matching " + regexp + ".");
2104
+ } else {
2105
+ return fail("Expected function to throw Error with message matching " + regexp + ".");
2106
+ }
2107
+ }
2108
+
2109
+ if (errorType) {
2110
+ if (thrown.constructor == errorType) {
2111
+ return pass("Expected function not to throw " + errorType.name + ".");
2112
+ } else {
2113
+ return fail("Expected function to throw " + errorType.name + ".");
2114
+ }
2115
+ }
2116
+
2117
+ if (message) {
2118
+ if (thrown.message == message) {
2119
+ return pass("Expected function not to throw an execption with message " + j$.pp(message) + ".");
2120
+ } else {
2121
+ return fail("Expected function to throw an execption with message " + j$.pp(message) + ".");
2122
+ }
2123
+ }
2124
+
2125
+ if (regexp) {
2126
+ if (regexp.test(thrown.message)) {
2127
+ return pass("Expected function not to throw an execption with a message matching " + j$.pp(regexp) + ".");
2128
+ } else {
2129
+ return fail("Expected function to throw an execption with a message matching " + j$.pp(regexp) + ".");
2130
+ }
2131
+ }
2132
+
2133
+ function pass(notMessage) {
2134
+ return {
2135
+ pass: true,
2136
+ message: notMessage
2137
+ };
2138
+ }
2139
+
2140
+ function fail(message) {
2141
+ return {
2142
+ pass: false,
2143
+ message: message
2144
+ };
2145
+ }
2146
+
2147
+ function extractExpectedParams() {
2148
+ if (arguments.length == 1) {
2149
+ return;
2150
+ }
2151
+
2152
+ if (arguments.length == 2) {
2153
+ var expected = arguments[1];
2154
+
2155
+ if (expected instanceof RegExp) {
2156
+ regexp = expected;
2157
+ } else if (typeof expected == "string") {
2158
+ message = expected;
2159
+ } else if (checkForAnErrorType(expected)) {
2160
+ errorType = expected;
2161
+ }
2162
+
2163
+ if (!(errorType || message || regexp)) {
2164
+ throw new Error("Expected is not an Error, string, or RegExp.");
2165
+ }
2166
+ } else {
2167
+ if (checkForAnErrorType(arguments[1])) {
2168
+ errorType = arguments[1];
2169
+ } else {
2170
+ throw new Error("Expected error type is not an Error.");
2171
+ }
2172
+
2173
+ if (arguments[2] instanceof RegExp) {
2174
+ regexp = arguments[2];
2175
+ } else if (typeof arguments[2] == "string") {
2176
+ message = arguments[2];
2177
+ } else {
2178
+ throw new Error("Expected error message is not a string or RegExp.");
2179
+ }
2180
+ }
2181
+ }
2182
+
2183
+ function checkForAnErrorType(type) {
2184
+ if (typeof type !== "function") {
2185
+ return false;
2186
+ }
2187
+
2188
+ var Surrogate = function() {};
2189
+ Surrogate.prototype = type.prototype;
2190
+ return (new Surrogate()) instanceof Error;
2191
+ }
2192
+ }
2193
+ };
2194
+ }
2195
+
2196
+ return toThrowError;
2197
+ };
2198
+ getJasmineRequireObj().version = function() {
2199
+ return "2.0.0-alpha";
2200
+ };